changeset 11247:b48dd9213016 libavcodec

Make Bink decoder able to skip alpha plane
author kostya
date Mon, 22 Feb 2010 14:59:51 +0000
parents b75449aaea3e
children 926dde10e50d
files bink.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bink.c	Mon Feb 22 13:51:32 2010 +0000
+++ b/bink.c	Mon Feb 22 14:59:51 2010 +0000
@@ -77,6 +77,7 @@
     DSPContext     dsp;
     AVFrame        pic, last;
     int            version;              ///< internal Bink file version
+    int            has_alpha;
     int            swap_planes;
     ScanTable      scantable;            ///< permutated scantable for DCT coeffs decoding
 
@@ -692,6 +693,14 @@
     }
 
     init_get_bits(&gb, pkt->data, bits_count);
+    if (c->has_alpha) {
+        int aplane_bits = get_bits_long(&gb, 32) << 3;
+        if (aplane_bits <= 32 || (aplane_bits & 0x1F)) {
+            av_log(avctx, AV_LOG_ERROR, "Incorrect alpha plane size %d\n", aplane_bits);
+            return -1;
+        }
+        skip_bits_long(&gb, aplane_bits - 32);
+    }
     if (c->version >= 'i')
         skip_bits_long(&gb, 32);
 
@@ -927,6 +936,7 @@
         av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version);
         return -1;
     }
+    c->has_alpha = 0; //TODO: demuxer should supply decoder with flags
     c->swap_planes = c->version >= 'i';
     if (!bink_trees[15].table) {
         for (i = 0; i < 16; i++) {