From 315b0f974252120cfacb0346954a2d817dff279a Mon Sep 17 00:00:00 2001
From: Panagiotis Issaris <takis.issaris@uhasselt.be>
Date: Wed, 20 Sep 2006 08:34:13 +0000
Subject: [PATCH] Remove the "bf" OptionDef parameter so the equally named
 AVOption will take over. Move over ffmpeg.c constraint checking, but allow
 value of zero to disable B-frame.

Originally committed as revision 6296 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 ffmpeg.c           | 15 ---------------
 libavcodec/utils.c |  2 +-
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 691d2c9dd55..c8810d9cc89 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -130,7 +130,6 @@ static int video_discard = 0;
 static int video_codec_id = CODEC_ID_NONE;
 static int video_codec_tag = 0;
 static int same_quality = 0;
-static int b_frames = 0;
 static int do_deinterlace = 0;
 static int workaround_bugs = FF_BUG_AUTODETECT;
 static int packet_size = 0;
@@ -2336,18 +2335,6 @@ static void opt_frame_aspect_ratio(const char *arg)
     frame_aspect_ratio = ar;
 }
 
-static void opt_b_frames(const char *arg)
-{
-    b_frames = atoi(arg);
-    if (b_frames > FF_MAX_B_FRAMES) {
-        fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
-        exit(1);
-    } else if (b_frames < 1) {
-        fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
-        exit(1);
-    }
-}
-
 static void opt_qscale(const char *arg)
 {
     video_qscale = atof(arg);
@@ -2968,7 +2955,6 @@ static void new_video_stream(AVFormatContext *oc)
         if(inter_matrix)
             video_enc->inter_matrix = inter_matrix;
 
-        video_enc->max_b_frames = b_frames;
         video_enc->qmin = video_qmin;
         video_enc->qmax = video_qmax;
         video_enc->lmin = video_lmin;
@@ -3921,7 +3907,6 @@ const OptionDef options[] = {
       "method" },
     { "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold",  "" },
     { "mb_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_mb_threshold}, "macroblock threshold",  "" },
-    { "bf", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_b_frames}, "use 'frames' B frames", "frames" },
     { "bug", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_workaround_bugs}, "workaround not auto detected encoder bugs", "param" },
     { "ps", HAS_ARG | OPT_EXPERT, {(void*)opt_packet_size}, "set packet size in bits", "size" },
     { "error", HAS_ARG | OPT_EXPERT, {(void*)opt_error_rate}, "error rate", "rate" },
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a3a4b4d52a9..5ec8ad620c5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -507,7 +507,7 @@ static const AVOption options[]={
 {"qmin", "min video quantiser scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 0, INT_MAX, V|E},
 {"qmax", "max video quantiser scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 0, INT_MAX, V|E},
 {"qdiff", "max difference between the quantiser scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, 3, INT_MIN, INT_MAX, V|E},
-{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, 0, FF_MAX_B_FRAMES, V|E},
 {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
 {"rc_strategy", NULL, OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"b_strategy", NULL, OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
-- 
GitLab