OSDN Git Service

tests: fix JPEG decoding test to match the latest API.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 31 Jul 2012 09:04:24 +0000 (11:04 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 1 Aug 2012 08:31:02 +0000 (10:31 +0200)
Fix bug in parsing Huffman DC table and also sync the code to match
the latest API change. In particular, pad the Huffman table with
zero to suit 4-byte boundaries.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit d4c88950dafefead1a775c0ae6636917e23339fd)

test/decode/tinyjpeg.c

index e9bcc1b..420fc52 100644 (file)
@@ -325,11 +325,9 @@ static int parse_DHT(struct jdec_private *priv, const unsigned char *stream)
      Th = index & 0x0f;
      if (Tc) {
         memcpy(priv->HTAC[index & 0xf].bits, stream, 16);
-        priv->HTAC_valid[index & 0xf] = 1;
      }
      else {
-         memcpy(priv->HTDC[index & 0xf].bits, stream, 12);
-         priv->HTDC_valid[index & 0xf] = 1;
+         memcpy(priv->HTDC[index & 0xf].bits, stream, 16);
      }
 
      count = 0;
@@ -347,9 +345,11 @@ static int parse_DHT(struct jdec_private *priv, const unsigned char *stream)
 
      if (Tc) {
         memcpy(priv->HTAC[index & 0xf].values, stream, count);
+        priv->HTAC_valid[index & 0xf] = 1;
      }
      else {
         memcpy(priv->HTDC[index & 0xf].values, stream, count);
+        priv->HTDC_valid[index & 0xf] = 1;
      }
 
      length -= 1;
@@ -663,6 +663,8 @@ int tinyjpeg_decode(struct jdec_private *priv)
                sizeof(huffman_table.huffman_table[i].num_ac_codes));
         memcpy(huffman_table.huffman_table[i].ac_values, priv->HTAC[i].values,
                sizeof(huffman_table.huffman_table[i].ac_values));
+        memset(huffman_table.huffman_table[i].pad, 0,
+               sizeof(huffman_table.huffman_table[i].pad));
     }
 
     va_status = vaCreateBuffer(va_dpy, context_id,