[FFmpeg-devel] [RFC][PATCH] Store CBP in picture data for RV3/4

Kostya kostya.shishkov
Thu Jul 17 11:43:51 CEST 2008


Since RV40 loop filter uses CBPs from both current and reference frame
(previous refernce in case of B-frames) for filtering decision,
I found it convenient to store CBP in picture data in separate arrays.

Also please comment if it's better to store CBP parts separately or
put them into one uint32_t.
-------------- next part --------------
Index: libavcodec/rv34.c
===================================================================
--- libavcodec/rv34.c	(revision 14044)
+++ libavcodec/rv34.c	(working copy)
@@ -1037,8 +1037,8 @@
 
     s->qscale = r->si.quant;
     cbp = cbp2 = rv34_decode_mb_header(r, intra_types);
-    r->cbp_luma  [s->mb_x + s->mb_y * s->mb_stride] = cbp;
-    r->cbp_chroma[s->mb_x + s->mb_y * s->mb_stride] = cbp >> 16;
+    s->current_picture_ptr->cbp_luma  [s->mb_x + s->mb_y * s->mb_stride] = cbp;
+    s->current_picture_ptr->cbp_chroma[s->mb_x + s->mb_y * s->mb_stride] = cbp >> 16;
     s->current_picture.qscale_table[s->mb_x + s->mb_y * s->mb_stride] = s->qscale;
 
     if(cbp == -1)
@@ -1130,8 +1130,6 @@
             r->intra_types_hist = av_realloc(r->intra_types_hist, s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
             r->intra_types = r->intra_types_hist + s->b4_stride * 4;
             r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
-            r->cbp_luma   = av_realloc(r->cbp_luma,   r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
-            r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
         }
         s->pict_type = r->si.type ? r->si.type : FF_I_TYPE;
         if(MPV_frame_start(s, s->avctx) < 0)
@@ -1224,9 +1222,6 @@
 
     r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
 
-    r->cbp_luma   = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
-    r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
-
     if(!intra_vlcs[0].cbppattern[0].bits)
         rv34_init_tables();
 
Index: libavcodec/rv34.h
===================================================================
--- libavcodec/rv34.h	(revision 14044)
+++ libavcodec/rv34.h	(working copy)
@@ -102,9 +105,6 @@
 
     int cur_pts, last_pts, next_pts;
 
-    uint16_t *cbp_luma;      ///< CBP values for luma subblocks
-    uint8_t  *cbp_chroma;    ///< CBP values for chroma subblocks
-
     /** 8x8 block available flags (for MV prediction) */
     DECLARE_ALIGNED_8(uint32_t, avail_cache[3*4]);
 
Index: libavcodec/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 14044)
+++ libavcodec/mpegvideo.c	(working copy)
@@ -232,6 +232,10 @@
         pic->qstride= s->mb_stride;
         CHECKED_ALLOCZ(pic->pan_scan , 1 * sizeof(AVPanScan))
     }
+    if(s->avctx->codec_id == CODEC_ID_RV30 || s->avctx->codec_id == CODEC_ID_RV40){
+        CHECKED_ALLOCZ(pic->cbp_luma  , mb_array_size * sizeof(int16_t))
+        CHECKED_ALLOCZ(pic->cbp_chroma, mb_array_size * sizeof(int8_t))
+    }
 
     /* It might be nicer if the application would keep track of these
      * but it would require an API change. */
@@ -278,6 +282,8 @@
         }
         pic->type= 0;
     }
+    av_freep(&pic->cbp_luma);
+    av_freep(&pic->cbp_chroma);
 }
 
 static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
Index: libavcodec/mpegvideo.h
===================================================================
--- libavcodec/mpegvideo.h	(revision 14260)
+++ libavcodec/mpegvideo.h	(working copy)
@@ -128,6 +128,8 @@
     uint8_t *mb_mean;           ///< Table for MB luminance
     int32_t *mb_cmp_score;      ///< Table for MB cmp scores, for mb decision FIXME remove
     int b_frame_score;          /* */
+    uint16_t *cbp_luma;         ///< Table for luminance part of coded block pattern
+    uint8_t *cbp_chroma;        ///< Table for chroma part of coded block pattern
 } Picture;
 
 struct MpegEncContext;



More information about the ffmpeg-devel mailing list