[x264-devel] Add an small per-MB cost penalty for lowres

Anton Mitrofanov git at videolan.org
Wed Mar 7 03:20:15 CET 2012


x264 | branch: master | Anton Mitrofanov <Bugmaster at narod.ru> | Thu Feb  9 15:27:53 2012 -0800| [037d123cf62c4af2dc13742b8606882b6d0d3d9e] | committer: Jason Garrett-Glaser

Add an small per-MB cost penalty for lowres
Helps avoid VBV predictors going nuts with very low-cost MBs.
One particular case this fixes is zero-cost MBs: adaptive quantization decreases the QP a lot, but (before this patch), no cost penalty gets factored in for this, because anything times zero is zero.

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

 encoder/slicetype.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index ddeb992..e77ba1d 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -457,6 +457,8 @@ static void x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a,
     x264_me_t m[2];
     int i_bcost = COST_MAX;
     int list_used = 0;
+    /* A small, arbitrary bias to avoid VBV problems caused by zero-residual lookahead blocks. */
+    int lowres_penalty = 4;
 
     h->mb.pic.p_fenc[0] = h->mb.pic.fenc_buf;
     h->mc.copy[PIXEL_8x8]( h->mb.pic.p_fenc[0], FENC_STRIDE, &fenc->lowres[0][i_pel_offset], i_stride, 8 );
@@ -653,7 +655,7 @@ lowres_intra_mb:
             }
         }
 
-        i_icost += intra_penalty;
+        i_icost += intra_penalty + lowres_penalty;
         fenc->i_intra_cost[i_mb_xy] = i_icost;
         int i_icost_aq = i_icost;
         if( h->param.rc.i_aq_mode )
@@ -665,6 +667,7 @@ lowres_intra_mb:
             fenc->i_cost_est_aq[0][0] += i_icost_aq;
         }
     }
+    i_bcost += lowres_penalty;
 
     /* forbid intra-mbs in B-frames, because it's rare and not worth checking */
     /* FIXME: Should we still forbid them now that we cache intra scores? */



More information about the x264-devel mailing list