]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mimic.c
fix adpcm ima qt decoding, channel at init is 0, correct stereo out since samples...
[ffmpeg] / libavcodec / mimic.c
index 8a4fba6c0e537bdada57d61ffda85047d20c2cce..7687f0ef6869bbb8b0b7cb527eee80e48526f8de 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "avcodec.h"
 #include "bitstream.h"
+#include "bytestream.h"
 #include "dsputil.h"
 
 #define MIMIC_HEADER_SIZE   20
@@ -157,9 +158,9 @@ const static int8_t vlcdec_lookup[9][64] = {
        -67,  67,  -66,  66,  -65,  65,  -64,  64, },
 };
 
-static int vlc_decode_block(MimicContext *ctx, DCTELEM *block, int num_coeffs,
-                            int qscale)
+static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
 {
+    DCTELEM *block = ctx->dct_block;
     unsigned int pos;
 
     memset(block, 0, 64 * sizeof(DCTELEM));
@@ -227,8 +228,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
                      * Chroma planes don't use backreferences. */
                     if(is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
 
-                        if(!vlc_decode_block(ctx, ctx->dct_block,
-                                             num_coeffs, qscale))
+                        if(!vlc_decode_block(ctx, num_coeffs, qscale))
                             return 0;
                         ctx->dsp.idct_put(dst, stride, ctx->dct_block);
                     } else {
@@ -282,24 +282,19 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
     int quality, num_coeffs;
     int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
 
-    /*
-     * Header structure:
-     *  uint16_t    I_dont_remember;
-     *  uint16_t    quality;
-     *  uint16_t    width;
-     *  uint16_t    height;
-     *  uint32_t    some_constant;
-     *  uint32_t    is_pframe;
-     *  uint32_t    num_coeffs;
-     */
-
     if(buf_size < MIMIC_HEADER_SIZE) {
         av_log(avctx, AV_LOG_ERROR, "insufficient data\n");
         return -1;
     }
 
-    width  = AV_RL16(buf + 4);
-    height = AV_RL16(buf + 6);
+    buf       += 2; /* some constant (always 256) */
+    quality    = bytestream_get_le16(&buf);
+    width      = bytestream_get_le16(&buf);
+    height     = bytestream_get_le16(&buf);
+    buf       += 4; /* some constant */
+    is_pframe  = bytestream_get_le32(&buf);
+    num_coeffs = bytestream_get_byte(&buf);
+    buf       += 3; /* some constant */
 
     if(!ctx->avctx) {
         int i;
@@ -323,10 +318,6 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
         return -1;
     }
 
-    quality    = AV_RL16(buf + 2);
-    is_pframe  = AV_RL32(buf + 12);
-    num_coeffs = buf[16];
-
     if(is_pframe && !ctx->buf_ptrs[ctx->prev_index].data[0]) {
         av_log(avctx, AV_LOG_ERROR, "decoding must start with keyframe\n");
         return -1;
@@ -347,7 +338,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_NOMEM;
 
     ctx->dsp.bswap_buf((uint32_t*)ctx->swap_buf,
-                        (const uint32_t*) (buf + MIMIC_HEADER_SIZE),
+                        (const uint32_t*) buf,
                         swap_buf_size>>2);
     init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3);