| 3380 | } |
| 3381 | |
| 3382 | static void quantize(SnowContext *s, SubBand *b, IDWTELEM *dst, DWTELEM *src, int stride, int bias){ |
| 3383 | const int w= b->width; |
| 3384 | const int h= b->height; |
| 3385 | const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); |
| 3386 | const int qmul= qexp[qlog&(QROOT-1)]<<((qlog>>QSHIFT) + ENCODER_EXTRA_BITS); |
| 3387 | int x,y, thres1, thres2; |
| 3388 | |
| 3389 | if(s->qlog == LOSSLESS_QLOG){ |
| 3390 | for(y=0; y<h; y++) |
| 3391 | for(x=0; x<w; x++) |
| 3392 | dst[x + y*stride]= src[x + y*stride]; |
| 3393 | return; |
| 3394 | } |
| 3395 | |
| 3396 | bias= bias ? 0 : (3*qmul)>>3; |
| 3397 | thres1= ((qmul - bias)>>QEXPSHIFT) - 1; |
| 3398 | thres2= 2*thres1; |
| 3399 | |
| 3400 | if(!bias){ |
| 3401 | for(y=0; y<h; y++){ |
| 3402 | for(x=0; x<w; x++){ |
| 3403 | int i= src[x + y*stride]; |
| 3404 | |
| 3405 | if((unsigned)(i+thres1) > thres2){ |
| 3406 | if(i>=0){ |
| 3407 | i<<= QEXPSHIFT; |
| 3408 | i/= qmul; //FIXME optimize |
| 3409 | dst[x + y*stride]= i; |
| 3410 | }else{ |
| 3411 | i= -i; |
| 3412 | i<<= QEXPSHIFT; |
| 3413 | i/= qmul; //FIXME optimize |
| 3414 | dst[x + y*stride]= -i; |
| 3415 | } |
| 3416 | }else |
| 3417 | dst[x + y*stride]= 0; |
| 3418 | } |
| 3419 | } |
| 3420 | }else{ |
| 3421 | for(y=0; y<h; y++){ |
| 3422 | for(x=0; x<w; x++){ |
| 3423 | int i= src[x + y*stride]; |
| 3424 | |
| 3425 | if((unsigned)(i+thres1) > thres2){ |
| 3426 | if(i>=0){ |
| 3427 | i<<= QEXPSHIFT; |
| 3428 | i= (i + bias) / qmul; //FIXME optimize |
| 3429 | dst[x + y*stride]= i; |
| 3430 | }else{ |
| 3431 | i= -i; |
| 3432 | i<<= QEXPSHIFT; |
| 3433 | i= (i + bias) / qmul; //FIXME optimize |
| 3434 | dst[x + y*stride]= -i; |
| 3435 | } |
| 3436 | }else |
| 3437 | dst[x + y*stride]= 0; |
| 3438 | } |
| 3439 | } |
no test coverage detected