]> git.sesse.net Git - x264/commitdiff
Warn users when using --(psnr|ssim) without --tune (psnr|ssim)
authorFiona Glaser <fiona@x264.com>
Tue, 12 Apr 2011 08:16:48 +0000 (01:16 -0700)
committerFiona Glaser <fiona@x264.com>
Tue, 12 Apr 2011 08:37:38 +0000 (01:37 -0700)
This is a counter to the proliferation of incredibly stupid psnr/ssim "benchmarks" of x264 in which the benchmarker conveniently "forgot" --tune psnr/ssim, crippling x264 in the test.

encoder/encoder.c

index 502ae636d4b473dd795f04d4341c0af6935a5fc3..8a1f8dcf175315db561fa52bd92e5869df56f058 100644 (file)
@@ -705,6 +705,36 @@ static int x264_validate_parameters( x264_t *h )
     }
     h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -12, 12);
     h->param.analyse.i_trellis = x264_clip3( h->param.analyse.i_trellis, 0, 2 );
+
+    if( h->param.i_log_level < X264_LOG_INFO )
+    {
+        h->param.analyse.b_psnr = 0;
+        h->param.analyse.b_ssim = 0;
+    }
+    /* Warn users trying to measure PSNR/SSIM with psy opts on. */
+    if( h->param.analyse.b_psnr || h->param.analyse.b_ssim )
+    {
+        char *s = NULL;
+
+        if( h->param.analyse.b_psy )
+        {
+            s = h->param.analyse.b_psnr ? "psnr" : "ssim";
+            x264_log( h, X264_LOG_WARNING, "--%s used with psy on: results will be invalid!\n", s );
+        }
+        else if( !h->param.rc.i_aq_mode && h->param.analyse.b_ssim )
+        {
+            x264_log( h, X264_LOG_WARNING, "--ssim used with AQ off: results will be invalid!\n" );
+            s = "ssim";
+        }
+        else if(  h->param.rc.i_aq_mode && h->param.analyse.b_psnr )
+        {
+            x264_log( h, X264_LOG_WARNING, "--psnr used with AQ on: results will be invalid!\n" );
+            s = "psnr";
+        }
+        if( s )
+            x264_log( h, X264_LOG_WARNING, "--tune %s should be used if attempting to benchmark %s!\n", s, s );
+    }
+
     if( !h->param.analyse.b_psy )
     {
         h->param.analyse.f_psy_rd = 0;
@@ -805,12 +835,6 @@ static int x264_validate_parameters( x264_t *h )
 
     h->param.i_sps_id &= 31;
 
-    if( h->param.i_log_level < X264_LOG_INFO )
-    {
-        h->param.analyse.b_psnr = 0;
-        h->param.analyse.b_ssim = 0;
-    }
-
     if( h->param.b_interlaced )
         h->param.b_pic_struct = 1;