[FFmpeg-devel] [PATCH v26] lavf/movenc: Add palette to video sample description

Michael Niedermayer michael at niedermayer.cc
Fri Feb 26 04:12:42 CET 2016


On Wed, Feb 24, 2016 at 12:51:45PM +0100, Mats Peterson wrote:
> Small fix. Sorry for my spam-like patch posting, but that's the way
> I work at the moment. I'll try to limit myself in the future.
> 
> Mats

>  movenc.c |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  movenc.h |    5 +++++
>  2 files changed, 66 insertions(+), 2 deletions(-)
> 8b9ff40144318e901cab56e455d8487d7cba118b  0001-lavf-movenc-Add-palette-to-video-sample-description.patch
> From 0cf62b279e2577655e3867e8b0287c191784eeaa Mon Sep 17 00:00:00 2001
> From: Mats Peterson <matsp888 at yahoo.com>
> Date: Wed, 24 Feb 2016 12:49:50 +0100
> Subject: [PATCH v26] lavf/movenc: Add palette to video sample description
> 
> ---
>  libavformat/movenc.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  libavformat/movenc.h |    5 ++++
>  2 files changed, 66 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index b9c0f7a..f9b16b4 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1711,10 +1711,29 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
>      avio_write(pb, compressor_name, 31);
>  
>      if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample)
> -        avio_wb16(pb, track->enc->bits_per_coded_sample);
> +        avio_wb16(pb, track->enc->bits_per_coded_sample |
> +                  (track->enc->pix_fmt == AV_PIX_FMT_GRAY8 ? 0x20 : 0));
>      else
>          avio_wb16(pb, 0x18); /* Reserved */
> -    avio_wb16(pb, 0xffff); /* Reserved */
> +
> +    if (track->is_unaligned_qt_rgb && track->enc->pix_fmt == AV_PIX_FMT_PAL8) {
> +        int i;
> +        avio_wb16(pb, 0);             /* Color table ID */
> +        avio_wb32(pb, 0);             /* Color table seed */
> +        avio_wb16(pb, 0x8000);        /* Color table flags */
> +        avio_wb16(pb, 255);           /* Color table size (zero-relative) */
> +        for (i = 0; i < 256; i++) {
> +            uint16_t r = (track->palette[i] >> 16) & 0xff;
> +            uint16_t g = (track->palette[i] >> 8)  & 0xff;
> +            uint16_t b = track->palette[i]         & 0xff;

fails on big endian (mips)
./ffmpeg -i matrixbench_mpeg2.mpg -pix_fmt pal8 -vcodec rawvideo  -t 10 test.mov

i assume (but didnt try) that reading the palette with AV_RL32 or
bytewise would work


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- 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/20160226/44ebae10/attachment.sig>


More information about the ffmpeg-devel mailing list