[FFmpeg-devel] [PATCH v2] lavf/avienc: Use palette side data packet if available

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Feb 28 00:34:10 CET 2016


On Sat, Feb 27, 2016 at 10:55:13PM +0100, Mats Peterson wrote:
> -                if (!avist->hdr_pal_done) {
> -                    int64_t cur_offset = avio_tell(pb);
> -                    avio_seek(pb, avist->pal_offset, SEEK_SET);
> -                    for (i = 0; i < pal_size; i++) {
> -                        uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
> -                        avio_wl32(pb, v & 0xffffff);
> -                    }
> -                    avio_seek(pb, cur_offset, SEEK_SET);
> -                    avist->hdr_pal_done++;
> -                }

Hadn't seen this before.
In principle it is a bit unfortunate as it means that streaming via
stdout is not possible.
It should at least be suppressed when seeking the output stream
is not possible.


> +        for (i = 0; i < pkt->side_data_elems; i++) {
> +            if (pkt->side_data[i].type == AV_PKT_DATA_PALETTE) {
> +                pal = pkt->side_data[i].data;
> +                break;
> +            }
> +        }

av_frame_get_side_data

> -                    uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
> -                    avio_wb32(pb, v<<8);
> +                    uint32_t v = AV_RL32(pal + 4*i);
> +                    avio_wl32(pb, v & 0xffffff);

You'll probably still need the if to use the one or the avio_w...
depending on format.
Unless it's possible to change the embedded format to match
the side data one.

> +            for (i = 0; i < pal_size; i++) {
> +                uint32_t v = AV_RL32(pal + 4*i);
> +                avio_wb32(pb, v<<8);

Why is the header format different? That seems a bit weird.


More information about the ffmpeg-devel mailing list