--- mbcoding.c 2003/06/09 13:52:12 1.44.2.12 +++ mbcoding.c 2003/10/03 13:47:00 1.44.2.15 @@ -19,7 +19,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: mbcoding.c,v 1.44.2.12 2003/06/09 13:52:12 edgomez Exp $ + * $Id: mbcoding.c,v 1.44.2.15 2003/10/03 13:47:00 syskin Exp $ * ****************************************************************************/ @@ -49,7 +49,7 @@ #ifdef BIGLUT static VLC coeff_VLC[2][2][4096][64]; VLC *intra_table; -static VLC *inter_table; +static VLC *inter_table; #else static VLC coeff_VLC[2][2][64][64]; #endif @@ -93,7 +93,7 @@ #ifdef BIGLUT intra_table = coeff_VLC[1]; - inter_table = coeff_VLC[0]; + inter_table = coeff_VLC[0]; #endif @@ -251,7 +251,7 @@ for (l=limit; l<= 2*limit-1; l++) { - sprite_trajectory_code[l+16384].code = l; + sprite_trajectory_code[l+16384].code = l; sprite_trajectory_code[l+16384].len = k+1; } } @@ -514,7 +514,7 @@ /* returns the number of bits required to encode qcoeff */ -int +int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag) { int bits = 0; @@ -765,9 +765,9 @@ Bitstream * bs, Statistics * pStat) { - if (frame->coding_type != I_VOP) + if (frame->coding_type != I_VOP) BitstreamPutBit(bs, 0); /* not_coded */ - + if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); else @@ -775,16 +775,6 @@ } - -/* moved to mbcoding.h so that in can be 'static __inline' */ -#if 0 -void -MBSkip(Bitstream * bs) -{ - BitstreamPutBit(bs, 1); /* not coded */ -} -#endif - /*************************************************************** * bframe encoding start ***************************************************************/ @@ -848,17 +838,22 @@ void -MBCodingBVOP(const MACROBLOCK * mb, +MBCodingBVOP(const FRAMEINFO * const frame, + const MACROBLOCK * mb, const int16_t qcoeff[6 * 64], const int32_t fcode, const int32_t bcode, Bitstream * bs, - Statistics * pStat, - int direction) + Statistics * pStat) { int vcode = fcode; unsigned int i; + const uint16_t *scan_table = + frame->vop_flags & XVID_VOP_ALTERNATESCAN ? + scan_tables[2] : scan_tables[0]; + + /* ------------------------------------------------------------------ when a block is skipped it is decoded DIRECT(0,0) hence is interpolated from forward & backward frames @@ -887,6 +882,25 @@ put_bvop_dbquant(bs, 0); /* todo: mb->dquant = 0 */ } + if (frame->vol_flags & XVID_VOL_INTERLACING) { + if (mb->cbp) { + BitstreamPutBit(bs, mb->field_dct); + DPRINTF(XVID_DEBUG_MB,"codep: field_dct: %i\n", mb->field_dct); + } + + /* if not direct block, write field ME flag */ + if (mb->mode != MODE_DIRECT) { + BitstreamPutBit(bs, 0 /*mb->field_pred*/); /* field ME not implemented */ + + /* write field prediction references */ + /* if (mb->field_pred) { + BitstreamPutBit(bs, mb->field_for_top); + BitstreamPutBit(bs, mb->field_for_bot); + }*/ + } + } + + switch (mb->mode) { case MODE_INTERPOLATE: CodeVector(bs, mb->pmvs[1].x, vcode, pStat); /* forward vector of interpolate mode */ @@ -927,7 +941,7 @@ * for BVOP addbits == max(fcode,bcode) - 1 * returns true or false */ -int +int check_resync_marker(Bitstream * bs, int addbits) { uint32_t nbits; @@ -967,7 +981,7 @@ { uint32_t index; - + index = MIN(BitstreamShowBits(bs, 9), 256); BitstreamSkip(bs, mcbpc_inter_table[index].len); @@ -1535,7 +1549,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, }, /* intra = 0, last = 1 */ - { + { 0, 40, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1579,9 +1593,9 @@ VLC sprite_trajectory_code[32768]; VLC sprite_trajectory_len[15] = { - { 0x00 , 2}, - { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3}, - { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7F, 7}, { 0xFE, 8}, + { 0x00 , 2}, + { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3}, + { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7E, 7}, { 0xFE, 8}, { 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} };