Mercurial > mplayer.hg
comparison libmpcodecs/vf_spp.c @ 11296:86916e46d445
different / faster / simpler "quantization"
filtered images look like with the old quantization (to me at least) if anyone notices a difference then tell me ASAP
author | michael |
---|---|
date | Mon, 27 Oct 2003 21:12:29 +0000 |
parents | 8b9ae87aff0f |
children | 14dbc88adaf0 |
comparison
equal
deleted
inserted
replaced
11295:8b9ae87aff0f | 11296:86916e46d445 |
---|---|
84 #define SHIFT 22 | 84 #define SHIFT 22 |
85 | 85 |
86 static inline void requantize(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ | 86 static inline void requantize(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ |
87 int i; | 87 int i; |
88 const int qmul= qp<<1; | 88 const int qmul= qp<<1; |
89 const int qadd= (qp-1)|1; | |
90 const int qinv= ((1<<(SHIFT-3)) + qmul/2)/ qmul; | |
91 int bias= 0; //FIXME | 89 int bias= 0; //FIXME |
92 unsigned int threshold1, threshold2; | 90 unsigned int threshold1, threshold2; |
93 | 91 |
94 threshold1= (1<<SHIFT) - bias - 1; | 92 threshold1= qmul*((1<<3) - bias) - 1; |
95 threshold2= (threshold1<<1); | 93 threshold2= (threshold1<<1); |
96 | 94 |
97 memset(dst, 0, 64*sizeof(DCTELEM)); | 95 memset(dst, 0, 64*sizeof(DCTELEM)); |
98 dst[0]= (src[0] + 4)>>3;; | 96 dst[0]= (src[0] + 4)>>3; |
99 | 97 |
100 for(i=1; i<64; i++){ | 98 for(i=1; i<64; i++){ |
101 int level= qinv*src[i]; | 99 int level= src[i]; |
102 if(((unsigned)(level+threshold1))>threshold2){ | 100 if(((unsigned)(level+threshold1))>threshold2){ |
103 const int j= permutation[i]; | 101 const int j= permutation[i]; |
104 if(level>0){ | 102 dst[j]= (level + 4)>>3; |
105 level= (bias + level)>>SHIFT; | |
106 dst[j]= level*qmul + qadd; | |
107 }else{ | |
108 level= (bias - level)>>SHIFT; | |
109 dst[j]= -level*qmul - qadd; | |
110 } | |
111 } | 103 } |
112 } | 104 } |
113 } | 105 } |
114 | 106 |
115 static inline void add_block(int16_t *dst, int stride, DCTELEM block[64]){ | 107 static inline void add_block(int16_t *dst, int stride, DCTELEM block[64]){ |