changeset 520:5d96fe8f6560 libavformat

added support for the elusive AVI palette change chunk, courtesy of Kostya <cannonball at bw-team.com>
author melanson
date Thu, 16 Sep 2004 02:14:50 +0000
parents d59dc270e1f5
children eb14a350e64a
files avidec.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/avidec.c	Wed Sep 15 01:35:09 2004 +0000
+++ b/avidec.c	Thu Sep 16 02:14:50 2004 +0000
@@ -490,6 +490,32 @@
             return size;
           }
         }
+        /* palette changed chunk */
+        if (   d[0] >= '0' && d[0] <= '9'
+            && d[1] >= '0' && d[1] <= '9'
+            && ((d[2] == 'p' && d[3] == 'c'))
+            && n < s->nb_streams && i + size <= avi->movi_end) {
+
+            AVStream *st;
+            int first, clr, flags, k, p;
+
+            st = s->streams[n];
+
+            first = get_byte(pb);
+            clr = get_byte(pb);
+            flags = get_le16(pb);
+            p = 4;
+            for (k = first; k < clr + first; k++) {
+                int r, g, b;
+                r = get_byte(pb);
+                g = get_byte(pb);
+                b = get_byte(pb);
+                    get_byte(pb);
+                st->codec.palctrl->palette[k] = b + (g << 8) + (r << 16);
+            }
+            st->codec.palctrl->palette_changed = 1;
+        }
+
     }
 
     return -1;