aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/snowenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-03-24 00:18:06 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2023-03-27 13:37:25 +0200
commita9655efa6f6df36d88bcba6abd8d7e335a262642 (patch)
tree95f328bc552c7c99eeb34a48ac589fa31e6eef95 /libavcodec/snowenc.c
parent8ec5085898e35cff252d8acc848285fecffb43c1 (diff)
downloadffmpeg-a9655efa6f6df36d88bcba6abd8d7e335a262642.tar.gz
avcodec/snowenc: Fix visual weight calculation
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 5b5fcadea059ab458a886261a5b7a1cc134b517a) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/snowenc.c')
-rw-r--r--libavcodec/snowenc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 96b0d320bc..c99313f1f6 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1533,10 +1533,10 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
int level, orientation, x, y;
for(level=0; level<s->spatial_decomposition_count; level++){
+ int64_t error=0;
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
IDWTELEM *ibuf= b->ibuf;
- int64_t error=0;
memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
@@ -1547,9 +1547,13 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
error += d*d;
}
}
-
+ if (orientation == 2)
+ error /= 2;
b->qlog= (int)(QROOT * log2(352256.0/sqrt(error)) + 0.5);
+ if (orientation != 1)
+ error = 0;
}
+ p->band[level][1].qlog = p->band[level][2].qlog;
}
}