3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Encoder main module - |
* - Encoder main module - |
5 |
* |
* |
6 |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
* Copyright(C) 2002-2010 Michael Militzer <isibaar@xvid.org> |
7 |
* 2002-2003 Peter Ross <pross@xvid.org> |
* 2002-2003 Peter Ross <pross@xvid.org> |
8 |
* 2002 Daniel Smith <danielsmith@astroboymail.com> |
* 2002 Daniel Smith <danielsmith@astroboymail.com> |
9 |
* |
* |
21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: encoder.c,v 1.129 2006-12-14 13:09:00 Isibaar Exp $ |
* $Id: encoder.c,v 1.133 2010-11-28 15:18:21 Isibaar Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
435 |
/* timestamp stuff */ |
/* timestamp stuff */ |
436 |
|
|
437 |
pEnc->mbParam.m_stamp = 0; |
pEnc->mbParam.m_stamp = 0; |
438 |
pEnc->m_framenum = 0; |
pEnc->m_framenum = create->start_frame_num; |
439 |
pEnc->current->stamp = 0; |
pEnc->current->stamp = 0; |
440 |
pEnc->reference->stamp = 0; |
pEnc->reference->stamp = 0; |
441 |
|
|
997 |
return; |
return; |
998 |
} |
} |
999 |
|
|
|
|
|
1000 |
/***************************************************************************** |
/***************************************************************************** |
1001 |
* IPB frame encoder entry point |
* IPB frame encoder entry point |
1002 |
* |
* |
1306 |
if (pEnc->current->stamp > 0) { |
if (pEnc->current->stamp > 0) { |
1307 |
call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1308 |
} |
} |
1309 |
else |
else if (stats) { |
1310 |
stats->type = XVID_TYPE_NOTHING; |
stats->type = XVID_TYPE_NOTHING; |
1311 |
} |
} |
1312 |
|
} |
1313 |
|
|
1314 |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1315 |
* closed-gop |
* closed-gop |
1655 |
|
|
1656 |
current->coding_type = P_VOP; |
current->coding_type = P_VOP; |
1657 |
|
|
1658 |
|
if (current->vop_flags & XVID_VOP_RD_PSNRHVSM) { |
1659 |
|
image_block_variance(¤t->image, pParam->edged_width, current->mbs, |
1660 |
|
pParam->mb_width, pParam->mb_height); |
1661 |
|
} |
1662 |
|
|
1663 |
call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
1664 |
|
|
1665 |
SetMacroblockQuants(&pEnc->mbParam, current); |
SetMacroblockQuants(&pEnc->mbParam, current); |
1888 |
#if 0 |
#if 0 |
1889 |
DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks); |
DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks); |
1890 |
#endif |
#endif |
1891 |
if (current->sStat.kblks + current->sStat.mblks <= |
if (current->sStat.kblks + current->sStat.mblks < |
1892 |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100 && |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100 && |
1893 |
( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) ) |
( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) ) |
1894 |
{ |
{ |
2007 |
} |
} |
2008 |
|
|
2009 |
frame->coding_type = B_VOP; |
frame->coding_type = B_VOP; |
2010 |
|
|
2011 |
|
if (pEnc->current->vop_flags & XVID_VOP_RD_PSNRHVSM) { |
2012 |
|
image_block_variance(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->current->mbs, |
2013 |
|
pEnc->mbParam.mb_width, pEnc->mbParam.mb_height); |
2014 |
|
} |
2015 |
|
|
2016 |
call_plugins(pEnc, frame, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
call_plugins(pEnc, frame, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
2017 |
|
|
2018 |
frame->fcode = frame->bcode = pEnc->current->fcode; |
frame->fcode = frame->bcode = pEnc->current->fcode; |