Browse code

Fix decoding of 24 bpp TM1 (except for aspect).

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

Reimar Döffinger authored on 2010/11/04 02:01:30
Showing 1 changed files
... ...
@@ -307,6 +307,7 @@ static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_
307 307
 static int truemotion1_decode_header(TrueMotion1Context *s)
308 308
 {
309 309
     int i;
310
+    int width_shift = 0;
310 311
     int new_pix_fmt;
311 312
     struct frame_header header;
312 313
     uint8_t header_buffer[128];  /* logical maximum size of the header */
... ...
@@ -373,8 +374,6 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
373 373
             }
374 374
         }
375 375
     }
376
-    if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
377
-        return -1;
378 376
 
379 377
     if (header.compression >= 17) {
380 378
         av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression);
... ...
@@ -396,11 +395,16 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
396 396
         }
397 397
     }
398 398
 
399
-    if (compression_types[header.compression].algorithm == ALGO_RGB24H)
399
+    if (compression_types[header.compression].algorithm == ALGO_RGB24H) {
400 400
         new_pix_fmt = PIX_FMT_RGB32;
401
-    else
401
+        width_shift = 1;
402
+    } else
402 403
         new_pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well
403 404
 
405
+    s->w >>= width_shift;
406
+    if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
407
+        return -1;
408
+
404 409
     if (s->w != s->avctx->width || s->h != s->avctx->height ||
405 410
         new_pix_fmt != s->avctx->pix_fmt) {
406 411
         if (s->frame.data[0])
... ...
@@ -413,7 +417,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
413 413
     /* There is 1 change bit per 4 pixels, so each change byte represents
414 414
      * 32 pixels; divide width by 4 to obtain the number of change bits and
415 415
      * then round up to the nearest byte. */
416
-    s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3;
416
+    s->mb_change_bits_row_size = ((s->avctx->width >> (2 - width_shift)) + 7) >> 3;
417 417
 
418 418
     if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
419 419
     {
... ...
@@ -827,7 +831,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
827 827
                 }
828 828
             }
829 829
 
830
-            pixels_left -= 4;
830
+            pixels_left -= 2;
831 831
         }
832 832
 
833 833
         /* next change row */