*/
/**
- * @file rv34.c
+ * @file libavcodec/rv34.c
* RV30/40 decoder common data
*/
/**
* Initialize all tables.
*/
-static av_cold void rv34_init_tables()
+static av_cold void rv34_init_tables(void)
{
int i, j, k;
int ones;
static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000};
static const int shifts[4] = { 0, 2, 8, 10 };
- int *curshift = shifts;
+ const int *curshift = shifts;
int i, t, mask;
code = get_vlc2(gb, vlc->cbppattern[table].table, 9, 2);
}
if(!right && up){
topleft = dst[-stride + 3] * 0x01010101;
- prev = &topleft;
+ prev = (uint8_t*)&topleft;
}
r->h.pred4x4[itype](dst, prev, stride);
}
}else
slice_count = avctx->slice_count;
+ //parse first slice header to check whether this frame can be decoded
+ if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){
+ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
+ return -1;
+ }
+ init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), buf_size-get_slice_offset(avctx, slices_hdr, 0));
+ if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){
+ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
+ return -1;
+ }
+ if((!s->last_picture_ptr || !s->last_picture_ptr->data[0]) && si.type == FF_B_TYPE)
+ return -1;
+ /* skip b frames if we are in a hurry */
+ if(avctx->hurry_up && si.type==FF_B_TYPE) return buf_size;
+ if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==FF_B_TYPE)
+ || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=FF_I_TYPE)
+ || avctx->skip_frame >= AVDISCARD_ALL)
+ return buf_size;
+ /* skip everything if we are in a hurry>=5 */
+ if(avctx->hurry_up>=5)
+ return buf_size;
+
for(i=0; i<slice_count; i++){
int offset= get_slice_offset(avctx, slices_hdr, i);
int size;
}else
r->si.end = si.start;
}
- if(!i && si.type == FF_B_TYPE && (!s->last_picture_ptr || !s->last_picture_ptr->data[0]))
- return -1;
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(last)