[mythtv] [patch] calc_cbp redux 2

Daniel Thor Kristjansson danielk at cat.nyu.edu
Sun Aug 22 13:12:24 EDT 2004


Oops!

I forgot the "-u" on my cvs diff. I've also moved calc_cbp to the end of
the file, with render_state and later other helper functions.

-- Daniel
-------------- next part --------------
Index: libs/libavcodec/xvmcvideo.c
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libavcodec/xvmcvideo.c,v
retrieving revision 1.8
diff -u -r1.8 xvmcvideo.c
--- libs/libavcodec/xvmcvideo.c	19 Aug 2004 20:14:07 -0000	1.8
+++ libs/libavcodec/xvmcvideo.c	22 Aug 2004 17:10:27 -0000
@@ -45,6 +45,7 @@
 #undef fprintf
 
 static inline xvmc_render_state_t *render_state(const MpegEncContext *s);
+static inline int calc_cbp(MpegEncContext *s);
 
 //set s->block
 void XVMC_init_block(MpegEncContext *s)
@@ -330,20 +331,11 @@
         (mv_block->macroblock_type & XVMC_MB_TYPE_INTRA)) {
 
         // calculate cbp
-        cbp = 0;
-        for(i=0; i<blocks_per_mb; i++) {
-            cbp+= cbp;
-            if (s->block_last_index[i] >= 0)
-                cbp++;
-        }
-
-        if (s->flags & CODEC_FLAG_GRAY && !s->mb_intra)
-            cbp &= 0xf << (blocks_per_mb - 4);
-
-        mv_block->coded_block_pattern = cbp;
+        mv_block->coded_block_pattern = calc_cbp(s);
 
         // ????
-        if (0==cbp) mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
+        if (!mv_block->coded_block_pattern)
+	    mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
     }
 
     for (i=0; i<blocks_per_mb; i++){
@@ -395,4 +387,40 @@
     return render;
 }
 
+static inline int calc_cbp(MpegEncContext *s)
+{
+    int cbp, cbp1;
+
+    cbp   = (s->block_last_index[0] >= 0) ? (1 << (5)) : 0;
+    cbp1  = (s->block_last_index[1] >= 0) ? (1 << (4)) : 0;
+    cbp  |= (s->block_last_index[2] >= 0) ? (1 << (3)) : 0;
+    cbp1 |= (s->block_last_index[3] >= 0) ? (1 << (2)) : 0;
+    cbp  |= cbp1;
+
+    if (s->flags & CODEC_FLAG_GRAY)
+        return cbp; // 4 block for grayscale one done
+
+    cbp |= (((s->block_last_index[4] >= 0) ? 1 << (1) : 0) | 
+            ((s->block_last_index[5] >= 0) ? 1 << (0) : 0));
+
+    if (s->chroma_format >= 2) {
+        if (s->chroma_format == 2)
+        { /* CHROMA_422 */
+            cbp |= (((s->block_last_index[4] >= 0) ? 1 << (6+1) : 0) |
+                    ((s->block_last_index[5] >= 0) ? 1 << (6+0) : 0));
+        }
+        else
+        { /* CHROMA_444 */
+            cbp  |= (s->block_last_index[ 6] >= 0) ? 1 << (6+5) : 0;
+            cbp1  = (s->block_last_index[ 7] >= 0) ? 1 << (6+3) : 0;
+            cbp  |= (s->block_last_index[ 8] >= 0) ? 1 << (6+4) : 0;
+            cbp1 |= (s->block_last_index[ 9] >= 0) ? 1 << (6+2) : 0;
+            cbp  |= (s->block_last_index[10] >= 0) ? 1 << (6+1) : 0;
+            cbp1 |= (s->block_last_index[11] >= 0) ? 1 << (6+0) : 0;
+            cbp  |= cbp1;
+        }
+    }
+    return cbp;
+}
+
 #endif


More information about the mythtv-dev mailing list