[FFmpeg-devel] [PATCH]Increase dynamics for more palettes

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Nov 13 03:24:47 CET 2011


Hi!

I found some more palettes that could need more dynamics.

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
index b316535..1a19c19 100644
--- a/libavcodec/bethsoftvideo.c
+++ b/libavcodec/bethsoftvideo.c
@@ -53,6 +53,7 @@ static void set_palette(AVFrame * frame, const uint8_t * palette_buffer)
     int a;
     for(a = 0; a < 256; a++){
         palette[a] = 0xFF << 24 | AV_RB24(&palette_buffer[a * 3]) * 4;
+        palette[a] |= palette[a] >> 6 & 0x30303;
     }
     frame->palette_has_changed = 1;
 }
diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index 947be39..94d1f9c 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -61,7 +61,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     if ((s->flags & BINTEXT_PALETTE)) {
         for (i = 0; i < 16; i++) {
-            s->palette[i] = 0xFF000000 | (AV_RB24(p) << 2);
+            s->palette[i] = 0xFF000000 | (AV_RB24(p) << 2) | (AV_RB24(p) >> 6) & 0x30303;
             p += 3;
         }
     } else {
diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index e5367d0..9111d17 100644
--- a/libavcodec/flicvideo.c
+++ b/libavcodec/flicvideo.c
@@ -239,6 +239,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
                     g = buf[stream_ptr++] << color_shift;
                     b = buf[stream_ptr++] << color_shift;
                     entry = 0xFF << 24 | r << 16 | g << 8 | b;
+                    if (color_shift == 2)
+                        entry |= entry >> 6 & 0x30303;
                     if (s->palette[palette_ptr] != entry)
                         s->new_palette = 1;
                     s->palette[palette_ptr++] = entry;
diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index ae6e488..436b96d 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -177,7 +177,7 @@ static int decode_frame(AVCodecContext *avctx,
         npal = FFMIN(esize / 3, 256);
         for (i = 0; i < npal; i++) {
             palette[i] = AV_RB24(buf + i*3) << 2;
-            palette[i] |= 0xFF << 24;
+            palette[i] |= 0xFF << 24 | palette[i] >> 6 & 0x30303;
         }
     } else {
         if (bpp == 1) {
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index be256e1..06c6255 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -265,6 +265,7 @@ static void vmd_decode(VmdVideoContext *s)
             g = *p++ * 4;
             b = *p++ * 4;
             palette32[i] = 0xFF << 24 | r << 16 | g << 8 | b;
+            palette32[i] |= palette32[i] >> 6 & 0x30303;
         }
     }
     if (p < p_end) {
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index 5db8a22..917e04b 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -403,6 +403,7 @@ static void vqa_decode_chunk(VqaContext *s)
             g = s->buf[cpl0_chunk++] * 4;
             b = s->buf[cpl0_chunk++] * 4;
             s->palette[i] = 0xFF << 24 | r << 16 | g << 8 | b;
+            s->palette[i] |= s->palette[i] >> 6 & 0x30303;
         }
     }
 


More information about the ffmpeg-devel mailing list