comparison dsputil.c @ 612:c0005de2be59 libavcodec

new ratecontrol code
author michaelni
date Sun, 25 Aug 2002 21:19:50 +0000
parents 3f8824eb4690
children 92e99e506920
comparison
equal deleted inserted replaced
611:3214d3f4519e 612:c0005de2be59
30 void (*diff_pixels)(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride); 30 void (*diff_pixels)(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride);
31 void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); 31 void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
32 void (*add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); 32 void (*add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
33 void (*gmc1)(UINT8 *dst, UINT8 *src, int srcStride, int h, int x16, int y16, int rounder); 33 void (*gmc1)(UINT8 *dst, UINT8 *src, int srcStride, int h, int x16, int y16, int rounder);
34 void (*clear_blocks)(DCTELEM *blocks); 34 void (*clear_blocks)(DCTELEM *blocks);
35 int (*pix_sum)(UINT8 * pix, int line_size);
36 int (*pix_norm1)(UINT8 * pix, int line_size);
35 37
36 op_pixels_abs_func pix_abs16x16; 38 op_pixels_abs_func pix_abs16x16;
37 op_pixels_abs_func pix_abs16x16_x2; 39 op_pixels_abs_func pix_abs16x16_x2;
38 op_pixels_abs_func pix_abs16x16_y2; 40 op_pixels_abs_func pix_abs16x16_y2;
39 op_pixels_abs_func pix_abs16x16_xy2; 41 op_pixels_abs_func pix_abs16x16_xy2;
157 lastIndexAfterPerm= zigzag_direct[lastIndex]; 159 lastIndexAfterPerm= zigzag_direct[lastIndex];
158 zigzag_end[lastIndex]= lastIndexAfterPerm + 1; 160 zigzag_end[lastIndex]= lastIndexAfterPerm + 1;
159 } 161 }
160 } 162 }
161 163
164 int pix_sum_c(UINT8 * pix, int line_size)
165 {
166 int s, i, j;
167
168 s = 0;
169 for (i = 0; i < 16; i++) {
170 for (j = 0; j < 16; j += 8) {
171 s += pix[0];
172 s += pix[1];
173 s += pix[2];
174 s += pix[3];
175 s += pix[4];
176 s += pix[5];
177 s += pix[6];
178 s += pix[7];
179 pix += 8;
180 }
181 pix += line_size - 16;
182 }
183 return s;
184 }
185
186 int pix_norm1_c(UINT8 * pix, int line_size)
187 {
188 int s, i, j;
189 UINT32 *sq = squareTbl + 256;
190
191 s = 0;
192 for (i = 0; i < 16; i++) {
193 for (j = 0; j < 16; j += 8) {
194 s += sq[pix[0]];
195 s += sq[pix[1]];
196 s += sq[pix[2]];
197 s += sq[pix[3]];
198 s += sq[pix[4]];
199 s += sq[pix[5]];
200 s += sq[pix[6]];
201 s += sq[pix[7]];
202 pix += 8;
203 }
204 pix += line_size - 16;
205 }
206 return s;
207 }
208
209
162 void get_pixels_c(DCTELEM *restrict block, const UINT8 *pixels, int line_size) 210 void get_pixels_c(DCTELEM *restrict block, const UINT8 *pixels, int line_size)
163 { 211 {
164 int i; 212 int i;
165 213
166 /* read the pixels */ 214 /* read the pixels */
239 pixels[7] = cm[pixels[7] + block[7]]; 287 pixels[7] = cm[pixels[7] + block[7]];
240 pixels += line_size; 288 pixels += line_size;
241 block += 8; 289 block += 8;
242 } 290 }
243 } 291 }
244
245 #if 0 292 #if 0
246 293
247 #define PIXOP2(OPNAME, OP) \ 294 #define PIXOP2(OPNAME, OP) \
248 void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ 295 void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
249 {\ 296 {\
567 OPNAME ## _no_rnd_pixels_y2,\ 614 OPNAME ## _no_rnd_pixels_y2,\
568 OPNAME ## _no_rnd_pixels_xy2,\ 615 OPNAME ## _no_rnd_pixels_xy2,\
569 }; 616 };
570 #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) ) 617 #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) )
571 #endif 618 #endif
572
573 #define op_put(a, b) a = b 619 #define op_put(a, b) a = b
574 620
575 PIXOP2(avg, op_avg) 621 PIXOP2(avg, op_avg)
576 PIXOP2(put, op_put) 622 PIXOP2(put, op_put)
577 #undef op_avg 623 #undef op_avg
682 #define avg2(a,b) ((a+b+1)>>1) 728 #define avg2(a,b) ((a+b+1)>>1)
683 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) 729 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
684 730
685 #define op_avg(a, b) a = avg2(a, b) 731 #define op_avg(a, b) a = avg2(a, b)
686 #define op_sub(a, b) a -= b 732 #define op_sub(a, b) a -= b
733 #define op_put(a, b) a = b
687 734
688 PIXOP(DCTELEM, sub, op_sub, 8) 735 PIXOP(DCTELEM, sub, op_sub, 8)
736 PIXOP(uint8_t, avg, op_avg, line_size)
737 PIXOP(uint8_t, put, op_put, line_size)
689 738
690 /* not rounding primitives */ 739 /* not rounding primitives */
691 #undef avg2 740 #undef avg2
692 #undef avg4 741 #undef avg4
693 #define avg2(a,b) ((a+b)>>1) 742 #define avg2(a,b) ((a+b)>>1)
694 #define avg4(a,b,c,d) ((a+b+c+d+1)>>2) 743 #define avg4(a,b,c,d) ((a+b+c+d+1)>>2)
695 744
745 PIXOP(uint8_t, avg_no_rnd, op_avg, line_size)
746 PIXOP(uint8_t, put_no_rnd, op_put, line_size)
696 /* motion estimation */ 747 /* motion estimation */
697 748
698 #undef avg2 749 #undef avg2
699 #undef avg4 750 #undef avg4
700 #endif 751 #endif
1259 diff_pixels = diff_pixels_c; 1310 diff_pixels = diff_pixels_c;
1260 put_pixels_clamped = put_pixels_clamped_c; 1311 put_pixels_clamped = put_pixels_clamped_c;
1261 add_pixels_clamped = add_pixels_clamped_c; 1312 add_pixels_clamped = add_pixels_clamped_c;
1262 gmc1= gmc1_c; 1313 gmc1= gmc1_c;
1263 clear_blocks= clear_blocks_c; 1314 clear_blocks= clear_blocks_c;
1315 pix_sum= pix_sum_c;
1316 pix_norm1= pix_norm1_c;
1264 1317
1265 pix_abs16x16 = pix_abs16x16_c; 1318 pix_abs16x16 = pix_abs16x16_c;
1266 pix_abs16x16_x2 = pix_abs16x16_x2_c; 1319 pix_abs16x16_x2 = pix_abs16x16_x2_c;
1267 pix_abs16x16_y2 = pix_abs16x16_y2_c; 1320 pix_abs16x16_y2 = pix_abs16x16_y2_c;
1268 pix_abs16x16_xy2 = pix_abs16x16_xy2_c; 1321 pix_abs16x16_xy2 = pix_abs16x16_xy2_c;