]> granicus.if.org Git - libx264/commitdiff
Give more meaningful error if 1st/2nd pass resolution differ
authorFiona Glaser <fiona@x264.com>
Sat, 21 Nov 2009 07:27:51 +0000 (23:27 -0800)
committerFiona Glaser <fiona@x264.com>
Sun, 22 Nov 2009 22:58:49 +0000 (14:58 -0800)
encoder/ratecontrol.c

index 7120ee571639ccb52b0c9c41aa395ab17f6c04c4..9a027db2633a87ade6ab73f62de42782abc92cdf 100644 (file)
@@ -546,13 +546,24 @@ int x264_ratecontrol_new( x264_t *h )
         /* check whether 1st pass options were compatible with current options */
         if( !strncmp( stats_buf, "#options:", 9 ) )
         {
-            int i;
+            int i, j;
             char *opts = stats_buf;
             stats_in = strchr( stats_buf, '\n' );
             if( !stats_in )
                 return -1;
             *stats_in = '\0';
             stats_in++;
+            if( sscanf( opts, "#options: %dx%d", &i, &j ) != 2 )
+            {
+                x264_log( h, X264_LOG_ERROR, "resolution specified in stats file not valid\n" );
+                return -1;
+            }
+            else if( h->param.rc.b_mb_tree && (i != h->param.i_width || j != h->param.i_height)  )
+            {
+                x264_log( h, X264_LOG_ERROR, "MB-tree doesn't support different resolution than 1st pass (%dx%d vs %dx%d)\n",
+                          h->param.i_width, h->param.i_height, i, j );
+                return -1;
+            }
 
             if( ( p = strstr( opts, "bframes=" ) ) && sscanf( p, "bframes=%d", &i )
                 && h->param.i_bframe != i )