[FFmpeg-devel] [PATCH] ffmpeg: merge extradata checks in write_frame

Michael Niedermayer michael at niedermayer.cc
Thu Sep 1 19:14:47 EEST 2016


On Thu, Sep 01, 2016 at 05:14:45PM +0200, Clément Bœsch wrote:
> From: Clément Bœsch <clement at stupeflix.com>
> 
> ---
>  ffmpeg.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 3229823..493b605 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -638,11 +638,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
>      AVCodecContext          *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec;
>      int ret;
>  
> -    if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) {
> -        ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
> -        if (ost->st->codec->extradata) {
> -            memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
> -            ost->st->codec->extradata_size = ost->enc_ctx->extradata_size;
> +    if (!ost->st->codecpar->extradata_size && ost->enc_ctx->extradata_size) {
> +        ost->st->codecpar->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
> +        if (ost->st->codecpar->extradata) {
> +            memcpy(ost->st->codecpar->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
> +            ost->st->codecpar->extradata_size = ost->enc_ctx->extradata_size;
>          }
>      }
>  
> @@ -696,15 +696,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
>      }
>      if (pkt->size == 0 && pkt->side_data_elems == 0)
>          return;
> -    if (!ost->st->codecpar->extradata && avctx->extradata) {
> -        ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
> -        if (!ost->st->codecpar->extradata) {
> -            av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
> -            exit_program(1);
> -        }
> -        ost->st->codecpar->extradata_size = avctx->extradata_size;
> -        memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
> -    }
>  
>      if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
>          if (pkt->dts != AV_NOPTS_VALUE &&

this changes the output of:
 ./ffmpeg -i tickets/3715/foo.aac -c copy -bsf:a aac_adtstoasc -t 0.1 out.m4a

(extradata seem lost)

 [...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160901/b1b4c216/attachment.sig>


More information about the ffmpeg-devel mailing list