summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-01-28 16:38:04 +0000
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-01-28 16:42:32 +0000
commitb986a4625d0e67710f155a9816dbab186a98020e (patch)
tree118c89f94a652571276175a55de0f4b21e00faea
parentc79252897096b89376bcf17a5bca6cdf8d21b6a0 (diff)
parent1482aff2048511b821ff9feac19426113cc641a2 (diff)
Merge commit '1482aff2048511b821ff9feac19426113cc641a2'
* commit '1482aff2048511b821ff9feac19426113cc641a2': lavc: Move noise_reduction to codec private options Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--libavcodec/avcodec.h9
-rw-r--r--libavcodec/libvpxenc.c10
-rw-r--r--libavcodec/libx264.c12
-rw-r--r--libavcodec/libxavs.c12
-rw-r--r--libavcodec/mpegvideo.c2
-rw-r--r--libavcodec/mpegvideo.h2
-rw-r--r--libavcodec/mpegvideo_enc.c16
-rw-r--r--libavcodec/options_table.h2
-rw-r--r--tests/fate/vcodec.mak3
9 files changed, 53 insertions, 15 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 60a7808fe1..346573f5ef 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2107,14 +2107,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 766b7bd755..643855accc 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -103,6 +103,7 @@ typedef struct VP8EncoderContext {
int frame_parallel;
int aq_mode;
int drop_threshold;
+ int noise_sensitivity;
} VP8Context;
/** String mappings for enum vp8e_enc_control_id */
@@ -612,7 +613,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8) {
- 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
@@ -1017,6 +1024,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
{ "crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 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}, \
{ "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \
{ "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index c795729c84..e4df82aa78 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -89,6 +89,7 @@ typedef struct X264Context {
int b_frame_strategy;
int chroma_offset;
int scenechange_threshold;
+ int noise_reduction;
char *x264_params;
} X264Context;
@@ -595,8 +596,14 @@ 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 FF_API_PRIVATE_OPT
+ FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->noise_reduction >= 0)
- x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
+ x4->noise_reduction = avctx->noise_reduction;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (x4->noise_reduction >= 0)
+ 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
@@ -984,6 +991,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 },
{ "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE },
{ "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
+ { "noise_reduction", "Noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, { .i64 = -1 }, 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 },
@@ -1007,7 +1015,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 42bddb7164..f257e5584d 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;
@@ -366,7 +367,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;
@@ -465,6 +474,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},
{ "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE},
{ "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE},
+ { "noise_reduction", "Noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE},
{ NULL },
};
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9b2cc9807a..236987b3d4 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -375,7 +375,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 feb5683afe..43d9c03019 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -558,6 +558,7 @@ typedef struct MpegEncContext {
int frame_skip_cmp;
int scenechange_threshold;
+ int noise_reduction;
} MpegEncContext;
/* mpegvideo_enc common options */
@@ -642,6 +643,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 f7a0ee96b4..2914ae2c65 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -884,6 +884,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;
@@ -922,7 +929,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);
}
@@ -1731,7 +1739,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);
@@ -1804,7 +1812,7 @@ static int frame_start(MpegEncContext *s)
}
if (s->dct_error_sum) {
- av_assert2(s->avctx->noise_reduction && s->encoding);
+ av_assert2(s->noise_reduction && s->encoding);
update_noise_reduction(s);
}
@@ -3576,7 +3584,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 a7d3796f50..530b20fd6e 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -344,7 +344,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 0d6e093932..ccf88ce427 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -220,7 +220,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-nsse: ENCOPTS = -qscale 7 -cmp nsse -subcmp nsse \
-mbcmp nsse -precmp nsse \