comparison rv30.c @ 8566:48a4d9f4c6f8 libavcodec

RV30 decoder passes possible frame sizes in extradata and selects an appropriate frame size from them in slice, make my decoder do that as well. This fixes issue 779
author kostya
date Sun, 11 Jan 2009 08:03:45 +0000
parents 51c9946c70f9
children 4a93620c5aac
comparison
equal deleted inserted replaced
8565:6687083ec76a 8566:48a4d9f4c6f8
36 static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si) 36 static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si)
37 { 37 {
38 int mb_bits; 38 int mb_bits;
39 int w = r->s.width, h = r->s.height; 39 int w = r->s.width, h = r->s.height;
40 int mb_size; 40 int mb_size;
41 int rpr;
41 42
42 memset(si, 0, sizeof(SliceInfo)); 43 memset(si, 0, sizeof(SliceInfo));
43 if(get_bits(gb, 3)) 44 if(get_bits(gb, 3))
44 return -1; 45 return -1;
45 si->type = get_bits(gb, 2); 46 si->type = get_bits(gb, 2);
47 if(get_bits1(gb)) 48 if(get_bits1(gb))
48 return -1; 49 return -1;
49 si->quant = get_bits(gb, 5); 50 si->quant = get_bits(gb, 5);
50 skip_bits1(gb); 51 skip_bits1(gb);
51 si->pts = get_bits(gb, 13); 52 si->pts = get_bits(gb, 13);
52 skip_bits(gb, r->rpr); 53 rpr = get_bits(gb, r->rpr);
53 si->width = w; 54 if(!rpr){
54 si->height = h; 55 si->width = w;
56 si->height = h;
57 }else{
58 si->width = r->s.avctx->extradata[6 + rpr*2] << 2;
59 si->height = r->s.avctx->extradata[7 + rpr*2] << 2;
60 }
55 mb_size = ((w + 15) >> 4) * ((h + 15) >> 4); 61 mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
56 mb_bits = ff_rv34_get_start_offset(gb, mb_size); 62 mb_bits = ff_rv34_get_start_offset(gb, mb_size);
57 si->start = get_bits(gb, mb_bits); 63 si->start = get_bits(gb, mb_bits);
58 skip_bits1(gb); 64 skip_bits1(gb);
59 return 0; 65 return 0;
246 av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n"); 252 av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
247 return -1; 253 return -1;
248 } 254 }
249 r->rpr = (avctx->extradata[1] & 7) >> 1; 255 r->rpr = (avctx->extradata[1] & 7) >> 1;
250 r->rpr = FFMIN(r->rpr + 1, 3); 256 r->rpr = FFMIN(r->rpr + 1, 3);
257 if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){
258 av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n",
259 6 + r->rpr * 2, avctx->extradata_size);
260 }
251 r->parse_slice_header = rv30_parse_slice_header; 261 r->parse_slice_header = rv30_parse_slice_header;
252 r->decode_intra_types = rv30_decode_intra_types; 262 r->decode_intra_types = rv30_decode_intra_types;
253 r->decode_mb_info = rv30_decode_mb_info; 263 r->decode_mb_info = rv30_decode_mb_info;
254 r->loop_filter = rv30_loop_filter; 264 r->loop_filter = rv30_loop_filter;
255 r->luma_dc_quant_i = rv30_luma_dc_quant; 265 r->luma_dc_quant_i = rv30_luma_dc_quant;