Mercurial > libavcodec.hg
comparison snow.c @ 5575:a6f5ed050335 libavcodec
use more bits on the encoder side
negligible increase in quality
author | michael |
---|---|
date | Thu, 23 Aug 2007 10:49:14 +0000 |
parents | c6fac563ec28 |
children | 3ae03eacbe9f |
comparison
equal
deleted
inserted
replaced
5574:33718fb21437 | 5575:a6f5ed050335 |
---|---|
391 .level= 0, | 391 .level= 0, |
392 }; | 392 }; |
393 | 393 |
394 #define LOG2_MB_SIZE 4 | 394 #define LOG2_MB_SIZE 4 |
395 #define MB_SIZE (1<<LOG2_MB_SIZE) | 395 #define MB_SIZE (1<<LOG2_MB_SIZE) |
396 #define ENCODER_EXTRA_BITS 4 | |
396 | 397 |
397 typedef struct x_and_coeff{ | 398 typedef struct x_and_coeff{ |
398 int16_t x; | 399 int16_t x; |
399 uint16_t coeff; | 400 uint16_t coeff; |
400 } x_and_coeff; | 401 } x_and_coeff; |
3400 static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int bias){ | 3401 static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int bias){ |
3401 const int level= b->level; | 3402 const int level= b->level; |
3402 const int w= b->width; | 3403 const int w= b->width; |
3403 const int h= b->height; | 3404 const int h= b->height; |
3404 const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); | 3405 const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); |
3405 const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); | 3406 const int qmul= qexp[qlog&(QROOT-1)]<<((qlog>>QSHIFT) + ENCODER_EXTRA_BITS); |
3406 int x,y, thres1, thres2; | 3407 int x,y, thres1, thres2; |
3407 // START_TIMER | 3408 // START_TIMER |
3408 | 3409 |
3409 if(s->qlog == LOSSLESS_QLOG) return; | 3410 if(s->qlog == LOSSLESS_QLOG) return; |
3410 | 3411 |
4192 for(y=0; y<h; y++){ | 4193 for(y=0; y<h; y++){ |
4193 for(x=0; x<w; x++){ | 4194 for(x=0; x<w; x++){ |
4194 s->spatial_dwt_buffer[y*w + x]= (s->spatial_dwt_buffer[y*w + x] + (1<<(FRAC_BITS-1))-1)>>FRAC_BITS; | 4195 s->spatial_dwt_buffer[y*w + x]= (s->spatial_dwt_buffer[y*w + x] + (1<<(FRAC_BITS-1))-1)>>FRAC_BITS; |
4195 } | 4196 } |
4196 } | 4197 } |
4198 }else{ | |
4199 for(y=0; y<h; y++){ | |
4200 for(x=0; x<w; x++){ | |
4201 s->spatial_dwt_buffer[y*w + x]<<=ENCODER_EXTRA_BITS; | |
4202 } | |
4203 } | |
4197 } | 4204 } |
4198 | 4205 |
4199 ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); | 4206 ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); |
4200 | 4207 |
4201 if(s->pass1_rc && plane_index==0){ | 4208 if(s->pass1_rc && plane_index==0){ |