412 |
Statistics * pStat) |
Statistics * pStat) |
413 |
{ |
{ |
414 |
|
|
|
int intra = (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q); |
|
|
|
|
415 |
if (frame->coding_type == P_VOP) { |
if (frame->coding_type == P_VOP) { |
|
if (pMB->cbp == 0 && pMB->mode == MODE_INTER && pMB->mvs[0].x == 0 && |
|
|
pMB->mvs[0].y == 0) { |
|
|
BitstreamPutBit(bs, 1); // not_coded |
|
|
return; |
|
|
} else |
|
416 |
BitstreamPutBit(bs, 0); // coded |
BitstreamPutBit(bs, 0); // coded |
417 |
} |
} |
418 |
|
|
419 |
if (intra) |
if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) |
420 |
CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); |
CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); |
421 |
else |
else |
422 |
CodeBlockInter(frame, pMB, qcoeff, bs, pStat); |
CodeBlockInter(frame, pMB, qcoeff, bs, pStat); |
423 |
|
|
424 |
} |
} |
425 |
|
|
426 |
|
|
427 |
|
void |
428 |
|
MBSkip(Bitstream * bs) |
429 |
|
{ |
430 |
|
BitstreamPutBit(bs, 1); // not coded |
431 |
|
return; |
432 |
|
} |
433 |
|
|
434 |
|
|
435 |
/*************************************************************** |
/*************************************************************** |
436 |
* bframe encoding start |
* bframe encoding start |
437 |
***************************************************************/ |
***************************************************************/ |
520 |
int i; |
int i; |
521 |
|
|
522 |
/* ------------------------------------------------------------------ |
/* ------------------------------------------------------------------ |
523 |
when a block is skipped it is decoded DIRECT(0,) |
when a block is skipped it is decoded DIRECT(0,0) |
524 |
hence are interpolated from forward & backward frames |
hence is interpolated from forward & backward frames |
525 |
------------------------------------------------------------------ */ |
------------------------------------------------------------------ */ |
526 |
|
|
527 |
if (mb->mode == 5) { |
if (mb->mode == MODE_DIRECT_NONE_MV) { |
528 |
BitstreamPutBit(bs, 1); // skipped |
BitstreamPutBit(bs, 1); // skipped |
529 |
return; |
return; |
530 |
} |
} |
558 |
} |
} |
559 |
|
|
560 |
if (mb->mode == MODE_DIRECT) { |
if (mb->mode == MODE_DIRECT) { |
561 |
// TODO: direct |
CodeVector(bs, mb->deltamv.x, 1, pStat); /* fcode is always 1 for delta vector */ |
562 |
|
CodeVector(bs, mb->deltamv.y, 1, pStat); /* prediction is always (0,0) */ |
563 |
} |
} |
564 |
|
|
565 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
576 |
***************************************************************/ |
***************************************************************/ |
577 |
|
|
578 |
|
|
|
void |
|
|
skip_stuffing(Bitstream *bs) |
|
|
{ |
|
|
while (BitstreamShowBits(bs, 9) == 1) |
|
|
BitstreamSkip(bs, 9); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
579 |
// for IVOP addbits == 0 |
// for IVOP addbits == 0 |
580 |
// for PVOP addbits == fcode - 1 |
// for PVOP addbits == fcode - 1 |
581 |
// for BVOP addbits == max(fcode,bcode) - 1 |
// for BVOP addbits == max(fcode,bcode) - 1 |
776 |
} |
} |
777 |
coeff += run; |
coeff += run; |
778 |
block[scan[coeff]] = level; |
block[scan[coeff]] = level; |
779 |
|
|
780 |
|
DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[coeff], level); |
781 |
|
//DPRINTF(DPRINTF_COEFF,"block[%i] %i %08x", scan[coeff], level, BitstreamShowBits(bs, 32)); |
782 |
|
|
783 |
if (level < -127 || level > 127) { |
if (level < -127 || level > 127) { |
784 |
DEBUG1("warning: intra_overflow", level); |
DEBUG1("warning: intra_overflow", level); |
785 |
} |
} |
809 |
p += run; |
p += run; |
810 |
|
|
811 |
block[scan[p]] = level; |
block[scan[p]] = level; |
812 |
|
|
813 |
|
DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[p], level); |
814 |
|
// DPRINTF(DPRINTF_COEFF,"block[%i] %i %08x", scan[p], level, BitstreamShowBits(bs, 32)); |
815 |
|
|
816 |
if (level < -127 || level > 127) { |
if (level < -127 || level > 127) { |
817 |
DEBUG1("warning: inter_overflow", level); |
DEBUG1("warning: inter_overflow", level); |
818 |
} |
} |