comparison h264.c @ 2707:360024d31dab libavcodec

H.264 deblocking optimizations (mmx for chroma_bS4 case, convert existing cases to 8-bit math)
author lorenm
date Wed, 18 May 2005 09:17:22 +0000
parents 7d86ebbccecf
children 16258de8ae06
comparison
equal deleted inserted replaced
2706:a23c44f7ed60 2707:360024d31dab
5663 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 5663 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 );
5664 const int alpha = alpha_table[index_a]; 5664 const int alpha = alpha_table[index_a];
5665 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 5665 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
5666 5666
5667 if( bS[0] < 4 ) { 5667 if( bS[0] < 4 ) {
5668 int tc[4]; 5668 int8_t tc[4];
5669 for(i=0; i<4; i++) 5669 for(i=0; i<4; i++)
5670 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1; 5670 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1;
5671 h->s.dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc); 5671 h->s.dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
5672 } else { 5672 } else {
5673 /* 16px edge length, because bS=4 is triggered by being at 5673 /* 16px edge length, because bS=4 is triggered by being at
5724 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 5724 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 );
5725 const int alpha = alpha_table[index_a]; 5725 const int alpha = alpha_table[index_a];
5726 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 5726 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
5727 5727
5728 if( bS[0] < 4 ) { 5728 if( bS[0] < 4 ) {
5729 int tc[4]; 5729 int8_t tc[4];
5730 for(i=0; i<4; i++) 5730 for(i=0; i<4; i++)
5731 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0; 5731 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0;
5732 h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc); 5732 h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
5733 } else { 5733 } else {
5734 /* 8px edge length, see filter_mb_edgev */ 5734 h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
5735 for( d = 0; d < 8; d++ ){
5736 const int p0 = pix[-1];
5737 const int p1 = pix[-2];
5738 const int q0 = pix[0];
5739 const int q1 = pix[1];
5740
5741 if( ABS( p0 - q0 ) < alpha &&
5742 ABS( p1 - p0 ) < beta &&
5743 ABS( q1 - q0 ) < beta ) {
5744
5745 pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
5746 pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
5747 tprintf("filter_mb_edgecv i:%d d:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
5748 }
5749 pix += stride;
5750 }
5751 } 5735 }
5752 } 5736 }
5753 5737
5754 static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int bS[8], int qp[2] ) { 5738 static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int bS[8], int qp[2] ) {
5755 int i; 5739 int i;
5911 const int alpha = alpha_table[index_a]; 5895 const int alpha = alpha_table[index_a];
5912 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 5896 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
5913 const int pix_next = stride; 5897 const int pix_next = stride;
5914 5898
5915 if( bS[0] < 4 ) { 5899 if( bS[0] < 4 ) {
5916 int tc[4]; 5900 int8_t tc[4];
5917 for(i=0; i<4; i++) 5901 for(i=0; i<4; i++)
5918 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1; 5902 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1;
5919 h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc); 5903 h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
5920 } else { 5904 } else {
5921 /* 16px edge length, see filter_mb_edgev */ 5905 /* 16px edge length, see filter_mb_edgev */
5968 static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) { 5952 static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) {
5969 int i, d; 5953 int i, d;
5970 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 5954 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 );
5971 const int alpha = alpha_table[index_a]; 5955 const int alpha = alpha_table[index_a];
5972 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 5956 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
5973 const int pix_next = stride;
5974 5957
5975 if( bS[0] < 4 ) { 5958 if( bS[0] < 4 ) {
5976 int tc[4]; 5959 int8_t tc[4];
5977 for(i=0; i<4; i++) 5960 for(i=0; i<4; i++)
5978 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0; 5961 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0;
5979 h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc); 5962 h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
5980 } else { 5963 } else {
5981 /* 8px edge length, see filter_mb_edgev */ 5964 h->s.dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
5982 for( d = 0; d < 8; d++ ) {
5983 const int p0 = pix[-1*pix_next];
5984 const int p1 = pix[-2*pix_next];
5985 const int q0 = pix[0];
5986 const int q1 = pix[1*pix_next];
5987
5988 if( ABS( p0 - q0 ) < alpha &&
5989 ABS( p1 - p0 ) < beta &&
5990 ABS( q1 - q0 ) < beta ) {
5991
5992 pix[-pix_next] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
5993 pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
5994 tprintf("filter_mb_edgech i:%d d:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, qp, index_a, alpha, beta, bS[i], pix[-3*pix_next], p1, p0, q0, q1, pix[2*pix_next], pix[-2*pix_next], pix[-pix_next], pix[0], pix[pix_next]);
5995 }
5996 pix++;
5997 }
5998 } 5965 }
5999 } 5966 }
6000 5967
6001 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { 5968 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
6002 MpegEncContext * const s = &h->s; 5969 MpegEncContext * const s = &h->s;