]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv30.c
imc: fix undefined float to int conversion
[ffmpeg] / libavcodec / rv30.c
index 97d87b0710f9a59873db849dd12c5f1a515e264c..22a5dd5b647908ef0265b5f38a7331dee5f4b3a8 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file rv30.c
+ * @file
  * RV30 decoder
  */
 
@@ -38,6 +38,7 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
     int mb_bits;
     int w = r->s.width, h = r->s.height;
     int mb_size;
+    int rpr;
 
     memset(si, 0, sizeof(SliceInfo));
     if(get_bits(gb, 3))
@@ -49,7 +50,11 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
     si->quant = get_bits(gb, 5);
     skip_bits1(gb);
     si->pts = get_bits(gb, 13);
-    skip_bits(gb, r->rpr);
+    rpr = get_bits(gb, r->rpr);
+    if(rpr){
+        w = r->s.avctx->extradata[6 + rpr*2] << 2;
+        h = r->s.avctx->extradata[7 + rpr*2] << 2;
+    }
     si->width  = w;
     si->height = h;
     mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
@@ -66,7 +71,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t
 {
     int i, j, k;
 
-    for(i = 0; i < 4; i++, dst += r->s.b4_stride - 4){
+    for(i = 0; i < 4; i++, dst += r->intra_types_stride - 4){
         for(j = 0; j < 4; j+= 2){
             int code = svq3_get_ue_golomb(gb) << 1;
             if(code >= 81*2){
@@ -74,7 +79,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t
                 return -1;
             }
             for(k = 0; k < 2; k++){
-                int A = dst[-r->s.b4_stride] + 1;
+                int A = dst[-r->intra_types_stride] + 1;
                 int B = dst[-1] + 1;
                 *dst++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + k]];
                 if(dst[-1] == 9){
@@ -248,6 +253,10 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx)
     }
     r->rpr = (avctx->extradata[1] & 7) >> 1;
     r->rpr = FFMIN(r->rpr + 1, 3);
+    if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){
+        av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n",
+               6 + r->rpr * 2, avctx->extradata_size);
+    }
     r->parse_slice_header = rv30_parse_slice_header;
     r->decode_intra_types = rv30_decode_intra_types;
     r->decode_mb_info     = rv30_decode_mb_info;
@@ -259,7 +268,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx)
 
 AVCodec rv30_decoder = {
     "rv30",
-    CODEC_TYPE_VIDEO,
+    AVMEDIA_TYPE_VIDEO,
     CODEC_ID_RV30,
     sizeof(RV34DecContext),
     rv30_decode_init,
@@ -267,5 +276,7 @@ AVCodec rv30_decoder = {
     ff_rv34_decode_end,
     ff_rv34_decode_frame,
     CODEC_CAP_DR1 | CODEC_CAP_DELAY,
+    .flush = ff_mpeg_flush,
     .long_name = NULL_IF_CONFIG_SMALL("RealVideo 3.0"),
+    .pix_fmts= ff_pixfmt_list_420,
 };