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.9 2003-03-16 12:04:13 suxen_drol Exp $ |
* $Id: encoder.c,v 1.95.2.14 2003-03-26 11:01:03 suxen_drol Exp $ |
30 |
* |
* |
31 |
****************************************************************************/ |
****************************************************************************/ |
32 |
|
|
116 |
|
|
117 |
|
|
118 |
int |
int |
119 |
enc_create(xvid_enc_create_t * create, xvid_enc_rc_t * rc) |
enc_create(xvid_enc_create_t * create) |
120 |
{ |
{ |
121 |
Encoder *pEnc; |
Encoder *pEnc; |
122 |
int n; |
int n; |
123 |
|
|
124 |
if (XVID_MAJOR(create->version) != 1 || (rc && XVID_MAJOR(rc->version) != 1)) /* v1.x.x */ |
if (XVID_MAJOR(create->version) != 1) /* v1.x.x */ |
125 |
return XVID_ERR_VERSION; |
return XVID_ERR_VERSION; |
126 |
|
|
127 |
if (create->width%2 || create->height%2) |
if (create->width%2 || create->height%2) |
597 |
xvid_free(pEnc->temp_dquants); |
xvid_free(pEnc->temp_dquants); |
598 |
} |
} |
599 |
|
|
600 |
|
|
601 |
|
if (pEnc->num_plugins>0) |
602 |
|
{ |
603 |
|
xvid_plg_destroy_t pdestroy; |
604 |
|
memset(&pdestroy, 0, sizeof(xvid_plg_destroy_t)); |
605 |
|
|
606 |
|
pdestroy.version = XVID_VERSION; |
607 |
|
pdestroy.num_frames = pEnc->m_framenum; |
608 |
|
|
609 |
for (i=0; i<pEnc->num_plugins;i++) { |
for (i=0; i<pEnc->num_plugins;i++) { |
610 |
if (pEnc->plugins[i].func) { |
if (pEnc->plugins[i].func) { |
611 |
pEnc->plugins[i].func(pEnc->plugins[i].param, XVID_PLG_DESTROY, 0, 0); |
pEnc->plugins[i].func(pEnc->plugins[i].param, XVID_PLG_DESTROY, &pdestroy, 0); |
612 |
} |
} |
613 |
} |
} |
614 |
xvid_free(pEnc->plugins); |
xvid_free(pEnc->plugins); |
615 |
|
} |
616 |
|
|
617 |
xvid_free(pEnc); |
xvid_free(pEnc); |
618 |
|
|
630 |
unsigned int i, j; |
unsigned int i, j; |
631 |
xvid_plg_data_t data; |
xvid_plg_data_t data; |
632 |
|
|
|
if (pEnc->num_plugins == 0) { |
|
|
for (j=0; j<pEnc->mbParam.mb_height; j++) |
|
|
for (i=0; i<pEnc->mbParam.mb_width; i++) { |
|
|
frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0; |
|
|
} |
|
|
return; |
|
|
} |
|
|
|
|
633 |
/* set data struct */ |
/* set data struct */ |
634 |
|
|
635 |
memset(&data, 0, sizeof(xvid_plg_data_t)); |
memset(&data, 0, sizeof(xvid_plg_data_t)); |
1007 |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
1008 |
|
|
1009 |
pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr; |
pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr; |
1010 |
|
inc_frame_num(pEnc); |
1011 |
pEnc->current->vol_flags = pEnc->mbParam.vol_flags; |
pEnc->current->vol_flags = pEnc->mbParam.vol_flags; |
1012 |
pEnc->current->vop_flags = frame->vop_flags; |
pEnc->current->vop_flags = frame->vop_flags; |
1013 |
pEnc->current->motion_flags = frame->motion; |
pEnc->current->motion_flags = frame->motion; |
1014 |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
1015 |
pEnc->current->bcode = pEnc->mbParam.m_fcode; |
pEnc->current->bcode = pEnc->mbParam.m_fcode; |
1016 |
|
|
1017 |
|
|
1018 |
if ((xFrame->vop_flags & XVID_CHROMAOPT)) { |
if ((xFrame->vop_flags & XVID_CHROMAOPT)) { |
1019 |
image_chroma_optimize(&pEnc->current->image, |
image_chroma_optimize(&pEnc->current->image, |
1020 |
pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width); |
pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width); |
1058 |
} |
} |
1059 |
} |
} |
1060 |
|
|
|
inc_frame_num(pEnc); |
|
1061 |
pEnc->iFrameNum++; |
pEnc->iFrameNum++; |
1062 |
|
|
1063 |
if ((pEnc->current->vop_flags & XVID_DEBUG)) { |
if ((pEnc->current->vop_flags & XVID_DEBUG)) { |
1857 |
continue; |
continue; |
1858 |
} |
} |
1859 |
|
|
1860 |
if (mb->mode != MODE_DIRECT_NONE_MV) { |
if (mb->mode != MODE_DIRECT_NONE_MV || pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
1861 |
MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image, |
MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image, |
1862 |
f_ref, &pEnc->f_refh, &pEnc->f_refv, |
f_ref, &pEnc->f_refh, &pEnc->f_refv, |
1863 |
&pEnc->f_refhv, b_ref, &pEnc->vInterH, |
&pEnc->f_refhv, b_ref, &pEnc->vInterH, |
1867 |
if (mb->mode == MODE_DIRECT_NO4V) mb->mode = MODE_DIRECT; |
if (mb->mode == MODE_DIRECT_NO4V) mb->mode = MODE_DIRECT; |
1868 |
mb->quant = frame->quant; |
mb->quant = frame->quant; |
1869 |
|
|
1870 |
mb->cbp = |
if (mb->mode != MODE_DIRECT_NONE_MV) |
1871 |
MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, x, y, dct_codes, qcoeff); |
mb->cbp = MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, x, y, dct_codes, qcoeff); |
1872 |
|
|
1873 |
if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0) |
if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0) |
1874 |
&& (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) { |
&& (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) { |