comparison dsputil.c @ 2415:db2cf6005d19 libavcodec

H.264 weighted prediction. Bidirectional weighting has not been tested for bitwise accuracy, but looks correct.
author lorenm
date Fri, 07 Jan 2005 05:56:07 +0000
parents 23e7af611c34
children bfa9192a22ce
comparison
equal deleted inserted replaced
2414:18d77621fbc7 2415:db2cf6005d19
2371 #undef op_avg 2371 #undef op_avg
2372 #undef op_put 2372 #undef op_put
2373 #undef op2_avg 2373 #undef op2_avg
2374 #undef op2_put 2374 #undef op2_put
2375 #endif 2375 #endif
2376
2377 static inline uint8_t clip1(int x){
2378 if(x > 255) return 255;
2379 if(x < 0) return 0;
2380 return x;
2381 }
2382 #define op_scale1(x) block[x] = clip1( (block[x]*weight + offset) >> log2_denom )
2383 #define op_scale2(x) dst[x] = clip( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1), 0, 255 )
2384 #define H264_WEIGHT(W,H) \
2385 static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \
2386 int x, y; \
2387 offset <<= log2_denom; \
2388 if(log2_denom) offset += 1<<(log2_denom-1); \
2389 for(y=0; y<H; y++, block += stride){ \
2390 op_scale1(0); \
2391 op_scale1(1); \
2392 if(W==2) continue; \
2393 op_scale1(2); \
2394 op_scale1(3); \
2395 if(W==4) continue; \
2396 op_scale1(4); \
2397 op_scale1(5); \
2398 op_scale1(6); \
2399 op_scale1(7); \
2400 if(W==8) continue; \
2401 op_scale1(8); \
2402 op_scale1(9); \
2403 op_scale1(10); \
2404 op_scale1(11); \
2405 op_scale1(12); \
2406 op_scale1(13); \
2407 op_scale1(14); \
2408 op_scale1(15); \
2409 } \
2410 } \
2411 static void biweight_h264_pixels ## W ## x ## H ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets){ \
2412 int x, y; \
2413 int offset = (offsets + offsetd + 1) >> 1; \
2414 offset = ((offset << 1) + 1) << log2_denom; \
2415 for(y=0; y<H; y++, dst += stride, src += stride){ \
2416 op_scale2(0); \
2417 op_scale2(1); \
2418 if(W==2) continue; \
2419 op_scale2(2); \
2420 op_scale2(3); \
2421 if(W==4) continue; \
2422 op_scale2(4); \
2423 op_scale2(5); \
2424 op_scale2(6); \
2425 op_scale2(7); \
2426 if(W==8) continue; \
2427 op_scale2(8); \
2428 op_scale2(9); \
2429 op_scale2(10); \
2430 op_scale2(11); \
2431 op_scale2(12); \
2432 op_scale2(13); \
2433 op_scale2(14); \
2434 op_scale2(15); \
2435 } \
2436 }
2437
2438 H264_WEIGHT(16,16)
2439 H264_WEIGHT(16,8)
2440 H264_WEIGHT(8,16)
2441 H264_WEIGHT(8,8)
2442 H264_WEIGHT(8,4)
2443 H264_WEIGHT(4,8)
2444 H264_WEIGHT(4,4)
2445 H264_WEIGHT(4,2)
2446 H264_WEIGHT(2,4)
2447 H264_WEIGHT(2,2)
2448
2449 #undef op_scale1
2450 #undef op_scale2
2451 #undef H264_WEIGHT
2376 2452
2377 static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){ 2453 static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
2378 uint8_t *cm = cropTbl + MAX_NEG_CROP; 2454 uint8_t *cm = cropTbl + MAX_NEG_CROP;
2379 int i; 2455 int i;
2380 2456
3602 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c; 3678 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;
3603 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c; 3679 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
3604 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c; 3680 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
3605 c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c; 3681 c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
3606 3682
3683 c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;
3684 c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;
3685 c->weight_h264_pixels_tab[2]= weight_h264_pixels8x16_c;
3686 c->weight_h264_pixels_tab[3]= weight_h264_pixels8x8_c;
3687 c->weight_h264_pixels_tab[4]= weight_h264_pixels8x4_c;
3688 c->weight_h264_pixels_tab[5]= weight_h264_pixels4x8_c;
3689 c->weight_h264_pixels_tab[6]= weight_h264_pixels4x4_c;
3690 c->weight_h264_pixels_tab[7]= weight_h264_pixels4x2_c;
3691 c->weight_h264_pixels_tab[8]= weight_h264_pixels2x4_c;
3692 c->weight_h264_pixels_tab[9]= weight_h264_pixels2x2_c;
3693 c->biweight_h264_pixels_tab[0]= biweight_h264_pixels16x16_c;
3694 c->biweight_h264_pixels_tab[1]= biweight_h264_pixels16x8_c;
3695 c->biweight_h264_pixels_tab[2]= biweight_h264_pixels8x16_c;
3696 c->biweight_h264_pixels_tab[3]= biweight_h264_pixels8x8_c;
3697 c->biweight_h264_pixels_tab[4]= biweight_h264_pixels8x4_c;
3698 c->biweight_h264_pixels_tab[5]= biweight_h264_pixels4x8_c;
3699 c->biweight_h264_pixels_tab[6]= biweight_h264_pixels4x4_c;
3700 c->biweight_h264_pixels_tab[7]= biweight_h264_pixels4x2_c;
3701 c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c;
3702 c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c;
3703
3607 c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c; 3704 c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
3608 c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; 3705 c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
3609 c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; 3706 c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
3610 c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; 3707 c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
3611 c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; 3708 c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;