]> git.sesse.net Git - x264/commitdiff
Make open-GOP Blu-ray compatible
authorLamont Alston <wewk584@gmail.com>
Tue, 29 Jun 2010 17:11:42 +0000 (10:11 -0700)
committerFiona Glaser <fiona@x264.com>
Fri, 2 Jul 2010 03:38:50 +0000 (20:38 -0700)
Blu-ray is even more braindamaged than we thought.
Accordingly, open-gop options are now "normal" and "bluray", as opposed to display and coded.
Normal should be used in all cases besides Blu-ray authoring.

encoder/encoder.c
encoder/slicetype.c
x264.c
x264.h

index e5156337a88046720821633048050d4f7c341893..27f332352a684b27ad5829f3ba676c78b05ea80d 100644 (file)
@@ -577,7 +577,7 @@ static int x264_validate_parameters( x264_t *h )
         h->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL;
     }
     h->param.i_bframe = x264_clip3( h->param.i_bframe, 0, X264_MIN( X264_BFRAME_MAX, h->param.i_keyint_max-1 ) );
-    h->param.i_open_gop = x264_clip3( h->param.i_open_gop, X264_OPEN_GOP_NONE, X264_OPEN_GOP_CODED_ORDER );
+    h->param.i_open_gop = x264_clip3( h->param.i_open_gop, X264_OPEN_GOP_NONE, X264_OPEN_GOP_BLURAY );
     if( h->param.i_keyint_max == 1 )
         h->param.b_intra_refresh = 0;
     h->param.i_bframe_bias = x264_clip3( h->param.i_bframe_bias, -90, 100 );
index 810779af1f1dd482a5b44da6ae84c86db800e498..566ce62703189efc9ae71c86d05aff77d693b140 100644 (file)
@@ -1233,17 +1233,11 @@ void x264_slicetype_analyse( x264_t *h, int keyframe )
     if( !h->param.b_intra_refresh )
         for( int i = keyint_limit+1; i <= num_frames; i += h->param.i_keyint_max )
         {
-            int j = i;
-            if( h->param.i_open_gop == X264_OPEN_GOP_CODED_ORDER )
-            {
-                while( IS_X264_TYPE_B( frames[i]->i_type ) )
-                    i++;
-                while( IS_X264_TYPE_B( frames[j-1]->i_type ) )
-                    j--;
-            }
             frames[i]->i_type = X264_TYPE_I;
             reset_start = X264_MIN( reset_start, i+1 );
-            i = j;
+            if( h->param.i_open_gop == X264_OPEN_GOP_BLURAY )
+                while( IS_X264_TYPE_B( frames[i-1]->i_type ) )
+                    i--;
         }
 
     if( vbv_lookahead )
@@ -1337,16 +1331,8 @@ void x264_slicetype_decide( x264_t *h )
             if( frm->i_type == X264_TYPE_AUTO || frm->i_type == X264_TYPE_I )
                 frm->i_type = h->param.i_open_gop && h->lookahead->i_last_keyframe >= 0 ? X264_TYPE_I : X264_TYPE_IDR;
             int warn = frm->i_type != X264_TYPE_IDR;
-            if( warn && h->param.i_open_gop == X264_OPEN_GOP_DISPLAY_ORDER )
-                warn &= frm->i_type != X264_TYPE_I && frm->i_type != X264_TYPE_KEYFRAME;
-            if( warn && h->param.i_open_gop == X264_OPEN_GOP_CODED_ORDER )
-            {
-                /* if this minigop ends with i, it's not a violation */
-                int j = bframes;
-                while( IS_X264_TYPE_B( h->lookahead->next.list[j]->i_type ) )
-                    j++;
-                warn = h->lookahead->next.list[j]->i_type != X264_TYPE_I && h->lookahead->next.list[j]->i_type != X264_TYPE_KEYFRAME;
-            }
+            if( warn && h->param.i_open_gop )
+                warn &= frm->i_type != X264_TYPE_I;
             if( warn )
                 x264_log( h, X264_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n", frm->i_type, frm->i_frame );
         }
@@ -1355,8 +1341,8 @@ void x264_slicetype_decide( x264_t *h )
             if( h->param.i_open_gop )
             {
                 h->lookahead->i_last_keyframe = frm->i_frame; // Use display order
-                if( h->param.i_open_gop == X264_OPEN_GOP_CODED_ORDER )
-                    h->lookahead->i_last_keyframe -= bframes; // Use coded order
+                if( h->param.i_open_gop == X264_OPEN_GOP_BLURAY )
+                    h->lookahead->i_last_keyframe -= bframes; // Use bluray order
                 frm->b_keyframe = 1;
             }
             else
diff --git a/x264.c b/x264.c
index df0438575a9092e87f53417e5be3cac10e9a0e58..f08ab416005dda58c19763d718e50ebbef54fbcd 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -382,10 +382,10 @@ static void Help( x264_param_t *defaults, int longhelp )
         "                                  - normal: Non-strict (not Blu-ray compatible)\n",
         strtable_lookup( x264_b_pyramid_names, defaults->i_bframe_pyramid ) );
     H1( "      --open-gop <string>     Use recovery points to close GOPs [none]\n"
-        "                                  - none: Use standard closed GOPs\n"
-        "                                  - display: Base GOP length on display order\n"
-        "                                             (not Blu-ray compatible)\n"
-        "                                  - coded: Base GOP length on coded order\n"
+        "                                  - none: closed GOPs only\n"
+        "                                  - normal: standard open GOPs\n"
+        "                                            (not Blu-ray compatible)\n"
+        "                                  - bluray: Blu-ray-compatible open GOPs\n"
         "                              Only available with b-frames\n" );
     H1( "      --no-cabac              Disable CABAC\n" );
     H1( "  -r, --ref <integer>         Number of reference frames [%d]\n", defaults->i_frame_reference );
diff --git a/x264.h b/x264.h
index e1ae0840b24dd3675e218609dd20c78d980e55ac..86f7426ae2f1bec03da2f1b7cc3d83b50b032d1c 100644 (file)
--- a/x264.h
+++ b/x264.h
@@ -153,8 +153,8 @@ typedef struct
 #define X264_B_PYRAMID_NORMAL        2
 #define X264_KEYINT_MIN_AUTO         0
 #define X264_OPEN_GOP_NONE           0
-#define X264_OPEN_GOP_DISPLAY_ORDER  1
-#define X264_OPEN_GOP_CODED_ORDER    2
+#define X264_OPEN_GOP_NORMAL         1
+#define X264_OPEN_GOP_BLURAY         2
 
 static const char * const x264_direct_pred_names[] = { "none", "spatial", "temporal", "auto", 0 };
 static const char * const x264_motion_est_names[] = { "dia", "hex", "umh", "esa", "tesa", 0 };
@@ -166,7 +166,7 @@ static const char * const x264_colorprim_names[] = { "", "bt709", "undef", "", "
 static const char * const x264_transfer_names[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m", "smpte240m", "linear", "log100", "log316", 0 };
 static const char * const x264_colmatrix_names[] = { "GBR", "bt709", "undef", "", "fcc", "bt470bg", "smpte170m", "smpte240m", "YCgCo", 0 };
 static const char * const x264_nal_hrd_names[] = { "none", "vbr", "cbr", 0 };
-static const char * const x264_open_gop_names[] = { "none", "display", "coded", 0 };
+static const char * const x264_open_gop_names[] = { "none", "normal", "bluray", 0 };
 
 /* Colorspace type
  * legacy only; nothing other than I420 is really supported. */
@@ -276,7 +276,7 @@ typedef struct x264_param_t
     int         i_bframe_adaptive;
     int         i_bframe_bias;
     int         i_bframe_pyramid;   /* Keep some B-frames as references: 0=off, 1=strict hierarchical, 2=normal */
-    int         i_open_gop;         /* Open gop: 1=display order, 2=coded order to determine gop size */
+    int         i_open_gop;         /* Open gop: 1=display order, 2=bluray compatibility braindamage mode */
 
     int         b_deblocking_filter;
     int         i_deblocking_filter_alphac0;    /* [-6, 6] -6 light filter, 6 strong */