Deprecate CODEC_FLAG2_NON_LINEAR_QUANT
---
 libavcodec/avcodec.h       |    2 ++
 libavcodec/mpeg12enc.c     |   15 ++++++++++++---
 libavcodec/mpegvideo_enc.c |    4 +++-
 libavcodec/options.c       |    2 +-
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8ab5f27..8dd70d4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -625,7 +625,9 @@ typedef struct RcOverride{
 #endif
 #define CODEC_FLAG2_SKIP_RD       0x00004000 ///< RD optimal MB level residual 
skipping
 #define CODEC_FLAG2_CHUNKS        0x00008000 ///< Input bitstream might be 
truncated at a packet boundaries instead of only at frame boundaries.
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
 #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear 
quantizer.
+#endif
 #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when 
encoding if possible
 #define CODEC_FLAG2_MBTREE        0x00040000 ///< Use macroblock tree 
ratecontrol (x264 only)
 #define CODEC_FLAG2_PSY           0x00080000 ///< Use psycho visual 
optimizations.
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 4ec669e..8c3e48b 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -935,9 +935,18 @@ static void mpeg1_encode_block(MpegEncContext *s,
 
 #define OFFSET(x) offsetof(MpegEncContext, x)
 #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
-static const AVOption options[] = {
-    { "intra_vlc",           "Use MPEG-2 intra VLC table.",       
OFFSET(intra_vlc_format),    FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
+#define COMMON_OPTS\
+    { "intra_vlc",           "Use MPEG-2 intra VLC table.",       
OFFSET(intra_vlc_format),    FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },\
     { "drop_frame_timecode", "Timecode is in drop frame format.", 
OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE},
+
+static const AVOption mpeg1_options[] = {
+    COMMON_OPTS
+    { NULL },
+};
+
+static const AVOption mpeg2_options[] = {
+    COMMON_OPTS
+    { "non_linear_quant",    "Use nonlinear quantizer.",          
OFFSET(q_scale_type),         FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
     { NULL },
 };
 
@@ -945,7 +954,7 @@ static const AVOption options[] = {
 static const AVClass mpeg## x ##_class = {\
     .class_name   = "mpeg" #x "video encoder",\
     .item_name    = av_default_item_name,\
-    .option       = options,\
+    .option       = mpeg## x ##_options,\
     .version      = LIBAVUTIL_VERSION_INT,\
 };
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 42fd660..1f8f9f4 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -338,8 +338,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
     s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
 #if FF_API_MPEGVIDEO_GLOBAL_OPTS
     s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
-#endif
     s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT);
+#endif
 
     if(avctx->rc_max_rate && !avctx->rc_buffer_size){
         av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding 
with a maximum bitrate\n");
@@ -463,10 +463,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
     }
 
     if(s->q_scale_type == 1){
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
         if(s->codec_id != CODEC_ID_MPEG2VIDEO){
             av_log(avctx, AV_LOG_ERROR, "non linear quant is only available 
for mpeg2\n");
             return -1;
         }
+#endif
         if(avctx->qmax > 12){
             av_log(avctx, AV_LOG_ERROR, "non linear quant only supports qmax 
<= 12 currently\n");
             return -1;
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 5231cb4..b991881 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -423,8 +423,8 @@ static const AVOption options[]={
 {"timecode_frame_start", "GOP timecode frame start number, in non drop frame 
format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, 
INT64_MAX, V|E},
 #if FF_API_MPEGVIDEO_GLOBAL_OPTS
 {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = 
CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"},
-#endif
 {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, {.dbl = 
CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
 #if FF_API_REQUEST_CHANNELS
 {"request_channels", "set desired number of audio channels", 
OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D},
 #endif
-- 
1.7.5.4

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to