aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-09-24 10:53:59 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-09-24 10:53:59 +0000
commit5e746b99959e8cf13af70af4f9f8c772dcc15fc5 (patch)
treec6188eb02a359ae00c39f7f59298eb758057a47c
parent99609036675ceb968a53397ab3e051e97a7181fd (diff)
downloadffmpeg-5e746b99959e8cf13af70af4f9f8c772dcc15fc5.tar.gz
darkness masking (lumi masking does only bright stuff now)
Originally committed as revision 967 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/avcodec.h11
-rw-r--r--libavcodec/mpegvideo.c7
-rw-r--r--libavcodec/ratecontrol.c7
3 files changed, 19 insertions, 6 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9b63af8138..c840bb08a6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5,8 +5,8 @@
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
-#define LIBAVCODEC_BUILD 4625
-#define LIBAVCODEC_BUILD_STR "4625"
+#define LIBAVCODEC_BUILD 4626
+#define LIBAVCODEC_BUILD_STR "4626"
enum CodecID {
CODEC_ID_NONE,
@@ -668,6 +668,13 @@ typedef struct AVCodecContext {
*/
float p_masking;
+ /**
+ * darkness masking (0-> disabled)
+ * encoding: set by user
+ * decoding: unused
+ */
+ float dark_masking;
+
//FIXME this should be reordered after kabis API is finished ...
//TODO kill kabi
/*
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a7d775ba06..4b2b0ad6fd 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -433,23 +433,24 @@ int MPV_encode_init(AVCodecContext *avctx)
} else {
s->intra_only = 0;
}
-
+
/* ME algorithm */
if (avctx->me_method == 0)
/* For compatibility */
s->me_method = motion_estimation_method;
else
s->me_method = avctx->me_method;
-
+
/* Fixed QSCALE */
s->fixed_qscale = (avctx->flags & CODEC_FLAG_QSCALE);
s->adaptive_quant= ( s->avctx->lumi_masking
+ || s->avctx->dark_masking
|| s->avctx->temporal_cplx_masking
|| s->avctx->spatial_cplx_masking
|| s->avctx->p_masking)
&& !s->fixed_qscale;
-
+
switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index c84fd223aa..cd0ff81da2 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -465,6 +465,7 @@ static void update_predictor(Predictor *p, double q, double var, double size)
static void adaptive_quantization(MpegEncContext *s, double q){
int i;
const float lumi_masking= s->avctx->lumi_masking / (128.0*128.0);
+ const float dark_masking= s->avctx->dark_masking / (128.0*128.0);
const float temp_cplx_masking= s->avctx->temporal_cplx_masking;
const float spatial_cplx_masking = s->avctx->spatial_cplx_masking;
const float p_masking = s->avctx->p_masking;
@@ -492,7 +493,11 @@ static void adaptive_quantization(MpegEncContext *s, double q){
factor= pow(temp_cplx, - temp_cplx_masking);
}
factor*=pow(spat_cplx, - spatial_cplx_masking);
- factor*= (1.0 - (lumi-128)*(lumi-128)*lumi_masking);
+
+ if(lumi>127)
+ factor*= (1.0 - (lumi-128)*(lumi-128)*lumi_masking);
+ else
+ factor*= (1.0 - (lumi-128)*(lumi-128)*dark_masking);
if(factor<0.00001) factor= 0.00001;