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
4caa3e1c
Commit
4caa3e1c
authored
Oct 08, 2015
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: add API to apply a list of bsfs to a packet
parent
39777460
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
avformat.h
libavformat/avformat.h
+11
-0
utils.c
libavformat/utils.c
+49
-0
No files found.
libavformat/avformat.h
View file @
4caa3e1c
...
...
@@ -2764,6 +2764,17 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
int
avformat_queue_attached_pictures
(
AVFormatContext
*
s
);
/**
* Apply a list of bitstream filters to a packet.
*
* @param codec AVCodecContext, usually from an AVStream
* @param pkt the packet to apply filters to
* @param bsfc a NULL-terminated list of filters to apply
* @return >=0 on success;
* AVERROR code on failure
*/
int
av_apply_bitstream_filters
(
AVCodecContext
*
codec
,
AVPacket
*
pkt
,
AVBitStreamFilterContext
*
bsfc
);
/**
* @}
...
...
libavformat/utils.c
View file @
4caa3e1c
...
...
@@ -4650,3 +4650,52 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
sd
->
size
=
size
;
return
data
;
}
int
av_apply_bitstream_filters
(
AVCodecContext
*
codec
,
AVPacket
*
pkt
,
AVBitStreamFilterContext
*
bsfc
)
{
int
ret
=
0
;
while
(
bsfc
)
{
AVPacket
new_pkt
=
*
pkt
;
int
a
=
av_bitstream_filter_filter
(
bsfc
,
codec
,
NULL
,
&
new_pkt
.
data
,
&
new_pkt
.
size
,
pkt
->
data
,
pkt
->
size
,
pkt
->
flags
&
AV_PKT_FLAG_KEY
);
if
(
a
==
0
&&
new_pkt
.
data
!=
pkt
->
data
)
{
uint8_t
*
t
=
av_malloc
(
new_pkt
.
size
+
AV_INPUT_BUFFER_PADDING_SIZE
);
//the new should be a subset of the old so cannot overflow
if
(
t
)
{
memcpy
(
t
,
new_pkt
.
data
,
new_pkt
.
size
);
memset
(
t
+
new_pkt
.
size
,
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
new_pkt
.
data
=
t
;
new_pkt
.
buf
=
NULL
;
a
=
1
;
}
else
{
a
=
AVERROR
(
ENOMEM
);
}
}
if
(
a
>
0
)
{
new_pkt
.
buf
=
av_buffer_create
(
new_pkt
.
data
,
new_pkt
.
size
,
av_buffer_default_free
,
NULL
,
0
);
if
(
new_pkt
.
buf
)
{
pkt
->
side_data
=
NULL
;
pkt
->
side_data_elems
=
0
;
av_packet_unref
(
pkt
);
}
else
{
av_freep
(
&
new_pkt
.
data
);
a
=
AVERROR
(
ENOMEM
);
}
}
if
(
a
<
0
)
{
av_log
(
codec
,
AV_LOG_ERROR
,
"Failed to open bitstream filter %s for stream %d with codec %s"
,
bsfc
->
filter
->
name
,
pkt
->
stream_index
,
codec
->
codec
?
codec
->
codec
->
name
:
"copy"
);
ret
=
a
;
break
;
}
*
pkt
=
new_pkt
;
bsfc
=
bsfc
->
next
;
}
return
ret
;
}
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