]> git.videolan.org Git - x264.git/commitdiff
Export the average effective CRF of each frame
authorJason Garrett-Glaser <jason@x264.com>
Mon, 30 Jul 2012 19:58:34 +0000 (12:58 -0700)
committerJason Garrett-Glaser <jason@x264.com>
Wed, 5 Sep 2012 18:59:45 +0000 (11:59 -0700)
Useful to judge the resulting quality of a frame when VBV is enabled.

common/frame.h
encoder/encoder.c
encoder/ratecontrol.c
x264.h

index 97c76d264072e15442db3c824e683010bd29d972..70e2878f39d343d7043ae08197c1f2b69ee777e2 100644 (file)
@@ -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 */
index 6c894e8c18d2e5931a7ca4551d48f48424918f21..a2744977478d586b7932212459c0fd7070ba83a0 100644 (file)
@@ -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 )
     {
index dd28437bd9bcca96dd8182b15d391e55d4edce1b..f154a13f34c5d511113985aeb92c4d17f3c8859d 100644 (file)
@@ -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 b6c258eccba24b5414ac1f78c1e651511f157eff..088fefeea52bf24b10eba9e1d1715f143ac16d88 100644 (file)
--- 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