summaryrefslogtreecommitdiff
path: root/libavcodec/h264_mp4toannexb_bsf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-04-19 19:37:49 +0200
committerAnton Khirnov <anton@khirnov.net>2016-04-24 10:06:23 +0200
commitf3ed484953b81856e40239d2410058a96188b2be (patch)
tree4652d717765785c18308db5e3b3913b315b510cb /libavcodec/h264_mp4toannexb_bsf.c
parent5fca95c8e515a5ae542d9626ec088bdfc658450e (diff)
downloadffmpeg-f3ed484953b81856e40239d2410058a96188b2be.tar.gz
h264_mp4toannexb_bsf: do not fail on annex B extradata
Just pass through the bitstream as is. This is the same as what is done for HEVC already.
Diffstat (limited to 'libavcodec/h264_mp4toannexb_bsf.c')
-rw-r--r--libavcodec/h264_mp4toannexb_bsf.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c
index c1e2a28adc..c65aaeb98a 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -131,10 +131,16 @@ static int h264_extradata_to_annexb(AVBSFContext *ctx, const int padding)
static int h264_mp4toannexb_init(AVBSFContext *ctx)
{
H264BSFContext *s = ctx->priv_data;
+ int extra_size = ctx->par_in->extradata_size;
int ret;
/* retrieve sps and pps NAL units from extradata */
- if (ctx->par_in->extradata_size >= 6) {
+ if (!extra_size ||
+ (extra_size >= 3 && AV_RB24(ctx->par_in->extradata) == 1) ||
+ (extra_size >= 4 && AV_RB32(ctx->par_in->extradata) == 1)) {
+ av_log(ctx, AV_LOG_VERBOSE,
+ "The input looks like it is Annex B already\n");
+ } else if (extra_size >= 6) {
ret = h264_extradata_to_annexb(ctx, AV_INPUT_BUFFER_PADDING_SIZE);
if (ret < 0)
return ret;
@@ -142,6 +148,9 @@ static int h264_mp4toannexb_init(AVBSFContext *ctx)
s->length_size = ret;
s->first_idr = 1;
s->extradata_parsed = 1;
+ } else {
+ av_log(ctx, AV_LOG_ERROR, "Invalid extradata size: %d\n", extra_size);
+ return AVERROR_INVALIDDATA;
}
return 0;