Browse code

TM2 fixes by Kostya

Originally committed as revision 4645 to svn://svn.ffmpeg.org/ffmpeg/trunk

Mike Melanson authored on 2005/10/15 23:33:11
Showing 1 changed files
... ...
@@ -29,7 +29,7 @@
29 29
 #include "dsputil.h"
30 30
 
31 31
 #define TM2_ESCAPE 0x80000000
32
-#define TM2_DELTAS 32
32
+#define TM2_DELTAS 64
33 33
 /* Huffman-coded streams of different types of blocks */
34 34
 enum TM2_STREAMS{ TM2_C_HI = 0, TM2_C_LO, TM2_L_HI, TM2_L_LO,
35 35
      TM2_UPD, TM2_MOT, TM2_TYPE, TM2_NUM_STREAMS};
... ...
@@ -218,7 +218,7 @@ static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf)
218 218
         length = LE_32(buf);
219 219
         buf += 4;
220 220
         
221
-        init_get_bits(&ctx->gb, buf, 32);
221
+        init_get_bits(&ctx->gb, buf, 32 * 8);
222 222
         size = get_bits_long(&ctx->gb, 31);
223 223
         h = get_bits(&ctx->gb, 15);
224 224
         w = get_bits(&ctx->gb, 15);
... ...
@@ -281,7 +281,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
281 281
             len = BE_32(buf); buf += 4; cur += 4;
282 282
         }
283 283
         if(len > 0) {
284
-            init_get_bits(&ctx->gb, buf, skip - cur);
284
+            init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
285 285
             if(tm2_read_deltas(ctx, stream_id) == -1)
286 286
                 return -1;
287 287
             buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
... ...
@@ -295,7 +295,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
295 295
     buf += 4; cur += 4;
296 296
     buf += 4; cur += 4; /* unused by decoder */
297 297
     
298
-    init_get_bits(&ctx->gb, buf, skip - cur);
298
+    init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
299 299
     if(tm2_build_huff_table(ctx, &codes) == -1)
300 300
         return -1;
301 301
     buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
... ...
@@ -312,11 +312,12 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
312 312
     ctx->tok_lens[stream_id] = toks;
313 313
     len = BE_32(buf); buf += 4; cur += 4;
314 314
     if(len > 0) {
315
-        init_get_bits(&ctx->gb, buf, skip - cur);
315
+        init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
316 316
         for(i = 0; i < toks; i++)
317 317
             ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
318 318
     } else {
319
-        memset(ctx->tokens[stream_id], 0, toks * sizeof(int));
319
+        for(i = 0; i < toks; i++)
320
+            ctx->tokens[stream_id][i] = codes.recode[0];
320 321
     }
321 322
     tm2_free_codes(&codes);
322 323
     
... ...
@@ -765,7 +766,8 @@ static int decode_frame(AVCodecContext *avctx,
765 765
     int skip, t;
766 766
 
767 767
     p->reference = 1;
768
-    if(avctx->get_buffer(avctx, p) < 0){
768
+    p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
769
+    if(avctx->reget_buffer(avctx, p) < 0){
769 770
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
770 771
         return -1;
771 772
     }