Discussion:
[PATCH 00/14] codec private options
(too old to reply)
Vittorio Giovara
2016-01-04 13:34:09 UTC
Permalink
AVCodecContext holds a lot of fields that are used seldom within
libavcodec, in most cases only to set options that apply to a single
family of codecs, or sometimes to completely unrelated codecs.
This was done before in the long past there was no codec private option,
and in fact nowadays global context options are rarely added (and only
when it really applies to something global), preferring to add codec
private options instead.

This set (1 of 3) tries to go over each context field and to identify
which not-really-global options should be moved to private codec options.
The rationale is that after my changes options would have a much more precise
scope, as right now it is not possible to understand which option affects
which codec without looking at the source code. The (long term) improvement
would also be to have a more compact context, with less fields to document

The option selection is a trade off between how widespread the option is
within libavcodec and how much it makes sense for an option to be global.

Vittorio

Vittorio Giovara (14):
lavc: Move b_frame_strategy and b_sensitivity to codec private options
lavc: Move brd_scale to codec private options
lavc: Move frame_skip_* to codec private options
lavc: Move chromaoffset to codec private options
lavc: Move scenechange_threshold to codec private options
lavc: Move noise_reduction to codec private options
lavc: Move mpeg_quant to codec private options
lavc: Move context_model to codec private options
lavc: Move timecode_frame_start to codec private options
lavc: Move rtp_payload_size to codec private options
lavc: Move {min,max}_prediction_order to codec private options
lavc: Move prediction_method to codec private options
lavc: Move me_penalty_compensation to codec private options
lavc: Move pre_me to codec private options

libavcodec/alacenc.c | 27 +++++++-
libavcodec/avcodec.h | 147 +++++++++++++++++++------------------------
libavcodec/ffv1.h | 1 +
libavcodec/ffv1enc.c | 20 ++++--
libavcodec/flacenc.c | 33 ++++++++--
libavcodec/huffyuvenc.c | 58 +++++++++++++++--
libavcodec/jpeglsenc.c | 39 +++++++++++-
libavcodec/libopenh264enc.c | 11 +---
libavcodec/libvpxenc.c | 21 ++++++-
libavcodec/libx264.c | 54 ++++++++++++++--
libavcodec/libxavs.c | 46 ++++++++++++--
libavcodec/libxvid.c | 10 +++
libavcodec/ljpegenc.c | 43 +++++++++++--
libavcodec/mjpegenc.c | 19 ++++++
libavcodec/mjpegenc_common.c | 4 +-
libavcodec/mjpegenc_common.h | 2 +-
libavcodec/mpeg12enc.c | 13 +++-
libavcodec/mpegvideo.c | 2 +-
libavcodec/mpegvideo.h | 48 ++++++++++++++
libavcodec/mpegvideo_enc.c | 129 +++++++++++++++++++++++++++----------
libavcodec/options_table.h | 26 ++++++++
libavcodec/pngenc.c | 35 ++++++++++-
libavcodec/qsvenc.c | 8 ++-
libavcodec/qsvenc.h | 2 +
libavcodec/qsvenc_h264.c | 2 +
libavcodec/qsvenc_hevc.c | 2 +
libavcodec/qsvenc_mpeg2.c | 2 +
libavcodec/utvideo.c | 2 +
libavcodec/utvideoenc.c | 29 ++++++++-
libavcodec/version.h | 3 +
tests/fate/utvideo.mak | 8 +--
tests/fate/vcodec.mak | 3 +-
32 files changed, 671 insertions(+), 178 deletions(-)
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:10 UTC
Permalink
The b_frame_strategy option is only used by mpegvideoenc, qsv, x264, and
xavs, while b_sensitivity is only used by mpegvideoenc.

These are very codec-specific options, so deprecate the global variants.
Set proper limits to the maximum allowed values.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 13 ++++++++-----
libavcodec/libx264.c | 13 ++++++++++++-
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 4 ++++
libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++-----------
libavcodec/options_table.h | 4 ++++
libavcodec/qsvenc.c | 8 +++++++-
libavcodec/qsvenc.h | 2 ++
libavcodec/qsvenc_h264.c | 2 ++
libavcodec/qsvenc_hevc.c | 2 ++
libavcodec/qsvenc_mpeg2.c | 2 ++
libavcodec/version.h | 3 +++
12 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8083111..66e6ac8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1594,7 +1594,11 @@ typedef struct AVCodecContext {
#define FF_RC_STRATEGY_XVID 1
#endif

+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int b_frame_strategy;
+#endif

/**
* qscale offset between IP and B-frames
@@ -1999,12 +2003,11 @@ typedef struct AVCodecContext {
*/
int mv0_threshold;

- /**
- * Adjust sensitivity of b_frame_strategy 1.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int b_sensitivity;
+#endif

/**
* Chromaticity coordinates of the source primaries.
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index fe0247f..bcb5dd1 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -79,6 +79,7 @@ typedef struct X264Context {
int motion_est;
int forced_idr;
int coder;
+ int b_frame_strategy;

char *x264_params;
} X264Context;
@@ -439,8 +440,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if (avctx->me_subpel_quality >= 0)
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->keyint_min >= 0)
x4->params.i_keyint_min = avctx->keyint_min;
#if FF_API_CODER_TYPE
@@ -527,6 +532,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->coder >= 0)
x4->params.b_cabac = x4->coder;

+ if (x4->b_frame_strategy >= 0)
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;
+
if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
@@ -730,6 +738,7 @@ static const AVOption options[] = {
{ "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" },
+ { "b-strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, 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 },
{ NULL },
@@ -754,7 +763,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "me_method", "-1" },
#endif
{ "subq", "-1" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ "keyint_min", "-1" },
#if FF_API_CODER_TYPE
{ "coder", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 43b0915..910d6c9 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -56,6 +56,7 @@ typedef struct XavsContext {
int motion_est;
int mbtree;
int mixed_refs;
+ int b_frame_strategy;

int64_t *pts_buffer;
int out_frame_count;
@@ -311,7 +312,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* cabac is not included in AVS JiZhun Profile */
x4->params.b_cabac = 0;

- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;

avctx->has_b_frames = !!avctx->max_b_frames;

@@ -439,6 +447,7 @@ static const AVOption options[] = {
{ "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
+ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},

{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 52c6f91..309a02f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -525,6 +525,8 @@ typedef struct MpegEncContext {

/* temporary frames used by b_frame_strategy = 2 */
AVFrame *tmp_frames[MAX_B_FRAMES + 2];
+ int b_frame_strategy;
+ int b_sensitivity;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -573,6 +575,8 @@ typedef struct MpegEncContext {
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
+{"b_strategy", "strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
+{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 34e008f..5856312 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -525,10 +525,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

- if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ s->b_frame_strategy = avctx->b_frame_strategy;
+ if (avctx->b_sensitivity != 40)
+ s->b_sensitivity = avctx->b_sensitivity;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_INFO,
"notice: b_frame_strategy only affects the first pass\n");
- avctx->b_frame_strategy = 0;
+ s->b_frame_strategy = 0;
}

i = av_gcd(avctx->time_base.den, avctx->time_base.num);
@@ -867,7 +876,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif

- if (avctx->b_frame_strategy == 2) {
+ if (s->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
if (!s->tmp_frames[i])
@@ -1302,7 +1311,7 @@ static int select_input_picture(MpegEncContext *s)
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
- int b_frames;
+ int b_frames = 0;

if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
@@ -1333,11 +1342,11 @@ static int select_input_picture(MpegEncContext *s)
}
}

- if (s->avctx->b_frame_strategy == 0) {
+ if (s->b_frame_strategy == 0) {
b_frames = s->max_b_frames;
while (b_frames && !s->input_picture[b_frames])
b_frames--;
- } else if (s->avctx->b_frame_strategy == 1) {
+ } else if (s->b_frame_strategy == 1) {
for (i = 1; i < s->max_b_frames + 1; i++) {
if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
@@ -1351,7 +1360,7 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < s->max_b_frames + 1; i++) {
if (!s->input_picture[i] ||
s->input_picture[i]->b_frame_score - 1 >
- s->mb_num / s->avctx->b_sensitivity)
+ s->mb_num / s->b_sensitivity)
break;
}

@@ -1361,11 +1370,8 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < b_frames + 1; i++) {
s->input_picture[i]->b_frame_score = 0;
}
- } else if (s->avctx->b_frame_strategy == 2) {
+ } else if (s->b_frame_strategy == 2) {
b_frames = estimate_best_b_count(s);
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
- b_frames = 0;
}

emms_c();
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 91b2bef..2c8fb94 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -119,7 +119,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_RC_STRATEGY
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#endif
+#if FF_API_PRIVATE_OPT
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
+#endif
{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#if FF_API_STAT_BITS
{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
@@ -390,7 +392,9 @@ static const AVOption avcodec_options[] = {
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
#endif /* FF_API_UNUSED_MEMBERS */
{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
+#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
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f19ca76..861cf63 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -498,8 +498,14 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
#endif

#if QSV_HAVE_BREF_TYPE
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- q->extco2.BRefType = avctx->b_frame_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
+ q->extco2.b_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (q->extco2.b_strategy >= 0)
+ q->extco2.BRefType = q->extco2.b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
if (q->adaptive_i >= 0)
q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
if (q->adaptive_b >= 0)
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index ec0c4df..97165fc 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -65,6 +65,7 @@
{ "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
+{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \

typedef struct QSVEncContext {
AVCodecContext *avctx;
@@ -118,6 +119,7 @@ typedef struct QSVEncContext {
int extbrc;
int adaptive_i;
int adaptive_b;
+ int b_strategy;

int int_ref_type;
int int_ref_cycle_size;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 2294604..7f4fb81 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -109,7 +109,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "coder", "ac" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 343733b..8884e24 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -244,7 +244,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "8" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index dcfcb81..f29f445 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -89,7 +89,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "3" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/version.h b/libavcodec/version.h
index e9e76b6..72a18ed 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -189,5 +189,8 @@
#ifndef FF_API_STAT_BITS
#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_PRIVATE_OPT
+#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif

#endif /* AVCODEC_VERSION_H */
--
2.6.4
Hendrik Leppkes
2016-01-04 13:39:09 UTC
Permalink
On Mon, Jan 4, 2016 at 2:34 PM, Vittorio Giovara
Post by Vittorio Giovara
The b_frame_strategy option is only used by mpegvideoenc, qsv, x264, and
xavs, while b_sensitivity is only used by mpegvideoenc.
These are very codec-specific options, so deprecate the global variants.
Set proper limits to the maximum allowed values.
---
libavcodec/avcodec.h | 13 ++++++++-----
libavcodec/libx264.c | 13 ++++++++++++-
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 4 ++++
libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++-----------
libavcodec/options_table.h | 4 ++++
libavcodec/qsvenc.c | 8 +++++++-
libavcodec/qsvenc.h | 2 ++
libavcodec/qsvenc_h264.c | 2 ++
libavcodec/qsvenc_hevc.c | 2 ++
libavcodec/qsvenc_mpeg2.c | 2 ++
libavcodec/version.h | 3 +++
12 files changed, 73 insertions(+), 19 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8083111..66e6ac8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1594,7 +1594,11 @@ typedef struct AVCodecContext {
#define FF_RC_STRATEGY_XVID 1
#endif
+#if FF_API_PRIVATE_OPT
+ attribute_deprecated
int b_frame_strategy;
+#endif
/**
* qscale offset between IP and B-frames
@@ -1999,12 +2003,11 @@ typedef struct AVCodecContext {
*/
int mv0_threshold;
- /**
- * Adjust sensitivity of b_frame_strategy 1.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ attribute_deprecated
int b_sensitivity;
+#endif
/**
* Chromaticity coordinates of the source primaries.
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index fe0247f..bcb5dd1 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -79,6 +79,7 @@ typedef struct X264Context {
int motion_est;
int forced_idr;
int coder;
+ int b_frame_strategy;
char *x264_params;
} X264Context;
@@ -439,8 +440,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if (avctx->me_subpel_quality >= 0)
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->keyint_min >= 0)
x4->params.i_keyint_min = avctx->keyint_min;
#if FF_API_CODER_TYPE
@@ -527,6 +532,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->coder >= 0)
x4->params.b_cabac = x4->coder;
+ if (x4->b_frame_strategy >= 0)
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;
+
if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
@@ -730,6 +738,7 @@ static const AVOption options[] = {
{ "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" },
+ { "b-strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE },
Use "b_strategy" to remain consistent with the global option and all
the other codecs.
Post by Vittorio Giovara
{ "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 },
{ NULL },
@@ -754,7 +763,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "me_method", "-1" },
#endif
{ "subq", "-1" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ "keyint_min", "-1" },
#if FF_API_CODER_TYPE
{ "coder", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 43b0915..910d6c9 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -56,6 +56,7 @@ typedef struct XavsContext {
int motion_est;
int mbtree;
int mixed_refs;
+ int b_frame_strategy;
int64_t *pts_buffer;
int out_frame_count;
@@ -311,7 +312,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* cabac is not included in AVS JiZhun Profile */
x4->params.b_cabac = 0;
- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;
avctx->has_b_frames = !!avctx->max_b_frames;
@@ -439,6 +447,7 @@ static const AVOption options[] = {
{ "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
+ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 52c6f91..309a02f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -525,6 +525,8 @@ typedef struct MpegEncContext {
/* temporary frames used by b_frame_strategy = 2 */
AVFrame *tmp_frames[MAX_B_FRAMES + 2];
+ int b_frame_strategy;
+ int b_sensitivity;
} MpegEncContext;
/* mpegvideo_enc common options */
@@ -573,6 +575,8 @@ typedef struct MpegEncContext {
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
+{"b_strategy", "strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
+{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \
extern const AVOption ff_mpv_generic_options[];
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 34e008f..5856312 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -525,10 +525,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}
- if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ s->b_frame_strategy = avctx->b_frame_strategy;
+ if (avctx->b_sensitivity != 40)
+ s->b_sensitivity = avctx->b_sensitivity;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_INFO,
"notice: b_frame_strategy only affects the first pass\n");
- avctx->b_frame_strategy = 0;
+ s->b_frame_strategy = 0;
}
i = av_gcd(avctx->time_base.den, avctx->time_base.num);
@@ -867,7 +876,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- if (avctx->b_frame_strategy == 2) {
+ if (s->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
if (!s->tmp_frames[i])
@@ -1302,7 +1311,7 @@ static int select_input_picture(MpegEncContext *s)
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
- int b_frames;
+ int b_frames = 0;
if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
@@ -1333,11 +1342,11 @@ static int select_input_picture(MpegEncContext *s)
}
}
- if (s->avctx->b_frame_strategy == 0) {
+ if (s->b_frame_strategy == 0) {
b_frames = s->max_b_frames;
while (b_frames && !s->input_picture[b_frames])
b_frames--;
- } else if (s->avctx->b_frame_strategy == 1) {
+ } else if (s->b_frame_strategy == 1) {
for (i = 1; i < s->max_b_frames + 1; i++) {
if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
@@ -1351,7 +1360,7 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < s->max_b_frames + 1; i++) {
if (!s->input_picture[i] ||
s->input_picture[i]->b_frame_score - 1 >
- s->mb_num / s->avctx->b_sensitivity)
+ s->mb_num / s->b_sensitivity)
break;
}
@@ -1361,11 +1370,8 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < b_frames + 1; i++) {
s->input_picture[i]->b_frame_score = 0;
}
- } else if (s->avctx->b_frame_strategy == 2) {
+ } else if (s->b_frame_strategy == 2) {
b_frames = estimate_best_b_count(s);
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
- b_frames = 0;
}
emms_c();
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 91b2bef..2c8fb94 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -119,7 +119,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_RC_STRATEGY
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#endif
+#if FF_API_PRIVATE_OPT
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
+#endif
{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#if FF_API_STAT_BITS
{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
@@ -390,7 +392,9 @@ static const AVOption avcodec_options[] = {
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
#endif /* FF_API_UNUSED_MEMBERS */
{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
+#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
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f19ca76..861cf63 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -498,8 +498,14 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
#endif
#if QSV_HAVE_BREF_TYPE
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- q->extco2.BRefType = avctx->b_frame_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
+ q->extco2.b_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (q->extco2.b_strategy >= 0)
+ q->extco2.BRefType = q->extco2.b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
This doesn't build, you used the wrong context to store/access things.
Post by Vittorio Giovara
if (q->adaptive_i >= 0)
q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
if (q->adaptive_b >= 0)
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index ec0c4df..97165fc 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -65,6 +65,7 @@
{ "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
+{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
typedef struct QSVEncContext {
AVCodecContext *avctx;
@@ -118,6 +119,7 @@ typedef struct QSVEncContext {
int extbrc;
int adaptive_i;
int adaptive_b;
+ int b_strategy;
int int_ref_type;
int int_ref_cycle_size;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 2294604..7f4fb81 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -109,7 +109,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "coder", "ac" },
{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 343733b..8884e24 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -244,7 +244,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "8" },
{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};
diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index dcfcb81..f29f445 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -89,7 +89,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "3" },
{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index e9e76b6..72a18ed 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -189,5 +189,8 @@
#ifndef FF_API_STAT_BITS
#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_PRIVATE_OPT
+#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */
--
2.6.4
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Vittorio Giovara
2016-01-11 20:42:21 UTC
Permalink
This option is only used by mpegvideoenc.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
Updated after nevcairiel's comments.
Vittorio

libavcodec/avcodec.h | 9 ++++-----
libavcodec/mpegvideo.h | 3 +++
libavcodec/mpegvideo_enc.c | 5 ++++-
libavcodec/options_table.h | 2 ++
4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4e1c877..fe3366b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1757,12 +1757,11 @@ typedef struct AVCodecContext {
*/
int last_predictor_count;

- /**
- * prepass for motion estimation
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int pre_me;
+#endif

/**
* motion estimation prepass comparison function
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 75ed8e8..4e25603 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -251,6 +251,7 @@ typedef struct MpegEncContext {
#endif
int motion_est; ///< ME algorithm
int me_penalty_compensation;
+ int me_pre; ///< prepass for motion estimation
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
@@ -618,6 +619,8 @@ FF_MPV_OPT_CMP_FUNC, \
{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \
{"rtp_ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 213367a..d16e408 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -300,6 +300,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
s->rtp_payload_size = avctx->rtp_payload_size;
if (avctx->me_penalty_compensation)
s->me_penalty_compensation = avctx->me_penalty_compensation;
+ if (avctx->pre_me)
+ s->me_pre = avctx->pre_me;
FF_ENABLE_DEPRECATION_WARNINGS
#endif

@@ -3465,7 +3467,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8;
s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8;
if (s->pict_type != AV_PICTURE_TYPE_B) {
- if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
+ if ((s->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) ||
+ s->me_pre == 2) {
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index fbf0967..fe6a548 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -279,7 +279,9 @@ static const AVOption avcodec_options[] = {
{"ildctcmp", "interlaced DCT compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"sad", "sum of absolute differences, fast (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"},
--
2.6.4
Vittorio Giovara
2016-01-11 20:43:05 UTC
Permalink
The b_frame_strategy option is only used by mpegvideoenc, qsv, x264, and
xavs, while b_sensitivity is only used by mpegvideoenc.

These are very codec-specific options, so deprecate the global variants.
Set proper limits to the maximum allowed values.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
Updated after nev's review.
Vittorio

libavcodec/avcodec.h | 13 ++++++++-----
libavcodec/libx264.c | 13 ++++++++++++-
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 4 ++++
libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++-----------
libavcodec/options_table.h | 4 ++++
libavcodec/qsvenc.c | 8 +++++++-
libavcodec/qsvenc.h | 2 ++
libavcodec/qsvenc_h264.c | 2 ++
libavcodec/qsvenc_hevc.c | 2 ++
libavcodec/qsvenc_mpeg2.c | 2 ++
libavcodec/version.h | 3 +++
12 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8083111..66e6ac8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1594,7 +1594,11 @@ typedef struct AVCodecContext {
#define FF_RC_STRATEGY_XVID 1
#endif

+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int b_frame_strategy;
+#endif

/**
* qscale offset between IP and B-frames
@@ -1999,12 +2003,11 @@ typedef struct AVCodecContext {
*/
int mv0_threshold;

- /**
- * Adjust sensitivity of b_frame_strategy 1.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int b_sensitivity;
+#endif

/**
* Chromaticity coordinates of the source primaries.
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index fe0247f..5db00ff 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -79,6 +79,7 @@ typedef struct X264Context {
int motion_est;
int forced_idr;
int coder;
+ int b_frame_strategy;

char *x264_params;
} X264Context;
@@ -439,8 +440,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if (avctx->me_subpel_quality >= 0)
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->keyint_min >= 0)
x4->params.i_keyint_min = avctx->keyint_min;
#if FF_API_CODER_TYPE
@@ -527,6 +532,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->coder >= 0)
x4->params.b_cabac = x4->coder;

+ if (x4->b_frame_strategy >= 0)
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;
+
if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
@@ -730,6 +738,7 @@ static const AVOption options[] = {
{ "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" },
+ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, 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 },
{ NULL },
@@ -754,7 +763,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "me_method", "-1" },
#endif
{ "subq", "-1" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ "keyint_min", "-1" },
#if FF_API_CODER_TYPE
{ "coder", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 43b0915..910d6c9 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -56,6 +56,7 @@ typedef struct XavsContext {
int motion_est;
int mbtree;
int mixed_refs;
+ int b_frame_strategy;

int64_t *pts_buffer;
int out_frame_count;
@@ -311,7 +312,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* cabac is not included in AVS JiZhun Profile */
x4->params.b_cabac = 0;

- x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ x4->b_frame_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_bframe_adaptive = x4->b_frame_strategy;

avctx->has_b_frames = !!avctx->max_b_frames;

@@ -439,6 +447,7 @@ static const AVOption options[] = {
{ "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
+ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},

{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 52c6f91..309a02f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -525,6 +525,8 @@ typedef struct MpegEncContext {

/* temporary frames used by b_frame_strategy = 2 */
AVFrame *tmp_frames[MAX_B_FRAMES + 2];
+ int b_frame_strategy;
+ int b_sensitivity;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -573,6 +575,8 @@ typedef struct MpegEncContext {
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
+{"b_strategy", "strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
+{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 34e008f..5856312 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -525,10 +525,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

- if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->b_frame_strategy)
+ s->b_frame_strategy = avctx->b_frame_strategy;
+ if (avctx->b_sensitivity != 40)
+ s->b_sensitivity = avctx->b_sensitivity;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_INFO,
"notice: b_frame_strategy only affects the first pass\n");
- avctx->b_frame_strategy = 0;
+ s->b_frame_strategy = 0;
}

i = av_gcd(avctx->time_base.den, avctx->time_base.num);
@@ -867,7 +876,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif

- if (avctx->b_frame_strategy == 2) {
+ if (s->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
if (!s->tmp_frames[i])
@@ -1302,7 +1311,7 @@ static int select_input_picture(MpegEncContext *s)
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
- int b_frames;
+ int b_frames = 0;

if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
@@ -1333,11 +1342,11 @@ static int select_input_picture(MpegEncContext *s)
}
}

- if (s->avctx->b_frame_strategy == 0) {
+ if (s->b_frame_strategy == 0) {
b_frames = s->max_b_frames;
while (b_frames && !s->input_picture[b_frames])
b_frames--;
- } else if (s->avctx->b_frame_strategy == 1) {
+ } else if (s->b_frame_strategy == 1) {
for (i = 1; i < s->max_b_frames + 1; i++) {
if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
@@ -1351,7 +1360,7 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < s->max_b_frames + 1; i++) {
if (!s->input_picture[i] ||
s->input_picture[i]->b_frame_score - 1 >
- s->mb_num / s->avctx->b_sensitivity)
+ s->mb_num / s->b_sensitivity)
break;
}

@@ -1361,11 +1370,8 @@ static int select_input_picture(MpegEncContext *s)
for (i = 0; i < b_frames + 1; i++) {
s->input_picture[i]->b_frame_score = 0;
}
- } else if (s->avctx->b_frame_strategy == 2) {
+ } else if (s->b_frame_strategy == 2) {
b_frames = estimate_best_b_count(s);
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
- b_frames = 0;
}

emms_c();
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 91b2bef..2c8fb94 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -119,7 +119,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_RC_STRATEGY
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#endif
+#if FF_API_PRIVATE_OPT
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
+#endif
{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#if FF_API_STAT_BITS
{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
@@ -390,7 +392,9 @@ static const AVOption avcodec_options[] = {
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
#endif /* FF_API_UNUSED_MEMBERS */
{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
+#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
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 4a33ade..bf3dc0f 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -498,8 +498,14 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
#endif

#if QSV_HAVE_BREF_TYPE
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->b_frame_strategy >= 0)
- q->extco2.BRefType = avctx->b_frame_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
+ q->b_strategy = avctx->b_frame_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (q->extco2.b_strategy >= 0)
+ q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
if (q->adaptive_i >= 0)
q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
if (q->adaptive_b >= 0)
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index ec0c4df..97165fc 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -65,6 +65,7 @@
{ "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
+{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \

typedef struct QSVEncContext {
AVCodecContext *avctx;
@@ -118,6 +119,7 @@ typedef struct QSVEncContext {
int extbrc;
int adaptive_i;
int adaptive_b;
+ int b_strategy;

int int_ref_type;
int int_ref_cycle_size;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 2294604..7f4fb81 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -109,7 +109,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "coder", "ac" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 343733b..8884e24 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -244,7 +244,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "8" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index dcfcb81..f29f445 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -89,7 +89,9 @@ static const AVCodecDefault qsv_enc_defaults[] = {
{ "bf", "3" },

{ "flags", "+cgop" },
+#if FF_API_PRIVATE_OPT
{ "b_strategy", "-1" },
+#endif
{ NULL },
};

diff --git a/libavcodec/version.h b/libavcodec/version.h
index e9e76b6..72a18ed 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -189,5 +189,8 @@
#ifndef FF_API_STAT_BITS
#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_PRIVATE_OPT
+#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif

#endif /* AVCODEC_VERSION_H */
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:11 UTC
Permalink
This option is only used by mpegvideoenc,
It is a very codec-specific option, so deprecate the global variant.
Set proper limits to the maximum allowed values.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/mpegvideo.h | 2 ++
libavcodec/mpegvideo_enc.c | 13 ++++++++++---
libavcodec/options_table.h | 2 ++
4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 66e6ac8..ba84d48 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1958,12 +1958,11 @@ typedef struct AVCodecContext {
*/
int bidir_refine;

- /**
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int brd_scale;
+#endif

/**
* minimum GOP size
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 309a02f..c02b4de 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -444,6 +444,7 @@ typedef struct MpegEncContext {
int top_field_first;
int concealment_motion_vectors;
int q_scale_type;
+ int brd_scale;
int intra_vlc_format;
int alternate_scan;
int repeat_first_field;
@@ -577,6 +578,7 @@ typedef struct MpegEncContext {
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{"b_strategy", "strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 5856312..b56450c 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -876,6 +876,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif

+#if FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->brd_scale)
+ s->brd_scale = avctx->brd_scale;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (s->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
@@ -883,8 +890,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
return AVERROR(ENOMEM);

s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P;
- s->tmp_frames[i]->width = s->width >> avctx->brd_scale;
- s->tmp_frames[i]->height = s->height >> avctx->brd_scale;
+ s->tmp_frames[i]->width = s->width >> s->brd_scale;
+ s->tmp_frames[i]->height = s->height >> s->brd_scale;

ret = av_frame_get_buffer(s->tmp_frames[i], 32);
if (ret < 0)
@@ -1182,7 +1189,7 @@ static int estimate_best_b_count(MpegEncContext *s)
{
AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id);
AVCodecContext *c = avcodec_alloc_context3(NULL);
- const int scale = s->avctx->brd_scale;
+ const int scale = s->brd_scale;
int i, j, out_size, p_lambda, b_lambda, lambda2;
int64_t best_rd = INT64_MAX;
int best_b_count = -1;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 2c8fb94..5a020ba 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -383,7 +383,9 @@ static const AVOption avcodec_options[] = {
{"nokey" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"all" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
+#if FF_API_PRIVATE_OPT
{"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E},
+#endif
{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
{"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:12 UTC
Permalink
These options are only used by mpegvideoenc and vpx.
They are very codec-specific options, so deprecate the global variants.

Add an allowed value to the private options for frame_skip_cmp which
seems to have been forgotten, but perfectly working.

The libvpx frame dropping feature uses one of such option
(frame_skip_threshold) without the other three. For this reason rename
the option to something more consistent with the other libvpx variables.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 30 ++++++++++--------------------
libavcodec/libvpxenc.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 27 +++++++++++++++++++++++++++
libavcodec/mpegvideo_enc.c | 23 ++++++++++++++++++-----
libavcodec/options_table.h | 2 ++
5 files changed, 67 insertions(+), 26 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ba84d48..160ab60 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2369,33 +2369,23 @@ typedef struct AVCodecContext {
int lmax;
#endif

- /**
- * frame skip threshold
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int frame_skip_threshold;

- /**
- * frame skip factor
- * - encoding: Set by user.
- * - decoding: unused
- */
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int frame_skip_factor;

- /**
- * frame skip exponent
- * - encoding: Set by user.
- * - decoding: unused
- */
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int frame_skip_exp;

- /**
- * frame skip comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int frame_skip_cmp;
+#endif /* FF_API_PRIVATE_OPT */

/**
* trellis RD quantization
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index a3f7b6c..5e84e73 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -67,6 +67,7 @@ typedef struct VP8EncoderContext {
int error_resilient;
int crf;
int static_thresh;
+ int drop_threshold;
} VP8Context;

/** String mappings for enum vp8e_enc_control_id */
@@ -257,7 +258,14 @@ static av_cold int vpx_init(AVCodecContext *avctx,
enccfg.rc_min_quantizer = avctx->qmin;
if (avctx->qmax > 0)
enccfg.rc_max_quantizer = avctx->qmax;
- enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->frame_skip_threshold)
+ ctx->drop_threshold = avctx->frame_skip_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ enccfg.rc_dropframe_thresh = ctx->drop_threshold;

//0-100 (0 => CBR, 100 => VBR)
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
@@ -594,6 +602,7 @@ static const AVOption options[] = {
#endif
{ "crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE },
{ "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
+ { "drop-threshold", "Frame drop threshold", offsetof(VP8Context, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
{ NULL }
};

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index c02b4de..99bc297 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -528,6 +528,12 @@ typedef struct MpegEncContext {
AVFrame *tmp_frames[MAX_B_FRAMES + 2];
int b_frame_strategy;
int b_sensitivity;
+
+ /* frame skip options for encoding */
+ int frame_skip_threshold;
+ int frame_skip_factor;
+ int frame_skip_exp;
+ int frame_skip_cmp;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -538,9 +544,26 @@ typedef struct MpegEncContext {
#define FF_MPV_FLAG_NAQ 0x0010
#define FF_MPV_FLAG_MV0 0x0020

+#define FF_MPV_OPT_CMP_FUNC \
+{ "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "satd", "Sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "dct", "Sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "psnr", "Sum of squared quantization errors, low quality", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "bit", "Number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "rd", "Rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "zero", "Zero", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "vsad", "Sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "vsse", "Sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "nsse", "Noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "dct264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT264 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }
+
#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
#define FF_MPV_COMMON_OPTS \
+FF_MPV_OPT_CMP_FUNC, \
{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
@@ -579,6 +602,10 @@ typedef struct MpegEncContext {
{"b_strategy", "strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, \
+{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index b56450c..9c0f015 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -780,8 +780,21 @@ FF_ENABLE_DEPRECATION_WARNINGS

s->quant_precision = 5;

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->frame_skip_threshold)
+ s->frame_skip_threshold = avctx->frame_skip_threshold;
+ if (avctx->frame_skip_factor)
+ s->frame_skip_factor = avctx->frame_skip_factor;
+ if (avctx->frame_skip_exp)
+ s->frame_skip_exp = avctx->frame_skip_exp;
+ if (avctx->frame_skip_cmp != FF_CMP_DCTMAX)
+ s->frame_skip_cmp = avctx->frame_skip_cmp;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, s->avctx->ildct_cmp);
- ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->avctx->frame_skip_cmp);
+ ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);

if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)
ff_h261_encode_init(s);
@@ -1149,7 +1162,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8);

- switch (s->avctx->frame_skip_exp) {
+ switch (s->frame_skip_exp) {
case 0: score = FFMAX(score, v); break;
case 1: score += FFABS(v); break;
case 2: score += v * v; break;
@@ -1163,9 +1176,9 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
if (score)
score64 = score;

- if (score64 < s->avctx->frame_skip_threshold)
+ if (score64 < s->frame_skip_threshold)
return 1;
- if (score64 < ((s->avctx->frame_skip_factor * (int64_t)s->lambda) >> 8))
+ if (score64 < ((s->frame_skip_factor * (int64_t) s->lambda) >> 8))
return 1;
return 0;
}
@@ -1320,7 +1333,7 @@ static int select_input_picture(MpegEncContext *s)
} else {
int b_frames = 0;

- if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
+ if (s->frame_skip_threshold || s->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
// FIXME check that te gop check above is +-1 correct
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 5a020ba..9efaf2c 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -363,10 +363,12 @@ static const AVOption avcodec_options[] = {
{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, INT_MIN, INT_MAX, A|E, "profile"},
{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
+#if FF_API_PRIVATE_OPT
{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"},
+#endif
#if FF_API_MPV_OPT
{"border_mask", "deprecated, use encoder private options instead", OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
#endif
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:13 UTC
Permalink
This option is only used by x264 and xavs.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/libx264.c | 12 +++++++++++-
libavcodec/libxavs.c | 12 +++++++++++-
libavcodec/options_table.h | 2 ++
4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 160ab60..355e6f6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1978,12 +1978,11 @@ typedef struct AVCodecContext {
*/
int refs;

- /**
- * chroma qp offset from luma
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int chromaoffset;
+#endif

#if FF_API_UNUSED_MEMBERS
/**
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index bcb5dd1..937583e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -80,6 +80,7 @@ typedef struct X264Context {
int forced_idr;
int coder;
int b_frame_strategy;
+ int chroma_offset;

char *x264_params;
} X264Context;
@@ -412,7 +413,15 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->i_quant_factor > 0)
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;

if (avctx->gop_size >= 0)
x4->params.i_keyint_max = avctx->gop_size;
@@ -739,6 +748,7 @@ static const AVOption options[] = {
{ "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" },
{ "b-strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE },
+ { "chroma-offset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 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 },
{ NULL },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 910d6c9..6dae5fe 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -57,6 +57,7 @@ typedef struct XavsContext {
int mbtree;
int mixed_refs;
int b_frame_strategy;
+ int chroma_offset;

int64_t *pts_buffer;
int out_frame_count;
@@ -379,7 +380,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* what is the RC method we are now using? Default NO */
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;

x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
x4->params.i_log_level = XAVS_LOG_DEBUG;
@@ -448,6 +457,7 @@ static const AVOption options[] = {
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
+ { "chroma_offset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE},

{ NULL },
};
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 9efaf2c..7a5766f 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -390,7 +390,9 @@ static const AVOption avcodec_options[] = {
#endif
{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"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_UNUSED_MEMBERS
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
--
2.6.4
Hendrik Leppkes
2016-01-04 13:45:59 UTC
Permalink
On Mon, Jan 4, 2016 at 2:34 PM, Vittorio Giovara
Post by Vittorio Giovara
This option is only used by x264 and xavs.
It is a very codec-specific option, so deprecate the global variant.
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/libx264.c | 12 +++++++++++-
libavcodec/libxavs.c | 12 +++++++++++-
libavcodec/options_table.h | 2 ++
4 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 160ab60..355e6f6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1978,12 +1978,11 @@ typedef struct AVCodecContext {
*/
int refs;
- /**
- * chroma qp offset from luma
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ attribute_deprecated
int chromaoffset;
+#endif
#if FF_API_UNUSED_MEMBERS
/**
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index bcb5dd1..937583e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -80,6 +80,7 @@ typedef struct X264Context {
int forced_idr;
int coder;
int b_frame_strategy;
+ int chroma_offset;
char *x264_params;
} X264Context;
@@ -412,7 +413,15 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->i_quant_factor > 0)
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;
if (avctx->gop_size >= 0)
x4->params.i_keyint_max = avctx->gop_size;
@@ -739,6 +748,7 @@ static const AVOption options[] = {
{ "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" },
{ "b-strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE },
+ { "chroma-offset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE },
How about keeping it "chromaoffset" to remain compatible with the
previous global option?
Also, whatever you decide, please keep it consistent between the two
encoders that use it.
Post by Vittorio Giovara
{ "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 },
{ NULL },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 910d6c9..6dae5fe 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -57,6 +57,7 @@ typedef struct XavsContext {
int mbtree;
int mixed_refs;
int b_frame_strategy;
+ int chroma_offset;
int64_t *pts_buffer;
int out_frame_count;
@@ -379,7 +380,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* what is the RC method we are now using? Default NO */
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;
x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
x4->params.i_log_level = XAVS_LOG_DEBUG;
@@ -448,6 +457,7 @@ static const AVOption options[] = {
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
+ { "chroma_offset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE},
{ NULL },
};
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 9efaf2c..7a5766f 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -390,7 +390,9 @@ static const AVOption avcodec_options[] = {
#endif
{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"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_UNUSED_MEMBERS
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
--
2.6.4
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Vittorio Giovara
2016-01-11 20:46:18 UTC
Permalink
This option is only used by x264 and xavs.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/libx264.c | 12 +++++++++++-
libavcodec/libxavs.c | 12 +++++++++++-
libavcodec/options_table.h | 2 ++
4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 160ab60..355e6f6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1978,12 +1978,11 @@ typedef struct AVCodecContext {
*/
int refs;

- /**
- * chroma qp offset from luma
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int chromaoffset;
+#endif

#if FF_API_UNUSED_MEMBERS
/**
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 5db00ff..1caf041 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -80,6 +80,7 @@ typedef struct X264Context {
int forced_idr;
int coder;
int b_frame_strategy;
+ int chroma_offset;

char *x264_params;
} X264Context;
@@ -412,7 +413,15 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->i_quant_factor > 0)
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;

if (avctx->gop_size >= 0)
x4->params.i_keyint_max = avctx->gop_size;
@@ -739,6 +748,7 @@ static const AVOption options[] = {
{ "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" },
{ "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 = 0 }, 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 },
{ NULL },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 910d6c9..2183376 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -57,6 +57,7 @@ typedef struct XavsContext {
int mbtree;
int mixed_refs;
int b_frame_strategy;
+ int chroma_offset;

int64_t *pts_buffer;
int out_frame_count;
@@ -379,7 +380,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* what is the RC method we are now using? Default NO */
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
- x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->chromaoffset)
+ x4->chroma_offset = avctx->chromaoffset;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;

x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
x4->params.i_log_level = XAVS_LOG_DEBUG;
@@ -448,6 +457,7 @@ static const AVOption options[] = {
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
+ { "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE},

{ NULL },
};
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 9efaf2c..7a5766f 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -390,7 +390,9 @@ static const AVOption avcodec_options[] = {
#endif
{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"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_UNUSED_MEMBERS
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:14 UTC
Permalink
This option is only used by mpegvideoenc, x264, and xavs.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 10 ++++------
libavcodec/libx264.c | 16 ++++++++++++++--
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 3 +++
libavcodec/mpegvideo_enc.c | 12 ++++++++++--
libavcodec/options_table.h | 2 ++
6 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 355e6f6..b4e41aa 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1872,13 +1872,11 @@ typedef struct AVCodecContext {
*/
uint16_t *inter_matrix;

- /**
- * scene change detection threshold
- * 0 is default, larger means fewer detected scene changes.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int scenechange_threshold;
+#endif

/**
* noise reduction strength
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 937583e..fad03a1 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -81,6 +81,7 @@ typedef struct X264Context {
int coder;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;

char *x264_params;
} X264Context;
@@ -427,8 +428,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0)
x4->params.i_bframe = avctx->max_b_frames;
- if (avctx->scenechange_threshold >= 0)
- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+ if (x4->scenechange_threshold >= 0)
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;
+
if (avctx->qmin >= 0)
x4->params.rc.i_qp_min = avctx->qmin;
if (avctx->qmax >= 0)
@@ -749,6 +758,7 @@ static const AVOption options[] = {
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 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 },
{ "chroma-offset", "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 },

{ "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 },
{ NULL },
@@ -765,7 +775,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ "refs", "-1" },
+#if FF_API_PRIVATE_OPT
{ "sc_threshold", "-1" },
+#endif
{ "trellis", "-1" },
{ "nr", "-1" },
{ "me_range", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 6dae5fe..0dbf340 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -58,6 +58,7 @@ typedef struct XavsContext {
int mixed_refs;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;

int64_t *pts_buffer;
int out_frame_count;
@@ -330,7 +331,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;

- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;

// x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER;

@@ -458,6 +466,7 @@ static const AVOption options[] = {
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
{ "chroma_offset", "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},

{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 99bc297..0d6a708 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -534,6 +534,8 @@ typedef struct MpegEncContext {
int frame_skip_factor;
int frame_skip_exp;
int frame_skip_cmp;
+
+ int scenechange_threshold;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -606,6 +608,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9c0f015..29358dd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -468,7 +468,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

- if (s->avctx->scenechange_threshold < 1000000000 &&
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ s->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->scenechange_threshold < 1000000000 &&
(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) {
av_log(avctx, AV_LOG_ERROR,
"closed gop with scene change detection are not supported yet, "
@@ -3453,7 +3460,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();

- if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
+ if (s->me.scene_change_score > s->scenechange_threshold &&
+ s->pict_type == AV_PICTURE_TYPE_P) {
s->pict_type= AV_PICTURE_TYPE_I;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 7a5766f..9b8739c 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -323,7 +323,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_STREAM_CODEC_TAG
{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#endif
+#if FF_API_PRIVATE_OPT
{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
#if FF_API_MPV_OPT
{"lmin", "deprecated, use encoder private options instead", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
{"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
--
2.6.4
Hendrik Leppkes
2016-01-04 13:50:51 UTC
Permalink
On Mon, Jan 4, 2016 at 2:34 PM, Vittorio Giovara
Post by Vittorio Giovara
This option is only used by mpegvideoenc, x264, and xavs.
It is a very codec-specific option, so deprecate the global variant.
---
libavcodec/avcodec.h | 10 ++++------
libavcodec/libx264.c | 16 ++++++++++++++--
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 3 +++
libavcodec/mpegvideo_enc.c | 12 ++++++++++--
libavcodec/options_table.h | 2 ++
6 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 355e6f6..b4e41aa 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1872,13 +1872,11 @@ typedef struct AVCodecContext {
*/
uint16_t *inter_matrix;
- /**
- * scene change detection threshold
- * 0 is default, larger means fewer detected scene changes.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ attribute_deprecated
int scenechange_threshold;
+#endif
/**
* noise reduction strength
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 937583e..fad03a1 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -81,6 +81,7 @@ typedef struct X264Context {
int coder;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;
char *x264_params;
} X264Context;
@@ -427,8 +428,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0)
x4->params.i_bframe = avctx->max_b_frames;
- if (avctx->scenechange_threshold >= 0)
- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+ if (x4->scenechange_threshold >= 0)
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;
+
if (avctx->qmin >= 0)
x4->params.rc.i_qp_min = avctx->qmin;
if (avctx->qmax >= 0)
@@ -749,6 +758,7 @@ static const AVOption options[] = {
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 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 },
{ "chroma-offset", "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 },
Just like the others, why is the libx264 option spelled differently
than all the other encoders?
Post by Vittorio Giovara
{ "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 },
{ NULL },
@@ -765,7 +775,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ "refs", "-1" },
+#if FF_API_PRIVATE_OPT
{ "sc_threshold", "-1" },
+#endif
{ "trellis", "-1" },
{ "nr", "-1" },
{ "me_range", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 6dae5fe..0dbf340 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -58,6 +58,7 @@ typedef struct XavsContext {
int mixed_refs;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;
int64_t *pts_buffer;
int out_frame_count;
@@ -330,7 +331,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;
// x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER;
@@ -458,6 +466,7 @@ static const AVOption options[] = {
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
{ "chroma_offset", "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},
{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 99bc297..0d6a708 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -534,6 +534,8 @@ typedef struct MpegEncContext {
int frame_skip_factor;
int frame_skip_exp;
int frame_skip_cmp;
+
+ int scenechange_threshold;
} MpegEncContext;
/* mpegvideo_enc common options */
@@ -606,6 +608,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
extern const AVOption ff_mpv_generic_options[];
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9c0f015..29358dd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -468,7 +468,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}
- if (s->avctx->scenechange_threshold < 1000000000 &&
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ s->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->scenechange_threshold < 1000000000 &&
(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) {
av_log(avctx, AV_LOG_ERROR,
"closed gop with scene change detection are not supported yet, "
@@ -3453,7 +3460,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();
- if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
+ if (s->me.scene_change_score > s->scenechange_threshold &&
+ s->pict_type == AV_PICTURE_TYPE_P) {
s->pict_type= AV_PICTURE_TYPE_I;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 7a5766f..9b8739c 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -323,7 +323,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_STREAM_CODEC_TAG
{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#endif
+#if FF_API_PRIVATE_OPT
{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
#if FF_API_MPV_OPT
{"lmin", "deprecated, use encoder private options instead", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
{"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
--
2.6.4
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Vittorio Giovara
2016-01-11 20:45:21 UTC
Permalink
Post by Hendrik Leppkes
On Mon, Jan 4, 2016 at 2:34 PM, Vittorio Giovara
Post by Vittorio Giovara
if (avctx->qmin >= 0)
x4->params.rc.i_qp_min = avctx->qmin;
if (avctx->qmax >= 0)
@@ -749,6 +758,7 @@ static const AVOption options[] = {
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 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 },
{ "chroma-offset", "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 },
Just like the others, why is the libx264 option spelled differently
than all the other encoders?
Because x264 options have a dash instead of an underscore, and it's
not the first time something like this happens. Anyway, since the
majority prefer underscores anyway, I'll switch styles.
--
Vittorio
Vittorio Giovara
2016-01-11 20:45:48 UTC
Permalink
This option is only used by mpegvideoenc, x264, and xavs.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 10 ++++------
libavcodec/libx264.c | 16 ++++++++++++++--
libavcodec/libxavs.c | 11 ++++++++++-
libavcodec/mpegvideo.h | 3 +++
libavcodec/mpegvideo_enc.c | 12 ++++++++++--
libavcodec/options_table.h | 2 ++
6 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 355e6f6..b4e41aa 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1872,13 +1872,11 @@ typedef struct AVCodecContext {
*/
uint16_t *inter_matrix;

- /**
- * scene change detection threshold
- * 0 is default, larger means fewer detected scene changes.
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int scenechange_threshold;
+#endif

/**
* noise reduction strength
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 1caf041..205fb3d 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -81,6 +81,7 @@ typedef struct X264Context {
int coder;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;

char *x264_params;
} X264Context;
@@ -427,8 +428,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0)
x4->params.i_bframe = avctx->max_b_frames;
- if (avctx->scenechange_threshold >= 0)
- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+ if (x4->scenechange_threshold >= 0)
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;
+
if (avctx->qmin >= 0)
x4->params.rc.i_qp_min = avctx->qmin;
if (avctx->qmax >= 0)
@@ -749,6 +758,7 @@ static const AVOption options[] = {
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 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 = 0 }, INT_MIN, INT_MAX, VE },
+ { "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 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 },
{ NULL },
@@ -765,7 +775,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ "refs", "-1" },
+#if FF_API_PRIVATE_OPT
{ "sc_threshold", "-1" },
+#endif
{ "trellis", "-1" },
{ "nr", "-1" },
{ "me_range", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 2183376..91a92ec 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -58,6 +58,7 @@ typedef struct XavsContext {
int mixed_refs;
int b_frame_strategy;
int chroma_offset;
+ int scenechange_threshold;

int64_t *pts_buffer;
int out_frame_count;
@@ -330,7 +331,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;

- x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ x4->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.i_scenecut_threshold = x4->scenechange_threshold;

// x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER;

@@ -458,6 +466,7 @@ static const AVOption options[] = {
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
{ "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},

{ NULL },
};
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 99bc297..0d6a708 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -534,6 +534,8 @@ typedef struct MpegEncContext {
int frame_skip_factor;
int frame_skip_exp;
int frame_skip_cmp;
+
+ int scenechange_threshold;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -606,6 +608,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
+{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9c0f015..29358dd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -468,7 +468,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

- if (s->avctx->scenechange_threshold < 1000000000 &&
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->scenechange_threshold)
+ s->scenechange_threshold = avctx->scenechange_threshold;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (s->scenechange_threshold < 1000000000 &&
(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) {
av_log(avctx, AV_LOG_ERROR,
"closed gop with scene change detection are not supported yet, "
@@ -3453,7 +3460,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();

- if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
+ if (s->me.scene_change_score > s->scenechange_threshold &&
+ s->pict_type == AV_PICTURE_TYPE_P) {
s->pict_type= AV_PICTURE_TYPE_I;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 7a5766f..9b8739c 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -323,7 +323,9 @@ static const AVOption avcodec_options[] = {
#if FF_API_STREAM_CODEC_TAG
{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#endif
+#if FF_API_PRIVATE_OPT
{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
#if FF_API_MPV_OPT
{"lmin", "deprecated, use encoder private options instead", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
{"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:15 UTC
Permalink
This option is only used by mpegvideoenc, x264, xavs, and vpx.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 +++------
libavcodec/libvpxenc.c | 10 +++++++++-
libavcodec/libx264.c | 13 +++++++++++--
libavcodec/libxavs.c | 12 +++++++++++-
libavcodec/mpegvideo.c | 2 +-
libavcodec/mpegvideo.h | 2 ++
libavcodec/mpegvideo_enc.c | 16 ++++++++++++----
libavcodec/options_table.h | 2 ++
tests/fate/vcodec.mak | 3 ++-
9 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b4e41aa..67a85b2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1876,14 +1876,11 @@ typedef struct AVCodecContext {
/** @deprecated use encoder private options instead */
attribute_deprecated
int scenechange_threshold;
-#endif

- /**
- * noise reduction strength
- * - encoding: Set by user.
- * - decoding: unused
- */
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int noise_reduction;
+#endif

#if FF_API_MPV_OPT
/**
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 5e84e73..26afaf5 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -68,6 +68,7 @@ typedef struct VP8EncoderContext {
int crf;
int static_thresh;
int drop_threshold;
+ int noise_sensitivity;
} VP8Context;

/** String mappings for enum vp8e_enc_control_id */
@@ -352,7 +353,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);

if (CONFIG_LIBVPX_VP8_ENCODER && iface == &vpx_codec_vp8_cx_algo) {
- codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->noise_reduction)
+ ctx->noise_sensitivity = avctx->noise_reduction;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, ctx->noise_sensitivity);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
}
#if FF_API_MPV_OPT
@@ -603,6 +610,7 @@ static const AVOption options[] = {
{ "crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE },
{ "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "drop-threshold", "Frame drop threshold", offsetof(VP8Context, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
+ { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE},
{ NULL }
};

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index fad03a1..ebb4929 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -82,6 +82,7 @@ typedef struct X264Context {
int b_frame_strategy;
int chroma_offset;
int scenechange_threshold;
+ int noise_reduction;

char *x264_params;
} X264Context;
@@ -454,8 +455,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.analyse.i_trellis = avctx->trellis;
if (avctx->me_range >= 0)
x4->params.analyse.i_me_range = avctx->me_range;
- if (avctx->noise_reduction >= 0)
- x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
+#if FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (!x4->noise_reduction)
+ x4->noise_reduction = avctx->noise_reduction;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ x4->params.analyse.i_noise_reduction = x4->noise_reduction;
if (avctx->me_subpel_quality >= 0)
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
#if FF_API_PRIVATE_OPT
@@ -759,6 +765,7 @@ static const AVOption options[] = {
{ "b-strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE },
{ "chroma-offset", "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 },

{ "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 },
{ NULL },
@@ -779,7 +786,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "sc_threshold", "-1" },
#endif
{ "trellis", "-1" },
+#if FF_API_PRIVATE_OPT
{ "nr", "-1" },
+#endif
{ "me_range", "-1" },
#if FF_API_MOTION_EST
{ "me_method", "-1" },
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 0dbf340..cb45ef3 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -59,6 +59,7 @@ typedef struct XavsContext {
int b_frame_strategy;
int chroma_offset;
int scenechange_threshold;
+ int noise_reduction;

int64_t *pts_buffer;
int out_frame_count;
@@ -368,7 +369,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.analyse.b_transform_8x8 = 1; //avctx->flags2 & AV_CODEC_FLAG2_8X8DCT;

x4->params.analyse.i_trellis = avctx->trellis;
- x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
+
+#if FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->noise_reduction >= 0)
+ x4->noise_reduction = avctx->noise_reduction;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ x4->params.analyse.i_noise_reduction = x4->noise_reduction;

if (avctx->level > 0)
x4->params.i_level_idc = avctx->level;
@@ -467,6 +476,7 @@ static const AVOption options[] = {
{ "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, VE},
{ "chroma_offset", "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},

{ NULL },
};
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index c5e8040..e0787a6 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -342,7 +342,7 @@ static int init_duplicate_context(MpegEncContext *s)
ME_MAP_SIZE * sizeof(uint32_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
ME_MAP_SIZE * sizeof(uint32_t), fail)
- if (s->avctx->noise_reduction) {
+ if (s->noise_reduction) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
2 * 64 * sizeof(int), fail)
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 0d6a708..413551d 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -536,6 +536,7 @@ typedef struct MpegEncContext {
int frame_skip_cmp;

int scenechange_threshold;
+ int noise_reduction;
} MpegEncContext;

/* mpegvideo_enc common options */
@@ -609,6 +610,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 29358dd..55cd6f8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -721,6 +721,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

+#if FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->noise_reduction)
+ s->noise_reduction = avctx->noise_reduction;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
avctx->has_b_frames = !s->low_delay;

s->encoding = 1;
@@ -760,7 +767,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail);

- if (s->avctx->noise_reduction) {
+
+ if (s->noise_reduction) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
2 * 64 * sizeof(uint16_t), fail);
}
@@ -1564,7 +1572,7 @@ static void update_noise_reduction(MpegEncContext *s)
}

for (i = 0; i < 64; i++) {
- s->dct_offset[intra][i] = (s->avctx->noise_reduction *
+ s->dct_offset[intra][i] = (s->noise_reduction *
s->dct_count[intra] +
s->dct_error_sum[intra][i] / 2) /
(s->dct_error_sum[intra][i] + 1);
@@ -1637,7 +1645,7 @@ static int frame_start(MpegEncContext *s)
}

if (s->dct_error_sum) {
- assert(s->avctx->noise_reduction && s->encoding);
+ assert(s->noise_reduction && s->encoding);
update_noise_reduction(s);
}

@@ -3315,7 +3323,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
MERGE(current_picture.encoding_error[1]);
MERGE(current_picture.encoding_error[2]);

- if(dst->avctx->noise_reduction){
+ if (dst->noise_reduction){
for(i=0; i<64; i++){
MERGE(dct_error_sum[0][i]);
MERGE(dct_error_sum[1][i]);
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 9b8739c..94f41dd 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -330,7 +330,9 @@ static const AVOption avcodec_options[] = {
{"lmin", "deprecated, use encoder private options instead", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
{"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
#endif
+#if FF_API_PRIVATE_OPT
{"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_ERROR_RATE
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index cb9b766..3bd8ad4 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -162,7 +162,8 @@ fate-vsynth%-mpeg4-error: ENCOPTS = -qscale 7 -flags +mv4+aic \
-data_partitioning 1 -mbd rd \
-ps 250 -error_rate 10

-fate-vsynth%-mpeg4-nr: ENCOPTS = -qscale 8 -flags +mv4 -mbd rd -nr 200
+fate-vsynth%-mpeg4-nr: ENCOPTS = -qscale 8 -flags +mv4 -mbd rd \
+ -noise_reduction 200

fate-vsynth%-mpeg4-qpel: ENCOPTS = -qscale 7 -flags +mv4+qpel -mbd 2 \
-bf 2 -cmp 1 -subcmp 2
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:16 UTC
Permalink
This option is only used by mpegvideoenc, and xvid.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/libxvid.c | 10 ++++++++++
libavcodec/mpegvideo.h | 1 +
libavcodec/mpegvideo_enc.c | 8 +++++++-
libavcodec/options_table.h | 2 ++
5 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 67a85b2..fab554c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1615,12 +1615,11 @@ typedef struct AVCodecContext {
*/
int has_b_frames;

- /**
- * 0-> h263 quant 1-> mpeg quant
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int mpeg_quant;
+#endif

/**
* qscale factor between P and I-frames
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 475ccec..b352849 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -74,6 +74,7 @@ struct xvid_context {
int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */
int gmc;
int me_quality; /**< Motion estimation quality. 0: fast 6: best. */
+ int mpeg_quant; /**< Quantization type. 0: H263, 1: MPEG */
};

/**
@@ -613,7 +614,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* Quant Matrices */
x->intra_matrix =
x->inter_matrix = NULL;
+
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->mpeg_quant)
+ x->mpeg_quant = avctx->mpeg_quant;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (x->mpeg_quant)
x->vol_flags |= XVID_VOL_MPEGQUANT;
if ((avctx->intra_matrix || avctx->inter_matrix)) {
x->vol_flags |= XVID_VOL_MPEGQUANT;
@@ -854,6 +863,7 @@ static const AVOption options[] = {
{ "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE },
{ "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "me_quality", "Motion estimation quality", OFFSET(me_quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE },
+ { "mpeg_quant", "Use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL },
};

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 413551d..0c725fc 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -611,6 +611,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 55cd6f8..b032148 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -313,7 +313,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->codec_id = avctx->codec->id;
s->strict_std_compliance = avctx->strict_std_compliance;
s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
- s->mpeg_quant = avctx->mpeg_quant;
s->rtp_mode = !!avctx->rtp_payload_size;
s->intra_dc_precision = avctx->intra_dc_precision;
s->user_specified_pts = AV_NOPTS_VALUE;
@@ -450,6 +449,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}

+#if FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->mpeg_quant)
+ s->mpeg_quant = avctx->mpeg_quant;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
// FIXME mpeg2 uses that too
if (s->mpeg_quant && s->codec_id != AV_CODEC_ID_MPEG4) {
av_log(avctx, AV_LOG_ERROR,
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 94f41dd..93b56fa 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -170,7 +170,9 @@ static const AVOption avcodec_options[] = {
{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_detect"},
{"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
+#if FF_API_PRIVATE_OPT
{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
#if FF_API_MPV_OPT
{"qsquish", "deprecated, use encoder private options instead", OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 99, V|E},
{"rc_qmod_amp", "deprecated, use encoder private options instead", OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:17 UTC
Permalink
This option is only used by ffv1 and ffvhuff.
It is a very codec-specific option, so deprecate the global variant.
Improve documentation a little.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/ffv1.h | 1 +
libavcodec/ffv1enc.c | 20 ++++++++++++++------
libavcodec/huffyuvenc.c | 33 +++++++++++++++++++++++++++++----
libavcodec/options_table.h | 2 ++
5 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fab554c..695f534 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2341,12 +2341,11 @@ typedef struct AVCodecContext {
int coder_type;
#endif /* FF_API_CODER_TYPE */

- /**
- * context model
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int context_model;
+#endif

#if FF_API_MPV_OPT
/**
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index b44253e..34370fa 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -103,6 +103,7 @@ typedef struct FFV1Context {
int ec;
int slice_damaged;
int key_frame_ok;
+ int context_model;

int bits_per_raw_sample;
int packed_at_lsb;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 0158605..0f712c4 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -261,7 +261,7 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
int stride, int plane_index)
{
int x, y, i;
- const int ring_size = s->avctx->context_model ? 3 : 2;
+ const int ring_size = s->context_model ? 3 : 2;
int16_t *sample[3];
s->run_index = 0;

@@ -297,7 +297,7 @@ static void encode_rgb_frame(FFV1Context *s, const uint8_t *src[3],
int w, int h, const int stride[3])
{
int x, y, p, i;
- const int ring_size = s->avctx->context_model ? 3 : 2;
+ const int ring_size = s->context_model ? 3 : 2;
int16_t *sample[MAX_PLANES][3];
int lbd = s->avctx->bits_per_raw_sample <= 8;
int bits = s->avctx->bits_per_raw_sample > 0
@@ -418,7 +418,7 @@ static void write_header(FFV1Context *f)
0);
for (j = 0; j < f->plane_count; j++) {
put_symbol(c, state, f->plane[j].quant_table_index, 0);
- av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
+ av_assert0(f->plane[j].quant_table_index == f->context_model);
}
}
}
@@ -671,12 +671,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx, AV_LOG_WARNING,
"Storing alpha plane, this will require a recent FFV1 decoder to playback!\n");
}
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->context_model)
+ s->context_model = avctx->context_model;
if (avctx->context_model > 1U) {
av_log(avctx, AV_LOG_ERROR,
"Invalid context model %d, valid values are 0 and 1\n",
avctx->context_model);
return AVERROR(EINVAL);
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif

if (s->ac == AC_RANGE_CUSTOM_TAB)
for (i = 1; i < 256; i++)
@@ -706,14 +712,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
s->context_count[0] = (11 * 11 * 11 + 1) / 2;
s->context_count[1] = (11 * 11 * 5 * 5 * 5 + 1) / 2;
- memcpy(s->quant_table, s->quant_tables[avctx->context_model],
+ memcpy(s->quant_table, s->quant_tables[s->context_model],
sizeof(s->quant_table));

for (i = 0; i < s->plane_count; i++) {
PlaneContext *const p = &s->plane[i];

memcpy(p->quant_table, s->quant_table, sizeof(p->quant_table));
- p->quant_table_index = avctx->context_model;
+ p->quant_table_index = s->context_model;
p->context_count = s->context_count[p->quant_table_index];
}

@@ -860,7 +866,7 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
0);
for (j = 0; j < f->plane_count; j++) {
put_symbol(c, state, f->plane[j].quant_table_index, 0);
- av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
+ av_assert0(f->plane[j].quant_table_index == f->context_model);
}
if (!f->frame->interlaced_frame)
put_symbol(c, state, 3, 0);
@@ -1081,6 +1087,8 @@ static const AVOption options[] = {
{ .i64 = AC_RANGE_DEFAULT_TAB }, INT_MIN, INT_MAX, VE, "coder" },
{ "range_tab", "Range with custom table", 0, AV_OPT_TYPE_CONST,
{ .i64 = AC_RANGE_CUSTOM_TAB }, INT_MIN, INT_MAX, VE, "coder" },
+ { "context", "Context model", OFFSET(context_model), AV_OPT_TYPE_INT,
+ { .i64 = 0 }, 0, 1, VE },

{ NULL }
};
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index c18b38c..bd36901 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -26,6 +26,8 @@
* huffyuv encoder
*/

+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "huffyuv.h"
#include "huffman.h"
@@ -163,6 +165,12 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->context_model == 1)
+ s->context = avctx->context_model;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif

switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
@@ -187,15 +195,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->decorrelate = s->bitstream_bpp >= 24;
s->predictor = avctx->prediction_method;
s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0;
- if (avctx->context_model == 1) {
- s->context = avctx->context_model;
+ if (s->context) {
if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_ERROR,
"context=1 is not compatible with "
"2 pass huffyuv encoding\n");
return -1;
}
- }else s->context= 0;
+ }

if (avctx->codec->id == AV_CODEC_ID_HUFFYUV) {
if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
@@ -204,12 +211,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
"vcodec=ffvhuff or format=422p\n");
return -1;
}
- if (avctx->context_model) {
+#if FF_API_PRIVATE_OPT
+ if (s->context) {
av_log(avctx, AV_LOG_ERROR,
"Error: per-frame huffman tables are not supported "
"by huffyuv; use vcodec=ffvhuff\n");
return -1;
}
+#endif
if (s->interlaced != ( s->height > 288 ))
av_log(avctx, AV_LOG_INFO,
"using huffyuv 2.2.0 or newer interlacing flag\n");
@@ -686,6 +695,9 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}

+#define OFFSET(x) offsetof(HYuvContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+
AVCodec ff_huffyuv_encoder = {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -704,12 +716,25 @@ AVCodec ff_huffyuv_encoder = {
};

#if CONFIG_FFVHUFF_ENCODER
+static const AVOption ffhuffyuv_options[] = {
+ { "context", "Set per-frame huffman tables", OFFSET(context), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { NULL }
+};
+
+static const AVClass ffhuffyuv_class = {
+ .class_name = "ffhuffyuv encoder",
+ .item_name = av_default_item_name,
+ .option = ffhuffyuv_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_ffvhuff_encoder = {
.name = "ffvhuff",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_FFVHUFF,
.priv_data_size = sizeof(HYuvContext),
+ .priv_class = &ffhuffyuv_class,
.init = encode_init,
.encode2 = encode_frame,
.close = encode_end,
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 93b56fa..afc5c1d 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -313,7 +313,9 @@ static const AVOption avcodec_options[] = {
{"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"},
#endif /* FF_API_UNUSED_MEMBERS */
#endif /* FF_API_CODER_TYPE */
+#if FF_API_PRIVATE_OPT
{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
{"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#if FF_API_XVMC
{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:18 UTC
Permalink
This option is only used by mpeg2.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/mpeg12enc.c | 13 +++++++++++--
libavcodec/mpegvideo.h | 1 +
libavcodec/options_table.h | 2 ++
4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 695f534..ca7cfa6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2398,12 +2398,11 @@ typedef struct AVCodecContext {
*/
int max_prediction_order;

- /**
- * GOP timecode frame start number, in non drop frame format
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int64_t timecode_frame_start;
+#endif

#if FF_API_RTP_CALLBACK
/**
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 6171678..67bc467 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -182,6 +182,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
return -1;
}

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->timecode_frame_start)
+ s->timecode_frame_start = avctx->timecode_frame_start;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
return 0;
}

@@ -307,7 +314,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
* fake MPEG frame rate in case of low frame rate */
fps = (framerate.num + framerate.den / 2) / framerate.den;
time_code = s->current_picture_ptr->f->coded_picture_number +
- s->avctx->timecode_frame_start;
+ s->timecode_frame_start;

s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
if (s->drop_frame_timecode) {
@@ -1050,7 +1057,9 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
{ "drop_frame_timecode", "Timecode is in drop frame format.", \
OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, \
{ "scan_offset", "Reserve space for SVCD scan offset user data.", \
- OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, \
+ { "timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", \
+ OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, VE}, \

static const AVOption mpeg1_options[] = {
COMMON_OPTS
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 0c725fc..d2d2257 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -439,6 +439,7 @@ typedef struct MpegEncContext {
// picture structure defines are loaded from mpegutils.h
int picture_structure;

+ int64_t timecode_frame_start; ///< GOP timecode frame start number, in non drop frame format
int intra_dc_precision;
int frame_pred_frame_dct;
int top_field_first;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index afc5c1d..3dbe315 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -412,7 +412,9 @@ static const AVOption avcodec_options[] = {
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
+#if FF_API_PRIVATE_OPT
{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, V|E},
+#endif
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"},
{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:19 UTC
Permalink
This option is only used by mpegvideoenc and openh264.
It is a very codec-specific option, so deprecate the global variant.

The openh264 option is dropped altogether since it is just a fallback
for -max_nal_size anyway.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 4 ++++
libavcodec/libopenh264enc.c | 11 +++--------
libavcodec/mpegvideo.h | 2 ++
libavcodec/mpegvideo_enc.c | 13 +++++++++++--
libavcodec/options_table.h | 2 +-
5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ca7cfa6..de367de 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2418,12 +2418,16 @@ typedef struct AVCodecContext {
void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
#endif

+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int rtp_payload_size; /* The size of the RTP payload: the coder will */
/* do its best to deliver a chunk with size */
/* below rtp_payload_size, the chunk will start */
/* with a start code on some codecs like H.263. */
/* This doesn't take account of any particular */
/* headers inside the transmitted RTP payload. */
+#endif

#if FF_API_STAT_BITS
/* statistics, used for 2-pass encoding */
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 04e7ffd..747beef 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -203,14 +203,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
param.uiMaxNalSize = s->max_nal_size;
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = s->max_nal_size;
} else {
- if (avctx->rtp_payload_size) {
- av_log(avctx,AV_LOG_DEBUG,"Using RTP Payload size for uiMaxNalSize");
- param.uiMaxNalSize = avctx->rtp_payload_size;
- param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = avctx->rtp_payload_size;
- } else {
- av_log(avctx,AV_LOG_ERROR,"Invalid -max_nal_size, specify a valid max_nal_size to use -slice_mode dyn\n");
- goto fail;
- }
+ av_log(avctx, AV_LOG_ERROR, "Invalid -max_nal_size, "
+ "specify a valid max_nal_size to use -slice_mode dyn\n");
+ goto fail;
}
}

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index d2d2257..c131d93 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -465,6 +465,7 @@ typedef struct MpegEncContext {

/* RTP specific */
int rtp_mode;
+ int rtp_payload_size;

uint8_t *ptr_lastgob;
int16_t (*pblocks[12])[64];
@@ -613,6 +614,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \
+{"rtp_ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index b032148..fbbbb00 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -294,6 +294,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
break;
}

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->rtp_payload_size)
+ s->rtp_payload_size = avctx->rtp_payload_size;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
s->bit_rate = avctx->bit_rate;
s->width = avctx->width;
s->height = avctx->height;
@@ -313,7 +320,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->codec_id = avctx->codec->id;
s->strict_std_compliance = avctx->strict_std_compliance;
s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
- s->rtp_mode = !!avctx->rtp_payload_size;
+ s->rtp_mode = !!s->rtp_payload_size;
s->intra_dc_precision = avctx->intra_dc_precision;
s->user_specified_pts = AV_NOPTS_VALUE;

@@ -2766,7 +2773,9 @@ static int encode_thread(AVCodecContext *c, void *arg){

current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);

- is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0;
+ is_gob_start = s->rtp_payload_size &&
+ current_packet_size >= s->rtp_payload_size &&
+ mb_y + mb_x > 0;

if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 3dbe315..570a66e 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -121,8 +121,8 @@ static const AVOption avcodec_options[] = {
#endif
#if FF_API_PRIVATE_OPT
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
-#endif
{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
#if FF_API_STAT_BITS
{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:20 UTC
Permalink
These options are only used by alac and flac.
They are very codec-specific options, so deprecate the global variants.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/alacenc.c | 27 ++++++++++++++++++++++++---
libavcodec/avcodec.h | 14 +++++---------
libavcodec/flacenc.c | 33 +++++++++++++++++++++++++++------
libavcodec/options_table.h | 2 +-
4 files changed, 57 insertions(+), 19 deletions(-)

diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 8a94f81..4857338 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "put_bits.h"
#include "internal.h"
@@ -57,6 +59,7 @@ typedef struct AlacLPCContext {
} AlacLPCContext;

typedef struct AlacEncodeContext {
+ AVCodecContext *avctx;
int frame_size; /**< current frame size */
int verbatim; /**< current frame verbatim mode flag */
int compression_level;
@@ -73,7 +76,6 @@ typedef struct AlacEncodeContext {
RiceContext rc;
AlacLPCContext lpc[2];
LPCContext lpc_ctx;
- AVCodecContext *avctx;
} AlacEncodeContext;


@@ -544,7 +546,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
AV_WB8(alac_extradata+20, s->rc.k_modifier);
}

- s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->min_prediction_order >= 0) {
if (avctx->min_prediction_order < MIN_LPC_ORDER ||
avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
@@ -557,7 +560,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
s->min_prediction_order = avctx->min_prediction_order;
}

- s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
if (avctx->max_prediction_order >= 0) {
if (avctx->max_prediction_order < MIN_LPC_ORDER ||
avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
@@ -569,6 +571,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)

s->max_prediction_order = avctx->max_prediction_order;
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif

if (s->max_prediction_order < s->min_prediction_order) {
av_log(avctx, AV_LOG_ERROR,
@@ -634,12 +638,29 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return 0;
}

+#define OFFSET(x) offsetof(AlacEncodeContext, x)
+#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MIN_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE },
+ { "max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MAX_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE },
+
+ { NULL },
+};
+
+static const AVClass alacenc_class = {
+ .class_name = "alacenc",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_alac_encoder = {
.name = "alac",
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_ALAC,
.priv_data_size = sizeof(AlacEncodeContext),
+ .priv_class = &alacenc_class,
.init = alac_encode_init,
.encode2 = alac_encode_frame,
.close = alac_encode_close,
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index de367de..e997129 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2386,19 +2386,15 @@ typedef struct AVCodecContext {
*/
int trellis;

- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int min_prediction_order;

- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int max_prediction_order;

-#if FF_API_PRIVATE_OPT
/** @deprecated use encoder private options instead */
attribute_deprecated
int64_t timecode_frame_start;
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 7349f44..e25e867 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -325,9 +325,9 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
if (s->options.max_partition_order < 0)
s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];

- if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
- s->options.min_prediction_order = 0;
- } else if (avctx->min_prediction_order >= 0) {
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->min_prediction_order >= 0) {
if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
av_log(avctx, AV_LOG_WARNING,
@@ -343,9 +343,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
s->options.min_prediction_order = avctx->min_prediction_order;
}
- if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
- s->options.max_prediction_order = 0;
- } else if (avctx->max_prediction_order >= 0) {
+ if (avctx->max_prediction_order >= 0) {
if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
av_log(avctx, AV_LOG_WARNING,
@@ -361,6 +359,26 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
s->options.max_prediction_order = avctx->max_prediction_order;
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
+ s->options.min_prediction_order = 0;
+ s->options.max_prediction_order = 0;
+ } else if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
+ if (s->options.min_prediction_order > MAX_FIXED_ORDER) {
+ av_log(avctx, AV_LOG_WARNING,
+ "invalid min prediction order %d, clamped to %d\n",
+ s->options.min_prediction_order, MAX_FIXED_ORDER);
+ s->options.min_prediction_order = MAX_FIXED_ORDER;
+ }
+ if (s->options.max_prediction_order > MAX_FIXED_ORDER) {
+ av_log(avctx, AV_LOG_WARNING,
+ "invalid max prediction order %d, clamped to %d\n",
+ s->options.max_prediction_order, MAX_FIXED_ORDER);
+ s->options.max_prediction_order = MAX_FIXED_ORDER;
+ }
+ }
+
if (s->options.max_prediction_order < s->options.min_prediction_order) {
av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",
s->options.min_prediction_order, s->options.max_prediction_order);
@@ -1332,6 +1350,9 @@ static const AVOption options[] = {
{ "left_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_LEFT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "right_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_RIGHT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "mid_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_MID_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
+{ "min_prediction_order", NULL, offsetof(FlacEncodeContext, options.min_prediction_order), AV_OPT_TYPE_INT, { .i64 = 0 }, MIN_LPC_ORDER, MAX_LPC_ORDER, FLAGS },
+{ "max_prediction_order", NULL, offsetof(FlacEncodeContext, options.max_prediction_order), AV_OPT_TYPE_INT, { .i64 = 0 }, MIN_LPC_ORDER, MAX_LPC_ORDER, FLAGS },
+
{ NULL },
};

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 570a66e..b93a72d 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -410,9 +410,9 @@ static const AVOption avcodec_options[] = {
{"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E},
#endif
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
+#if FF_API_PRIVATE_OPT
{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
-#if FF_API_PRIVATE_OPT
{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, V|E},
#endif
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:22 UTC
Permalink
This option is only used by mpegvideoenc.
It is a very codec-specific options, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 7 ++++---
libavcodec/mpegvideo.h | 2 ++
libavcodec/mpegvideo_enc.c | 6 ++++--
libavcodec/options_table.h | 2 ++
4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 04617fe..4e1c877 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1938,12 +1938,13 @@ typedef struct AVCodecContext {
*/
int mb_lmax;

+#if FF_API_PRIVATE_OPT
/**
- *
- * - encoding: Set by user.
- * - decoding: unused
+ * @deprecated use encoder private options instead
*/
+ attribute_deprecated
int me_penalty_compensation;
+#endif

/**
*
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 3d81183..75ed8e8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -250,6 +250,7 @@ typedef struct MpegEncContext {
int me_method; ///< ME algorithm
#endif
int motion_est; ///< ME algorithm
+ int me_penalty_compensation;
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
@@ -616,6 +617,7 @@ FF_MPV_OPT_CMP_FUNC, \
{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \
{"rtp_ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 599cd06..213367a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -298,6 +298,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->rtp_payload_size)
s->rtp_payload_size = avctx->rtp_payload_size;
+ if (avctx->me_penalty_compensation)
+ s->me_penalty_compensation = avctx->me_penalty_compensation;
FF_ENABLE_DEPRECATION_WARNINGS
#endif

@@ -3460,8 +3462,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)

/* Estimate motion for every MB */
if(s->pict_type != AV_PICTURE_TYPE_I){
- s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
- s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
+ s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8;
+ s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8;
if (s->pict_type != AV_PICTURE_TYPE_B) {
if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 1106317..fbf0967 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -384,7 +384,9 @@ static const AVOption avcodec_options[] = {
#endif
{"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E},
{"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, V|E},
+#endif
{"skip_loop_filter", NULL, OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"skip_idct" , NULL, OFFSET(skip_idct) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"skip_frame" , NULL, OFFSET(skip_frame) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:21 UTC
Permalink
This options is only used by huffyuv, ffvhuv, jpegls, mjpeg,
mpegvideoenc, png, utvideo.
It is a very codec-specific options, so deprecate the global variant.
Set proper limits to the maximum allowed values, and update utvideoenc
tests to use the new option name.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 10 +++++-----
libavcodec/huffyuvenc.c | 37 ++++++++++++++++++++++++++++++-------
libavcodec/jpeglsenc.c | 39 ++++++++++++++++++++++++++++++++++++---
libavcodec/ljpegenc.c | 43 ++++++++++++++++++++++++++++++++++++++-----
libavcodec/mjpegenc.c | 19 +++++++++++++++++++
libavcodec/mjpegenc_common.c | 4 ++--
libavcodec/mjpegenc_common.h | 2 +-
libavcodec/mpegvideo.h | 1 +
libavcodec/mpegvideo_enc.c | 5 ++++-
libavcodec/options_table.h | 2 ++
libavcodec/pngenc.c | 35 ++++++++++++++++++++++++++++++++---
libavcodec/utvideo.c | 2 ++
libavcodec/utvideoenc.c | 29 ++++++++++++++++++++++++++++-
tests/fate/utvideo.mak | 8 ++++----
14 files changed, 204 insertions(+), 32 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e997129..04617fe 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1678,15 +1678,15 @@ typedef struct AVCodecContext {
* - decoding: Set by user (or 0).
*/
int slice_count;
- /**
- * prediction method (needed for huffyuv)
- * - encoding: Set by user.
- * - decoding: unused
- */
+
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int prediction_method;
#define FF_PRED_LEFT 0
#define FF_PRED_PLANE 1
#define FF_PRED_MEDIAN 2
+#endif

/**
* slice offsets in the frame in bytes
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index bd36901..a6ffd24 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -193,7 +193,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
avctx->bits_per_coded_sample = s->bitstream_bpp;
s->decorrelate = s->bitstream_bpp >= 24;
- s->predictor = avctx->prediction_method;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->predictor = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0;
if (s->context) {
if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) {
@@ -698,12 +703,34 @@ static av_cold int encode_end(AVCodecContext *avctx)
#define OFFSET(x) offsetof(HYuvContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

+#define HUFF_CLASS(variant) \
+static const AVClass variant ## _class = { \
+ .class_name = # variant, \
+ .item_name = av_default_item_name, \
+ .option = variant ## _options, \
+ .version = LIBAVUTIL_VERSION_INT, \
+}
+
+#define FF_HUFFYUV_COMMON_OPTS \
+{ "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, "pred" }, \
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, "pred" }, \
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, "pred" }, \
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, "pred" }
+
+static const AVOption huffyuv_options[] = {
+ FF_HUFFYUV_COMMON_OPTS,
+ { NULL},
+};
+
+HUFF_CLASS(huffyuv);
+
AVCodec ff_huffyuv_encoder = {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_HUFFYUV,
.priv_data_size = sizeof(HYuvContext),
+ .priv_class = &huffyuv_class,
.init = encode_init,
.encode2 = encode_frame,
.close = encode_end,
@@ -717,16 +744,12 @@ AVCodec ff_huffyuv_encoder = {

#if CONFIG_FFVHUFF_ENCODER
static const AVOption ffhuffyuv_options[] = {
+ FF_HUFFYUV_COMMON_OPTS,
{ "context", "Set per-frame huffman tables", OFFSET(context), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL }
};

-static const AVClass ffhuffyuv_class = {
- .class_name = "ffhuffyuv encoder",
- .item_name = av_default_item_name,
- .option = ffhuffyuv_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
+HUFF_CLASS(ffhuffyuv);

AVCodec ff_ffvhuff_encoder = {
.name = "ffvhuff",
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 1f32928..8131d27 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -34,6 +34,12 @@
#include "mjpegenc.h"
#include "jpegls.h"

+typedef struct JPEGLSContext {
+ AVClass *class;
+
+ int pred;
+} JPEGLSContext;
+
/**
* Encode error from regular symbol
*/
@@ -249,8 +255,8 @@ static void ls_store_lse(JLSState *state, PutBitContext *pb)
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
+ JPEGLSContext *ctx = avctx->priv_data;
const AVFrame *const p = pict;
- const int near = avctx->prediction_method;
PutBitContext pb, pb2;
GetBitContext gb;
uint8_t *buf2 = NULL;
@@ -261,6 +267,13 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
int i, size, ret;
int comps;

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ ctx->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1;
@@ -301,7 +314,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
put_bits(&pb, 8, i); // component ID
put_bits(&pb, 8, 0); // mapping index: none
}
- put_bits(&pb, 8, near);
+ put_bits(&pb, 8, ctx->pred);
put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
put_bits(&pb, 8, 0); // point transform: none

@@ -310,7 +323,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
goto memfail;

/* initialize JPEG-LS state from JPEG parameters */
- state->near = near;
+ state->near = ctx->pred;
state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
@@ -433,11 +446,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}

+#define OFFSET(x) offsetof(JPEGLSContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass jpegls_class = {
+ .class_name = "jpegls",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_jpegls_encoder = {
.name = "jpegls",
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
+ .priv_data_size = sizeof(JPEGLSContext),
+ .priv_class = &jpegls_class,
.init = encode_init_ls,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 41dba89..b6d73a4 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -43,6 +43,7 @@
#include "mjpegenc.h"

typedef struct LJpegEncContext {
+ AVClass *class;
IDCTDSPContext idsp;
ScanTable scantable;
uint16_t matrix[64];
@@ -56,6 +57,7 @@ typedef struct LJpegEncContext {
uint8_t huff_size_dc_chrominance[12];

uint16_t (*scratch)[4];
+ int pred;
} LJpegEncContext;

static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
@@ -66,15 +68,21 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
const int height = frame->height;
const int linesize = frame->linesize[0];
uint16_t (*buffer)[4] = s->scratch;
- const int predictor = avctx->prediction_method+1;
int left[3], top[3], topleft[3];
int x, y, i;

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
for (i = 0; i < 3; i++)
buffer[0][i] = 1 << (9 - 1);

for (y = 0; y < height; y++) {
- const int modified_predictor = y ? predictor : 1;
+ const int modified_predictor = y ? s->pred : 1;
uint8_t *ptr = frame->data[0] + (linesize * y);

if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 3 * 3) {
@@ -181,12 +189,18 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
const AVFrame *frame)
{
- const int predictor = avctx->prediction_method + 1;
LJpegEncContext *s = avctx->priv_data;
const int mb_width = (avctx->width + s->hsample[0] - 1) / s->hsample[0];
const int mb_height = (avctx->height + s->vsample[0] - 1) / s->vsample[0];
int mb_x, mb_y;

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
for (mb_y = 0; mb_y < mb_height; mb_y++) {
if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) <
mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) {
@@ -195,7 +209,7 @@ static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
}

for (mb_x = 0; mb_x < mb_width; mb_x++)
- ljpeg_encode_yuv_mb(s, pb, frame, predictor, mb_x, mb_y);
+ ljpeg_encode_yuv_mb(s, pb, frame, s->pred, mb_x, mb_y);
}

return 0;
@@ -227,7 +241,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&pb, pkt->data, pkt->size);

ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
- s->matrix);
+ s->pred, s->matrix);

header_bits = put_bits_count(&pb);

@@ -316,12 +330,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}

+#define OFFSET(x) offsetof(LJpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass ljpeg_class = {
+ .class_name = "ljpeg",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_ljpeg_encoder = {
.name = "ljpeg",
.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_LJPEG,
.priv_data_size = sizeof(LJpegEncContext),
+ .priv_class = &ljpeg_class,
.init = ljpeg_encode_init,
.encode2 = ljpeg_encode_frame,
.close = ljpeg_encode_close,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 6724310..e48c945 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -154,12 +154,31 @@ void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[8][64])
s->i_tex_bits += get_bits_diff(s);
}

+#define OFFSET(x) offsetof(MpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass mjpeg_class = {
+ .class_name = "mjpeg",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_mjpeg_encoder = {
.name = "mjpeg",
.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MJPEG,
.priv_data_size = sizeof(MpegEncContext),
+ .priv_class = &mjpeg_class,
.init = ff_mpv_encode_init,
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 54df987..2262de6 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -134,7 +134,7 @@ static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
}

void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
- ScanTable *intra_scantable,
+ ScanTable *intra_scantable, int pred,
uint16_t intra_matrix[64])
{
int chroma_h_shift, chroma_v_shift;
@@ -217,7 +217,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
put_bits(pb, 4, 1); /* DC huffman table index */
put_bits(pb, 4, lossless ? 0 : 1); /* AC huffman table index */

- put_bits(pb, 8, lossless ? avctx->prediction_method + 1 : 0); /* Ss (not used) */
+ put_bits(pb, 8, lossless ? pred : 0); /* Ss (not used) */

switch (avctx->codec_id) {
case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index b48911e..9b5933e 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -28,7 +28,7 @@
#include "put_bits.h"

void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
- ScanTable *intra_scantable,
+ ScanTable *intra_scantable, int pred,
uint16_t intra_matrix[64]);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_encode_stuffing(PutBitContext *pbc);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index c131d93..3d81183 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -405,6 +405,7 @@ typedef struct MpegEncContext {

/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
+ int pred;

/* MSMPEG4 specific */
int mv_table_index;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index fbbbb00..599cd06 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -921,6 +921,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->brd_scale)
s->brd_scale = avctx->brd_scale;
+
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif

@@ -3583,7 +3586,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
- s->intra_matrix);
+ s->pred, s->intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index b93a72d..1106317 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -236,10 +236,12 @@ static const AVOption avcodec_options[] = {
{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_GUESS_MVS }, INT_MIN, INT_MAX, V|D, "ec"},
{"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"},
{"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
+#if FF_API_PRIVATE_OPT
{"pred", "prediction method", OFFSET(prediction_method), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"},
{"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},
{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
{"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},
+#endif
{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E},
{"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
{"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 28df5af..f91c54c 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

+#include "libavutil/opt.h"
#include "libavutil/stereo3d.h"

#include "avcodec.h"
@@ -35,6 +36,7 @@
#define IOBUF_SIZE 4096

typedef struct PNGEncContext {
+ AVClass *class;
HuffYUVEncDSPContext hdsp;

uint8_t *bytestream;
@@ -486,21 +488,48 @@ FF_ENABLE_DEPRECATION_WARNINGS

ff_huffyuvencdsp_init(&s->hdsp);

- s->filter_type = av_clip(avctx->prediction_method,
- PNG_FILTER_VALUE_NONE,
- PNG_FILTER_VALUE_MIXED);
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->filter_type = av_clip(avctx->prediction_method,
+ PNG_FILTER_VALUE_NONE,
+ PNG_FILTER_VALUE_MIXED);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
s->filter_type = PNG_FILTER_VALUE_NONE;

return 0;
}

+#define OFFSET(x) offsetof(PNGEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(filter_type), AV_OPT_TYPE_INT, { .i64 = PNG_FILTER_VALUE_NONE }, PNG_FILTER_VALUE_NONE, PNG_FILTER_VALUE_MIXED, VE, "pred" },
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_NONE }, INT_MIN, INT_MAX, VE, "pred" },
+ { "sub", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_SUB }, INT_MIN, INT_MAX, VE, "pred" },
+ { "up", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_UP }, INT_MIN, INT_MAX, VE, "pred" },
+ { "avg", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_AVG }, INT_MIN, INT_MAX, VE, "pred" },
+ { "paeth", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_PAETH }, INT_MIN, INT_MAX, VE, "pred" },
+ { "mixed", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_MIXED }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass png_class = {
+ .class_name = "png",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
AVCodec ff_png_encoder = {
.name = "png",
.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PNG,
.priv_data_size = sizeof(PNGEncContext),
+ .priv_class = &png_class,
.init = png_enc_init,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c
index eb5a924..35e927c 100644
--- a/libavcodec/utvideo.c
+++ b/libavcodec/utvideo.c
@@ -26,9 +26,11 @@

#include "utvideo.h"

+#if FF_API_PRIVATE_OPT
const int ff_ut_pred_order[5] = {
PRED_LEFT, PRED_MEDIAN, PRED_MEDIAN, PRED_NONE, PRED_GRADIENT
};
+#endif

const int ff_ut_rgb_order[4] = { 1, 2, 0, 3 }; // G, B, R, A

diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 9af0f66..7fb838e 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -26,6 +26,8 @@

#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "internal.h"
#include "bswapdsp.h"
@@ -111,6 +113,8 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
ff_bswapdsp_init(&c->bdsp);
ff_huffyuvencdsp_init(&c->hdsp);

+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
/* Check the prediction method, and error out if unsupported */
if (avctx->prediction_method < 0 || avctx->prediction_method > 4) {
av_log(avctx, AV_LOG_WARNING,
@@ -126,7 +130,10 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
}

/* Convert from libavcodec prediction type to Ut Video's */
- c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+ if (avctx->prediction_method)
+ c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif

if (c->frame_pred == PRED_GRADIENT) {
av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
@@ -631,12 +638,32 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}

+#define OFFSET(x) offsetof(UtvideoContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(frame_pred), AV_OPT_TYPE_INT, { .i64 = PRED_LEFT }, PRED_NONE, PRED_MEDIAN, VE, "pred" },
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_NONE }, INT_MIN, INT_MAX, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_LEFT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "gradient", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_GRADIENT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_MEDIAN }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass utvideo_class = {
+ .class_name = "utvideo",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_utvideo_encoder = {
.name = "utvideo",
.long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_UTVIDEO,
.priv_data_size = sizeof(UtvideoContext),
+ .priv_class = &utvideo_class,
.init = utvideo_encode_init,
.encode2 = utvideo_encode_frame,
.close = utvideo_encode_close,
diff --git a/tests/fate/utvideo.mak b/tests/fate/utvideo.mak
index e1ef7ec..4c0c6bf 100644
--- a/tests/fate/utvideo.mak
+++ b/tests/fate/utvideo.mak
@@ -37,7 +37,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_rgba_median
fate-utvideoenc_rgba_median: OPTS = -pix_fmt rgba -pred median

FATE_UTVIDEOENC += fate-utvideoenc_rgba_none
-fate-utvideoenc_rgba_none: OPTS = -pix_fmt rgba -pred 3
+fate-utvideoenc_rgba_none: OPTS = -pix_fmt rgba -pred none

FATE_UTVIDEOENC += fate-utvideoenc_rgb_left
fate-utvideoenc_rgb_left: OPTS = -pix_fmt rgb24 -pred left
@@ -46,7 +46,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_rgb_median
fate-utvideoenc_rgb_median: OPTS = -pix_fmt rgb24 -pred median

FATE_UTVIDEOENC += fate-utvideoenc_rgb_none
-fate-utvideoenc_rgb_none: OPTS = -pix_fmt rgb24 -pred 3
+fate-utvideoenc_rgb_none: OPTS = -pix_fmt rgb24 -pred none

FATE_UTVIDEOENC += fate-utvideoenc_yuv420_left
fate-utvideoenc_yuv420_left: OPTS = -pix_fmt yuv420p -pred left
@@ -55,7 +55,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_yuv420_median
fate-utvideoenc_yuv420_median: OPTS = -pix_fmt yuv420p -pred median

FATE_UTVIDEOENC += fate-utvideoenc_yuv420_none
-fate-utvideoenc_yuv420_none: OPTS = -pix_fmt yuv420p -pred 3
+fate-utvideoenc_yuv420_none: OPTS = -pix_fmt yuv420p -pred none

FATE_UTVIDEOENC += fate-utvideoenc_yuv422_left
fate-utvideoenc_yuv422_left: OPTS = -pix_fmt yuv422p -pred left
@@ -64,7 +64,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_yuv422_median
fate-utvideoenc_yuv422_median: OPTS = -pix_fmt yuv422p -pred median

FATE_UTVIDEOENC += fate-utvideoenc_yuv422_none
-fate-utvideoenc_yuv422_none: OPTS = -pix_fmt yuv422p -pred 3
+fate-utvideoenc_yuv422_none: OPTS = -pix_fmt yuv422p -pred none

$(FATE_UTVIDEOENC): $(VREF)
--
2.6.4
Vittorio Giovara
2016-01-04 13:34:23 UTC
Permalink
This option is only used by mpegvideoenc.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <***@gmail.com>
---
libavcodec/avcodec.h | 9 ++++-----
libavcodec/mpegvideo.h | 3 +++
libavcodec/mpegvideo_enc.c | 5 ++++-
libavcodec/options_table.h | 2 ++
4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4e1c877..fe3366b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1757,12 +1757,11 @@ typedef struct AVCodecContext {
*/
int last_predictor_count;

- /**
- * prepass for motion estimation
- * - encoding: Set by user.
- * - decoding: unused
- */
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int pre_me;
+#endif

/**
* motion estimation prepass comparison function
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 75ed8e8..4e25603 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -251,6 +251,7 @@ typedef struct MpegEncContext {
#endif
int motion_est; ///< ME algorithm
int me_penalty_compensation;
+ int me_pre; ///< prepass for motion estimation
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
@@ -618,6 +619,8 @@ FF_MPV_OPT_CMP_FUNC, \
{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \
{"rtp_ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
+

extern const AVOption ff_mpv_generic_options[];

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 213367a..d16e408 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -300,6 +300,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
s->rtp_payload_size = avctx->rtp_payload_size;
if (avctx->me_penalty_compensation)
s->me_penalty_compensation = avctx->me_penalty_compensation;
+ if (avctx->pre_me)
+ s->me_pre = avctx->pre_me;
FF_ENABLE_DEPRECATION_WARNINGS
#endif

@@ -3465,7 +3467,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8;
s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8;
if (s->pict_type != AV_PICTURE_TYPE_B) {
- if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
+ if ((s->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) ||
+ s->me_pre == 2) {
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index fbf0967..fe6a548 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -279,7 +279,9 @@ static const AVOption avcodec_options[] = {
{"ildctcmp", "interlaced DCT compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#if FF_API_PRIVATE_OPT
{"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"sad", "sum of absolute differences, fast (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"},
--
2.6.4
Vittorio Giovara
2016-01-11 20:46:53 UTC
Permalink
On Mon, Jan 4, 2016 at 8:34 AM, Vittorio Giovara
Post by Vittorio Giovara
AVCodecContext holds a lot of fields that are used seldom within
libavcodec, in most cases only to set options that apply to a single
family of codecs, or sometimes to completely unrelated codecs.
This was done before in the long past there was no codec private option,
and in fact nowadays global context options are rarely added (and only
when it really applies to something global), preferring to add codec
private options instead.
This set (1 of 3) tries to go over each context field and to identify
which not-really-global options should be moved to private codec options.
The rationale is that after my changes options would have a much more precise
scope, as right now it is not possible to understand which option affects
which codec without looking at the source code. The (long term) improvement
would also be to have a more compact context, with less fields to document
The option selection is a trade off between how widespread the option is
within libavcodec and how much it makes sense for an option to be global.
Vittorio
ping on the set with the replaced - to _
--
Vittorio
Luca Barbato
2016-01-11 21:14:36 UTC
Permalink
Post by Vittorio Giovara
On Mon, Jan 4, 2016 at 8:34 AM, Vittorio Giovara
Post by Vittorio Giovara
AVCodecContext holds a lot of fields that are used seldom within
libavcodec, in most cases only to set options that apply to a single
family of codecs, or sometimes to completely unrelated codecs.
This was done before in the long past there was no codec private option,
and in fact nowadays global context options are rarely added (and only
when it really applies to something global), preferring to add codec
private options instead.
This set (1 of 3) tries to go over each context field and to identify
which not-really-global options should be moved to private codec options.
The rationale is that after my changes options would have a much more precise
scope, as right now it is not possible to understand which option affects
which codec without looking at the source code. The (long term) improvement
would also be to have a more compact context, with less fields to document
The option selection is a trade off between how widespread the option is
within libavcodec and how much it makes sense for an option to be global.
Vittorio
ping on the set with the replaced - to _
I'm not against it.
Vittorio Giovara
2016-01-19 16:30:33 UTC
Permalink
Post by Luca Barbato
Post by Vittorio Giovara
On Mon, Jan 4, 2016 at 8:34 AM, Vittorio Giovara
Post by Vittorio Giovara
AVCodecContext holds a lot of fields that are used seldom within
libavcodec, in most cases only to set options that apply to a single
family of codecs, or sometimes to completely unrelated codecs.
This was done before in the long past there was no codec private option,
and in fact nowadays global context options are rarely added (and only
when it really applies to something global), preferring to add codec
private options instead.
This set (1 of 3) tries to go over each context field and to identify
which not-really-global options should be moved to private codec options.
The rationale is that after my changes options would have a much more precise
scope, as right now it is not possible to understand which option affects
which codec without looking at the source code. The (long term) improvement
would also be to have a more compact context, with less fields to document
The option selection is a trade off between how widespread the option is
within libavcodec and how much it makes sense for an option to be global.
Vittorio
ping on the set with the replaced - to _
I'm not against it.
Any more comments on the set anyone? I'd like to push it soon
--
Vittorio
Continue reading on narkive:
Loading...