mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
lavc: Move noise_reduction to codec private options
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 <vittorio.giovara@gmail.com>
This commit is contained in:
parent
7c79587d74
commit
1482aff204
@ -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
|
||||
/**
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
@ -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 },
|
||||
{ "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 },
|
||||
|
||||
{ "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" },
|
||||
|
@ -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},
|
||||
{ "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 },
|
||||
};
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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[];
|
||||
|
||||
|
@ -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]);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user