aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-02-27 20:06:23 +0100
committerAnton Khirnov <anton@khirnov.net>2012-02-29 07:26:24 +0100
commit23bfcc066d468e2ec6159be2f5af3d5a59f40d79 (patch)
tree00c37a92ba7055dd7aae9b3453a6e88a96300f49
parent16b7557b794c6cd47c5a256a246f8c930c01eef7 (diff)
downloadffmpeg-23bfcc066d468e2ec6159be2f5af3d5a59f40d79.tar.gz
mpegvideo_enc: add quantizer_noise_shaping private option.
Deprecate corresponding AVCodecContext field.
-rw-r--r--libavcodec/avcodec.h8
-rw-r--r--libavcodec/mpegvideo.h4
-rw-r--r--libavcodec/mpegvideo_enc.c12
-rw-r--r--libavcodec/options.c4
4 files changed, 17 insertions, 11 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a9fc31e900..f4db08335a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1757,12 +1757,12 @@ typedef struct AVCodecContext {
attribute_deprecated int inter_threshold;
#endif
+#if FF_API_MPV_GLOBAL_OPTS
/**
- * quantizer noise shaping
- * - encoding: Set by user.
- * - decoding: unused
+ * @deprecated use mpegvideo private options instead
*/
- int quantizer_noise_shaping;
+ attribute_deprecated int quantizer_noise_shaping;
+#endif
/**
* Motion estimation threshold below which no motion estimation is
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 084f4be769..ad0bd3a164 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -691,6 +691,7 @@ typedef struct MpegEncContext {
void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
int mpv_flags; ///< flags set by private options
+ int quantizer_noise_shaping;
} MpegEncContext;
#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \
@@ -715,7 +716,8 @@ typedef struct MpegEncContext {
{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\
FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\
- FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },
+ FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
+{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { 0 }, 0, 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 8a516b3016..0940eeda2f 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -630,6 +630,8 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
s->mpv_flags |= FF_MPV_FLAG_SKIP_RD;
if (avctx->flags2 & CODEC_FLAG2_STRICT_GOP)
s->mpv_flags |= FF_MPV_FLAG_STRICT_GOP;
+ if (avctx->quantizer_noise_shaping)
+ s->quantizer_noise_shaping = avctx->quantizer_noise_shaping;
#endif
switch (avctx->codec->id) {
@@ -1949,7 +1951,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
}
}
- if (s->avctx->quantizer_noise_shaping) {
+ if (s->quantizer_noise_shaping) {
if (!skip_dct[0])
get_visual_weight(weight[0], ptr_y , wrap_y);
if (!skip_dct[1])
@@ -1990,7 +1992,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
} else
s->block_last_index[i] = -1;
}
- if (s->avctx->quantizer_noise_shaping) {
+ if (s->quantizer_noise_shaping) {
for (i = 0; i < mb_block_count; i++) {
if (!skip_dct[i]) {
s->block_last_index[i] =
@@ -3738,7 +3740,7 @@ STOP_TIMER("init rem[]")
#ifdef REFINE_STATS
{START_TIMER
#endif
- analyze_gradient = last_non_zero > 2 || s->avctx->quantizer_noise_shaping >= 3;
+ analyze_gradient = last_non_zero > 2 || s->quantizer_noise_shaping >= 3;
if(analyze_gradient){
#ifdef REFINE_STATS
@@ -3796,7 +3798,7 @@ STOP_TIMER("dct")}
const int level= block[j];
int change, old_coeff;
- if(s->avctx->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
+ if(s->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
break;
if(level){
@@ -3814,7 +3816,7 @@ STOP_TIMER("dct")}
int score, new_coeff, unquant_change;
score=0;
- if(s->avctx->quantizer_noise_shaping < 2 && FFABS(new_level) > FFABS(level))
+ if(s->quantizer_noise_shaping < 2 && FFABS(new_level) > FFABS(level))
continue;
if(new_level){
diff --git a/libavcodec/options.c b/libavcodec/options.c
index dbf3427d91..288c75437a 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -325,7 +325,9 @@ static const AVOption options[]={
#endif
{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
{"error", NULL, OFFSET(error_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#if FF_API_MPV_GLOBAL_OPTS
+{"qns", "deprecated, use mpegvideo private options instead", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
+#endif
{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"},
{"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
{"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},