]> granicus.if.org Git - libx264/commitdiff
Support forced frametypes with scenecut/b-adapt
authorFiona Glaser <fiona@x264.com>
Wed, 14 Jan 2009 01:22:36 +0000 (20:22 -0500)
committerFiona Glaser <fiona@x264.com>
Wed, 14 Jan 2009 02:00:26 +0000 (21:00 -0500)
This allows an input qpfile to be used to force I-frames, for example.
The same can be done through the library interface.
Document the format of the qpfile in --longhelp and the forcing of frametypes in x264.h
Note that forcing B-frames and B-refs may not always have the intended result.
Patch partially by Steven Walters <kemuri9@gmail.com>.

encoder/slicetype.c
x264.c
x264.h

index 3fc8145411ac252fbfcc20b1142f4748041a4ebf..a1f73fa386a6b8475e049119ada3b2e4f219fa3b 100644 (file)
@@ -489,7 +489,7 @@ static void x264_slicetype_analyse( x264_t *h )
     if( !h->frames.last_nonb )
         return;
     frames[0] = h->frames.last_nonb;
-    for( j = 0; h->frames.next[j]; j++ )
+    for( j = 0; h->frames.next[j] && h->frames.next[j]->i_type == X264_TYPE_AUTO; j++ )
         frames[j+1] = h->frames.next[j];
     keyint_limit = h->param.i_keyint_max - frames[0]->i_frame + h->frames.i_last_idr - 1;
     num_frames = X264_MIN( j, keyint_limit );
@@ -630,10 +630,8 @@ void x264_slicetype_decide( x264_t *h )
                 frm->i_type = X264_TYPE_P;
         }
 
-        if( frm->i_type != X264_TYPE_AUTO && frm->i_type != X264_TYPE_B && frm->i_type != X264_TYPE_BREF )
-            break;
-
-        frm->i_type = X264_TYPE_B;
+        if( frm->i_type == X264_TYPE_AUTO ) frm->i_type = X264_TYPE_B;
+        else if( !IS_X264_TYPE_B( frm->i_type ) ) break;
     }
 }
 
diff --git a/x264.c b/x264.c
index a1a8c94ff0fd89ff4a4f1b236bc277af94447301..e149945215268c9f9299bd4c046fea9b326e632c 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -220,7 +220,9 @@ static void Help( x264_param_t *defaults, int b_longhelp )
         "                                  where <option> is either\n"
         "                                      q=<integer> (force QP)\n"
         "                                  or  b=<float> (bitrate multiplier)\n" );
-    H1( "      --qpfile <string>       Force frametypes and QPs\n" );
+    H1( "      --qpfile <string>       Force frametypes and QPs for some or all frames\n"
+        "                              Format of each line: framenumber frametype QP\n"
+        "                              QP of -1 lets x264 choose. Frametypes: I,i,P,B,b.\n" );
     H0( "\n" );
     H0( "Analysis:\n" );
     H0( "\n" );
@@ -563,8 +565,6 @@ static int  Parse( int argc, char **argv,
                     fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg );
                     return -1;
                 }
-                param->i_scenecut_threshold = -1;
-                param->i_bframe_adaptive = X264_B_ADAPT_NONE;
                 break;
             case OPT_THREAD_INPUT:
                 b_thread_input = 1;
diff --git a/x264.h b/x264.h
index 8c517b1ebbdd4bd66a14545b65e7f0b5c0582a00..6e123ac9d7f7cbc731d0a8f1b4733a30e6bacb87 100644 (file)
--- a/x264.h
+++ b/x264.h
@@ -342,7 +342,11 @@ typedef struct
 
 typedef struct
 {
-    /* In: force picture type (if not auto) XXX: ignored for now
+    /* In: force picture type (if not auto)
+     *     If x264 encoding parameters are violated in the forcing of picture types,
+     *     x264 will correct the input picture type and log a warning.
+     *     The quality of frametype decisions may suffer if a great deal of fine-grained
+     *     mixing of auto and forced frametypes is done.
      * Out: type of the picture encoded */
     int     i_type;
     /* In: force quantizer for > 0 */