--- mbcoding.c 2002/07/24 19:34:14 1.22 +++ mbcoding.c 2002/09/08 14:43:04 1.26 @@ -1,53 +1,37 @@ - /****************************************************************************** - * * - * This file is part of XviD, a free MPEG-4 video encoder/decoder * - * * - * XviD is an implementation of a part of one or more MPEG-4 Video tools * - * as specified in ISO/IEC 14496-2 standard. Those intending to use this * - * software module in hardware or software products are advised that its * - * use may infringe existing patents or copyrights, and any such use * - * would be at such party's own risk. The original developer of this * - * software module and his/her company, and subsequent editors and their * - * companies, will have no liability for use of this software or * - * modifications or derivatives thereof. * - * * - * XviD is free software; you can redistribute it and/or modify it * - * under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * XviD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * * - ******************************************************************************/ - - /****************************************************************************** - * * - * mbcoding.c * - * * - * Copyright (C) 2002 - Michael Militzer * - * * - * For more information visit the XviD homepage: http://www.xvid.org * - * * - ******************************************************************************/ - - /****************************************************************************** - * * - * Revision history: * - * * - * 28.06.2002 added check_resync_marker() * - * 14.04.2002 bframe encoding * - * 08.03.2002 initial version; isibaar * - * * - ******************************************************************************/ - - +/***************************************************************************** + * + * XVID MPEG-4 VIDEO CODEC + * - Vector Length Coding tables - + * + * Copyright(C) 2002 Michael Militzer + * + * + * This program is an implementation of a part of one or more MPEG-4 + * Video tools as specified in ISO/IEC 14496-2 standard. Those intending + * to use this software module in hardware or software products are + * advised that its use may infringe existing patents or copyrights, and + * any such use would be at such party's own risk. The original + * developer of this software module and his/her company, and subsequent + * editors and their companies, will have no liability for use of this + * software or modifications or derivatives thereof. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.26 2002/09/08 14:43:04 edgomez Exp $ + * + ****************************************************************************/ #include #include "../portab.h" @@ -61,11 +45,19 @@ #define ABS(X) (((X)>0)?(X):-(X)) #define CLIP(X,A) (X > A) ? (A) : (X) -VLC intra_table[524032]; -VLC inter_table[524032]; - -VLC DCT3Dintra[4096]; -VLC DCT3Dinter[4096]; +/***************************************************************************** + * Local data + ****************************************************************************/ + +static VLC intra_table[524032]; +static VLC inter_table[524032]; + +static VLC DCT3Dintra[4096]; +static VLC DCT3Dinter[4096]; + +/***************************************************************************** + * Functions + ****************************************************************************/ void init_vlc_tables(void) @@ -82,8 +74,11 @@ vlc[0] = intra_table; vlc[1] = inter_table; - // generate encoding vlc lookup tables - // the lookup table idea is taken from the excellent fame project by Vivien Chapellier + /* + * Generate encoding vlc lookup tables + * the lookup table idea is taken from the excellent fame project + * by Vivien Chapellier + */ for (i = 0; i < 4; i++) { intra = i % 2; last = i / 2; @@ -370,8 +365,10 @@ // interlacing if (frame->global_flags & XVID_INTERLACING) { - BitstreamPutBit(bs, pMB->field_dct); - DEBUG1("codep: field_dct: ", pMB->field_dct); + if (pMB->cbp) { + BitstreamPutBit(bs, pMB->field_dct); + DEBUG1("codep: field_dct: ", pMB->field_dct); + } // if inter block, write field ME flag if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { @@ -413,18 +410,6 @@ { if (frame->coding_type == P_VOP) { - if (pMB->cbp == 0 && pMB->mode == MODE_INTER && pMB->mvs[0].x == 0 && - pMB->mvs[0].y == 0) { - -#ifdef _DISABLE_SKIP -/* disable SKIP when Bframes active until some workaround for the B-SKIP problem is found */ - BitstreamPutBit(bs, 0); // always coded! -#else - BitstreamPutBit(bs, 1); // not_coded - - return; -#endif - } else BitstreamPutBit(bs, 0); // coded } @@ -435,6 +420,15 @@ } + +void +MBSkip(Bitstream * bs) +{ + BitstreamPutBit(bs, 1); // not coded + return; +} + + /*************************************************************** * bframe encoding start ***************************************************************/ @@ -561,8 +555,8 @@ } if (mb->mode == MODE_DIRECT) { - CodeVector(bs, mb->mvs[0].x, 1, pStat); /* fcode is always 1 for delta vector */ - CodeVector(bs, mb->mvs[0].y, 1, pStat); /* prediction is always (0,0) */ + CodeVector(bs, mb->deltamv.x, 1, pStat); /* fcode is always 1 for delta vector */ + CodeVector(bs, mb->deltamv.y, 1, pStat); /* prediction is always (0,0) */ } for (i = 0; i < 6; i++) {