]> granicus.if.org Git - libx264/commitdiff
Fix a potential infinite loop in QPfile parsing on Windows
authorAnton Mitrofanov <BugMaster@narod.ru>
Fri, 7 Aug 2009 17:44:13 +0000 (10:44 -0700)
committerFiona Glaser <fiona@x264.com>
Fri, 7 Aug 2009 17:44:13 +0000 (10:44 -0700)
ftell doesn't seem to work properly on Windows in text mode.

x264.c

diff --git a/x264.c b/x264.c
index 09ec7a563afe5c82f3b3edf0a9d7188ac1486c6b..74e32b7c8f804760e6779eb32f321d37ce3e53bd 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -781,7 +781,7 @@ static int  Parse( int argc, char **argv,
                 }
                 break;
             case OPT_QPFILE:
-                opt->qpfile = fopen( optarg, "r" );
+                opt->qpfile = fopen( optarg, "rb" );
                 if( !opt->qpfile )
                 {
                     fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg );
@@ -1036,7 +1036,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 )
+        if( num < i_frame && ret == 3 )
             continue;
         pic->i_qpplus1 = qp+1;
         if     ( type == 'I' ) pic->i_type = X264_TYPE_IDR;