37 |
* MinChen <chenm001@163.com> |
* MinChen <chenm001@163.com> |
38 |
* 14.04.2002 added FrameCodeB() |
* 14.04.2002 added FrameCodeB() |
39 |
* |
* |
40 |
* $Id: encoder.c,v 1.50 2002-06-28 15:14:40 suxen_drol Exp $ |
* $Id: encoder.c,v 1.52 2002-07-06 17:04:57 chl Exp $ |
41 |
* |
* |
42 |
****************************************************************************/ |
****************************************************************************/ |
43 |
|
|
66 |
#include "quant/quant_matrix.h" |
#include "quant/quant_matrix.h" |
67 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
68 |
|
|
69 |
|
#ifdef _SMP |
70 |
|
#include "motion/smp_motion_est.h" |
71 |
|
#endif |
72 |
/***************************************************************************** |
/***************************************************************************** |
73 |
* Local macros |
* Local macros |
74 |
****************************************************************************/ |
****************************************************************************/ |
628 |
{ |
{ |
629 |
if (pEnc->queue_size >= pEnc->mbParam.max_bframes) |
if (pEnc->queue_size >= pEnc->mbParam.max_bframes) |
630 |
{ |
{ |
631 |
DPRINTF("FATAL: QUEUE FULL"); |
DPRINTF(DPRINTF_DEBUG,"FATAL: QUEUE FULL"); |
632 |
return; |
return; |
633 |
} |
} |
634 |
|
|
635 |
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", |
636 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
637 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
638 |
|
|
700 |
* frame as a pframe |
* frame as a pframe |
701 |
*/ |
*/ |
702 |
|
|
703 |
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", |
704 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
705 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
706 |
|
|
719 |
} |
} |
720 |
|
|
721 |
|
|
722 |
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", |
723 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
724 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
725 |
|
|
741 |
|
|
742 |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
743 |
|
|
744 |
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", |
745 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
746 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
747 |
|
|
811 |
|
|
812 |
} else if (BitstreamPos(&bs) == 0) { |
} else if (BitstreamPos(&bs) == 0) { |
813 |
|
|
814 |
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", |
815 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
816 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
817 |
|
|
927 |
* This will be coded as an Intra Frame |
* This will be coded as an Intra Frame |
928 |
*/ |
*/ |
929 |
|
|
930 |
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", |
931 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
932 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
933 |
|
|
975 |
* This will be coded as a Predicted Frame |
* This will be coded as a Predicted Frame |
976 |
*/ |
*/ |
977 |
|
|
978 |
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", |
979 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
980 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
981 |
|
|
998 |
* This will be coded as a Bidirectional Frame |
* This will be coded as a Bidirectional Frame |
999 |
*/ |
*/ |
1000 |
|
|
1001 |
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", |
1002 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
1003 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
1004 |
|
|
1338 |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
tmp.y -= (tmp.y >= high) ? high * 2 : 0; |
1339 |
|
|
1340 |
get_pmvdata(pEnc->current->mbs, x, y, pEnc->mbParam.mb_width, |
get_pmvdata(pEnc->current->mbs, x, y, pEnc->mbParam.mb_width, |
1341 |
0, pred, dummy, 0, 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; |
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, |
get_pmvdata(pEnc->current->mbs, x, y, |
1361 |
pEnc->mbParam.mb_width, vec, pred, dummy, 0, 0); |
pEnc->mbParam.mb_width, vec, pred, dummy); |
1362 |
|
|
1363 |
pMB->mvs[vec].x = tmp.x; |
pMB->mvs[vec].x = tmp.x; |
1364 |
pMB->mvs[vec].y = tmp.y; |
pMB->mvs[vec].y = tmp.y; |
1594 |
if (pEnc->current->global_flags & XVID_HINTEDME_SET) { |
if (pEnc->current->global_flags & XVID_HINTEDME_SET) { |
1595 |
HintedMESet(pEnc, &bIntra); |
HintedMESet(pEnc, &bIntra); |
1596 |
} else { |
} else { |
1597 |
|
|
1598 |
|
#ifdef _SMP |
1599 |
|
if (NUMTHREADS > 1) |
1600 |
|
bIntra = |
1601 |
|
SMP_MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
1602 |
|
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1603 |
|
iLimit); |
1604 |
|
else |
1605 |
|
#endif |
1606 |
|
|
1607 |
bIntra = |
bIntra = |
1608 |
MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference, |
1609 |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1610 |
iLimit); |
iLimit); |
1611 |
|
|
1612 |
|
|
1613 |
} |
} |
1614 |
stop_motion_timer(); |
stop_motion_timer(); |
1615 |
|
|