32 |
* |
* |
33 |
* History |
* History |
34 |
* |
* |
35 |
|
* 10.07.2002 added BFRAMES_DEC_DEBUG support |
36 |
|
* MinChen <chenm001@163.com> |
37 |
* 20.06.2002 bframe patch |
* 20.06.2002 bframe patch |
38 |
* 08.05.2002 fix some problem in DEBUG mode; |
* 08.05.2002 fix some problem in DEBUG mode; |
39 |
* MinChen <chenm001@163.com> |
* MinChen <chenm001@163.com> |
40 |
* 14.04.2002 added FrameCodeB() |
* 14.04.2002 added FrameCodeB() |
41 |
* |
* |
42 |
* $Id: encoder.c,v 1.46 2002-06-23 03:58:32 suxen_drol Exp $ |
* $Id: encoder.c,v 1.54 2002-07-11 00:15:59 chenm001 Exp $ |
43 |
* |
* |
44 |
****************************************************************************/ |
****************************************************************************/ |
45 |
|
|
53 |
#include "global.h" |
#include "global.h" |
54 |
#include "utils/timer.h" |
#include "utils/timer.h" |
55 |
#include "image/image.h" |
#include "image/image.h" |
56 |
|
#ifdef BFRAMES |
57 |
#include "image/font.h" |
#include "image/font.h" |
58 |
|
#endif |
59 |
#include "motion/motion.h" |
#include "motion/motion.h" |
60 |
#include "bitstream/cbp.h" |
#include "bitstream/cbp.h" |
61 |
#include "utils/mbfunctions.h" |
#include "utils/mbfunctions.h" |
68 |
#include "quant/quant_matrix.h" |
#include "quant/quant_matrix.h" |
69 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
70 |
|
|
71 |
|
#ifdef _SMP |
72 |
|
#include "motion/smp_motion_est.h" |
73 |
|
#endif |
74 |
/***************************************************************************** |
/***************************************************************************** |
75 |
* Local macros |
* Local macros |
76 |
****************************************************************************/ |
****************************************************************************/ |
383 |
pEnc->bframenum_head = 0; |
pEnc->bframenum_head = 0; |
384 |
pEnc->bframenum_tail = 0; |
pEnc->bframenum_tail = 0; |
385 |
pEnc->flush_bframes = 0; |
pEnc->flush_bframes = 0; |
386 |
|
pEnc->bframenum_dx50bvop = -1; |
387 |
|
|
388 |
pEnc->queue = NULL; |
pEnc->queue = NULL; |
389 |
|
|
630 |
{ |
{ |
631 |
if (pEnc->queue_size >= pEnc->mbParam.max_bframes) |
if (pEnc->queue_size >= pEnc->mbParam.max_bframes) |
632 |
{ |
{ |
633 |
DPRINTF("FATAL: QUEUE FULL"); |
DPRINTF(DPRINTF_DEBUG,"FATAL: QUEUE FULL"); |
634 |
return; |
return; |
635 |
} |
} |
636 |
|
|
637 |
DPRINTF("*** QUEUE bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** QUEUE bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
638 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
639 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
640 |
|
|
702 |
* frame as a pframe |
* frame as a pframe |
703 |
*/ |
*/ |
704 |
|
|
705 |
DPRINTF("*** BFRAME (final frame) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** BFRAME (final frame) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
706 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
707 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
708 |
|
|
721 |
} |
} |
722 |
|
|
723 |
|
|
724 |
DPRINTF("*** BFRAME (flush) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** BFRAME (flush) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
725 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
726 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
727 |
|
|
743 |
|
|
744 |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
745 |
|
|
746 |
DPRINTF("*** EMPTY bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** EMPTY bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
747 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
748 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
749 |
|
|
|
|
|
750 |
BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); |
BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); |
751 |
BitstreamPad(&bs); |
BitstreamPad(&bs); |
752 |
BitstreamPutBits(&bs, 0x7f, 8); |
BitstreamPutBits(&bs, 0x7f, 8); |
764 |
|
|
765 |
bvop_loop: |
bvop_loop: |
766 |
|
|
767 |
if (input_valid) { |
if (pEnc->bframenum_dx50bvop != -1) |
768 |
|
{ |
769 |
|
|
770 |
|
SWAP(pEnc->current, pEnc->reference); |
771 |
|
SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]); |
772 |
|
|
773 |
|
if ((pEnc->global & XVID_GLOBAL_DEBUG)) { |
774 |
|
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 IVOP"); |
775 |
|
} |
776 |
|
|
777 |
|
if (input_valid) |
778 |
|
{ |
779 |
|
queue_image(pEnc, pFrame); |
780 |
|
input_valid = 0; |
781 |
|
} |
782 |
|
|
783 |
|
} else if (input_valid) { |
784 |
|
|
785 |
SWAP(pEnc->current, pEnc->reference); |
SWAP(pEnc->current, pEnc->reference); |
786 |
|
|
813 |
|
|
814 |
} else if (BitstreamPos(&bs) == 0) { |
} else if (BitstreamPos(&bs) == 0) { |
815 |
|
|
816 |
DPRINTF("*** SKIP bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** SKIP bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
817 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
818 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
819 |
|
|
|
|
|
820 |
pFrame->intra = 0; |
pFrame->intra = 0; |
821 |
|
|
822 |
BitstreamPutBits(&bs, 0x7f, 8); |
BitstreamPutBits(&bs, 0x7f, 8); |
838 |
* comment style :-) |
* comment style :-) |
839 |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
840 |
|
|
|
//$$ SWAP(pEnc->current, pEnc->reference); |
|
|
|
|
841 |
emms(); |
emms(); |
842 |
|
|
843 |
|
// only inc frame num, adapt quant, etc. if we havent seen it before |
844 |
|
if (pEnc->bframenum_dx50bvop < 0 ) |
845 |
|
{ |
846 |
if (pFrame->quant == 0) |
if (pFrame->quant == 0) |
847 |
pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0); |
pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0); |
848 |
else |
else |
856 |
|
|
857 |
pEnc->current->global_flags = pFrame->general; |
pEnc->current->global_flags = pFrame->general; |
858 |
pEnc->current->motion_flags = pFrame->motion; |
pEnc->current->motion_flags = pFrame->motion; |
859 |
pEnc->current->seconds = pEnc->mbParam.m_seconds; |
|
|
pEnc->current->ticks = pEnc->mbParam.m_ticks; |
|
860 |
/* ToDo : dynamic fcode (in both directions) */ |
/* ToDo : dynamic fcode (in both directions) */ |
861 |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
862 |
pEnc->current->bcode = pEnc->mbParam.m_fcode; |
pEnc->current->bcode = pEnc->mbParam.m_fcode; |
863 |
|
|
864 |
//$$$ start_timer(); |
pEnc->current->seconds = pEnc->mbParam.m_seconds; |
865 |
//$$$ if (image_input |
pEnc->current->ticks = pEnc->mbParam.m_ticks; |
866 |
//$$$ (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height, |
|
867 |
//$$$ pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace)) |
inc_frame_num(pEnc); |
|
//$$$ return XVID_ERR_FORMAT; |
|
|
//$$$ stop_conv_timer(); |
|
868 |
|
|
869 |
#ifdef _DEBUG_PSNR |
#ifdef _DEBUG_PSNR |
870 |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
878 |
"%i if:%i st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks); |
"%i if:%i st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks); |
879 |
} |
} |
880 |
|
|
|
|
|
881 |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
882 |
* Luminance masking |
* Luminance masking |
883 |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
907 |
} |
} |
908 |
|
|
909 |
#undef OFFSET |
#undef OFFSET |
|
|
|
910 |
} |
} |
911 |
|
|
912 |
xvid_free(temp_dquants); |
xvid_free(temp_dquants); |
913 |
} |
} |
914 |
|
|
915 |
|
} |
916 |
|
|
917 |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
918 |
* ivop/pvop/bvop selection |
* ivop/pvop/bvop selection |
919 |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
920 |
|
|
921 |
|
|
922 |
if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || |
if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 || |
923 |
(pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 && |
(pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 && |
924 |
pEnc->iFrameNum >= pEnc->iMaxKeyInterval) |
pEnc->iFrameNum >= pEnc->iMaxKeyInterval) |
925 |
|| image_mad(&pEnc->reference->image, &pEnc->current->image, |
|| image_mad(&pEnc->reference->image, &pEnc->current->image, |
929 |
* This will be coded as an Intra Frame |
* This will be coded as an Intra Frame |
930 |
*/ |
*/ |
931 |
|
|
932 |
DPRINTF("*** IFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** IFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
933 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
934 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
935 |
|
|
937 |
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP"); |
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP"); |
938 |
} |
} |
939 |
|
|
940 |
FrameCodeI(pEnc, &bs, &bits); |
// when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe |
941 |
|
|
942 |
|
if ((pEnc->global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) { |
943 |
|
|
944 |
|
pEnc->bframenum_tail--; |
945 |
|
pEnc->bframenum_dx50bvop = pEnc->bframenum_tail; |
946 |
|
|
947 |
|
SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]); |
948 |
|
if ((pEnc->global & XVID_GLOBAL_DEBUG)) { |
949 |
|
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP"); |
950 |
|
} |
951 |
|
FrameCodeP(pEnc, &bs, &bits, 1, 0); |
952 |
|
|
953 |
|
pFrame->intra = 0; |
954 |
|
|
955 |
|
} else { |
956 |
|
|
957 |
|
FrameCodeI(pEnc, &bs, &bits); |
958 |
pFrame->intra = 1; |
pFrame->intra = 1; |
|
pEnc->flush_bframes = 1; |
|
959 |
|
|
960 |
inc_frame_num(pEnc); |
pEnc->bframenum_dx50bvop = -1; |
961 |
|
} |
962 |
|
|
963 |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
pEnc->flush_bframes = 1; |
964 |
|
|
965 |
|
if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) { |
966 |
BitstreamPad(&bs); |
BitstreamPad(&bs); |
967 |
input_valid = 0; |
input_valid = 0; |
968 |
goto ipvop_loop; |
goto ipvop_loop; |
977 |
* This will be coded as a Predicted Frame |
* This will be coded as a Predicted Frame |
978 |
*/ |
*/ |
979 |
|
|
980 |
DPRINTF("*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
981 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
982 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
983 |
|
|
989 |
pFrame->intra = 0; |
pFrame->intra = 0; |
990 |
pEnc->flush_bframes = 1; |
pEnc->flush_bframes = 1; |
991 |
|
|
|
inc_frame_num(pEnc); |
|
|
|
|
992 |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
993 |
BitstreamPad(&bs); |
BitstreamPad(&bs); |
994 |
input_valid = 0; |
input_valid = 0; |
1000 |
* This will be coded as a Bidirectional Frame |
* This will be coded as a Bidirectional Frame |
1001 |
*/ |
*/ |
1002 |
|
|
1003 |
DPRINTF("*** BFRAME (store) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
DPRINTF(DPRINTF_DEBUG,"*** BFRAME (store) bf: head=%i tail=%i queue: head=%i tail=%i size=%i", |
1004 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
1005 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
1006 |
|
|
1025 |
pFrame->intra = 0; |
pFrame->intra = 0; |
1026 |
pFrame->length = 0; |
pFrame->length = 0; |
1027 |
|
|
|
inc_frame_num(pEnc); |
|
|
|
|
1028 |
input_valid = 0; |
input_valid = 0; |
1029 |
goto bvop_loop; |
goto bvop_loop; |
1030 |
} |
} |
1317 |
&pEnc->current->mbs[x + y * pEnc->mbParam.mb_width]; |
&pEnc->current->mbs[x + y * pEnc->mbParam.mb_width]; |
1318 |
MVBLOCKHINT *bhint = |
MVBLOCKHINT *bhint = |
1319 |
&hint->mvhint.block[x + y * pEnc->mbParam.mb_width]; |
&hint->mvhint.block[x + y * pEnc->mbParam.mb_width]; |
1320 |
VECTOR pred[4]; |
VECTOR pred; |
1321 |
VECTOR tmp; |
VECTOR tmp; |
|
int32_t dummy[4]; |
|
1322 |
int vec; |
int vec; |
1323 |
|
|
1324 |
pMB->mode = |
pMB->mode = |
1338 |
tmp.x -= (tmp.x >= high) ? high * 2 : 0; |
tmp.x -= (tmp.x >= high) ? high * 2 : 0; |
1339 |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
1340 |
|
|
1341 |
get_pmvdata(pEnc->current->mbs, x, y, pEnc->mbParam.mb_width, |
pred = get_pmv2(pEnc->current->mbs,pEnc->mbParam.mb_width,0,x,y,0); |
|
0, pred, dummy); |
|
1342 |
|
|
1343 |
for (vec = 0; vec < 4; ++vec) { |
for (vec = 0; vec < 4; ++vec) { |
1344 |
pMB->mvs[vec].x = tmp.x; |
pMB->mvs[vec].x = tmp.x; |
1345 |
pMB->mvs[vec].y = tmp.y; |
pMB->mvs[vec].y = tmp.y; |
1346 |
pMB->pmvs[vec].x = pMB->mvs[0].x - pred[0].x; |
pMB->pmvs[vec].x = pMB->mvs[0].x - pred.x; |
1347 |
pMB->pmvs[vec].y = pMB->mvs[0].y - pred[0].y; |
pMB->pmvs[vec].y = pMB->mvs[0].y - pred.y; |
1348 |
} |
} |
1349 |
} else if (pMB->mode == MODE_INTER4V) { |
} else if (pMB->mode == MODE_INTER4V) { |
1350 |
for (vec = 0; vec < 4; ++vec) { |
for (vec = 0; vec < 4; ++vec) { |
1357 |
tmp.x -= (tmp.x >= high) ? high * 2 : 0; |
tmp.x -= (tmp.x >= high) ? high * 2 : 0; |
1358 |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
1359 |
|
|
1360 |
get_pmvdata(pEnc->current->mbs, x, y, |
pred = get_pmv2(pEnc->current->mbs,pEnc->mbParam.mb_width,0,x,y,vec); |
|
pEnc->mbParam.mb_width, vec, pred, dummy); |
|
1361 |
|
|
1362 |
pMB->mvs[vec].x = tmp.x; |
pMB->mvs[vec].x = tmp.x; |
1363 |
pMB->mvs[vec].y = tmp.y; |
pMB->mvs[vec].y = tmp.y; |
1364 |
pMB->pmvs[vec].x = pMB->mvs[vec].x - pred[0].x; |
pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x; |
1365 |
pMB->pmvs[vec].y = pMB->mvs[vec].y - pred[0].y; |
pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y; |
1366 |
} |
} |
1367 |
} else // intra / stuffing / not_coded |
} else // intra / stuffing / not_coded |
1368 |
{ |
{ |
1593 |
if (pEnc->current->global_flags & XVID_HINTEDME_SET) { |
if (pEnc->current->global_flags & XVID_HINTEDME_SET) { |
1594 |
HintedMESet(pEnc, &bIntra); |
HintedMESet(pEnc, &bIntra); |
1595 |
} else { |
} else { |
1596 |
|
|
1597 |
|
#ifdef _SMP |
1598 |
|
if (NUMTHREADS > 1) |
1599 |
|
bIntra = |
1600 |
|
SMP_MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
1601 |
|
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1602 |
|
iLimit); |
1603 |
|
else |
1604 |
|
#endif |
1605 |
|
|
1606 |
bIntra = |
bIntra = |
1607 |
MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
1608 |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1609 |
iLimit); |
iLimit); |
1610 |
|
|
1611 |
|
|
1612 |
} |
} |
1613 |
stop_motion_timer(); |
stop_motion_timer(); |
1614 |
|
|
1742 |
IMAGE *f_ref = &pEnc->reference->image; |
IMAGE *f_ref = &pEnc->reference->image; |
1743 |
IMAGE *b_ref = &pEnc->current->image; |
IMAGE *b_ref = &pEnc->current->image; |
1744 |
|
|
1745 |
|
#ifdef BFRAMES_DEC_DEBUG |
1746 |
|
FILE *fp; |
1747 |
|
static char first=0; |
1748 |
|
#define BFRAME_DEBUG if (!first && fp){ \ |
1749 |
|
fprintf(fp,"Y=%3d X=%3d MB=%2d CBP=%02X\n",y,x,mb->mode,mb->cbp); \ |
1750 |
|
} |
1751 |
|
|
1752 |
|
if (!first){ |
1753 |
|
fp=fopen("C:\\XVIDDBGE.TXT","w"); |
1754 |
|
} |
1755 |
|
#endif |
1756 |
|
|
1757 |
// forward |
// forward |
1758 |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
1759 |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
1820 |
if (mb->mode == MODE_NOT_CODED) { |
if (mb->mode == MODE_NOT_CODED) { |
1821 |
mb->mvs[0].x = 0; |
mb->mvs[0].x = 0; |
1822 |
mb->mvs[0].y = 0; |
mb->mvs[0].y = 0; |
1823 |
|
|
1824 |
|
mb->cbp = 0; |
1825 |
|
#ifdef BFRAMES_DEC_DEBUG |
1826 |
|
BFRAME_DEBUG |
1827 |
|
#endif |
1828 |
continue; |
continue; |
1829 |
} |
} |
1830 |
|
|
1861 |
} |
} |
1862 |
// DPRINTF("%05i : [%i %i] M=%i CBP=%i MVS=%i,%i forward=%i,%i", pEnc->m_framenum, x, y, mb->mode, mb->cbp, mb->mvs[0].x, mb->mvs[0].y, forward.x, forward.y); |
// DPRINTF("%05i : [%i %i] M=%i CBP=%i MVS=%i,%i forward=%i,%i", pEnc->m_framenum, x, y, mb->mode, mb->cbp, mb->mvs[0].x, mb->mvs[0].y, forward.x, forward.y); |
1863 |
|
|
1864 |
|
#ifdef BFRAMES_DEC_DEBUG |
1865 |
|
BFRAME_DEBUG |
1866 |
|
#endif |
1867 |
start_timer(); |
start_timer(); |
1868 |
MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs, |
MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs, |
1869 |
&pEnc->sStat); |
&pEnc->sStat); |
1876 |
// TODO: dynamic fcode/bcode ??? |
// TODO: dynamic fcode/bcode ??? |
1877 |
|
|
1878 |
*pBits = BitstreamPos(bs) - *pBits; |
*pBits = BitstreamPos(bs) - *pBits; |
1879 |
|
|
1880 |
|
#ifdef BFRAMES_DEC_DEBUG |
1881 |
|
if (!first){ |
1882 |
|
first=1; |
1883 |
|
if (fp) |
1884 |
|
fclose(fp); |
1885 |
|
} |
1886 |
|
#endif |
1887 |
} |
} |
1888 |
#endif |
#endif |