diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index 790dfb0394..3b3732bbd0 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -121,7 +121,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) HEVCBSFContext *s = ctx->priv_data; AVPacket *in; GetByteContext gb; - + int has_sps = 0, has_pps = 0; int got_irap = 0; int i, ret = 0; @@ -155,10 +155,13 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) } nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f; + has_sps = (has_sps || nalu_type == HEVC_NAL_SPS); + has_pps = (has_pps || nalu_type == HEVC_NAL_PPS); /* prepend extradata to IRAP frames */ is_irap = nalu_type >= 16 && nalu_type <= 23; - add_extradata = is_irap && !got_irap; + /* ignore the extradata if IRAP frame has sps and pps */ + add_extradata = is_irap && !got_irap && !(has_sps && has_pps); extra_size = add_extradata * ctx->par_out->extradata_size; got_irap |= is_irap;