diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2023-03-24 00:18:06 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2023-04-07 23:40:48 +0200 |
commit | e5a261e93dac7ba72982249df5af704e45dc7d63 (patch) | |
tree | 9e385b89be7bf4eb95f183925cf0381a35421d15 /libavcodec | |
parent | 00c20730714abcb4f42a9f96edee25345373f11a (diff) | |
download | ffmpeg-e5a261e93dac7ba72982249df5af704e45dc7d63.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.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 16d2b7c302..a0e8745ce3 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1544,10 +1544,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; @@ -1558,9 +1558,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; } } |