support strictly enforcing gop size
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 15 Oct 2004 02:37:04 +0000 (02:37 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 15 Oct 2004 02:37:04 +0000 (02:37 +0000)
Originally committed as revision 3594 to svn://svn.ffmpeg.org/ffmpeg/trunk

ffmpeg.c
libavcodec/avcodec.h
libavcodec/mpegvideo.c

index 4178d0a..69ddf71 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -162,6 +162,7 @@ static int use_qprd = 0;
 static int use_cbprd = 0;
 static int qns = 0;
 static int closed_gop = 0;
+static int strict_gop = 0;
 static int do_deinterlace = 0;
 static int do_interlace_dct = 0;
 static int do_interlace_me = 0;
@@ -3075,6 +3076,9 @@ static void opt_output_file(const char *filename)
                if (closed_gop) {
                     video_enc->flags |= CODEC_FLAG_CLOSED_GOP;
                 }
+                if (strict_gop) {
+                    video_enc->flags2 |= CODEC_FLAG2_STRICT_GOP;
+                }
                if (use_qpel) {
                     video_enc->flags |= CODEC_FLAG_QPEL;
                 }
@@ -3847,6 +3851,7 @@ const OptionDef options[] = {
     { "cbp", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&use_cbprd}, "" },
     { "trell", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&use_trell}, "enable trellis quantization" },
     { "cgop", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&closed_gop}, "closed gop" },
+    { "sgop", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&strict_gop}, "strict gop" },
     { "scan_offset", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&use_scan_offset}, "enable SVCD Scan Offset placeholder" },
     { "qpel", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&use_qpel}, "enable 1/4-pel" },
     { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix}, "specify intra matrix coeffs", "matrix" },
index a1888fa..e653d32 100644 (file)
@@ -296,6 +296,7 @@ extern int motion_estimation_method;
 #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
 #define CODEC_FLAG_CLOSED_GOP     0x80000000
 #define CODEC_FLAG2_FAST          0x00000001 ///< allow non spec compliant speedup tricks
+#define CODEC_FLAG2_STRICT_GOP    0x00000002 ///< strictly enforce GOP size
 
 /* Unsupported options :
  *             Syntax Arithmetic coding (SAC)
index f5e8359..fc7cd00 100644 (file)
@@ -2064,9 +2064,13 @@ static void select_input_picture(MpegEncContext *s){
             }
 
             if(s->picture_in_gop_number + b_frames >= s->gop_size){
+              if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){
+                    b_frames= s->gop_size - s->picture_in_gop_number - 1;
+              }else{
                 if(s->flags & CODEC_FLAG_CLOSED_GOP)
                     b_frames=0;
                 s->input_picture[b_frames]->pict_type= I_TYPE;
+              }
             }
             
             if(   (s->flags & CODEC_FLAG_CLOSED_GOP)