[FFmpeg-devel] [PATCH] Google WebP support
Stefano Sabatini
stefano.sabatini-lala
Wed Oct 6 20:37:23 CEST 2010
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/webpenc.c
> ===================================================================
> --- libavformat/webpenc.c (revision 0)
> +++ libavformat/webpenc.c (revision 0)
> @@ -0,0 +1,124 @@
[...]
> +static int write_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> + AVStream *stream = s->streams[pkt->stream_index];
> + AVCodecContext *codec = stream->codec;
> + ByteIOContext *pb = s->pb;
> + uint64_t vp8_start;
> +
> + if (codec->codec_id != CODEC_ID_VP8) {
> + av_log(s, AV_LOG_ERROR, "muxer only supports VP8 codec.");
> + return AVERROR_NOTSUPP;
> + }
Please use AVERROR(EINVAL), AVERROR_NOTSUPP is deprecated, we should
eventually use AVERROR(ENOSYS) but in this case I'd say that EINVAL is
acceptable (or PATCHWELCOME if it could be extended...).
[...]
> 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" :
...
chunk_size);
but feel free to completely ignore this nit if you prefer the other way.
Regards.
--
FFmpeg = Forgiving Fostering Meaningful Ponderous EnGraver
More information about the ffmpeg-devel
mailing list