--- mbtransquant.c 2004/12/05 13:56:13 1.26 +++ mbtransquant.c 2005/12/09 04:45:35 1.30 @@ -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.26 2004/12/05 13:56:13 syskin Exp $ + * $Id: mbtransquant.c,v 1.30 2005/12/09 04:45:35 syskin Exp $ * ****************************************************************************/ @@ -90,12 +90,12 @@ /* Perform DCT */ start_timer(); - fdct(&data[0 * 64]); - fdct(&data[1 * 64]); - fdct(&data[2 * 64]); - fdct(&data[3 * 64]); - fdct(&data[4 * 64]); - fdct(&data[5 * 64]); + fdct((short * const)&data[0 * 64]); + fdct((short * const)&data[1 * 64]); + fdct((short * const)&data[2 * 64]); + fdct((short * const)&data[3 * 64]); + fdct((short * const)&data[4 * 64]); + fdct((short * const)&data[5 * 64]); stop_dct_timer(); } @@ -105,12 +105,12 @@ const uint8_t cbp) { start_timer(); - if(cbp & (1 << (5 - 0))) idct(&data[0 * 64]); - if(cbp & (1 << (5 - 1))) idct(&data[1 * 64]); - if(cbp & (1 << (5 - 2))) idct(&data[2 * 64]); - if(cbp & (1 << (5 - 3))) idct(&data[3 * 64]); - if(cbp & (1 << (5 - 4))) idct(&data[4 * 64]); - if(cbp & (1 << (5 - 5))) idct(&data[5 * 64]); + if(cbp & (1 << (5 - 0))) idct((short * const)&data[0 * 64]); + if(cbp & (1 << (5 - 1))) idct((short * const)&data[1 * 64]); + if(cbp & (1 << (5 - 2))) idct((short * const)&data[2 * 64]); + if(cbp & (1 << (5 - 3))) idct((short * const)&data[3 * 64]); + if(cbp & (1 << (5 - 4))) idct((short * const)&data[4 * 64]); + if(cbp & (1 << (5 - 5))) idct((short * const)&data[5 * 64]); stop_idct_timer(); } @@ -183,7 +183,8 @@ const uint16_t * const Zigzag, const uint16_t * const QuantMatrix, int Non_Zero, - int Sum); + int Sum, + int Lambda_Mod); /* Quantize all blocks -- Inter mode */ static __inline uint8_t @@ -216,7 +217,7 @@ sum = quant[mpeg](&qcoeff[i*64], &data[i*64], pMB->quant, pParam->mpeg_quant_matrices); - if(sum && (frame->vop_flags & XVID_VOP_TRELLISQUANT)) { + if(sum && (pMB->quant > 2) && (frame->vop_flags & XVID_VOP_TRELLISQUANT)) { const uint16_t *matrix; const static uint16_t h263matrix[] = { @@ -235,7 +236,8 @@ pMB->quant, &scan_tables[0][0], matrix, 63, - sum); + sum, + pMB->lambda[i]); } stop_quant_timer(); @@ -764,7 +766,8 @@ const uint16_t * const Zigzag, const uint16_t * const QuantMatrix, int Non_Zero, - int Sum) + int Sum, + int Lambda_Mod) { /* Note: We should search last non-zero coeffs on *real* DCT input coeffs @@ -774,12 +777,12 @@ * helps. */ typedef struct { int16_t Run, Level; } NODE; - NODE Nodes[65], Last; + NODE Nodes[65], Last = { 0, 0}; uint32_t Run_Costs0[64+1]; uint32_t * const Run_Costs = Run_Costs0 + 1; /* it's 1/lambda, actually */ - const int Lambda = Trellis_Lambda_Tabs[Q-1]; + const int Lambda = (Lambda_Mod*Trellis_Lambda_Tabs[Q-1])>>LAMBDA_EXP; int Run_Start = -1; uint32_t Min_Cost = 2<