[x264-devel] commit: Save a few bits in multislice encoding (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Sun Apr 11 06:50:31 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Apr  8 18:44:16 2010 -0700| [f1320f8e9c68f10da09c2e31758b5ce4c79db9e1] | committer: Jason Garrett-Glaser 

Save a few bits in multislice encoding
Set the initial QP for each slice to the last QP of the previous slice.

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

 encoder/encoder.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 829dc12..289f458 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1743,6 +1743,16 @@ static int x264_slice_write( x264_t *h )
 
     /* Slice header */
     x264_macroblock_thread_init( h );
+
+    /* If this isn't the first slice in the threadslice, set the slice QP
+     * equal to the last QP in the previous slice for more accurate
+     * CABAC initialization. */
+    if( h->sh.i_first_mb != h->i_threadslice_start * h->sps->i_mb_width )
+    {
+        h->sh.i_qp = h->mb.i_last_qp;
+        h->sh.i_qp_delta = h->sh.i_qp - h->pps->i_pic_init_qp;
+    }
+
     x264_slice_header_write( &h->out.bs, &h->sh, h->i_nal_ref_idc );
     if( h->param.b_cabac )
     {



More information about the x264-devel mailing list