Mercurial > libavcodec.hg
comparison aasc.c @ 8264:48dcf657f897 libavcodec
AASC can contain raw data in addition to MS-RLE
author | kostya |
---|---|
date | Sat, 06 Dec 2008 08:57:31 +0000 |
parents | f874e1d5cf07 |
children | e9d9d946f213 |
comparison
equal
deleted
inserted
replaced
8263:2e8368ea591a | 8264:48dcf657f897 |
---|---|
60 static int aasc_decode_frame(AVCodecContext *avctx, | 60 static int aasc_decode_frame(AVCodecContext *avctx, |
61 void *data, int *data_size, | 61 void *data, int *data_size, |
62 const uint8_t *buf, int buf_size) | 62 const uint8_t *buf, int buf_size) |
63 { | 63 { |
64 AascContext *s = avctx->priv_data; | 64 AascContext *s = avctx->priv_data; |
65 int compr, i, stride; | |
65 | 66 |
66 s->frame.reference = 1; | 67 s->frame.reference = 1; |
67 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; | 68 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
68 if (avctx->reget_buffer(avctx, &s->frame)) { | 69 if (avctx->reget_buffer(avctx, &s->frame)) { |
69 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); | 70 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
70 return -1; | 71 return -1; |
71 } | 72 } |
72 | 73 |
73 ff_msrle_decode(avctx, &s->frame, 8, buf, buf_size); | 74 compr = AV_RL32(buf); |
75 buf += 4; | |
76 buf_size -= 4; | |
77 switch(compr){ | |
78 case 0: | |
79 stride = (avctx->width * 3 + 3) & ~3; | |
80 for(i = avctx->height - 1; i >= 0; i--){ | |
81 memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width*3); | |
82 buf += stride; | |
83 } | |
84 break; | |
85 case 1: | |
86 ff_msrle_decode(avctx, &s->frame, 8, buf - 4, buf_size + 4); | |
87 break; | |
88 default: | |
89 av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); | |
90 return -1; | |
91 } | |
74 | 92 |
75 *data_size = sizeof(AVFrame); | 93 *data_size = sizeof(AVFrame); |
76 *(AVFrame*)data = s->frame; | 94 *(AVFrame*)data = s->frame; |
77 | 95 |
78 /* report that the buffer was completely consumed */ | 96 /* report that the buffer was completely consumed */ |