]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv40.c
Apply 'cold' attribute to init/uninit functions in libavcodec
[ffmpeg] / libavcodec / rv40.c
index 791ed17901ca1cd6838483b4b4015d407c63a9a6..38bc48a08bdce38e54755183cae99e18bae160e3 100644 (file)
@@ -27,6 +27,7 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
+#include "golomb.h"
 
 #include "rv34.h"
 #include "rv40vlc2.h"
@@ -39,7 +40,7 @@ static VLC ptype_vlc[NUM_PTYPE_VLCS], btype_vlc[NUM_BTYPE_VLCS];
 /**
  * Initialize all tables.
  */
-static void rv40_init_tables()
+static av_cold void rv40_init_tables()
 {
     int i;
 
@@ -119,6 +120,8 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
     t = get_bits(gb, 13); /// ???
     if(!si->type || !get_bits1(gb))
         rv40_parse_picture_size(gb, &w, &h);
+    if(avcodec_check_dimensions(r->s.avctx, w, h) < 0)
+        return -1;
     si->width  = w;
     si->height = h;
     mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
@@ -131,13 +134,13 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
 /**
  * Decode 4x4 intra types array.
  */
-static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int *dst)
+static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t *dst)
 {
     MpegEncContext *s = &r->s;
     int i, j, k, v;
     int A, B, C;
     int pattern;
-    int *ptr;
+    int8_t *ptr;
 
     for(i = 0; i < 4; i++, dst += s->b4_stride){
         if(!i && s->first_slice_line){
@@ -205,18 +208,18 @@ static int rv40_decode_mb_info(RV34DecContext *r)
     int count = 0;
 
     if(!r->s.mb_skip_run)
-        r->s.mb_skip_run = ff_rv34_get_gamma(gb);
+        r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
 
     if(--r->s.mb_skip_run)
          return RV34_MB_SKIP;
 
-    if(r->avail[0])
+    if(r->avail_cache[5-1])
         blocks[r->mb_type[mb_pos - 1]]++;
-    if(r->avail[1]){
+    if(r->avail_cache[5-4]){
         blocks[r->mb_type[mb_pos - s->mb_stride]]++;
-        if(r->avail[2])
+        if(r->avail_cache[5-2])
             blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;
-        if(r->avail[3])
+        if(r->avail_cache[5-5])
             blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;
     }
 
@@ -226,7 +229,7 @@ static int rv40_decode_mb_info(RV34DecContext *r)
             prev_type = i;
         }
     }
-    if(s->pict_type == P_TYPE){
+    if(s->pict_type == FF_P_TYPE){
         prev_type = block_num_to_ptype_vlc_num[prev_type];
         q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
         if(q < PBTYPE_ESCAPE)
@@ -247,7 +250,7 @@ static int rv40_decode_mb_info(RV34DecContext *r)
 /**
  * Initialize decoder.
  */
-static int rv40_decode_init(AVCodecContext *avctx)
+static av_cold int rv40_decode_init(AVCodecContext *avctx)
 {
     RV34DecContext *r = avctx->priv_data;
 
@@ -272,4 +275,5 @@ AVCodec rv40_decoder = {
     NULL,
     ff_rv34_decode_end,
     ff_rv34_decode_frame,
+    CODEC_CAP_DR1 | CODEC_CAP_DELAY,
 };