--- mbtransquant.c 2002/09/04 06:24:37 1.11 +++ mbtransquant.c 2002/11/12 16:05:27 1.11.2.5 @@ -65,12 +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 3 /* skip blocks having a coefficient sum below this value */ - -/* this isnt pretty, but its better than 20 ifdefs */ +#define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ void MBTransQuantIntra(const MBParam * pParam, @@ -193,6 +193,8 @@ stop_interlacing_timer(); for (i = 0; i < 6; i++) { + uint32_t increase_limit = (iQuant == 1) ? 1 : 0; + /* * no need to transfer 8->16-bit * (this is performed already in motion compensation) @@ -211,7 +213,7 @@ stop_quant_timer(); } - if ((sum >= TOOSMALL_LIMIT) || (qcoeff[i*64] != 0) || + 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) { @@ -576,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 }; @@ -616,11 +632,7 @@ } } - if (frame > field) { - MBFrameToField(data); - } - - return (frame > field); + return (frame >= (field + 350)); }