From 656ffb504de10f2e95fc0d4cf4ea83cc8a11c225 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 31 Jul 2012 11:04:24 +0200 Subject: tests: fix JPEG decoding test to match the latest API. 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 (cherry picked from commit d4c88950dafefead1a775c0ae6636917e23339fd) --- test/decode/tinyjpeg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/decode/tinyjpeg.c b/test/decode/tinyjpeg.c index e9bcc1b..420fc52 100644 --- a/test/decode/tinyjpeg.c +++ b/test/decode/tinyjpeg.c @@ -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, -- cgit v1.2.1