Merge commit '1482aff2048511b821ff9feac19426113cc641a2'

* commit '1482aff2048511b821ff9feac19426113cc641a2':
  lavc: Move noise_reduction to codec private options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2016-01-28 16:38:04 +00:00
commit b986a4625d
9 changed files with 53 additions and 15 deletions

View File

@ -2107,14 +2107,11 @@ typedef struct AVCodecContext {
/** @deprecated use encoder private options instead */ /** @deprecated use encoder private options instead */
attribute_deprecated attribute_deprecated
int scenechange_threshold; int scenechange_threshold;
#endif
/** /** @deprecated use encoder private options instead */
* noise reduction strength attribute_deprecated
* - encoding: Set by user.
* - decoding: unused
*/
int noise_reduction; int noise_reduction;
#endif
#if FF_API_MPV_OPT #if FF_API_MPV_OPT
/** /**

View File

@ -103,6 +103,7 @@ typedef struct VP8EncoderContext {
int frame_parallel; int frame_parallel;
int aq_mode; int aq_mode;
int drop_threshold; int drop_threshold;
int noise_sensitivity;
} VP8Context; } VP8Context;
/** String mappings for enum vp8e_enc_control_id */ /** 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); codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8) { 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)); codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
} }
#if FF_API_MPV_OPT #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 }, \ { "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 }, \ { "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 }, \ { "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 }, \ { "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 }, \ { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \

View File

@ -89,6 +89,7 @@ typedef struct X264Context {
int b_frame_strategy; int b_frame_strategy;
int chroma_offset; int chroma_offset;
int scenechange_threshold; int scenechange_threshold;
int noise_reduction;
char *x264_params; char *x264_params;
} X264Context; } X264Context;
@ -595,8 +596,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_trellis = avctx->trellis;
if (avctx->me_range >= 0) if (avctx->me_range >= 0)
x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_me_range = avctx->me_range;
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->noise_reduction >= 0) 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) if (avctx->me_subpel_quality >= 0)
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
#if FF_API_PRIVATE_OPT #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 }, { "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 }, { "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 }, { "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 }, { "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 }, { NULL },
@ -1007,7 +1015,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "sc_threshold", "-1" }, { "sc_threshold", "-1" },
#endif #endif
{ "trellis", "-1" }, { "trellis", "-1" },
#if FF_API_PRIVATE_OPT
{ "nr", "-1" }, { "nr", "-1" },
#endif
{ "me_range", "-1" }, { "me_range", "-1" },
#if FF_API_MOTION_EST #if FF_API_MOTION_EST
{ "me_method", "-1" }, { "me_method", "-1" },

View File

@ -59,6 +59,7 @@ typedef struct XavsContext {
int b_frame_strategy; int b_frame_strategy;
int chroma_offset; int chroma_offset;
int scenechange_threshold; int scenechange_threshold;
int noise_reduction;
int64_t *pts_buffer; int64_t *pts_buffer;
int out_frame_count; 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.b_transform_8x8 = 1; //avctx->flags2 & AV_CODEC_FLAG2_8X8DCT;
x4->params.analyse.i_trellis = avctx->trellis; 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) if (avctx->level > 0)
x4->params.i_level_idc = avctx->level; 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}, { "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}, { "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}, { "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 }, { NULL },
}; };

View File

@ -375,7 +375,7 @@ static int init_duplicate_context(MpegEncContext *s)
ME_MAP_SIZE * sizeof(uint32_t), fail) ME_MAP_SIZE * sizeof(uint32_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
ME_MAP_SIZE * sizeof(uint32_t), fail) 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, FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
2 * 64 * sizeof(int), fail) 2 * 64 * sizeof(int), fail)
} }

View File

@ -558,6 +558,7 @@ typedef struct MpegEncContext {
int frame_skip_cmp; int frame_skip_cmp;
int scenechange_threshold; int scenechange_threshold;
int noise_reduction;
} MpegEncContext; } MpegEncContext;
/* mpegvideo_enc common options */ /* 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_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" }, \ {"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 }, \ {"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[]; extern const AVOption ff_mpv_generic_options[];

View File

@ -884,6 +884,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1; 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; avctx->has_b_frames = !s->low_delay;
s->encoding = 1; s->encoding = 1;
@ -922,7 +929,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail); MAX_PICTURE_COUNT * sizeof(Picture *), fail);
if (s->avctx->noise_reduction) {
if (s->noise_reduction) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
2 * 64 * sizeof(uint16_t), fail); 2 * 64 * sizeof(uint16_t), fail);
} }
@ -1731,7 +1739,7 @@ static void update_noise_reduction(MpegEncContext *s)
} }
for (i = 0; i < 64; i++) { 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_count[intra] +
s->dct_error_sum[intra][i] / 2) / s->dct_error_sum[intra][i] / 2) /
(s->dct_error_sum[intra][i] + 1); (s->dct_error_sum[intra][i] + 1);
@ -1804,7 +1812,7 @@ static int frame_start(MpegEncContext *s)
} }
if (s->dct_error_sum) { if (s->dct_error_sum) {
av_assert2(s->avctx->noise_reduction && s->encoding); av_assert2(s->noise_reduction && s->encoding);
update_noise_reduction(s); 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[1]);
MERGE(current_picture.encoding_error[2]); MERGE(current_picture.encoding_error[2]);
if(dst->avctx->noise_reduction){ if (dst->noise_reduction){
for(i=0; i<64; i++){ for(i=0; i<64; i++){
MERGE(dct_error_sum[0][i]); MERGE(dct_error_sum[0][i]);
MERGE(dct_error_sum[1][i]); MERGE(dct_error_sum[1][i]);

View File

@ -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}, {"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}, {"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
#endif #endif
#if FF_API_PRIVATE_OPT
{"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"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}, {"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"}, {"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
#if FF_API_ERROR_RATE #if FF_API_ERROR_RATE

View File

@ -220,7 +220,8 @@ fate-vsynth%-mpeg4-error: ENCOPTS = -qscale 7 -flags +mv4+aic \
-data_partitioning 1 -mbd rd \ -data_partitioning 1 -mbd rd \
-ps 250 -error_rate 10 -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 \ fate-vsynth%-mpeg4-nsse: ENCOPTS = -qscale 7 -cmp nsse -subcmp nsse \
-mbcmp nsse -precmp nsse \ -mbcmp nsse -precmp nsse \