Currently the only palettized pixel format in FFmpeg is AV_PIX_FMT_PAL8. In case there will be other palettized formats in the future, I have "guarded" myself by using 1 << bits_per_coded_sample in avienc.c and movenc.c for calculating the number of palette entries in packets containing a palette at the end, rather than just assuming 256 entries.

If we can agree on using this 1 << bits_per_coded_sample logic overall for packets containing a palette, in the same way as it is done in AVI and QuickTime, here's a patch of ff_reshuffle_raw_rgb() that makes it somewhat more future-proof.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 4d755a3167450f161a13fe4c6a9f74eacf5f1180 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Sat, 27 Feb 2016 14:02:34 +0100
Subject: [PATCH] lavf/rawutils: Make ff_reshuffle_raw_rgb() somewhat more future-proof

---
 libavformat/rawutils.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c
index 26ebbb5..1424152 100644
--- a/libavformat/rawutils.c
+++ b/libavformat/rawutils.c
@@ -28,8 +28,8 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *en
     AVPacket *pkt = *ppkt;
     int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
     int min_stride = (enc->width * bpc + 7) >> 3;
-    int with_pal_size = min_stride * enc->height + 1024;
-    int contains_pal = bpc == 8 && pkt->size == with_pal_size;
+    int with_pal_size = min_stride * enc->height + (1 << bpc) * 4;
+    int contains_pal = bpc >= 1 && bpc <= 8 && pkt->size == with_pal_size;
     int size = contains_pal ? min_stride * enc->height : pkt->size;
     int stride = size / enc->height;
     int padding = expected_stride - FFMIN(expected_stride, stride);
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to