Browse code

AASC can contain raw data in addition to MS-RLE

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

Kostya Shishkov authored on 2008/12/06 17:57:31
Showing 1 changed files
... ...
@@ -62,6 +62,7 @@ static int aasc_decode_frame(AVCodecContext *avctx,
62 62
                               const uint8_t *buf, int buf_size)
63 63
 {
64 64
     AascContext *s = avctx->priv_data;
65
+    int compr, i, stride;
65 66
 
66 67
     s->frame.reference = 1;
67 68
     s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
... ...
@@ -70,7 +71,24 @@ static int aasc_decode_frame(AVCodecContext *avctx,
70 70
         return -1;
71 71
     }
72 72
 
73
-    ff_msrle_decode(avctx, &s->frame, 8, buf, buf_size);
73
+    compr = AV_RL32(buf);
74
+    buf += 4;
75
+    buf_size -= 4;
76
+    switch(compr){
77
+    case 0:
78
+        stride = (avctx->width * 3 + 3) & ~3;
79
+        for(i = avctx->height - 1; i >= 0; i--){
80
+            memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width*3);
81
+            buf += stride;
82
+        }
83
+        break;
84
+    case 1:
85
+        ff_msrle_decode(avctx, &s->frame, 8, buf - 4, buf_size + 4);
86
+        break;
87
+    default:
88
+        av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
89
+        return -1;
90
+    }
74 91
 
75 92
     *data_size = sizeof(AVFrame);
76 93
     *(AVFrame*)data = s->frame;