diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5f13f865e4..b964d3e77f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -935,6 +935,58 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_FLAG2_RO_FLUSH_NOOP  (1 << 30)
 
+#if FF_API_MPV_GLOBAL_OPTS
+#define AV_CODEC_FLAG_CBP_RD         0x04000000 ///< Use rate distortion optimization for cbp.
+#define AV_CODEC_FLAG_QP_RD          0x08000000 ///< Use rate distortion optimization for qp selectioon.
+#define AV_CODEC_FLAG2_STRICT_GOP    0x00000002 ///< Strictly enforce GOP size.
+#define AV_CODEC_FLAG2_SKIP_RD       0x00004000 ///< RD optimal MB level residual skipping
+#endif
+
+/**
+ * @defgroup deprecated_flags Deprecated codec flags
+ * Use corresponding private codec options instead.
+ * @{
+ */
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+#define AV_CODEC_FLAG_OBMC           0x00000001 ///< OBMC
+#define AV_CODEC_FLAG_H263P_AIV      0x00000008 ///< H.263 alternative inter VLC
+#define AV_CODEC_FLAG_PART   0x0080  ///< Use data partitioning.
+#define AV_CODEC_FLAG_ALT_SCAN       0x00100000 ///< Use alternate scan.
+#define AV_CODEC_FLAG_H263P_UMV      0x02000000 ///< unlimited motion vector
+#define AV_CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
+#define AV_CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
+#define AV_CODEC_FLAG2_INTRA_VLC     0x00000800 ///< Use MPEG-2 intra VLC table.
+#ifndef AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
+#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
+#endif
+#define AV_CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
+#endif
+#if FF_API_MJPEG_GLOBAL_OPTS
+#define AV_CODEC_FLAG_EXTERN_HUFF     0x1000   ///< Use external Huffman table (for MJPEG).
+#endif
+#if FF_API_X264_GLOBAL_OPTS
+#define AV_CODEC_FLAG2_BPYRAMID      0x00000010 ///< H.264 allow B-frames to be used as references.
+#define AV_CODEC_FLAG2_WPRED         0x00000020 ///< H.264 weighted biprediction for B-frames
+#define AV_CODEC_FLAG2_MIXED_REFS    0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
+#define AV_CODEC_FLAG2_8X8DCT        0x00000080 ///< H.264 high profile 8x8 transform
+#define AV_CODEC_FLAG2_FASTPSKIP     0x00000100 ///< H.264 fast pskip
+#define AV_CODEC_FLAG2_AUD           0x00000200 ///< H.264 access unit delimiters
+#define AV_CODEC_FLAG2_BRDO          0x00000400 ///< B-frame rate-distortion optimization
+#define AV_CODEC_FLAG2_MBTREE        0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
+#define AV_CODEC_FLAG2_PSY           0x00080000 ///< Use psycho visual optimizations.
+#define AV_CODEC_FLAG2_SSIM          0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
+#define AV_CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
+#endif
+#if FF_API_SNOW_GLOBAL_OPTS
+#define AV_CODEC_FLAG2_MEMC_ONLY     0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
+#endif
+#if FF_API_LAME_GLOBAL_OPTS
+#define AV_CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
+#endif
+/**
+ * @}
+ */
+
 /* Unsupported options :
  *              Syntax Arithmetic coding (SAC)
  *              Reference Picture Selection
@@ -1753,6 +1805,22 @@ typedef struct AVCodecContext {
     int b_frame_strategy;
 #endif
 
+#if FF_API_MPV_GLOBAL_OPTS
+    /**
+     * luma single coefficient elimination threshold
+     * - encoding: Set by user.
+     * - decoding: unused
+     */
+    attribute_deprecated int luma_elim_threshold;
+
+    /**
+     * chroma single coeff elimination threshold
+     * - encoding: Set by user.
+     * - decoding: unused
+     */
+    attribute_deprecated int chroma_elim_threshold;
+#endif
+
     /**
      * qscale offset between IP and B-frames
      * - encoding: Set by user.
@@ -1993,6 +2061,13 @@ typedef struct AVCodecContext {
     int noise_reduction;
 #endif
 
+#if FF_API_MPV_GLOBAL_OPTS
+    /**
+     * @deprecated use mpegvideo private options instead
+     */
+    attribute_deprecated int quantizer_noise_shaping;
+#endif
+
     /**
      * precision of the intra DC coefficient - 8
      * - encoding: Set by user.
@@ -2068,6 +2143,20 @@ typedef struct AVCodecContext {
     int chromaoffset;
 #endif
 
+#if FF_API_X264_GLOBAL_OPTS
+    /**
+     * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
+     * - encoding: Set by user.
+     * - decoding: unused
+     */
+    attribute_deprecated int partitions;
+#define X264_PART_I4X4 0x001  /* Analyze i4x4 */
+#define X264_PART_I8X8 0x002  /* Analyze i8x8 (requires 8x8 transform) */
+#define X264_PART_P8X8 0x010  /* Analyze p16x8, p8x16 and p8x8 */
+#define X264_PART_P4X4 0x020  /* Analyze p8x4, p4x8, p4x4 */
+#define X264_PART_B8X8 0x100  /* Analyze b16x8, b8x16 and b8x8 */
+#endif
+
     /**
      * Note: Value depends upon the compare function used for fullpel ME.
      * - encoding: Set by user.
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index 5e26743f29..f010d5bc1a 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -133,6 +133,9 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
     lame_set_bWriteVbrTag(s->gfp,0);
 
     /* bit reservoir usage */
+#if FF_API_LAME_GLOBAL_OPTS
+    s->reservoir = avctx->flags2 & AV_CODEC_FLAG2_BIT_RESERVOIR;
+#endif
     lame_set_disable_reservoir(s->gfp, !s->reservoir);
 
     /* set specified parameters */
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 9c67c91f33..a211cbd18b 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -61,6 +61,7 @@ typedef struct X264Context {
     float aq_strength;
     char *psy_rd;
     int psy;
+    float psy_trellis;
     int rc_lookahead;
     int weightp;
     int weightb;
@@ -75,6 +76,8 @@ typedef struct X264Context {
     int aud;
     int mbtree;
     char *deblock;
+    int deblockalpha;
+    int deblockbeta;
     float cplxblur;
     char *partitions;
     int direct_pred;
@@ -621,7 +624,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if (x4->aq_strength >= 0)
         x4->params.rc.f_aq_strength = x4->aq_strength;
     PARSE_X264_OPT("psy-rd", psy_rd);
+    if (x4->psy_trellis >= 0)
+        x4->params.analyse.f_psy_trellis = x4->psy_trellis;
     PARSE_X264_OPT("deblock", deblock);
+    if (x4->params.i_deblocking_filter_alphac0 == 0)
+        x4->params.i_deblocking_filter_alphac0 = x4->deblockalpha;
+    if (x4->params.i_deblocking_filter_beta == 0)
+        x4->params.i_deblocking_filter_beta    = x4->deblockbeta;
     PARSE_X264_OPT("partitions", partitions);
     PARSE_X264_OPT("stats", stats);
     if (x4->psy >= 0)
@@ -758,6 +767,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)
         x4->params.b_repeat_headers = 0;
 
+#if FF_API_X264_GLOBAL_OPTS
+    if (avctx->partitions) {
+        if (avctx->partitions & X264_PART_I4X4)
+            x4->params.analyse.inter |= X264_ANALYSE_I4x4;
+        if (avctx->partitions & X264_PART_I8X8)
+            x4->params.analyse.inter |= X264_ANALYSE_I8x8;
+        if (avctx->partitions & X264_PART_P8X8)
+            x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
+        if (avctx->partitions & X264_PART_P4X4)
+            x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
+        if (avctx->partitions & X264_PART_B8X8)
+            x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
+    }
+    x4->params.analyse.b_ssim             = avctx->flags2 & AV_CODEC_FLAG2_SSIM;
+    x4->params.b_intra_refresh            = avctx->flags2 & AV_CODEC_FLAG2_INTRA_REFRESH;
+    x4->params.i_bframe_pyramid           = avctx->flags2 & AV_CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
+    x4->params.analyse.b_weighted_bipred  = avctx->flags2 & AV_CODEC_FLAG2_WPRED;
+    x4->params.analyse.b_mixed_references = avctx->flags2 & AV_CODEC_FLAG2_MIXED_REFS;
+    x4->params.analyse.b_transform_8x8    = avctx->flags2 & AV_CODEC_FLAG2_8X8DCT;
+    x4->params.analyse.b_fast_pskip       = avctx->flags2 & AV_CODEC_FLAG2_FASTPSKIP;
+    x4->params.b_aud                      = avctx->flags2 & AV_CODEC_FLAG2_AUD;
+    x4->params.analyse.b_psy              = avctx->flags2 & AV_CODEC_FLAG2_PSY;
+    x4->params.rc.b_mb_tree               = !!(avctx->flags2 & AV_CODEC_FLAG2_MBTREE);
+#endif
+
     if(x4->x264opts){
         const char *p= x4->x264opts;
         while(p){
@@ -905,6 +939,7 @@ static const AVOption options[] = {
 #endif
     { "aq-strength",   "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, VE},
     { "psy",           "Use psychovisual optimizations.",                 OFFSET(psy),           AV_OPT_TYPE_BOOL,   { .i64 = -1 }, -1, 1, VE },
+    { "psy-trellis",   "Specify psychovisual trellis",                    OFFSET(psy_trellis),   AV_OPT_TYPE_FLOAT,  { .dbl = -1 }, -1, FLT_MAX, VE },
     { "psy-rd",        "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING,  {0 }, 0, 0, VE},
     { "rc-lookahead",  "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
     { "weightb",       "Weighted prediction for B-frames.",               OFFSET(weightb),       AV_OPT_TYPE_BOOL,   { .i64 = -1 }, -1, 1, VE },
@@ -951,17 +986,30 @@ static const AVOption options[] = {
     { "tesa",          NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
     { "forced-idr",   "If forcing keyframes, force them as IDR frames.",                                  OFFSET(forced_idr),  AV_OPT_TYPE_BOOL,   { .i64 = 0 }, -1, 1, VE },
     { "coder",    "Coder type",                                           OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "coder" },
-    { "default",          NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, VE, "coder" },
-    { "cavlc",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  INT_MIN, INT_MAX, VE, "coder" },
-    { "cabac",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  INT_MIN, INT_MAX, VE, "coder" },
-    { "vlc",              NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  INT_MIN, INT_MAX, VE, "coder" },
-    { "ac",               NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  INT_MIN, INT_MAX, VE, "coder" },
+    { "default",       NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 },                INT_MIN, INT_MAX, VE, "coder" },
+    { "cavlc",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, VE, "coder" },
+    { "cabac",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_CODER_TYPE_AC },  INT_MIN, INT_MAX, VE, "coder" },
+    { "vlc",           NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, VE, "coder" },
+    { "ac",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_CODER_TYPE_AC },  INT_MIN, INT_MAX, VE, "coder" },
     { "b_strategy",   "Strategy to choose between I/P/B-frames",          OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE },
     { "chromaoffset", "QP difference between chroma and luma",            OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE },
     { "sc_threshold", "Scene change threshold",                           OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE },
     { "noise_reduction", "Noise reduction",                               OFFSET(noise_reduction), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE },
 
     { "x264-params",  "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
+    /* old options */
+    { "cqp",           "Constant quantization parameter rate control method",OFFSET(cqp),        AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX, VE },
+    { "aq_mode",       "AQ method",                                       OFFSET(aq_mode),       AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX, VE, "aq_mode" },
+    { "aq_strength",   "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, { .dbl = -1 }, -1, FLT_MAX, VE },
+    { "psy_rd",        "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING,  { 0 }, 0, 0, VE },
+    { "psy_trellis",   "Specify psychovisual trellis",                    OFFSET(psy_trellis),   AV_OPT_TYPE_FLOAT,  { .dbl = -1 }, -1, FLT_MAX, VE },
+    { "rc_lookahead",  "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
+    { "intra_refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, 1, VE },
+    { "bframebias",    "Influences how often B-frames are used",          OFFSET(b_bias),        AV_OPT_TYPE_INT,    { .i64 = INT_MIN }, INT_MIN, INT_MAX, VE },
+    { "deblockalpha",  "in-loop deblocking filter alphac0 parameter",     OFFSET(deblockalpha),  AV_OPT_TYPE_INT,    { .i64 =  0 }, -6, 6, VE },
+    { "deblockbeta",   "in-loop deblocking filter beta parameter",        OFFSET(deblockbeta),   AV_OPT_TYPE_INT,    { .i64 =  0 }, -6, 6, VE },
+    { "complexityblur","Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT,  { .dbl = -1 }, -1, FLT_MAX, VE },
+    { "directpred",    "Direct MV prediction mode",                       OFFSET(direct_pred),   AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX, VE, "direct-pred" },
     { NULL },
 };
 
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 865b5f62ef..632a0cb7de 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -266,6 +266,22 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
         }
     }
 
+#if FF_API_X264_GLOBAL_OPTS
+    if (avctx->partitions) {
+        if (avctx->partitions & XAVS_PART_I8X8)
+            x4->params.analyse.inter |= XAVS_ANALYSE_I8x8;
+        if (avctx->partitions & XAVS_PART_P8X8)
+            x4->params.analyse.inter |= XAVS_ANALYSE_PSUB16x16;
+        if (avctx->partitions & XAVS_PART_B8X8)
+            x4->params.analyse.inter |= XAVS_ANALYSE_BSUB16x16;
+    }
+    x4->params.rc.b_mb_tree               = !!(avctx->flags2 & AV_CODEC_FLAG2_MBTREE);
+    x4->params.b_aud                      = avctx->flags2 & AV_CODEC_FLAG2_AUD;
+    x4->params.analyse.b_mixed_references = avctx->flags2 & AV_CODEC_FLAG2_MIXED_REFS;
+    x4->params.analyse.b_fast_pskip       = avctx->flags2 & AV_CODEC_FLAG2_FASTPSKIP;
+    x4->params.analyse.b_weighted_bipred  = avctx->flags2 & AV_CODEC_FLAG2_WPRED;
+#endif
+
     if (x4->aud >= 0)
         x4->params.b_aud                      = x4->aud;
     if (x4->mbtree >= 0)
@@ -449,7 +465,11 @@ static const AVOption options[] = {
     { "chromaoffset", "QP difference between chroma and luma",           OFFSET(chroma_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE},
     { "sc_threshold", "Scene change threshold",                           OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE},
     { "noise_reduction", "Noise reduction",                               OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE},
-
+    /* old options */
+    { "cqp",           "Constant quantization parameter rate control method",OFFSET(cqp),        AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX, VE },
+    { "bframebias",    "Influences how often B-frames are used",          OFFSET(b_bias),        AV_OPT_TYPE_INT,    { .i64 = INT_MIN }, INT_MIN, INT_MAX, VE },
+    { "complexityblur","Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT,  { .dbl = -1 }, -1, FLT_MAX, VE },
+    { "directpred",    "Direct MV prediction mode",                       OFFSET(direct_pred),   AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX, VE, "direct-pred" },
     { NULL },
 };
 
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 5b2409755c..9d1580a586 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -151,6 +151,10 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
     if ((ret = build_basic_mjpeg_vlc(s)) < 0)
         return ret;
 
+#if FF_API_MJPEG_GLOBAL_OPTS
+    if (avctx->flags & AV_CODEC_FLAG_EXTERN_HUFF)
+        s->extern_huff = 1;
+#endif
     if (s->extern_huff) {
         av_log(avctx, AV_LOG_INFO, "using external huffman table\n");
         if ((ret = init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8)) < 0)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index f45598a087..f05d2ceb98 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -142,6 +142,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (ff_mpv_encode_init(avctx) < 0)
         return -1;
 
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if (avctx->flags2 & AV_CODEC_FLAG2_DROP_FRAME_TIMECODE)
+        s->drop_frame_timecode = 1;
+    if (avctx->flags & AV_CODEC_FLAG_SVCD_SCAN_OFFSET)
+        s->scan_offset = 1;
+#endif
+
     if (find_frame_rate_index(s) < 0) {
         if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
             av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d fps\n",
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f1f4989231..a891c8aa6c 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -381,7 +381,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
     s->max_b_frames = avctx->max_b_frames;
     s->codec_id     = avctx->codec->id;
+#if FF_API_MPV_GLOBAL_OPTS
+    if (avctx->luma_elim_threshold)
+        s->luma_elim_threshold   = avctx->luma_elim_threshold;
+    if (avctx->chroma_elim_threshold)
+        s->chroma_elim_threshold = avctx->chroma_elim_threshold;
+#endif
     s->strict_std_compliance = avctx->strict_std_compliance;
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if (avctx->flags & AV_CODEC_FLAG_PART)
+        s->data_partitioning = 1;
+#endif
     s->quarter_sample     = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
     s->rtp_mode           = !!s->rtp_payload_size;
     s->intra_dc_precision = avctx->intra_dc_precision;
@@ -418,6 +428,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
     /* Fixed QSCALE */
     s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);
 
+#if FF_API_MPV_GLOBAL_OPTS
+    if (s->avctx->flags & AV_CODEC_FLAG_QP_RD)
+        s->mpv_flags |= FF_MPV_FLAG_QP_RD;
+#endif
+
     s->adaptive_quant = (s->avctx->lumi_masking ||
                          s->avctx->dark_masking ||
                          s->avctx->temporal_cplx_masking ||
@@ -428,6 +443,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
                         !s->fixed_qscale;
 
     s->loop_filter = !!(s->avctx->flags & AV_CODEC_FLAG_LOOP_FILTER);
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if (!s->alternate_scan)
+        s->alternate_scan   = !!(s->avctx->flags  & AV_CODEC_FLAG_ALT_SCAN);
+    if (!s->intra_vlc_format)
+        s->intra_vlc_format = !!(s->avctx->flags2 & AV_CODEC_FLAG2_INTRA_VLC);
+    if (!s->q_scale_type)
+        s->q_scale_type     = !!(s->avctx->flags2 & AV_CODEC_FLAG2_NON_LINEAR_QUANT);
+    if (!s->obmc)
+        s->obmc             = !!(s->avctx->flags  & AV_CODEC_FLAG_OBMC);
+#endif
 
     if (avctx->rc_max_rate && !avctx->rc_buffer_size) {
         switch(avctx->codec_id) {
@@ -521,11 +546,27 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return -1;
     }
 
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if (s->obmc && s->codec_id != AV_CODEC_ID_H263 &&
+        s->codec_id != AV_CODEC_ID_H263P) {
+        av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
+        return -1;
+    }
+#endif
+
     if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) {
         av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
         return -1;
     }
 
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if (s->data_partitioning && s->codec_id != AV_CODEC_ID_MPEG4) {
+        av_log(avctx, AV_LOG_ERROR,
+               "data partitioning not supported by codec\n");
+        return -1;
+    }
+#endif
+
     if (s->max_b_frames                    &&
         s->codec_id != AV_CODEC_ID_MPEG4      &&
         s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
@@ -601,7 +642,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
          return -1;
     }
 
-    if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) &&
+    if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+                           | AV_CODEC_FLAG_ALT_SCAN
+#endif
+        )) &&
         s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
         av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
         return -1;
@@ -622,6 +667,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return -1;
     }
 
+#if FF_API_MPV_GLOBAL_OPTS
+    if (s->avctx->flags & AV_CODEC_FLAG_CBP_RD)
+        s->mpv_flags |= FF_MPV_FLAG_CBP_RD;
+#endif
+
     if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) {
         av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
         return -1;
@@ -657,6 +707,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return -1;
     }
 
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+    if ((s->avctx->flags2 & AV_CODEC_FLAG2_INTRA_VLC) &&
+        s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
+        av_log(avctx, AV_LOG_ERROR,
+               "intra vlc table not supported by codec\n");
+        return -1;
+    }
+#endif
+
     if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) {
         if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO &&
             s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
@@ -673,6 +732,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     if (s->q_scale_type == 1) {
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+        if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "non linear quant is only available for mpeg2\n");
+            return -1;
+        }
+#endif
         if (avctx->qmax > 28) {
             av_log(avctx, AV_LOG_ERROR,
                    "non linear quant only supports qmax <= 28 currently\n");
@@ -691,7 +757,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
         s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
         s->codec_id != AV_CODEC_ID_MPEG2VIDEO &&
         s->codec_id != AV_CODEC_ID_MJPEG      &&
-        (s->codec_id != AV_CODEC_ID_H263P)) {
+        (s->codec_id != AV_CODEC_ID_H263P
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+         || !(s->avctx->flags & AV_CODEC_FLAG_H263P_SLICE_STRUCT)
+#endif
+         )) {
         av_log(avctx, AV_LOG_ERROR,
                "multi threaded encoding not supported by codec\n");
         return -1;
@@ -760,6 +830,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
     s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
 
+#if FF_API_MPV_GLOBAL_OPTS
+    if (s->avctx->flags2 & AV_CODEC_FLAG2_SKIP_RD)
+        s->mpv_flags |= FF_MPV_FLAG_SKIP_RD;
+    if (s->avctx->flags2 & AV_CODEC_FLAG2_STRICT_GOP)
+        s->mpv_flags |= FF_MPV_FLAG_STRICT_GOP;
+    if (avctx->quantizer_noise_shaping)
+        s->quantizer_noise_shaping = avctx->quantizer_noise_shaping;
+#endif
+
     switch (avctx->codec->id) {
     case AV_CODEC_ID_MPEG1VIDEO:
         s->out_format = FMT_MPEG1;
@@ -817,6 +896,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
         s->out_format = FMT_H263;
         s->h263_plus  = 1;
         /* Fx */
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+        if (avctx->flags & AV_CODEC_FLAG_H263P_UMV)
+            s->umvplus = 1;
+        if (avctx->flags & AV_CODEC_FLAG_H263P_AIV)
+            s->alt_inter_vlc = 1;
+        if (avctx->flags & AV_CODEC_FLAG_H263P_SLICE_STRUCT)
+            s->h263_slice_structured = 1;
+#endif
         s->h263_aic        = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;
         s->modified_quant  = s->h263_aic;
         s->loop_filter     = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index d89f58d540..4a54b102d1 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -51,23 +51,52 @@ static const AVOption avcodec_options[] = {
 {"flags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, UINT_MAX, V|A|S|E|D, "flags"},
 {"unaligned", "allow decoders to produce unaligned output", 0, AV_OPT_TYPE_CONST, { .i64 = AV_CODEC_FLAG_UNALIGNED }, INT_MIN, INT_MAX, V | D, "flags" },
 {"mv4", "use four motion vectors per macroblock (MPEG-4)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"obmc", "use overlapped block motion compensation (h263+)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_OBMC }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
 {"qpel", "use 1/4-pel motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"},
 {"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"},
 {"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"part", "use data partitioning", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PART }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
 {"pass1", "use internal 2-pass ratecontrol in first  pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"},
 {"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
+#if FF_API_MJPEG_GLOBAL_OPTS
+{"extern_huff", "use external huffman table (for mjpeg)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_EXTERN_HUFF }, INT_MIN, INT_MAX, 0, "flags"},
+#endif
 {"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"},
 {"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"},
 {"truncated", "Input bitstream might be randomly truncated", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, V|D, "flags"},
 {"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"},
 {"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_ALT_SCAN }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
 {"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"},
 {"bitexact", "use only bitexact functions (except (I)DCT)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"},
 {"aic", "H.263 advanced intra coding / MPEG-4 AC prediction", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"umv", "use unlimited motion vectors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_H263P_UMV }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
+#if FF_API_MPV_GLOBAL_OPTS
+{"cbp", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
+{"qprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"aiv", "h263 alternative inter vlc", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"},
+{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
 {"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"scan_offset", "will reserve space for svcd scan offset user data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
 {"cgop", "closed GOP", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"},
 {"output_corrupt", "Output even potentially corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_OUTPUT_CORRUPT }, INT_MIN, INT_MAX, V|D, "flags"},
 {"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
+#if FF_API_MPV_GLOBAL_OPTS
+{"sgop", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
 {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
 {"ignorecrop", "ignore cropping information from sps", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"},
 {"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"},
@@ -124,6 +153,10 @@ static const AVOption avcodec_options[] = {
 {"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"},
 {"ms", "work around various bugs in Microsoft's broken decoders", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"},
 {"trunc", "truncated frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"},
+#if FF_API_MPV_GLOBAL_OPTS
+{"lelim", "single coefficient elimination threshold for luminance (negative values also consider DC coefficient)", OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+{"celim", "single coefficient elimination threshold for chrominance (negative values also consider DC coefficient)", OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
 {"iedge", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_IEDGE }, INT_MIN, INT_MAX, V|D, "bug"},
 {"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
 {"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
@@ -271,7 +304,20 @@ static const AVOption avcodec_options[] = {
 {"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
 #endif
 {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
+#if FF_API_X264_GLOBAL_OPTS
+#define X264_DEFAULTS AV_CODEC_FLAG2_FASTPSKIP|AV_CODEC_FLAG2_PSY|AV_CODEC_FLAG2_MBTREE
+#else
+#define X264_DEFAULTS 0
+#endif
+#if FF_API_LAME_GLOBAL_OPTS
+#define LAME_DEFAULTS AV_CODEC_FLAG2_BIT_RESERVOIR
+#else
+#define LAME_DEFAULTS 0
+#endif
+{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = X264_DEFAULTS|LAME_DEFAULTS }, 0, UINT_MAX, V|A|E|D, "flags2"},
+#if FF_API_MPV_GLOBAL_OPTS
+{"qns", "deprecated, use mpegvideo private options instead", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
 {"threads", "set the number of threads", OFFSET(thread_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, V|A|E|D, "threads"},
 {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
 {"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.i64 = 0 }, -8, 16, V|E},
@@ -334,7 +380,29 @@ static const AVOption avcodec_options[] = {
 {"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
 #endif
 {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
+#if FF_API_X264_GLOBAL_OPTS
+{"bpyramid", "allows B-frames to be used as references for predicting", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"wpred", "weighted biprediction for b-frames (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"dct8x8", "high profile 8x8 transform (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"fastpskip", "fast pskip (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"aud", "access unit delimiters (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
+#if FF_API_MPV_GLOBAL_OPTS
+{"skiprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
+#if FF_API_X264_GLOBAL_OPTS
+{"partitions", "macroblock subpartition sizes to consider", OFFSET(partitions), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "partitions"},
+{"parti4x4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_PART_I4X4 }, INT_MIN, INT_MAX, V|E, "partitions"},
+{"parti8x8", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_PART_I8X8 }, INT_MIN, INT_MAX, V|E, "partitions"},
+{"partp4x4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_PART_P4X4 }, INT_MIN, INT_MAX, V|E, "partitions"},
+{"partp8x8", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_PART_P8X8 }, INT_MIN, INT_MAX, V|E, "partitions"},
+{"partb8x8", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_PART_B8X8 }, INT_MIN, INT_MAX, V|E, "partitions"},
+#endif
 {"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"ivlc", "intra vlc table", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
 #if FF_API_PRIVATE_OPT
 {"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E},
 #endif
@@ -344,6 +412,16 @@ static const AVOption avcodec_options[] = {
 {"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
 {"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, V|E},
 #endif
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
+{"drop_frame_timecode", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"non_linear_q", "use non linear quantizer", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
+#if FF_API_LAME_GLOBAL_OPTS
+{"reservoir", "use bit reservoir", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"},
+#endif
+#if FF_API_X264_GLOBAL_OPTS
+{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
 {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX},
 {"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_UINT64, {.i64 = DEFAULT }, 0, UINT64_MAX, A|E|D, "channel_layout"},
 {"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_UINT64, {.i64 = DEFAULT }, 0, UINT64_MAX, A|D, "request_channel_layout"},
@@ -424,6 +502,11 @@ static const AVOption avcodec_options[] = {
 {"bottomleft",  "Bottom-left", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_BOTTOMLEFT },  INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
 {"bottom",      "Bottom",      0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_BOTTOM },      INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
 {"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
+#if FF_API_X264_GLOBAL_OPTS
+{"psy", "use psycho visual optimization", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"ssim", "ssim will be calculated during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"},
+#endif
 {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX },
 {"slices", "set the number of slices, used in parallelized encoding", OFFSET(slices), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
 {"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.i64 = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|A|E|D, "thread_type"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 69f124a4c6..82dda60aa3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -51,6 +51,24 @@
  * at once through the bump. This improves the git bisect-ability of the change.
  */
 
+#ifndef FF_API_MPV_GLOBAL_OPTS
+#define FF_API_MPV_GLOBAL_OPTS  (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_X264_GLOBAL_OPTS
+#define FF_API_X264_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS
+#define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_LAME_GLOBAL_OPTS
+#define FF_API_LAME_GLOBAL_OPTS  (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_SNOW_GLOBAL_OPTS
+#define FF_API_SNOW_GLOBAL_OPTS  (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_MJPEG_GLOBAL_OPTS
+#define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 #ifndef FF_API_LOWRES
 #define FF_API_LOWRES            (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index c0344550f9..9641b4a6d6 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -189,8 +189,8 @@ fate-vsynth%-h261-trellis:       ENCOPTS = -qscale 12 -trellis 1 -mbd rd
 
 FATE_VCODEC-$(call ENCDEC, H263, AVI)   += h263 h263-obmc h263p
 fate-vsynth%-h263:               ENCOPTS = -qscale 10
-fate-vsynth%-h263-obmc:          ENCOPTS = -qscale 10 -obmc 1
-fate-vsynth%-h263p:              ENCOPTS = -qscale 2 -flags +aic -umv 1 -aiv 1 -ps 300
+fate-vsynth%-h263-obmc:          ENCOPTS = -qscale 10 -flags +obmc
+fate-vsynth%-h263p:              ENCOPTS = -qscale 2 -flags +umv+aiv+aic -ps 300
 
 FATE_VCODEC-$(call ENCDEC, HUFFYUV, AVI) += huffyuv huffyuvbgr24 huffyuvbgra
 fate-vsynth%-huffyuv:            ENCOPTS = -c:v huffyuv -pix_fmt yuv422p -sws_flags neighbor
@@ -249,7 +249,7 @@ fate-vsynth%-mpeg2-422:          ENCOPTS = -b:v 1000k                   \
                                            -trellis 1                   \
                                            -flags +ildct+ilme           \
                                            -mpv_flags +qp_rd+mv0        \
-                                           -intra_vlc 1                 \
+                                           -flags2 +ivlc                \
                                            -mbd rd                      \
                                            -pix_fmt yuv422p
 fate-vsynth%-mpeg2-idct-int:     ENCOPTS = -qscale 10 -idct int -dct int
@@ -258,13 +258,13 @@ fate-vsynth%-mpeg2-ivlc-qprd:    ENCOPTS = -b:v 500k                    \
                                            -bf 2                        \
                                            -trellis 1                   \
                                            -mpv_flags +qp_rd+mv0        \
-                                           -intra_vlc 1                 \
+                                           -flags2 +ivlc                \
                                            -cmp 2 -subcmp 2             \
                                            -mbd rd
 fate-vsynth%-mpeg2-thread:       ENCOPTS = -qscale 10 -bf 2 -flags +ildct+ilme \
                                            -threads 2 -slices 2
 fate-vsynth%-mpeg2-thread-ivlc:  ENCOPTS = -qscale 10 -bf 2 -flags +ildct+ilme \
-                                           -intra_vlc 1 -threads 2 -slices 2
+                                           -flags2 +ivlc -threads 2 -slices 2
 
 FATE_MPEG4_MP4 = mpeg4
 FATE_MPEG4_AVI = mpeg4-rc                                               \
@@ -288,12 +288,12 @@ fate-vsynth%-mpeg4-adap:         ENCOPTS = -b 550k -bf 2 -flags +mv4     \
                                            -mbd rd -scplx_mask 0.3       \
                                            -mpv_flags +mv0
 
-fate-vsynth%-mpeg4-adv:          ENCOPTS = -qscale 9 -flags +mv4+aic       \
-                                           -data_partitioning 1 -trellis 1 \
+fate-vsynth%-mpeg4-adv:          ENCOPTS = -qscale 9 -flags +mv4+part+aic \
+                                           -trellis 1                     \
                                            -mbd bits -ps 200
 
-fate-vsynth%-mpeg4-error:        ENCOPTS = -qscale 7 -flags +mv4+aic    \
-                                           -data_partitioning 1 -mbd rd \
+fate-vsynth%-mpeg4-error:        ENCOPTS = -qscale 7 -flags +mv4+part+aic \
+                                           -mbd rd                        \
                                            -ps 250 -error_rate 10
 
 fate-vsynth%-mpeg4-nr:           ENCOPTS = -qscale 8 -flags +mv4 -mbd rd \
@@ -312,8 +312,8 @@ fate-vsynth%-mpeg4-qprd:         ENCOPTS = -b 450k -bf 2 -trellis 1          \
 
 fate-vsynth%-mpeg4-rc:           ENCOPTS = -b 400k -bf 2
 
-fate-vsynth%-mpeg4-thread:       ENCOPTS = -b 500k -flags +mv4+aic         \
-                                           -data_partitioning 1 -trellis 1 \
+fate-vsynth%-mpeg4-thread:       ENCOPTS = -b 500k -flags +mv4+part+aic    \
+                                           -trellis 1                      \
                                            -mbd bits -ps 200 -bf 2         \
                                            -threads 2 -slices 2
 
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 45c877e4ac..e4549e5110 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -87,7 +87,7 @@ do_lavf_timecode mxf "-ar 48000 -bf 2 -threads 1"
 fi
 
 if [ -n "$do_mxf_d10" ]; then
-do_lavf mxf_d10 "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,pad=720:608:0:32 -vcodec mpeg2video -g 0 -flags +ildct+low_delay -dc 10 -non_linear_quant 1 -intra_vlc 1 -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10"
+do_lavf mxf_d10 "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,pad=720:608:0:32 -vcodec mpeg2video -g 0 -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10"
 fi
 
 if [ -n "$do_mxf_dv25" ]; then
