[FFmpeg-devel] [PATCH] Google WebP support

Aurelien Jacobs aurel
Wed Oct 6 23:01:11 CEST 2010


On Wed, Oct 06, 2010 at 08:37:23PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2010-10-05 13:49:06 -0700, Pascal Massimino encoded:
> > Aurelien,
> > 
> > another iteration:
> > 
> > On Tue, Oct 5, 2010 at 12:45 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
> [...]
> > Index: libavformat/webpdec.c
> > ===================================================================
> > --- libavformat/webpdec.c	(revision 0)
> > +++ libavformat/webpdec.c	(revision 0)
> > @@ -0,0 +1,120 @@
> [...]
> > +static int read_packet(AVFormatContext *s, AVPacket *pkt)
> > +{
> > +    AVStream *stream = s->streams[pkt->stream_index];
> > +    uint32_t tag = get_le32(s->pb);
> > +    uint32_t chunk_size = get_le32(s->pb);
> > +    int ret = -1;
> > +    if (tag == stream->codec->codec_tag)
> > +        ret = av_get_packet(s->pb, pkt, chunk_size);
> 
> > +    else if (tag == AV_RL32("IART"))
> > +        ret = get_metadata(s->pb, stream, "artist", chunk_size);
> > +    else if (tag == AV_RL32("ICOP"))
> > +        ret = get_metadata(s->pb, stream, "copyright", chunk_size);
> > +    else if (tag == AV_RL32("INAM"))
> > +        ret = get_metadata(s->pb, stream, "title", chunk_size);
> > +    else if (tag == AV_RL32("ICMT"))
> > +        ret = get_metadata(s->pb, stream, "comment", chunk_size);
> 
> This can be factorized:
> ret = get_metadata(s->pb, stream, tag == AV_RL32("IART") ? "artist"    :
>                                   tag == AV_RL32("ICOP") ? "copyright" :
>                                   ...

Actually you shouldn't use "artist", "title" and other generic strings
as keys. Instead you should use "IART", "INAM" and others directly, and
just set an appropriate conversion table in AVInputFormat.metadata_conv.
Same applies to the muxer.

Aurel



More information about the ffmpeg-devel mailing list