comparison dsputil.c @ 2633:72e6ffa1f3a5 libavcodec

MMX for H.264 deblocking filter
author lorenm
date Mon, 25 Apr 2005 01:01:41 +0000
parents e25782262d7d
children e2780f828440
comparison
equal deleted inserted replaced
2632:67171616ead6 2633:72e6ffa1f3a5
2638 src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4; 2638 src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
2639 } 2639 }
2640 } 2640 }
2641 } 2641 }
2642 2642
2643 static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int *tc0)
2644 {
2645 int i, d;
2646 for( i = 0; i < 4; i++ ) {
2647 if( tc0[i] < 0 ) {
2648 pix += 4*ystride;
2649 continue;
2650 }
2651 for( d = 0; d < 4; d++ ) {
2652 const int p0 = pix[-1*xstride];
2653 const int p1 = pix[-2*xstride];
2654 const int p2 = pix[-3*xstride];
2655 const int q0 = pix[0];
2656 const int q1 = pix[1*xstride];
2657 const int q2 = pix[2*xstride];
2658
2659 if( ABS( p0 - q0 ) < alpha &&
2660 ABS( p1 - p0 ) < beta &&
2661 ABS( q1 - q0 ) < beta ) {
2662
2663 int tc = tc0[i];
2664 int i_delta;
2665
2666 if( ABS( p2 - p0 ) < beta ) {
2667 pix[-2*xstride] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
2668 tc++;
2669 }
2670 if( ABS( q2 - q0 ) < beta ) {
2671 pix[xstride] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
2672 tc++;
2673 }
2674
2675 i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
2676 pix[-xstride] = clip_uint8( p0 + i_delta ); /* p0' */
2677 pix[0] = clip_uint8( q0 - i_delta ); /* q0' */
2678 }
2679 pix += ystride;
2680 }
2681 }
2682 }
2683 static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int *tc0)
2684 {
2685 h264_loop_filter_luma_c(pix, stride, 1, alpha, beta, tc0);
2686 }
2687 static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int *tc0)
2688 {
2689 h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0);
2690 }
2691
2692 static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int *tc0)
2693 {
2694 int i, d;
2695 for( i = 0; i < 4; i++ ) {
2696 const int tc = tc0[i];
2697 if( tc <= 0 ) {
2698 pix += 2*ystride;
2699 continue;
2700 }
2701 for( d = 0; d < 2; d++ ) {
2702 const int p0 = pix[-1*xstride];
2703 const int p1 = pix[-2*xstride];
2704 const int q0 = pix[0];
2705 const int q1 = pix[1*xstride];
2706
2707 if( ABS( p0 - q0 ) < alpha &&
2708 ABS( p1 - p0 ) < beta &&
2709 ABS( q1 - q0 ) < beta ) {
2710
2711 int delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
2712
2713 pix[-xstride] = clip_uint8( p0 + delta ); /* p0' */
2714 pix[0] = clip_uint8( q0 - delta ); /* q0' */
2715 }
2716 pix += ystride;
2717 }
2718 }
2719 }
2720 static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int *tc0)
2721 {
2722 h264_loop_filter_chroma_c(pix, stride, 1, alpha, beta, tc0);
2723 }
2724 static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int *tc0)
2725 {
2726 h264_loop_filter_chroma_c(pix, 1, stride, alpha, beta, tc0);
2727 }
2728
2643 static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) 2729 static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2644 { 2730 {
2645 int s, i; 2731 int s, i;
2646 2732
2647 s = 0; 2733 s = 0;
3737 3823
3738 c->add_bytes= add_bytes_c; 3824 c->add_bytes= add_bytes_c;
3739 c->diff_bytes= diff_bytes_c; 3825 c->diff_bytes= diff_bytes_c;
3740 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; 3826 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
3741 c->bswap_buf= bswap_buf; 3827 c->bswap_buf= bswap_buf;
3828
3829 c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c;
3830 c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c;
3831 c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c;
3832 c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c;
3742 3833
3743 c->h263_h_loop_filter= h263_h_loop_filter_c; 3834 c->h263_h_loop_filter= h263_h_loop_filter_c;
3744 c->h263_v_loop_filter= h263_v_loop_filter_c; 3835 c->h263_v_loop_filter= h263_v_loop_filter_c;
3745 3836
3746 c->h261_loop_filter= h261_loop_filter_c; 3837 c->h261_loop_filter= h261_loop_filter_c;