26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* $Id: encoder.c,v 1.95.2.25 2003-05-22 16:34:47 edgomez Exp $ |
* $Id: encoder.c,v 1.95.2.26 2003-06-09 01:16:24 edgomez Exp $ |
30 |
* |
* |
31 |
****************************************************************************/ |
****************************************************************************/ |
32 |
|
|
714 |
|
|
715 |
/* todo: [vol,vop,motion]_flags*/ |
/* todo: [vol,vop,motion]_flags*/ |
716 |
|
|
717 |
} else { // XVID_PLG_AFTER |
} else { /* XVID_PLG_AFTER */ |
718 |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
719 |
data.original.csp = XVID_CSP_USER; |
data.original.csp = XVID_CSP_USER; |
720 |
data.original.plane[0] = original->y; |
data.original.plane[0] = original->y; |
1048 |
goto done; /* nothing to encode yet; encoder lag */ |
goto done; /* nothing to encode yet; encoder lag */ |
1049 |
} |
} |
1050 |
|
|
1051 |
// the current FRAME becomes the reference |
/* the current FRAME becomes the reference */ |
1052 |
SWAP(FRAMEINFO*, pEnc->current, pEnc->reference); |
SWAP(FRAMEINFO*, pEnc->current, pEnc->reference); |
1053 |
|
|
1054 |
// remove frame from encoding-queue (head), and move it into the current |
/* remove frame from encoding-queue (head), and move it into the current */ |
1055 |
image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image); |
image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image); |
1056 |
frame = &pEnc->queue[pEnc->queue_head].frame; |
frame = &pEnc->queue[pEnc->queue_head].frame; |
1057 |
pEnc->queue_head = (pEnc->queue_head + 1) % (pEnc->mbParam.max_bframes+1); |
pEnc->queue_head = (pEnc->queue_head + 1) % (pEnc->mbParam.max_bframes+1); |
1167 |
|
|
1168 |
if (type == I_VOP && (pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP) && pEnc->bframenum_tail > 0) { |
if (type == I_VOP && (pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP) && pEnc->bframenum_tail > 0) { |
1169 |
|
|
1170 |
// place this frame back on the encoding-queue (head) |
/* place this frame back on the encoding-queue (head) */ |
1171 |
// we will deal with it next time |
/* we will deal with it next time */ |
1172 |
dec_frame_num(pEnc); |
dec_frame_num(pEnc); |
1173 |
pEnc->iFrameNum--; |
pEnc->iFrameNum--; |
1174 |
|
|
1176 |
pEnc->queue_size++; |
pEnc->queue_size++; |
1177 |
image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image); |
image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image); |
1178 |
|
|
1179 |
// grab the last frame from the bframe-queue |
/* grab the last frame from the bframe-queue */ |
1180 |
|
|
1181 |
pEnc->bframenum_tail--; |
pEnc->bframenum_tail--; |
1182 |
SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]); |
SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]); |
1238 |
* encode this frame as an p-vop |
* encode this frame as an p-vop |
1239 |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
1240 |
|
|
1241 |
} else { // (type == P_VOP || type == S_VOP) |
} else { /* (type == P_VOP || type == S_VOP) */ |
1242 |
|
|
1243 |
DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i\n", |
DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i\n", |
1244 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
1469 |
|
|
1470 |
pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type; |
pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type; |
1471 |
pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type; |
pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type; |
1472 |
//pEnc->current->quarterpel = pEnc->mbParam.m_quarterpel; |
/* pEnc->current->quarterpel = pEnc->mbParam.m_quarterpel; */ |
1473 |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
1474 |
|
|
1475 |
if (!force_inter) |
if (!force_inter) |
1771 |
pEnc->fMvPrevSigma = fSigma; |
pEnc->fMvPrevSigma = fSigma; |
1772 |
|
|
1773 |
/* frame drop code */ |
/* frame drop code */ |
1774 |
//DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", pEnc->current->sStat.kblks, pEnc->current->sStat.mblks, pEnc->current->sStat.ublks); |
#if 0 |
1775 |
|
DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", pEnc->current->sStat.kblks, pEnc->current->sStat.mblks, pEnc->current->sStat.ublks); |
1776 |
|
#endif |
1777 |
if (pEnc->current->sStat.kblks + pEnc->current->sStat.mblks < |
if (pEnc->current->sStat.kblks + pEnc->current->sStat.mblks < |
1778 |
(pEnc->mbParam.frame_drop_ratio * mb_width * mb_height) / 100) |
(pEnc->mbParam.frame_drop_ratio * mb_width * mb_height) / 100) |
1779 |
{ |
{ |
1789 |
pEnc->current->quant = pEnc->reference->quant; |
pEnc->current->quant = pEnc->reference->quant; |
1790 |
pEnc->current->motion_flags = pEnc->reference->motion_flags; |
pEnc->current->motion_flags = pEnc->reference->motion_flags; |
1791 |
pEnc->current->rounding_type = pEnc->reference->rounding_type; |
pEnc->current->rounding_type = pEnc->reference->rounding_type; |
1792 |
//pEnc->current->quarterpel = pEnc->reference->quarterpel; |
/* pEnc->current->quarterpel = pEnc->reference->quarterpel; */ |
1793 |
pEnc->current->fcode = pEnc->reference->fcode; |
pEnc->current->fcode = pEnc->reference->fcode; |
1794 |
pEnc->current->bcode = pEnc->reference->bcode; |
pEnc->current->bcode = pEnc->reference->bcode; |
1795 |
image_copy(&pEnc->current->image, &pEnc->reference->image, pEnc->mbParam.edged_width, pEnc->mbParam.height); |
image_copy(&pEnc->current->image, &pEnc->reference->image, pEnc->mbParam.edged_width, pEnc->mbParam.height); |
1855 |
} |
} |
1856 |
#endif |
#endif |
1857 |
|
|
1858 |
//frame->quarterpel = pEnc->mbParam.m_quarterpel; |
/* frame->quarterpel = pEnc->mbParam.m_quarterpel; */ |
1859 |
|
|
1860 |
/* forward */ |
/* forward */ |
1861 |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
image_setedges(f_ref, pEnc->mbParam.edged_width, |