comparison h264.c @ 4118:a1786732cd62 libavcodec

merge clip() into the alpha/beta/tc0 tables (10% faster filter_mb_fast() on P3)
author michael
date Wed, 01 Nov 2006 19:34:30 +0000
parents 4ce3923d5806
children 171e768324cd
comparison
equal deleted inserted replaced
4117:c647eff78d91 4118:a1786732cd62
6737 } 6737 }
6738 6738
6739 6739
6740 static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) { 6740 static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
6741 int i, d; 6741 int i, d;
6742 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 6742 const int index_a = qp + h->slice_alpha_c0_offset;
6743 const int alpha = alpha_table[index_a]; 6743 const int alpha = (alpha_table+52)[index_a];
6744 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 6744 const int beta = (beta_table+52)[qp + h->slice_beta_offset];
6745 6745
6746 if( bS[0] < 4 ) { 6746 if( bS[0] < 4 ) {
6747 int8_t tc[4]; 6747 int8_t tc[4];
6748 for(i=0; i<4; i++) 6748 for(i=0; i<4; i++)
6749 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1; 6749 tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] : -1;
6750 h->s.dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc); 6750 h->s.dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
6751 } else { 6751 } else {
6752 /* 16px edge length, because bS=4 is triggered by being at 6752 /* 16px edge length, because bS=4 is triggered by being at
6753 * the edge of an intra MB, so all 4 bS are the same */ 6753 * the edge of an intra MB, so all 4 bS are the same */
6754 for( d = 0; d < 16; d++ ) { 6754 for( d = 0; d < 16; d++ ) {
6798 } 6798 }
6799 } 6799 }
6800 } 6800 }
6801 static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) { 6801 static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
6802 int i; 6802 int i;
6803 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 6803 const int index_a = qp + h->slice_alpha_c0_offset;
6804 const int alpha = alpha_table[index_a]; 6804 const int alpha = (alpha_table+52)[index_a];
6805 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 6805 const int beta = (beta_table+52)[qp + h->slice_beta_offset];
6806 6806
6807 if( bS[0] < 4 ) { 6807 if( bS[0] < 4 ) {
6808 int8_t tc[4]; 6808 int8_t tc[4];
6809 for(i=0; i<4; i++) 6809 for(i=0; i<4; i++)
6810 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0; 6810 tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] + 1 : 0;
6811 h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc); 6811 h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
6812 } else { 6812 } else {
6813 h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta); 6813 h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
6814 } 6814 }
6815 } 6815 }
6831 if( bS[bS_index] == 0 ) { 6831 if( bS[bS_index] == 0 ) {
6832 continue; 6832 continue;
6833 } 6833 }
6834 6834
6835 qp_index = MB_FIELD ? (i >> 3) : (i & 1); 6835 qp_index = MB_FIELD ? (i >> 3) : (i & 1);
6836 index_a = clip( qp[qp_index] + h->slice_alpha_c0_offset, 0, 51 ); 6836 index_a = qp[qp_index] + h->slice_alpha_c0_offset;
6837 alpha = alpha_table[index_a]; 6837 alpha = (alpha_table+52)[index_a];
6838 beta = beta_table[clip( qp[qp_index] + h->slice_beta_offset, 0, 51 )]; 6838 beta = (beta_table+52)[qp[qp_index] + h->slice_beta_offset];
6839 6839
6840 if( bS[bS_index] < 4 ) { 6840 if( bS[bS_index] < 4 ) {
6841 const int tc0 = tc0_table[index_a][bS[bS_index] - 1]; 6841 const int tc0 = (tc0_table+52)[index_a][bS[bS_index] - 1];
6842 const int p0 = pix[-1]; 6842 const int p0 = pix[-1];
6843 const int p1 = pix[-2]; 6843 const int p1 = pix[-2];
6844 const int p2 = pix[-3]; 6844 const int p2 = pix[-3];
6845 const int q0 = pix[0]; 6845 const int q0 = pix[0];
6846 const int q1 = pix[1]; 6846 const int q1 = pix[1];
6925 if( bS[bS_index] == 0 ) { 6925 if( bS[bS_index] == 0 ) {
6926 continue; 6926 continue;
6927 } 6927 }
6928 6928
6929 qp_index = MB_FIELD ? (i >> 2) : (i & 1); 6929 qp_index = MB_FIELD ? (i >> 2) : (i & 1);
6930 index_a = clip( qp[qp_index] + h->slice_alpha_c0_offset, 0, 51 ); 6930 index_a = qp[qp_index] + h->slice_alpha_c0_offset;
6931 alpha = alpha_table[index_a]; 6931 alpha = (alpha_table+52)[index_a];
6932 beta = beta_table[clip( qp[qp_index] + h->slice_beta_offset, 0, 51 )]; 6932 beta = (beta_table+52)[qp[qp_index] + h->slice_beta_offset];
6933 6933
6934 if( bS[bS_index] < 4 ) { 6934 if( bS[bS_index] < 4 ) {
6935 const int tc = tc0_table[index_a][bS[bS_index] - 1] + 1; 6935 const int tc = (tc0_table+52)[index_a][bS[bS_index] - 1] + 1;
6936 const int p0 = pix[-1]; 6936 const int p0 = pix[-1];
6937 const int p1 = pix[-2]; 6937 const int p1 = pix[-2];
6938 const int q0 = pix[0]; 6938 const int q0 = pix[0];
6939 const int q1 = pix[1]; 6939 const int q1 = pix[1];
6940 6940
6965 } 6965 }
6966 } 6966 }
6967 6967
6968 static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) { 6968 static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
6969 int i, d; 6969 int i, d;
6970 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 6970 const int index_a = qp + h->slice_alpha_c0_offset;
6971 const int alpha = alpha_table[index_a]; 6971 const int alpha = (alpha_table+52)[index_a];
6972 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 6972 const int beta = (beta_table+52)[qp + h->slice_beta_offset];
6973 const int pix_next = stride; 6973 const int pix_next = stride;
6974 6974
6975 if( bS[0] < 4 ) { 6975 if( bS[0] < 4 ) {
6976 int8_t tc[4]; 6976 int8_t tc[4];
6977 for(i=0; i<4; i++) 6977 for(i=0; i<4; i++)
6978 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] : -1; 6978 tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] : -1;
6979 h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc); 6979 h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
6980 } else { 6980 } else {
6981 /* 16px edge length, see filter_mb_edgev */ 6981 /* 16px edge length, see filter_mb_edgev */
6982 for( d = 0; d < 16; d++ ) { 6982 for( d = 0; d < 16; d++ ) {
6983 const int p0 = pix[-1*pix_next]; 6983 const int p0 = pix[-1*pix_next];
7025 } 7025 }
7026 } 7026 }
7027 7027
7028 static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) { 7028 static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
7029 int i; 7029 int i;
7030 const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); 7030 const int index_a = qp + h->slice_alpha_c0_offset;
7031 const int alpha = alpha_table[index_a]; 7031 const int alpha = (alpha_table+52)[index_a];
7032 const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; 7032 const int beta = (beta_table+52)[qp + h->slice_beta_offset];
7033 7033
7034 if( bS[0] < 4 ) { 7034 if( bS[0] < 4 ) {
7035 int8_t tc[4]; 7035 int8_t tc[4];
7036 for(i=0; i<4; i++) 7036 for(i=0; i<4; i++)
7037 tc[i] = bS[i] ? tc0_table[index_a][bS[i] - 1] + 1 : 0; 7037 tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] + 1 : 0;
7038 h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc); 7038 h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
7039 } else { 7039 } else {
7040 h->s.dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta); 7040 h->s.dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
7041 } 7041 }
7042 } 7042 }