[x264-devel] commit: Relax QPfile restrictions (Jason Garrett-Glaser )

git version control git at videolan.org
Sat Jul 12 22:36:46 CEST 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sat Jul 12 14:37:58 2008 -0600| [9c5e557c5544690b22f61614fae9b516c7e53ba1]

Relax QPfile restrictions
Allow a QPfile to contain fewer frames than the total number of frames in the video and have ratecontrol fill in the rest.
Patch by kemuri9.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=9c5e557c5544690b22f61614fae9b516c7e53ba1
---

 x264.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/x264.c b/x264.c
index 14466e5..5741d00 100644
--- a/x264.c
+++ b/x264.c
@@ -691,11 +691,20 @@ static int  Parse( int argc, char **argv,
 
 static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
 {
-    int num = -1, qp;
+    int num = -1, qp, ret;
     char type;
+    uint64_t file_pos;
     while( num < i_frame )
     {
-        int ret = fscanf( opt->qpfile, "%d %c %d\n", &num, &type, &qp );
+        file_pos = ftell( opt->qpfile );
+        ret = fscanf( opt->qpfile, "%d %c %d\n", &num, &type, &qp );
+		if( num > i_frame || ret == EOF )
+		{
+			pic->i_type = X264_TYPE_AUTO;
+			pic->i_qpplus1 = 0;
+			fseek( opt->qpfile , file_pos , SEEK_SET );
+			break;
+		}
         if( num < i_frame )
             continue;
         pic->i_qpplus1 = qp+1;
@@ -705,7 +714,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
         else if( type == 'B' ) pic->i_type = X264_TYPE_BREF;
         else if( type == 'b' ) pic->i_type = X264_TYPE_B;
         else ret = 0;
-        if( ret != 3 || qp < 0 || qp > 51 || num > i_frame )
+        if( ret != 3 || qp < -1 || qp > 51 )
         {
             fprintf( stderr, "x264 [error]: can't parse qpfile for frame %d\n", i_frame );
             fclose( opt->qpfile );



More information about the x264-devel mailing list