[FFmpeg-devel] [PATCH] avformat/flacenc: support writing attached pictures

Timo Teras timo.teras at iki.fi
Wed Apr 4 08:11:17 EEST 2018


On Wed,  4 Apr 2018 01:30:54 -0300
James Almer <jamrial at gmail.com> wrote:

> From: Rodger Combs <rodger.combs at gmail.com>
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> Now using the packet list API instead of duplicating the code locally.
> 
>  libavformat/flacenc.c | 274
> +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed,
> 238 insertions(+), 36 deletions(-)
> 
> diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
> index b894f9ef61..99f4ce7bad 100644
>[snip]
> -        c->streaminfo = av_malloc(FLAC_STREAMINFO_SIZE);
> -        if (!c->streaminfo)
> -            return AVERROR(ENOMEM);
> -        memcpy(c->streaminfo, streaminfo, FLAC_STREAMINFO_SIZE);
> +        /* warn only once for each stream */
> +        if (s->streams[pkt->stream_index]->nb_frames == 1) {
> +            av_log(s, AV_LOG_WARNING, "Got more than one picture in
> stream %d,"
> +                   " ignoring.\n", pkt->stream_index);
> +        }
> +        if (!c->waiting_pics ||
> s->streams[pkt->stream_index]->nb_frames >= 1)
> +            return 0;
> +
> +        if (index > c->audio_stream_idx)
> +            index--;
> +
> +        if ((ret = av_packet_ref(&c->pics[index], pkt)) < 0)
> +            return ret;
> +        c->waiting_pics--;
> +
> +        /* flush the buffered audio packets */
> +        if (!c->waiting_pics &&
> +            (ret = flac_queue_flush(s)) < 0)
> +            return ret;
>      }
>  
> -    if (pkt->size)
> -        avio_write(s->pb, pkt->data, pkt->size);
>      return 0;
>  }
>  

I've submitted attached picture support to movenc just now. Instead of
defining separate pictures queue, I'm reusing the AVStream.attached_pic
to hold it. Would it make sense to share this small piece of code in
some utility function (and use also AVStream.attached_pic here)?

See: https://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/227708.html




More information about the ffmpeg-devel mailing list