diff mbox

[FFmpeg-devel] lavc/qdrw: Read PixMap palette

Message ID CAB0OVGodOy2CMa1jbp4uRWbXVF5JMygCp8LbebODA-yif+Exdg@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos May 5, 2018, 12:26 a.m. UTC
Hi!

Attached patch fixes ticket #6195 for me.

Please comment, Carl Eugen

Comments

Carl Eugen Hoyos May 7, 2018, 4:19 p.m. UTC | #1
2018-05-05 2:26 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Attached patch fixes ticket #6195 for me.

I'll push this if there are no comments.

Carl Eugen
Carl Eugen Hoyos May 10, 2018, 9:06 p.m. UTC | #2
2018-05-05 2:26 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Attached patch fixes ticket #6195 for me.

Patch applied.

Carl Eugen
diff mbox

Patch

From 3aaeb2e44972d23d021e4567c9826162beb816f2 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sat, 5 May 2018 02:24:15 +0200
Subject: [PATCH] lavc/qdrw: Read PixMap palette.

Fixes ticket #6195.
---
 libavcodec/qdrw.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index 82cc528..32ba410 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -45,14 +45,14 @@  enum QuickdrawOpcodes {
 };
 
 static int parse_palette(AVCodecContext *avctx, GetByteContext *gbc,
-                         uint32_t *pal, int colors)
+                         uint32_t *pal, int colors, int pixmap)
 {
     int i;
 
     for (i = 0; i <= colors; i++) {
         uint8_t r, g, b;
         unsigned int idx = bytestream2_get_be16(gbc); /* color index */
-        if (idx > 255) {
+        if (idx > 255 && !pixmap) {
             av_log(avctx, AV_LOG_WARNING,
                    "Palette index out of range: %u\n", idx);
             bytestream2_skip(gbc, 6);
@@ -66,7 +66,7 @@  static int parse_palette(AVCodecContext *avctx, GetByteContext *gbc,
         bytestream2_skip(gbc, 1);
         b = bytestream2_get_byte(gbc);
         bytestream2_skip(gbc, 1);
-        pal[idx] = (0xFFU << 24) | (r << 16) | (g << 8) | b;
+        pal[pixmap ? i : idx] = (0xFFU << 24) | (r << 16) | (g << 8) | b;
     }
     return 0;
 }
@@ -335,6 +335,7 @@  static int decode_frame(AVCodecContext *avctx,
     while (bytestream2_get_bytes_left(&gbc) >= 4) {
         int bppcnt, bpp;
         int rowbytes, pack_type;
+        int flags;
         int opcode = bytestream2_get_be16(&gbc);
 
         switch(opcode) {
@@ -345,7 +346,8 @@  static int decode_frame(AVCodecContext *avctx,
         case PACKBITSRGN:
             av_log(avctx, AV_LOG_DEBUG, "Parsing Packbit opcode\n");
 
-            bytestream2_skip(&gbc, 30);
+            flags = bytestream2_get_be16(&gbc) & 0xC000;
+            bytestream2_skip(&gbc, 28);
             bppcnt = bytestream2_get_be16(&gbc); /* cmpCount */
             bpp    = bytestream2_get_be16(&gbc); /* cmpSize */
 
@@ -380,7 +382,7 @@  static int decode_frame(AVCodecContext *avctx,
             if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
                 return ret;
 
-            ret = parse_palette(avctx, &gbc, (uint32_t *)p->data[1], colors);
+            ret = parse_palette(avctx, &gbc, (uint32_t *)p->data[1], colors, flags & 0x8000);
             if (ret < 0)
                 return ret;
             p->palette_has_changed = 1;
-- 
1.7.10.4