--- mbtransquant.c 2002/08/09 19:58:41 1.8 +++ mbtransquant.c 2002/09/25 16:51:05 1.11.2.2 @@ -42,10 +42,10 @@ * * * Revision history: * * * - * 29.03.2002 interlacing speedup - used transfer strides instead of - * manual field-to-frame conversion - * 26.03.2002 interlacing support - moved transfers outside loops - * 22.12.2001 get_dc_scaler() moved to common.h + * 29.03.2002 interlacing speedup - used transfer strides instead of * + * manual field-to-frame conversion * + * 26.03.2002 interlacing support - moved transfers outside loops * + * 22.12.2001 get_dc_scaler() moved to common.h * * 19.11.2001 introduced coefficient thresholding (Isibaar) * * 17.11.2001 initial version * * * @@ -65,10 +65,12 @@ #include "../quant/quant_h263.h" #include "../encoder.h" +MBFIELDTEST_PTR MBFieldTest; + #define MIN(X, Y) ((X)<(Y)?(X):(Y)) #define MAX(X, Y) ((X)>(Y)?(X):(Y)) -#define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ +#define TOOSMALL_LIMIT 2 /* skip blocks having a coefficient sum below this value */ /* this isnt pretty, but its better than 20 ifdefs */ @@ -105,7 +107,9 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING)) { + if ((frame->global_flags & XVID_INTERLACING) && + (x_pos>0) && (x_posmb_width-1) && + (y_pos>0) && (y_posmb_height-1)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); @@ -183,7 +187,9 @@ start_timer(); pMB->field_dct = 0; - if ((frame->global_flags & XVID_INTERLACING)) { + if ((frame->global_flags & XVID_INTERLACING) && + (x_pos>0) && (x_posmb_width-1) && + (y_pos>0) && (y_posmb_height-1)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); @@ -207,7 +213,8 @@ stop_quant_timer(); } - if (sum >= TOOSMALL_LIMIT) { // skip block ? + if ((sum >= TOOSMALL_LIMIT) || (qcoeff[i*64] != 0) || + (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { if (pParam->m_quant_type == H263_QUANT) { start_timer(); @@ -295,8 +302,6 @@ 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]) { @@ -573,13 +578,27 @@ -/* if sum(diff between field lines) < sum(diff between frame lines), use field dct */ +/* permute block and return field dct choice */ uint32_t MBDecideFieldDCT(int16_t data[6 * 64]) { + uint32_t field = MBFieldTest(data); + + if (field) { + MBFrameToField(data); + } + return field; +} + + +/* if sum(diff between field lines) < sum(diff between frame lines), use field dct */ + +uint32_t +MBFieldTest_c(int16_t data[6 * 64]) +{ const uint8_t blocks[] = { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 }; const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 }; @@ -613,11 +632,7 @@ } } - if (frame > field) { - MBFrameToField(data); - } - - return (frame > field); + return (frame >= field); }