--- mbtransquant.c 2003/02/15 15:22:19 1.21 +++ mbtransquant.c 2003/03/10 00:38:49 1.21.2.2 @@ -83,14 +83,14 @@ uint32_t stride = pParam->edged_width; uint32_t stride2 = stride / 2; - uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); + uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8); uint32_t i; uint32_t iQuant = frame->quant; uint8_t *pY_Cur, *pU_Cur, *pV_Cur; IMAGE *pCurrent = &frame->image; start_timer(); - if ((frame->global_flags & XVID_REDUCED)) + if ((frame->vop_flags & XVID_REDUCED)) { pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); @@ -119,7 +119,7 @@ /* XXX: rrv+interlacing is buggy */ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING) && + if ((frame->vol_flags & XVID_INTERLACING) && (x_pos>0) && (x_posmb_width-1) && (y_pos>0) && (y_posmb_height-1)) { pMB->field_dct = MBDecideFieldDCT(data); @@ -133,7 +133,7 @@ fdct(&data[i * 64]); stop_dct_timer(); - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); stop_quant_timer(); @@ -146,7 +146,7 @@ /* speedup: dont decode when encoding only ivops */ if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0) { - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); stop_iquant_timer(); @@ -172,7 +172,7 @@ } start_timer(); - if ((frame->global_flags & XVID_REDUCED)) + if ((frame->vop_flags & XVID_REDUCED)) { copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); @@ -207,7 +207,7 @@ uint32_t stride = pParam->edged_width; uint32_t stride2 = stride / 2; - uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); + uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8); uint32_t i; uint32_t iQuant = frame->quant; uint8_t *pY_Cur, *pU_Cur, *pV_Cur; @@ -215,7 +215,7 @@ uint32_t sum; IMAGE *pCurrent = &frame->image; - if ((frame->global_flags & XVID_REDUCED)) + if ((frame->vop_flags & XVID_REDUCED)) { pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); @@ -228,7 +228,7 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING) && + if ((frame->vol_flags & XVID_INTERLACING) && (x_pos>0) && (x_posmb_width-1) && (y_pos>0) && (y_posmb_height-1)) { pMB->field_dct = MBDecideFieldDCT(data); @@ -246,7 +246,7 @@ fdct(&data[i * 64]); stop_dct_timer(); - if (pParam->m_quant_type == 0) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); stop_quant_timer(); @@ -259,7 +259,7 @@ if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) || (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); stop_iquant_timer(); @@ -283,7 +283,7 @@ } start_timer(); - if ((frame->global_flags & XVID_REDUCED)) + if ((frame->vop_flags & XVID_REDUCED)) { if (cbp & 32) add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); @@ -361,6 +361,8 @@ MBTransQuantInterBVOP(const MBParam * pParam, FRAMEINFO * frame, MACROBLOCK * pMB, + const uint32_t x_pos, + const uint32_t y_pos, int16_t data[6 * 64], int16_t qcoeff[6 * 64]) { @@ -371,7 +373,20 @@ MBfDCT(pParam,frame,pMB,data); cbp = MBQuantInter(pParam,frame->quant,data,qcoeff); -/* we don't have to DeQuant, iDCT and Transfer back data for B-frames */ + /* + * History comment: + * we don't have to DeQuant, iDCT and Transfer back data for B-frames + */ + + /* + * As an exception to the previous rule, if we are willing to have extra + * stats then we have to DeQuant, iDCT and Transfer back the data :-) + */ + if(frame->vop_flags & XVID_EXTRASTATS) { + MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp); + MBiDCT(data,cbp); + MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp); + } return cbp; } @@ -387,7 +402,7 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING)) { + if ((frame->vol_flags & XVID_INTERLACING)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); @@ -411,7 +426,7 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING)) { + if ((frame->vol_flags & XVID_INTERLACING)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); @@ -419,7 +434,7 @@ for (i = 0; i < 6; i++) { uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); stop_quant_timer(); @@ -451,7 +466,7 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING)) { + if ((frame->vol_flags & XVID_INTERLACING)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); @@ -459,7 +474,7 @@ for (i = 0; i < 6; i++) { uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); stop_quant_timer(); @@ -482,7 +497,7 @@ for (i = 0; i < 6; i++) { uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); stop_iquant_timer(); @@ -507,7 +522,7 @@ for (i = 0; i < 6; i++) { - if (pParam->m_quant_type == 0) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); stop_quant_timer(); @@ -536,7 +551,7 @@ for (i = 0; i < 6; i++) { if (cbp & (1 << (5 - i))) { - if (pParam->m_quant_type == H263_QUANT) { + if (!(pParam->vol_flags & XVID_MPEGQUANT)) { start_timer(); dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); stop_iquant_timer();