summaryrefslogtreecommitdiff
path: root/libavcodec/wnv1.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2009-02-01 16:11:33 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2009-02-01 16:11:33 +0000
commitb7093975305c639630fd7ee5698b4d6c311a76f6 (patch)
tree839255ac97d1edeca5831bde6764af77d0870d01 /libavcodec/wnv1.c
parent94f694a4764f2616b41310b9ec7fcc8f22bc3957 (diff)
Make WNV1 decoder use temporary buffer for bit-reversed input
Originally committed as revision 16920 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/wnv1.c')
-rw-r--r--libavcodec/wnv1.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
index 47e54ee6b2..7c0105f1ef 100644
--- a/libavcodec/wnv1.c
+++ b/libavcodec/wnv1.c
@@ -58,13 +58,20 @@ static inline int wnv1_get_code(WNV1Context *w, int base_value)
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
WNV1Context * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic;
unsigned char *Y,*U,*V;
int i, j;
int prev_y = 0, prev_u = 0, prev_v = 0;
+ uint8_t *rbuf;
+
+ rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if(!rbuf){
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
+ return -1;
+ }
if(p->data[0])
avctx->release_buffer(avctx, p);
@@ -72,13 +79,14 @@ static int decode_frame(AVCodecContext *avctx,
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ av_free(rbuf);
return -1;
}
p->key_frame = 1;
for(i=8; i<buf_size; i++)
- buf[i]= ff_reverse[ buf[i] ]; //FIXME ensure that the buffer is modifyable or use a temp one
- init_get_bits(&l->gb, buf+8, (buf_size-8)*8);
+ rbuf[i]= ff_reverse[ buf[i] ];
+ init_get_bits(&l->gb, rbuf+8, (buf_size-8)*8);
if (buf[2] >> 4 == 6)
l->shift = 2;
@@ -112,6 +120,7 @@ static int decode_frame(AVCodecContext *avctx,
*data_size = sizeof(AVFrame);
*(AVFrame*)data = l->pic;
+ av_free(rbuf);
return buf_size;
}