[x264-devel] commit: Fix CABAC+PCM, regression in r1592 (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Wed May 26 19:39:32 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Tue May 25 17:49:07 2010 -0700| [cf5769dc3f2dcf699fc8bf850d375508495297ef] | committer: Jason Garrett-Glaser 

Fix CABAC+PCM, regression in r1592
Changes to queue in CABAC didn't get propagated to PCM code.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=cf5769dc3f2dcf699fc8bf850d375508495297ef
---

 common/cabac.c  |   11 ++++++++---
 common/cabac.h  |    2 +-
 encoder/cabac.c |    5 +----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/common/cabac.c b/common/cabac.c
index 11988a1..d0888d0 100644
--- a/common/cabac.c
+++ b/common/cabac.c
@@ -768,12 +768,17 @@ void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int
     }
 }
 
-void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end )
+void x264_cabac_encode_init_core( x264_cabac_t *cb )
 {
     cb->i_low   = 0;
     cb->i_range = 0x01FE;
     cb->i_queue = -9; // the first bit will be shifted away and not written
     cb->i_bytes_outstanding = 0;
+}
+
+void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end )
+{
+    x264_cabac_encode_init_core( cb );
     cb->p_start = p_data;
     cb->p       = p_data;
     cb->p_end   = p_end;
@@ -877,9 +882,9 @@ void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb )
     cb->i_queue += 9;
     x264_cabac_putbyte( cb );
     x264_cabac_putbyte( cb );
-    cb->i_low <<= 8 - cb->i_queue;
+    cb->i_low <<= -cb->i_queue;
     cb->i_low |= (0x35a4e4f5 >> (h->i_frame & 31) & 1) << 10;
-    cb->i_queue = 8;
+    cb->i_queue = 0;
     x264_cabac_putbyte( cb );
 
     while( cb->i_bytes_outstanding > 0 )
diff --git a/common/cabac.h b/common/cabac.h
index 9fc3007..cec4e51 100644
--- a/common/cabac.h
+++ b/common/cabac.h
@@ -51,7 +51,7 @@ extern const uint16_t x264_cabac_entropy[128];
 /* init the contexts given i_slice_type, the quantif and the model */
 void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model );
 
-/* encoder only: */
+void x264_cabac_encode_init_core( x264_cabac_t *cb );
 void x264_cabac_encode_init ( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end );
 void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b );
 void x264_cabac_encode_decision_asm( x264_cabac_t *cb, int i_ctx, int b );
diff --git a/encoder/cabac.c b/encoder/cabac.c
index bc76fc8..012791a 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -776,10 +776,7 @@ void x264_macroblock_write_cabac( x264_t *h, x264_cabac_t *cb )
             memcpy( cb->p + i*8, h->mb.pic.p_fenc[2] + i*FENC_STRIDE, 8 );
         cb->p += 64;
 
-        cb->i_low   = 0;
-        cb->i_range = 0x01FE;
-        cb->i_queue = -1;
-        cb->i_bytes_outstanding = 0;
+        x264_cabac_encode_init_core( cb );
 
         h->stat.frame.i_tex_bits += x264_cabac_pos( cb ) - i_mb_pos_tex;
         return;



More information about the x264-devel mailing list