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
af7e2734
Unverified
Commit
af7e2734
authored
Apr 20, 2016
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: update auto-bsf to new BSF API
parent
150e5e13
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
24 deletions
+91
-24
internal.h
libavformat/internal.h
+3
-2
mux.c
libavformat/mux.c
+35
-10
segment.c
libavformat/segment.c
+4
-2
utils.c
libavformat/utils.c
+49
-10
No files found.
libavformat/internal.h
View file @
af7e2734
...
...
@@ -135,11 +135,12 @@ struct AVStreamInternal {
int
reorder
;
/**
* bitstream filter to run on stream
* bitstream filter
s
to run on stream
* - encoding: Set by muxer using ff_stream_add_bitstream_filter
* - decoding: unused
*/
AVBitStreamFilterContext
*
bsfc
;
AVBSFContext
**
bsfcs
;
int
nb_bsfcs
;
/**
* Whether or not check_bitstream should still be run on each packet
...
...
libavformat/mux.c
View file @
af7e2734
...
...
@@ -1082,7 +1082,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in
int
av_interleaved_write_frame
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
int
ret
,
flush
=
0
;
int
ret
,
flush
=
0
,
i
;
ret
=
prepare_input_packet
(
s
,
pkt
);
if
(
ret
<
0
)
...
...
@@ -1100,15 +1100,40 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
}
}
av_apply_bitstream_filters
(
st
->
internal
->
avctx
,
pkt
,
st
->
internal
->
bsfc
);
if
(
pkt
->
size
==
0
&&
pkt
->
side_data_elems
==
0
)
return
0
;
if
(
!
st
->
codecpar
->
extradata
&&
st
->
internal
->
avctx
->
extradata
)
{
int
eret
=
ff_alloc_extradata
(
st
->
codecpar
,
st
->
internal
->
avctx
->
extradata_size
);
if
(
eret
<
0
)
return
AVERROR
(
ENOMEM
);
st
->
codecpar
->
extradata_size
=
st
->
internal
->
avctx
->
extradata_size
;
memcpy
(
st
->
codecpar
->
extradata
,
st
->
internal
->
avctx
->
extradata
,
st
->
internal
->
avctx
->
extradata_size
);
for
(
i
=
0
;
i
<
st
->
internal
->
nb_bsfcs
;
i
++
)
{
AVBSFContext
*
ctx
=
st
->
internal
->
bsfcs
[
i
];
if
(
i
>
0
)
{
AVBSFContext
*
prev_ctx
=
st
->
internal
->
bsfcs
[
i
-
1
];
if
(
prev_ctx
->
par_out
->
extradata_size
!=
ctx
->
par_in
->
extradata_size
)
{
if
((
ret
=
avcodec_parameters_copy
(
ctx
->
par_in
,
prev_ctx
->
par_out
))
<
0
)
goto
fail
;
}
}
// TODO: when any bitstream filter requires flushing at EOF, we'll need to
// flush each stream's BSF chain on write_trailer.
if
((
ret
=
av_bsf_send_packet
(
ctx
,
pkt
))
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Failed to send packet to filter %s for stream %d"
,
ctx
->
filter
->
name
,
pkt
->
stream_index
);
goto
fail
;
}
// TODO: when any automatically-added bitstream filter is generating multiple
// output packets for a single input one, we'll need to call this in a loop
// and write each output packet.
if
((
ret
=
av_bsf_receive_packet
(
ctx
,
pkt
))
<
0
)
{
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
return
0
;
av_log
(
ctx
,
AV_LOG_ERROR
,
"Failed to send packet to filter %s for stream %d"
,
ctx
->
filter
->
name
,
pkt
->
stream_index
);
goto
fail
;
}
if
(
i
==
st
->
internal
->
nb_bsfcs
-
1
)
{
if
(
ctx
->
par_out
->
extradata_size
!=
st
->
codecpar
->
extradata_size
)
{
if
((
ret
=
avcodec_parameters_copy
(
st
->
codecpar
,
ctx
->
par_out
))
<
0
)
goto
fail
;
}
}
}
if
(
s
->
debug
&
FF_FDEBUG_TS
)
...
...
libavformat/segment.c
View file @
af7e2734
...
...
@@ -966,8 +966,10 @@ static int seg_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
if
(
ret
==
1
)
{
AVStream
*
st
=
s
->
streams
[
pkt
->
stream_index
];
AVStream
*
ost
=
oc
->
streams
[
pkt
->
stream_index
];
st
->
internal
->
bsfc
=
ost
->
internal
->
bsfc
;
ost
->
internal
->
bsfc
=
NULL
;
st
->
internal
->
bsfcs
=
ost
->
internal
->
bsfcs
;
st
->
internal
->
nb_bsfcs
=
ost
->
internal
->
nb_bsfcs
;
ost
->
internal
->
bsfcs
=
NULL
;
ost
->
internal
->
nb_bsfcs
=
0
;
}
return
ret
;
}
...
...
libavformat/utils.c
View file @
af7e2734
...
...
@@ -3962,6 +3962,10 @@ static void free_stream(AVStream **pst)
if
(
st
->
internal
)
{
avcodec_free_context
(
&
st
->
internal
->
avctx
);
for
(
i
=
0
;
i
<
st
->
internal
->
nb_bsfcs
;
i
++
)
{
av_bsf_free
(
&
st
->
internal
->
bsfcs
[
i
]);
av_freep
(
&
st
->
internal
->
bsfcs
);
}
}
av_freep
(
&
st
->
internal
);
...
...
@@ -4986,23 +4990,58 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
int
ff_stream_add_bitstream_filter
(
AVStream
*
st
,
const
char
*
name
,
const
char
*
args
)
{
AVBitStreamFilterContext
*
bsfc
=
NULL
;
AVBitStreamFilterContext
**
dest
=
&
st
->
internal
->
bsfc
;
while
(
*
dest
&&
(
*
dest
)
->
next
)
dest
=
&
(
*
dest
)
->
next
;
int
ret
;
const
AVBitStreamFilter
*
bsf
;
AVBSFContext
*
bsfc
;
AVCodecParameters
*
in_par
;
if
(
!
(
bsf
c
=
av_bitstream_filter_init
(
name
)))
{
if
(
!
(
bsf
=
av_bsf_get_by_name
(
name
)))
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Unknown bitstream filter '%s'
\n
"
,
name
);
return
AVERROR
(
EINVAL
)
;
return
AVERROR
_BSF_NOT_FOUND
;
}
if
(
args
&&
!
(
bsfc
->
args
=
av_strdup
(
args
)))
{
av_bitstream_filter_close
(
bsfc
);
return
AVERROR
(
ENOMEM
);
if
((
ret
=
av_bsf_alloc
(
bsf
,
&
bsfc
))
<
0
)
return
ret
;
if
(
st
->
internal
->
nb_bsfcs
)
{
in_par
=
st
->
internal
->
bsfcs
[
st
->
internal
->
nb_bsfcs
-
1
]
->
par_out
;
bsfc
->
time_base_in
=
st
->
internal
->
bsfcs
[
st
->
internal
->
nb_bsfcs
-
1
]
->
time_base_out
;
}
else
{
in_par
=
st
->
codecpar
;
bsfc
->
time_base_in
=
st
->
time_base
;
}
if
((
ret
=
avcodec_parameters_copy
(
bsfc
->
par_in
,
in_par
))
<
0
)
{
av_bsf_free
(
&
bsfc
);
return
ret
;
}
if
(
args
&&
bsfc
->
filter
->
priv_class
)
{
const
AVOption
*
opt
=
av_opt_next
(
bsfc
->
priv_data
,
NULL
);
const
char
*
shorthand
[
2
]
=
{
NULL
};
if
(
opt
)
shorthand
[
0
]
=
opt
->
name
;
if
((
ret
=
av_opt_set_from_string
(
bsfc
->
priv_data
,
args
,
shorthand
,
"="
,
":"
))
<
0
)
{
av_bsf_free
(
&
bsfc
);
return
ret
;
}
}
if
((
ret
=
av_bsf_init
(
bsfc
))
<
0
)
{
av_bsf_free
(
&
bsfc
);
return
ret
;
}
if
((
ret
=
av_dynarray_add_nofree
(
&
st
->
internal
->
bsfcs
,
&
st
->
internal
->
nb_bsfcs
,
bsfc
)))
{
av_bsf_free
(
&
bsfc
);
return
ret
;
}
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"Automatically inserted bitstream filter '%s'; args='%s'
\n
"
,
name
,
args
?
args
:
""
);
*
dest
=
bsfc
;
return
1
;
}
...
...
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