[x264-devel] Export the average effective CRF of each frame

Jason Garrett-Glaser git at videolan.org
Wed Sep 5 21:07:21 CEST 2012


x264 | branch: master | Jason Garrett-Glaser <jason at x264.com> | Mon Jul 30 12:58:34 2012 -0700| [f57e7070d949b02e1a548382a549c34cf491e05e] | committer: Jason Garrett-Glaser

Export the average effective CRF of each frame
Useful to judge the resulting quality of a frame when VBV is enabled.

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

 common/frame.h        |    1 +
 encoder/encoder.c     |    1 +
 encoder/ratecontrol.c |    2 ++
 x264.h                |    5 ++++-
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/common/frame.h b/common/frame.h
index 97c76d2..70e2878 100644
--- a/common/frame.h
+++ b/common/frame.h
@@ -61,6 +61,7 @@ typedef struct x264_frame
     uint8_t i_bframes;   /* number of bframes following this nonb in coded order */
     float   f_qp_avg_rc; /* QPs as decided by ratecontrol */
     float   f_qp_avg_aq; /* QPs as decided by AQ in addition to ratecontrol */
+    float   f_crf_avg;   /* Average effective CRF for this frame */
     int     i_poc_l0ref0; /* poc of first refframe in L0, used to check if direct temporal is possible */
 
     /* YUV buffer */
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 6c894e8..a274497 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -3306,6 +3306,7 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
         return -1;
 
     pic_out->hrd_timing = h->fenc->hrd_timing;
+    pic_out->prop.f_crf_avg = h->fdec->f_crf_avg;
 
     while( filler > 0 )
     {
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index dd28437..f154a13 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -1787,6 +1787,7 @@ int x264_ratecontrol_end( x264_t *h, int bits, int *filler )
 
     h->fdec->f_qp_avg_rc = rc->qpa_rc /= h->mb.i_mb_count;
     h->fdec->f_qp_avg_aq = (float)rc->qpa_aq / h->mb.i_mb_count;
+    h->fdec->f_crf_avg = h->param.rc.f_rf_constant + h->fdec->f_qp_avg_rc - rc->qp_novbv;
 
     if( h->param.rc.b_stat_write )
     {
@@ -2429,6 +2430,7 @@ static float rate_estimate_qscale( x264_t *h )
                 double w = x264_clip3f( cur_time*100, 0.0, 1.0 );
                 q *= pow( (double)total_bits / rcc->expected_bits_sum, w );
             }
+            rcc->qp_novbv = qscale2qp( q );
             if( rcc->b_vbv )
             {
                 /* Do not overflow vbv */
diff --git a/x264.h b/x264.h
index b6c258e..088fefe 100644
--- a/x264.h
+++ b/x264.h
@@ -41,7 +41,7 @@
 
 #include "x264_config.h"
 
-#define X264_BUILD 125
+#define X264_BUILD 126
 
 /* Application developers planning to link against a shared library version of
  * libx264 from a Microsoft Visual Studio or similar development environment
@@ -728,6 +728,9 @@ typedef struct
     double f_psnr_avg;
     /* Out: PSNR of Y, U, and V (if x264_param_t.b_psnr is set) */
     double f_psnr[3];
+
+    /* Out: Average effective CRF of the encoded frame */
+    double f_crf_avg;
 } x264_image_properties_t;
 
 typedef struct



More information about the x264-devel mailing list