[FFmpeg-devel] [PATCH 01/11] lavf/mux: fix auto-inserted bsfs that read extradata

Hendrik Leppkes h.leppkes at gmail.com
Fri Apr 15 11:17:20 CEST 2016


On Fri, Apr 15, 2016 at 10:37 AM, Rodger Combs <rodger.combs at gmail.com> wrote:
> ---
>  libavformat/mux.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index 33301f1..0ed0c3d 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1054,6 +1054,16 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
>              }
>          }
>
> +        if (!st->internal->avctx->extradata && st->codecpar->extradata) {
> +            int size = st->codecpar->extradata_size;
> +            if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
> +                return AVERROR(EINVAL);
> +            st->internal->avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
> +            if (!st->internal->avctx->extradata)
> +                return AVERROR(ENOMEM);
> +            st->internal->avctx->extradata_size = size;
> +            memcpy(st->internal->avctx->extradata, st->codecpar->extradata, size);
> +        }
>          av_apply_bitstream_filters(st->internal->avctx, pkt, st->internal->bsfc);
>          if (pkt->size == 0 && pkt->side_data_elems == 0)
>              return 0;
> --
> 2.7.3

Derek is actively working on merging the new BSF API right now, it
might be better to just update this to the new API instead of wasting
some time on the old one.
It solves a bunch of these problems by accepting codecpar directly.

- Hendrik


More information about the ffmpeg-devel mailing list