[x264-devel] commit: Support forced frametypes with scenecut/b-adapt ( Jason Garrett-Glaser )

git version control git at videolan.org
Wed Jan 14 03:17:46 CET 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Tue Jan 13 20:22:36 2009 -0500| [79bfb039de253c986986fbd99935c0d4a95ad503] | committer: Jason Garrett-Glaser 

Support forced frametypes with scenecut/b-adapt
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 at gmail.com>.

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

 encoder/slicetype.c |    8 +++-----
 x264.c              |    6 +++---
 x264.h              |    6 +++++-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index b24e5b6..e00be6f 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -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 a1a8c94..e149945 100644
--- 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 8c517b1..6e123ac 100644
--- 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 */



More information about the x264-devel mailing list