Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
12f050a8
Commit
12f050a8
authored
May 23, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/asubprocess: support 16, 24 and 32 bit subprocess input wavs
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
0bee9b20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
af_asubprocess.c
libavfilter/af_asubprocess.c
+30
-5
No files found.
libavfilter/af_asubprocess.c
View file @
12f050a8
...
...
@@ -207,6 +207,7 @@ typedef struct AndioWMarkContext {
int
fd
;
int
state
;
unsigned
int
chunk_size
;
int
in_bit_depth
;
int
out_bit_depth
;
SP
*
sp
;
int
nb_samples
;
...
...
@@ -217,7 +218,8 @@ typedef struct AndioWMarkContext {
#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
asubprocess_options
[]
=
{
{
"command"
,
"set command to run as subprocess"
,
OFFSET
(
command
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
A
},
{
"command"
,
"set command to run as subprocess"
,
OFFSET
(
command
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
A
},
{
"bits"
,
"set wav bit depth for subprocess input"
,
OFFSET
(
in_bit_depth
),
AV_OPT_TYPE_INT
,
{.
i64
=
32
},
0
,
32
,
A
},
{
NULL
},
};
...
...
@@ -230,6 +232,10 @@ static av_cold int init(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_ERROR
,
"No command provided
\n
"
);
return
AVERROR
(
EINVAL
);
}
if
(
s
->
in_bit_depth
!=
16
&&
s
->
in_bit_depth
!=
24
&&
s
->
in_bit_depth
!=
32
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Only 16, 24 and 32 input bit depth supported
\n
"
);
return
AVERROR
(
EINVAL
);
}
return
0
;
}
...
...
@@ -249,7 +255,7 @@ static int config_input(AVFilterLink *inlink)
AVFilterContext
*
ctx
=
inlink
->
dst
;
ASubProcessContext
*
s
=
ctx
->
priv
;
s
->
sp
=
sp_new
(
s
->
command
);
int
bit_depth
=
16
;
int
bit_depth
=
s
->
in_bit_depth
;
int
sample_rate
=
inlink
->
sample_rate
;
int
nb_channels
=
inlink
->
ch_layout
.
nb_channels
;
AVIOContext
*
wav_header
=
NULL
;
...
...
@@ -305,10 +311,29 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
short
buffer
[
100000
];
int
k
=
0
;
int32_t
*
xd
=
(
int32_t
*
)
in
->
data
[
0
];
for
(
k
=
0
;
k
<
in
->
nb_samples
*
inlink
->
ch_layout
.
nb_channels
;
k
++
)
{
AV_WL16
(
buffer
+
k
,
xd
[
k
]
>>
16
);
int
sample_size
=
s
->
in_bit_depth
/
8
;
int
todo
=
in
->
nb_samples
*
inlink
->
ch_layout
.
nb_channels
;
if
(
s
->
in_bit_depth
==
16
)
{
for
(
k
=
0
;
k
<
todo
;
k
++
)
AV_WL16
(
buffer
+
k
,
xd
[
k
]
>>
16
);
}
if
(
s
->
in_bit_depth
==
24
)
{
uint8_t
*
in
=
(
uint8_t
*
)
buffer
;
for
(
int
k
=
0
;
k
<
todo
;
k
++
)
{
AV_WL24
(
in
,
xd
[
k
]
>>
8
);
in
+=
3
;
}
}
if
(
s
->
in_bit_depth
==
32
)
{
int32_t
*
i32buffer
=
(
int32_t
*
)
buffer
;
for
(
k
=
0
;
k
<
todo
;
k
++
)
AV_WL32
(
i32buffer
+
k
,
xd
[
k
]);
}
sp_write
(
s
->
sp
,
buffer
,
2
*
k
);
sp_write
(
s
->
sp
,
buffer
,
sample_size
*
todo
);
if
(
s
->
eof
)
{
while
(
!
sp_write
(
s
->
sp
,
0
,
0
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment