[FFmpeg-devel] [PATCH v2 1/4] lavf/riffenc: Write space for palette

Michael Niedermayer michael at niedermayer.cc
Sat Feb 20 03:40:32 CET 2016


On Sat, Feb 20, 2016 at 12:02:15AM +0100, Mats Peterson wrote:
> 
> -- 
> Mats Peterson
> http://matsp888.no-ip.org/~mats/

>  riffenc.c |   23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 63ec167e5794087397c65d3a5002e6bbd7a32caf  0001-lavf-riffenc-Write-space-for-palette.patch
> From 41964552559234f19917a6ea40e71f0753a20ede Mon Sep 17 00:00:00 2001
> From: Mats Peterson <matsp888 at yahoo.com>
> Date: Fri, 19 Feb 2016 23:55:25 +0100
> Subject: [PATCH v2 1/4] lavf/riffenc: Write space for palette
> 
> ---
>  libavformat/riffenc.c |   23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
> index ceb27f2..c7bad74 100644
> --- a/libavformat/riffenc.c
> +++ b/libavformat/riffenc.c
> @@ -210,6 +210,9 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
>                        !memcmp(enc->extradata + enc->extradata_size - 9, "BottomUp", 9);
>      int extradata_size = enc->extradata_size - 9*keep_height;
>  
> +    if (!enc->extradata_size && enc->bits_per_coded_sample >= 1 && enc->bits_per_coded_sample <= 8)
> +        extradata_size = 4 * (1 << enc->bits_per_coded_sample);

this should probably be limited to the CODEC_ID_RAWVIDEO case
and also to avi and not asf until it is implemented for asf too


> +
>      /* size */
>      avio_wl32(pb, 40 + (ignore_extradata ? 0 :extradata_size));
>      avio_wl32(pb, enc->width);
> @@ -228,10 +231,22 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
>      avio_wl32(pb, 0);
>  
>      if (!ignore_extradata) {
> -        avio_write(pb, enc->extradata, extradata_size);
> -
> -        if (!for_asf && extradata_size & 1)
> -            avio_w8(pb, 0);
> +        if (enc->extradata_size) {
> +            avio_write(pb, enc->extradata, extradata_size);
> +            if (!for_asf && extradata_size & 1)
> +                avio_w8(pb, 0);
> +        } else if (enc->bits_per_coded_sample >= 1 && enc->bits_per_coded_sample <= 8) {
> +            int i;

> +            int64_t *pal_offset = (int64_t *)enc->priv_data;

the codec priv_data must not be accessed from a muxer, its private to
the codec


> +            *pal_offset = avio_tell(pb);
> +            for (i = 0; i < 1 << enc->bits_per_coded_sample; i++) {
> +                /* Initialize 1 bpp palette to black & white */
> +                if (!i && enc->bits_per_coded_sample == 1)
> +                    avio_wl32(pb, 0xffffff);
> +                else
> +                    avio_wl32(pb, 0);
> +            }
> +        }
>      }
>  }


[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160220/159dc413/attachment.sig>


More information about the ffmpeg-devel mailing list