[x264-devel] commit: omit delta_quant in i16x16 blocks with no residual ( Jason Garrett-Glaser )

git version control git at videolan.org
Sat May 17 08:57:03 CEST 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu May 15 22:44:12 2008 -0600| [18a1d7eed0d0131d3e728d39d1c1cc81c519e1f7]

omit delta_quant in i16x16 blocks with no residual
(all other block types were already covered, but i16x16 cbp is special)

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

 encoder/cabac.c |    9 +++++++++
 encoder/cavlc.c |   11 +++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/encoder/cabac.c b/encoder/cabac.c
index d482c06..7e70a25 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -304,6 +304,15 @@ static void x264_cabac_mb_qp_delta( x264_t *h, x264_cabac_t *cb )
     int i_dqp = h->mb.i_qp - h->mb.i_last_qp;
     int ctx;
 
+    /* Avoid writing a delta quant if we have an empty i16x16 block, e.g. in a completely flat background area */
+    if( h->mb.i_type == I_16x16 && !h->mb.cbp[h->mb.i_mb_xy] )
+    {
+#ifndef RD_SKIP_BS
+        h->mb.i_qp = h->mb.i_last_qp;
+#endif
+        i_dqp = 0;
+    }
+
     /* No need to test for PCM / SKIP */
     if( h->mb.i_last_dqp &&
         ( h->mb.type[i_mbn_xy] == I_16x16 || (h->mb.cbp[i_mbn_xy]&0x3f) ) )
diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index 726d024..b0d951d 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -220,6 +220,17 @@ static void block_residual_write_cavlc( x264_t *h, bs_t *s, int i_idx, int16_t *
 static void cavlc_qp_delta( x264_t *h, bs_t *s )
 {
     int i_dqp = h->mb.i_qp - h->mb.i_last_qp;
+
+    /* Avoid writing a delta quant if we have an empty i16x16 block, e.g. in a completely flat background area */
+    if( h->mb.i_type == I_16x16 && !(h->mb.i_cbp_luma | h->mb.i_cbp_chroma)
+        && !array_non_zero(h->dct.luma16x16_dc) )
+    {
+#ifndef RD_SKIP_BS
+        h->mb.i_qp = h->mb.i_last_qp;
+#endif
+        i_dqp = 0;
+    }
+
     if( i_dqp )
     {
         if( i_dqp < -26 )



More information about the x264-devel mailing list