29 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
30 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
31 |
* |
* |
32 |
* $Id: mbcoding.c,v 1.29 2002-09-10 21:29:03 edgomez Exp $ |
* $Id: mbcoding.c,v 1.30 2002-09-10 22:52:12 edgomez Exp $ |
33 |
* |
* |
34 |
****************************************************************************/ |
****************************************************************************/ |
35 |
|
|
437 |
return; |
return; |
438 |
} |
} |
439 |
|
|
|
#if 0 |
|
|
/*************************************************************** |
|
|
* bframe encoding start |
|
|
***************************************************************/ |
|
|
|
|
|
/* |
|
|
mbtype |
|
|
0 1b direct(h263) mvdb |
|
|
1 01b interpolate mc+q dbquant, mvdf, mvdb |
|
|
2 001b backward mc+q dbquant, mvdb |
|
|
3 0001b forward mc+q dbquant, mvdf |
|
|
*/ |
|
|
|
|
|
void |
|
|
put_bvop_mbtype(Bitstream * bs, |
|
|
int value) |
|
|
{ |
|
|
switch (value) { |
|
|
case 0: |
|
|
BitstreamPutBit(bs, 1); |
|
|
return; |
|
|
|
|
|
case 1: |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 1); |
|
|
return; |
|
|
|
|
|
case 2: |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 1); |
|
|
return; |
|
|
|
|
|
case 3: |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 0); |
|
|
BitstreamPutBit(bs, 1); |
|
|
return; |
|
|
|
|
|
default:; // invalid! |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/* |
|
|
dbquant |
|
|
-2 10b |
|
|
0 0b |
|
|
+2 11b |
|
|
*/ |
|
|
|
|
|
void |
|
|
put_bvop_dbquant(Bitstream * bs, |
|
|
int value) |
|
|
{ |
|
|
switch (value) { |
|
|
case 0: |
|
|
BitstreamPutBit(bs, 0); |
|
|
return; |
|
|
|
|
|
case -2: |
|
|
BitstreamPutBit(bs, 1); |
|
|
BitstreamPutBit(bs, 0); |
|
|
return; |
|
|
|
|
|
case 2: |
|
|
BitstreamPutBit(bs, 1); |
|
|
BitstreamPutBit(bs, 1); |
|
|
return; |
|
|
|
|
|
default:; // invalid |
|
|
} |
|
|
} |
|
|
|
|
|
void |
|
|
MBCodingBVOP(const MACROBLOCK * mb, |
|
|
const int16_t qcoeff[6 * 64], |
|
|
const int32_t fcode, |
|
|
const int32_t bcode, |
|
|
Bitstream * bs, |
|
|
Statistics * pStat) |
|
|
{ |
|
|
int i; |
|
|
|
|
|
/* ------------------------------------------------------------------ |
|
|
when a block is skipped it is decoded DIRECT(0,0) |
|
|
hence is interpolated from forward & backward frames |
|
|
------------------------------------------------------------------ */ |
|
|
|
|
|
if (mb->mode == MODE_DIRECT_NONE_MV) { |
|
|
BitstreamPutBit(bs, 1); // skipped |
|
|
return; |
|
|
} |
|
|
|
|
|
BitstreamPutBit(bs, 0); // not skipped |
|
|
|
|
|
if (mb->cbp == 0) { |
|
|
BitstreamPutBit(bs, 1); // cbp == 0 |
|
|
} else { |
|
|
BitstreamPutBit(bs, 0); // cbp == xxx |
|
|
} |
|
|
|
|
|
put_bvop_mbtype(bs, mb->mode); |
|
|
|
|
|
if (mb->cbp) { |
|
|
BitstreamPutBits(bs, mb->cbp, 6); |
|
|
} |
|
|
|
|
|
if (mb->mode != MODE_DIRECT && mb->cbp != 0) { |
|
|
put_bvop_dbquant(bs, 0); // todo: mb->dquant = 0 |
|
|
} |
|
|
|
|
|
if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_FORWARD) { |
|
|
CodeVector(bs, mb->pmvs[0].x, fcode, pStat); |
|
|
CodeVector(bs, mb->pmvs[0].y, fcode, pStat); |
|
|
} |
|
|
|
|
|
if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_BACKWARD) { |
|
|
CodeVector(bs, mb->b_pmvs[0].x, bcode, pStat); |
|
|
CodeVector(bs, mb->b_pmvs[0].y, bcode, pStat); |
|
|
} |
|
|
|
|
|
if (mb->mode == MODE_DIRECT) { |
|
|
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++) { |
|
|
if (mb->cbp & (1 << (5 - i))) { |
|
|
CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
440 |
/***************************************************************************** |
/***************************************************************************** |
441 |
* decoding stuff starts here |
* decoding stuff starts here |
442 |
****************************************************************************/ |
****************************************************************************/ |