Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
f821ae85
Commit
f821ae85
authored
Apr 17, 2020
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fftools/ffmpeg: use a bsf list instead of individual bsfs
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
425e08d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
101 deletions
+24
-101
ffmpeg.c
fftools/ffmpeg.c
+20
-54
ffmpeg.h
fftools/ffmpeg.h
+1
-2
ffmpeg_opt.c
fftools/ffmpeg_opt.c
+3
-45
No files found.
fftools/ffmpeg.c
View file @
f821ae85
...
@@ -558,9 +558,7 @@ static void ffmpeg_cleanup(int ret)
...
@@ -558,9 +558,7 @@ static void ffmpeg_cleanup(int ret)
if
(
!
ost
)
if
(
!
ost
)
continue
;
continue
;
for
(
j
=
0
;
j
<
ost
->
nb_bitstream_filters
;
j
++
)
av_bsf_free
(
&
ost
->
bsf_ctx
);
av_bsf_free
(
&
ost
->
bsf_ctx
[
j
]);
av_freep
(
&
ost
->
bsf_ctx
);
av_frame_free
(
&
ost
->
filtered_frame
);
av_frame_free
(
&
ost
->
filtered_frame
);
av_frame_free
(
&
ost
->
last_frame
);
av_frame_free
(
&
ost
->
last_frame
);
...
@@ -859,40 +857,15 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
...
@@ -859,40 +857,15 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
{
{
int
ret
=
0
;
int
ret
=
0
;
/* apply the output bitstream filters, if any */
/* apply the output bitstream filters */
if
(
ost
->
nb_bitstream_filters
)
{
if
(
ost
->
bsf_ctx
)
{
int
idx
;
ret
=
av_bsf_send_packet
(
ost
->
bsf_ctx
,
eof
?
NULL
:
pkt
);
ret
=
av_bsf_send_packet
(
ost
->
bsf_ctx
[
0
],
eof
?
NULL
:
pkt
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
finish
;
goto
finish
;
while
((
ret
=
av_bsf_receive_packet
(
ost
->
bsf_ctx
,
pkt
))
>=
0
)
eof
=
0
;
write_packet
(
of
,
pkt
,
ost
,
0
);
idx
=
1
;
if
(
ret
==
AVERROR
(
EAGAIN
))
while
(
idx
)
{
ret
=
0
;
/* get a packet from the previous filter up the chain */
ret
=
av_bsf_receive_packet
(
ost
->
bsf_ctx
[
idx
-
1
],
pkt
);
if
(
ret
==
AVERROR
(
EAGAIN
))
{
ret
=
0
;
idx
--
;
continue
;
}
else
if
(
ret
==
AVERROR_EOF
)
{
eof
=
1
;
}
else
if
(
ret
<
0
)
goto
finish
;
/* send it to the next filter down the chain or to the muxer */
if
(
idx
<
ost
->
nb_bitstream_filters
)
{
ret
=
av_bsf_send_packet
(
ost
->
bsf_ctx
[
idx
],
eof
?
NULL
:
pkt
);
if
(
ret
<
0
)
goto
finish
;
idx
++
;
eof
=
0
;
}
else
if
(
eof
)
goto
finish
;
else
write_packet
(
of
,
pkt
,
ost
,
0
);
}
}
else
if
(
!
eof
)
}
else
if
(
!
eof
)
write_packet
(
of
,
pkt
,
ost
,
0
);
write_packet
(
of
,
pkt
,
ost
,
0
);
...
@@ -3015,35 +2988,28 @@ static int check_init_output_file(OutputFile *of, int file_index)
...
@@ -3015,35 +2988,28 @@ static int check_init_output_file(OutputFile *of, int file_index)
static
int
init_output_bsfs
(
OutputStream
*
ost
)
static
int
init_output_bsfs
(
OutputStream
*
ost
)
{
{
AVBSFContext
*
ctx
;
AVBSFContext
*
ctx
=
ost
->
bsf_ctx
;
int
i
,
ret
;
int
ret
;
if
(
!
ost
->
nb_bitstream_filters
)
if
(
!
ctx
)
return
0
;
return
0
;
for
(
i
=
0
;
i
<
ost
->
nb_bitstream_filters
;
i
++
)
{
ret
=
avcodec_parameters_copy
(
ctx
->
par_in
,
ost
->
st
->
codecpar
);
ctx
=
ost
->
bsf_ctx
[
i
];
if
(
ret
<
0
)
return
ret
;
ret
=
avcodec_parameters_copy
(
ctx
->
par_in
,
i
?
ost
->
bsf_ctx
[
i
-
1
]
->
par_out
:
ost
->
st
->
codecpar
);
if
(
ret
<
0
)
return
ret
;
ctx
->
time_base_in
=
i
?
ost
->
bsf_ctx
[
i
-
1
]
->
time_base_out
:
ost
->
st
->
time_base
;
ctx
->
time_base_in
=
ost
->
st
->
time_base
;
ret
=
av_bsf_init
(
ctx
);
ret
=
av_bsf_init
(
ctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error initializing bitstream filter: %s
\n
"
,
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error initializing bitstream filter: %s
\n
"
,
ost
->
bsf_ctx
[
i
]
->
filter
->
name
);
ctx
->
filter
->
name
);
return
ret
;
return
ret
;
}
}
}
ctx
=
ost
->
bsf_ctx
[
ost
->
nb_bitstream_filters
-
1
];
ret
=
avcodec_parameters_copy
(
ost
->
st
->
codecpar
,
ctx
->
par_out
);
ret
=
avcodec_parameters_copy
(
ost
->
st
->
codecpar
,
ctx
->
par_out
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
ost
->
st
->
time_base
=
ctx
->
time_base_out
;
ost
->
st
->
time_base
=
ctx
->
time_base_out
;
return
0
;
return
0
;
...
...
fftools/ffmpeg.h
View file @
f821ae85
...
@@ -459,8 +459,7 @@ typedef struct OutputStream {
...
@@ -459,8 +459,7 @@ typedef struct OutputStream {
AVRational
mux_timebase
;
AVRational
mux_timebase
;
AVRational
enc_timebase
;
AVRational
enc_timebase
;
int
nb_bitstream_filters
;
AVBSFContext
*
bsf_ctx
;
AVBSFContext
**
bsf_ctx
;
AVCodecContext
*
enc_ctx
;
AVCodecContext
*
enc_ctx
;
AVCodecParameters
*
ref_par
;
/* associated input codec parameters with encoders options applied */
AVCodecParameters
*
ref_par
;
/* associated input codec parameters with encoders options applied */
...
...
fftools/ffmpeg_opt.c
View file @
f821ae85
...
@@ -1528,54 +1528,12 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
...
@@ -1528,54 +1528,12 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
MATCH_PER_STREAM_OPT
(
copy_prior_start
,
i
,
ost
->
copy_prior_start
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
copy_prior_start
,
i
,
ost
->
copy_prior_start
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
bitstream_filters
,
str
,
bsfs
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
bitstream_filters
,
str
,
bsfs
,
oc
,
st
);
while
(
bsfs
&&
*
bsfs
)
{
if
(
bsfs
&&
*
bsfs
)
{
const
AVBitStreamFilter
*
filter
;
ret
=
av_bsf_list_parse_str
(
bsfs
,
&
ost
->
bsf_ctx
);
char
*
bsf
,
*
bsf_options_str
,
*
bsf_name
;
bsf
=
av_get_token
(
&
bsfs
,
","
);
if
(
!
bsf
)
exit_program
(
1
);
bsf_name
=
av_strtok
(
bsf
,
"="
,
&
bsf_options_str
);
if
(
!
bsf_name
)
exit_program
(
1
);
filter
=
av_bsf_get_by_name
(
bsf_name
);
if
(
!
filter
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Unknown bitstream filter %s
\n
"
,
bsf_name
);
exit_program
(
1
);
}
ost
->
bsf_ctx
=
av_realloc_array
(
ost
->
bsf_ctx
,
ost
->
nb_bitstream_filters
+
1
,
sizeof
(
*
ost
->
bsf_ctx
));
if
(
!
ost
->
bsf_ctx
)
exit_program
(
1
);
ret
=
av_bsf_alloc
(
filter
,
&
ost
->
bsf_ctx
[
ost
->
nb_bitstream_filters
]);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error
allocating a bitstream filter context
\n
"
);
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error
parsing bitstream filter sequence '%s': %s
\n
"
,
bsfs
,
av_err2str
(
ret
)
);
exit_program
(
1
);
exit_program
(
1
);
}
}
ost
->
nb_bitstream_filters
++
;
if
(
bsf_options_str
&&
filter
->
priv_class
)
{
const
AVOption
*
opt
=
av_opt_next
(
ost
->
bsf_ctx
[
ost
->
nb_bitstream_filters
-
1
]
->
priv_data
,
NULL
);
const
char
*
shorthand
[
2
]
=
{
NULL
};
if
(
opt
)
shorthand
[
0
]
=
opt
->
name
;
ret
=
av_opt_set_from_string
(
ost
->
bsf_ctx
[
ost
->
nb_bitstream_filters
-
1
]
->
priv_data
,
bsf_options_str
,
shorthand
,
"="
,
":"
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error parsing options for bitstream filter %s
\n
"
,
bsf_name
);
exit_program
(
1
);
}
}
av_freep
(
&
bsf
);
if
(
*
bsfs
)
bsfs
++
;
}
}
MATCH_PER_STREAM_OPT
(
codec_tags
,
str
,
codec_tag
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
codec_tags
,
str
,
codec_tag
,
oc
,
st
);
...
...
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