--- mbtransquant.c 2003/11/24 22:06:19 1.21.2.20 +++ mbtransquant.c 2004/05/26 05:46:20 1.23.2.2 @@ -21,7 +21,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: mbtransquant.c,v 1.21.2.20 2003/11/24 22:06:19 edgomez Exp $ + * $Id: mbtransquant.c,v 1.23.2.2 2004/05/26 05:46:20 syskin Exp $ * ****************************************************************************/ @@ -138,12 +138,12 @@ /* Quantize the block */ start_timer(); - quant[mpeg](&data[0 * 64], &qcoeff[0 * 64], pMB->quant, scaler_lum); - quant[mpeg](&data[1 * 64], &qcoeff[1 * 64], pMB->quant, scaler_lum); - quant[mpeg](&data[2 * 64], &qcoeff[2 * 64], pMB->quant, scaler_lum); - quant[mpeg](&data[3 * 64], &qcoeff[3 * 64], pMB->quant, scaler_lum); - quant[mpeg](&data[4 * 64], &qcoeff[4 * 64], pMB->quant, scaler_chr); - quant[mpeg](&data[5 * 64], &qcoeff[5 * 64], pMB->quant, scaler_chr); + quant[mpeg](&data[0 * 64], &qcoeff[0 * 64], pMB->quant, scaler_lum, pParam->mpeg_quant_matrices); + quant[mpeg](&data[1 * 64], &qcoeff[1 * 64], pMB->quant, scaler_lum, pParam->mpeg_quant_matrices); + quant[mpeg](&data[2 * 64], &qcoeff[2 * 64], pMB->quant, scaler_lum, pParam->mpeg_quant_matrices); + quant[mpeg](&data[3 * 64], &qcoeff[3 * 64], pMB->quant, scaler_lum, pParam->mpeg_quant_matrices); + quant[mpeg](&data[4 * 64], &qcoeff[4 * 64], pMB->quant, scaler_chr, pParam->mpeg_quant_matrices); + quant[mpeg](&data[5 * 64], &qcoeff[5 * 64], pMB->quant, scaler_chr, pParam->mpeg_quant_matrices); stop_quant_timer(); } @@ -168,12 +168,12 @@ scaler_chr = get_dc_scaler(iQuant, 0); start_timer(); - dequant[mpeg](&qcoeff[0 * 64], &data[0 * 64], iQuant, scaler_lum); - dequant[mpeg](&qcoeff[1 * 64], &data[1 * 64], iQuant, scaler_lum); - dequant[mpeg](&qcoeff[2 * 64], &data[2 * 64], iQuant, scaler_lum); - dequant[mpeg](&qcoeff[3 * 64], &data[3 * 64], iQuant, scaler_lum); - dequant[mpeg](&qcoeff[4 * 64], &data[4 * 64], iQuant, scaler_chr); - dequant[mpeg](&qcoeff[5 * 64], &data[5 * 64], iQuant, scaler_chr); + dequant[mpeg](&qcoeff[0 * 64], &data[0 * 64], iQuant, scaler_lum, pParam->mpeg_quant_matrices); + dequant[mpeg](&qcoeff[1 * 64], &data[1 * 64], iQuant, scaler_lum, pParam->mpeg_quant_matrices); + dequant[mpeg](&qcoeff[2 * 64], &data[2 * 64], iQuant, scaler_lum, pParam->mpeg_quant_matrices); + dequant[mpeg](&qcoeff[3 * 64], &data[3 * 64], iQuant, scaler_lum, pParam->mpeg_quant_matrices); + dequant[mpeg](&qcoeff[4 * 64], &data[4 * 64], iQuant, scaler_chr, pParam->mpeg_quant_matrices); + dequant[mpeg](&qcoeff[5 * 64], &data[5 * 64], iQuant, scaler_chr, pParam->mpeg_quant_matrices); stop_iquant_timer(); } @@ -183,7 +183,8 @@ int Q, const uint16_t * const Zigzag, const uint16_t * const QuantMatrix, - int Non_Zero); + int Non_Zero, + int Sum); /* Quantize all blocks -- Inter mode */ static __inline uint8_t @@ -214,9 +215,10 @@ /* Quantize the block */ start_timer(); - sum = quant[mpeg](&qcoeff[i*64], &data[i*64], pMB->quant); + sum = quant[mpeg](&qcoeff[i*64], &data[i*64], pMB->quant, pParam->mpeg_quant_matrices); if(sum && (frame->vop_flags & XVID_VOP_TRELLISQUANT)) { + const uint16_t *matrix; const static uint16_t h263matrix[] = { 16, 16, 16, 16, 16, 16, 16, 16, @@ -228,10 +230,13 @@ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }; + + matrix = (mpeg)?get_inter_matrix(pParam->mpeg_quant_matrices):h263matrix; sum = dct_quantize_trellis_c(&qcoeff[i*64], &data[i*64], pMB->quant, &scan_tables[0][0], - (mpeg)?(uint16_t*)get_inter_matrix():h263matrix, - 63); + matrix, + 63, + sum); } stop_quant_timer(); @@ -281,12 +286,12 @@ mpeg = !!(pParam->vol_flags & XVID_VOL_MPEGQUANT); start_timer(); - if(cbp & (1 << (5 - 0))) dequant[mpeg](&data[0 * 64], &qcoeff[0 * 64], iQuant); - if(cbp & (1 << (5 - 1))) dequant[mpeg](&data[1 * 64], &qcoeff[1 * 64], iQuant); - if(cbp & (1 << (5 - 2))) dequant[mpeg](&data[2 * 64], &qcoeff[2 * 64], iQuant); - if(cbp & (1 << (5 - 3))) dequant[mpeg](&data[3 * 64], &qcoeff[3 * 64], iQuant); - if(cbp & (1 << (5 - 4))) dequant[mpeg](&data[4 * 64], &qcoeff[4 * 64], iQuant); - if(cbp & (1 << (5 - 5))) dequant[mpeg](&data[5 * 64], &qcoeff[5 * 64], iQuant); + if(cbp & (1 << (5 - 0))) dequant[mpeg](&data[0 * 64], &qcoeff[0 * 64], iQuant, pParam->mpeg_quant_matrices); + if(cbp & (1 << (5 - 1))) dequant[mpeg](&data[1 * 64], &qcoeff[1 * 64], iQuant, pParam->mpeg_quant_matrices); + if(cbp & (1 << (5 - 2))) dequant[mpeg](&data[2 * 64], &qcoeff[2 * 64], iQuant, pParam->mpeg_quant_matrices); + if(cbp & (1 << (5 - 3))) dequant[mpeg](&data[3 * 64], &qcoeff[3 * 64], iQuant, pParam->mpeg_quant_matrices); + if(cbp & (1 << (5 - 4))) dequant[mpeg](&data[4 * 64], &qcoeff[4 * 64], iQuant, pParam->mpeg_quant_matrices); + if(cbp & (1 << (5 - 5))) dequant[mpeg](&data[5 * 64], &qcoeff[5 * 64], iQuant, pParam->mpeg_quant_matrices); stop_iquant_timer(); } @@ -369,11 +374,6 @@ transfer_operation_16to8_t *transfer_op = NULL; - if (pMB->field_dct) { - next_block = stride; - stride *= 2; - } - /* Makes this vars booleans */ vop_reduced = !!(frame->vop_flags & XVID_VOP_REDUCED); @@ -382,6 +382,11 @@ pU_Cur = pCurrent->u + (y_pos << (3+vop_reduced)) * stride2 + (x_pos << (3+vop_reduced)); pV_Cur = pCurrent->v + (y_pos << (3+vop_reduced)) * stride2 + (x_pos << (3+vop_reduced)); + if (pMB->field_dct) { + next_block = stride; + stride *= 2; + } + /* Block size */ cst = 8<=0) { Out[Zigzag[i]] = Nodes[i].Level; - sum += abs(Nodes[i].Level); + Sum += abs(Nodes[i].Level); i -= Nodes[i].Run; } - return sum; + return Sum; } /* original version including heavy debugging info */