summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-03-24 00:18:06 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2023-04-21 01:55:18 +0200
commitf36a243c044ec59dbbbb6a1f88d48b3d7b74d2ee (patch)
tree8d3bc73e3d4a531b1c7c48e799a4f196011c63d3 /libavcodec
parent022eee9ad9717b7984eba14bb379c908bd8d9ac5 (diff)
downloadffmpeg-f36a243c044ec59dbbbb6a1f88d48b3d7b74d2ee.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')
-rw-r--r--libavcodec/snowenc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 3f2a75a670..971f9361c2 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1543,10 +1543,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;
@@ -1557,9 +1557,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;
}
}