Mercurial > libavcodec.hg
comparison mpegvideo.c @ 764:d4726182dfd2 libavcodec
optimize block_permute()
optimize dct_quantize_c()
dont permute s->q_inter/intra_matrix
| author | michaelni |
|---|---|
| date | Wed, 23 Oct 2002 15:11:07 +0000 |
| parents | 339db642859d |
| children | 8d36b35a7e6e |
comparison
equal
deleted
inserted
replaced
| 763:339db642859d | 764:d4726182dfd2 |
|---|---|
| 92 /* 16 <= qscale * quant_matrix[i] <= 7905 */ | 92 /* 16 <= qscale * quant_matrix[i] <= 7905 */ |
| 93 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | 93 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ |
| 94 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ | 94 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ |
| 95 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ | 95 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
| 96 | 96 |
| 97 qmat[qscale][j] = (int)((UINT64_C(1) << QMAT_SHIFT) / | 97 qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / |
| 98 (qscale * quant_matrix[j])); | 98 (qscale * quant_matrix[j])); |
| 99 } | 99 } |
| 100 } else if (s->fdct == fdct_ifast) { | 100 } else if (s->fdct == fdct_ifast) { |
| 101 for(i=0;i<64;i++) { | 101 for(i=0;i<64;i++) { |
| 102 const int j= s->idct_permutation[i]; | 102 const int j= s->idct_permutation[i]; |
| 103 /* 16 <= qscale * quant_matrix[i] <= 7905 */ | 103 /* 16 <= qscale * quant_matrix[i] <= 7905 */ |
| 104 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | 104 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ |
| 105 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ | 105 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ |
| 106 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ | 106 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
| 107 | 107 |
| 108 qmat[qscale][j] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) / | 108 qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) / |
| 109 (aanscales[i] * qscale * quant_matrix[j])); | 109 (aanscales[i] * qscale * quant_matrix[j])); |
| 110 } | 110 } |
| 111 } else { | 111 } else { |
| 112 for(i=0;i<64;i++) { | 112 for(i=0;i<64;i++) { |
| 113 const int j= s->idct_permutation[i]; | 113 const int j= s->idct_permutation[i]; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scantable){ | 138 void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scantable){ |
| 139 int i; | 139 int i; |
| 140 int end; | 140 int end; |
| 141 | |
| 142 st->scantable= src_scantable; | |
| 141 | 143 |
| 142 for(i=0; i<64; i++){ | 144 for(i=0; i<64; i++){ |
| 143 int j; | 145 int j; |
| 144 j = src_scantable[i]; | 146 j = src_scantable[i]; |
| 145 st->permutated[i] = s->idct_permutation[j]; | 147 st->permutated[i] = s->idct_permutation[j]; |
| 2966 DCTELEM *block, int n, | 2968 DCTELEM *block, int n, |
| 2967 int qscale, int *overflow) | 2969 int qscale, int *overflow) |
| 2968 { | 2970 { |
| 2969 int i, j, level, last_non_zero, q; | 2971 int i, j, level, last_non_zero, q; |
| 2970 const int *qmat; | 2972 const int *qmat; |
| 2973 const UINT8 *scantable= s->intra_scantable.scantable; | |
| 2971 int bias; | 2974 int bias; |
| 2972 int max=0; | 2975 int max=0; |
| 2973 unsigned int threshold1, threshold2; | 2976 unsigned int threshold1, threshold2; |
| 2974 | 2977 |
| 2975 s->fdct (block); | 2978 s->fdct (block); |
| 2976 | |
| 2977 #ifndef ARCH_ALPHA /* Alpha uses unpermuted matrix */ | |
| 2978 /* we need this permutation so that we correct the IDCT | |
| 2979 permutation. will be moved into DCT code */ | |
| 2980 block_permute(block, s->idct_permutation); //FIXME remove | |
| 2981 #endif | |
| 2982 | 2979 |
| 2983 if (s->mb_intra) { | 2980 if (s->mb_intra) { |
| 2984 if (!s->h263_aic) { | 2981 if (!s->h263_aic) { |
| 2985 if (n < 4) | 2982 if (n < 4) |
| 2986 q = s->y_dc_scale; | 2983 q = s->y_dc_scale; |
| 3005 } | 3002 } |
| 3006 threshold1= (1<<QMAT_SHIFT) - bias - 1; | 3003 threshold1= (1<<QMAT_SHIFT) - bias - 1; |
| 3007 threshold2= (threshold1<<1); | 3004 threshold2= (threshold1<<1); |
| 3008 | 3005 |
| 3009 for(;i<64;i++) { | 3006 for(;i<64;i++) { |
| 3010 j = s->intra_scantable.permutated[i]; | 3007 j = scantable[i]; |
| 3011 level = block[j]; | 3008 level = block[j]; |
| 3012 level = level * qmat[j]; | 3009 level = level * qmat[j]; |
| 3013 | 3010 |
| 3014 // if( bias+level >= (1<<(QMAT_SHIFT - 3)) | 3011 // if( bias+level >= (1<<(QMAT_SHIFT - 3)) |
| 3015 // || bias-level >= (1<<(QMAT_SHIFT - 3))){ | 3012 // || bias-level >= (1<<(QMAT_SHIFT - 3))){ |
| 3027 block[j]=0; | 3024 block[j]=0; |
| 3028 } | 3025 } |
| 3029 } | 3026 } |
| 3030 *overflow= s->max_qcoeff < max; //overflow might have happend | 3027 *overflow= s->max_qcoeff < max; //overflow might have happend |
| 3031 | 3028 |
| 3029 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ | |
| 3030 ff_block_permute(block, s->idct_permutation, scantable, last_non_zero); | |
| 3031 | |
| 3032 return last_non_zero; | 3032 return last_non_zero; |
| 3033 } | 3033 } |
| 3034 | 3034 |
| 3035 static void dct_unquantize_mpeg1_c(MpegEncContext *s, | 3035 static void dct_unquantize_mpeg1_c(MpegEncContext *s, |
| 3036 DCTELEM *block, int n, int qscale) | 3036 DCTELEM *block, int n, int qscale) |
