[FFmpeg-devel] [PATCH] Add ICO muxer

Michael Niedermayer michaelni at gmx.at
Sun Aug 12 15:38:34 CEST 2012


On Thu, Aug 09, 2012 at 08:35:34PM -0600, Michael Bradshaw wrote:
> Hi,
> 
> Attached patch adds support for ICO muxing. I expect I'll need to make
> changes, so please don't hold back in your reviews (I've never written
> a muxer before so I'm still unsure if I got all the API contracts
> right). I'm mostly unsure of the flushing (if I didn't flush, my very
> small files would have missing data).
[...]
> +static int ico_write_trailer(AVFormatContext *s)
> +{
> +    IcoMuxContext *ico = s->priv_data;
> +    AVIOContext *pb = s->pb;
> +    int i;
> +
> +    if (ico->current_image != ico->nb_images) {
> +        av_log(s, AV_LOG_ERROR, "Error: ico is missing %d frames\n", ico->nb_images - ico->current_image);
> +        return AVERROR(EIO);
> +    }
> +
> +    avio_seek(pb, 6, SEEK_SET);
> +
> +    for (i = 0; i < ico->nb_images; i++) {
> +        avio_w8(pb, ico->images[i].width);
> +        avio_w8(pb, ico->images[i].height);
> +
> +        if (s->streams[i]->codec->codec_id == CODEC_ID_BMP &&
> +            s->streams[i]->codec->pix_fmt == PIX_FMT_PAL8) {
> +            avio_w8(pb, (ico->images[i].bits >= 8) ? 0 : 1 << ico->images[i].bits);
> +        } else {
> +            avio_w8(pb, 0);
> +        }
> +
> +        avio_w8(pb, 0); // reserved
> +        avio_wl16(pb, 1); // color planes
> +        avio_wl16(pb, ico->images[i].bits);
> +        avio_wl32(pb, ico->images[i].size);
> +        avio_wl32(pb, ico->images[i].offset);
> +    }
> +

> +    avio_flush(pb);

av_write_trailer()
calls avio_flush(), so this should not be needed

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120812/1d7efded/attachment.asc>


More information about the ffmpeg-devel mailing list