summaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_mp4toannexb_bsf.c
diff options
context:
space:
mode:
authorChris \"Koying\" Browet <cbro@semperpax.com>2014-07-26 09:15:57 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-27 03:36:24 +0200
commitad91bf854b559f1afc42fc06f8a7dfbb75def5c8 (patch)
treee902a22071d7ef1513fadcba262fb1dbeb812d76 /libavcodec/h264_mp4toannexb_bsf.c
parente97f5bef95a224d32715ed5bcd456e327551975c (diff)
downloadffmpeg-streaming-ad91bf854b559f1afc42fc06f8a7dfbb75def5c8.zip
ffmpeg-streaming-ad91bf854b559f1afc42fc06f8a7dfbb75def5c8.tar.gz
avcodec/h264_mp4toannexb_bsf: fix issue when sps/pps are already in the bistream
Diffstat (limited to 'libavcodec/h264_mp4toannexb_bsf.c')
-rw-r--r--libavcodec/h264_mp4toannexb_bsf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c
index 0f142bb..a7b4f41 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -28,6 +28,7 @@
typedef struct H264BSFContext {
uint8_t length_size;
uint8_t first_idr;
+ uint8_t idr_sps_pps_seen;
int extradata_parsed;
} H264BSFContext;
@@ -155,6 +156,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
return ret;
ctx->length_size = ret;
ctx->first_idr = 1;
+ ctx->idr_sps_pps_seen = 0;
ctx->extradata_parsed = 1;
}
@@ -174,8 +176,12 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
if (buf + nal_size > buf_end || nal_size < 0)
goto fail;
- /* prepend only to the first type 5 NAL unit of an IDR picture */
- if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
+ if (ctx->first_idr && (unit_type == 7 || unit_type == 8))
+ ctx->idr_sps_pps_seen = 1;
+
+
+ /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */
+ if (ctx->first_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) {
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
avctx->extradata, avctx->extradata_size,
buf, nal_size)) < 0)
@@ -185,8 +191,10 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
NULL, 0, buf, nal_size)) < 0)
goto fail;
- if (!ctx->first_idr && unit_type == 1)
+ if (!ctx->first_idr && unit_type == 1) {
ctx->first_idr = 1;
+ ctx->idr_sps_pps_seen = 0;
+ }
}
buf += nal_size;
OpenPOWER on IntegriCloud