]> git.sesse.net Git - x264/commitdiff
Fix bugs in qpfile parsing with omitted QPs
authorFiona Glaser <fiona@x264.com>
Sat, 13 Nov 2010 12:38:44 +0000 (04:38 -0800)
committerFiona Glaser <fiona@x264.com>
Sun, 14 Nov 2010 06:12:47 +0000 (22:12 -0800)
x264.c

diff --git a/x264.c b/x264.c
index 9846be717b7489f63cf88586b9ada446870925c0..e8de506bcb6b89204b4810e11f3ee6896e9bf21c 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -1484,7 +1484,8 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
     while( num < i_frame )
     {
         file_pos = ftell( opt->qpfile );
-        ret = fscanf( opt->qpfile, "%d %c %d\n", &num, &type, &qp );
+        qp = -1;
+        ret = fscanf( opt->qpfile, "%d %c%*[ \t]%d\n", &num, &type, &qp );
         pic->i_type = X264_TYPE_AUTO;
         pic->i_qpplus1 = X264_QP_AUTO;
         if( num > i_frame || ret == EOF )
@@ -1492,7 +1493,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
             fseek( opt->qpfile, file_pos, SEEK_SET );
             break;
         }
-        if( num < i_frame && ret == 3 )
+        if( num < i_frame && ret >= 2 )
             continue;
         if( ret == 3 && qp >= 0 )
             pic->i_qpplus1 = qp+1;