170 |
pParam->max_quantizer, pParam->min_quantizer); |
pParam->max_quantizer, pParam->min_quantizer); |
171 |
} |
} |
172 |
|
|
|
create_vlc_tables(); |
|
173 |
init_timer(); |
init_timer(); |
174 |
|
|
175 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
187 |
image_destroy(&pEnc->sReference, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
image_destroy(&pEnc->sReference, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
188 |
image_destroy(&pEnc->vInterH, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
image_destroy(&pEnc->vInterH, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
189 |
image_destroy(&pEnc->vInterV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
image_destroy(&pEnc->vInterV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
190 |
|
image_destroy(&pEnc->vInterVf, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
191 |
image_destroy(&pEnc->vInterHV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
image_destroy(&pEnc->vInterHV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
192 |
|
image_destroy(&pEnc->vInterHVf, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); |
193 |
xvid_free(pEnc); |
xvid_free(pEnc); |
194 |
|
|
|
destroy_vlc_tables(); |
|
|
|
|
195 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
196 |
} |
} |
197 |
|
|
435 |
else |
else |
436 |
iLimit = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height + 1; |
iLimit = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height + 1; |
437 |
|
|
438 |
if ((pEnc->mbParam.global_flags & XVID_HALFPEL) > 0) |
if ((pEnc->mbParam.global_flags & XVID_HALFPEL) > 0) { |
|
{ |
|
|
IMAGE *vInterV = NULL; |
|
|
IMAGE *vInterVf = NULL; |
|
|
IMAGE *vInterHV = NULL; |
|
|
IMAGE *vInterHVf = NULL; |
|
|
|
|
|
// interpolate fields together if field ME is used |
|
|
if (pEnc->mbParam.global_flags & XVID_INTERLACING && |
|
|
pEnc->mbParam.global_flags & XVID_FIELDME) |
|
|
{ |
|
|
vInterVf = &pEnc->vInterVf; |
|
|
vInterHVf = &pEnc->vInterHVf; |
|
|
} |
|
|
|
|
|
// perform normal interpolation, unless only field-based ME is allowed |
|
|
if (!(pEnc->mbParam.global_flags & XVID_INTERLACING) || |
|
|
!(pEnc->mbParam.global_flags & XVID_FIELDMEONLY)) |
|
|
{ |
|
|
vInterV = &pEnc->vInterV; |
|
|
vInterHV = &pEnc->vInterHV; |
|
|
} |
|
|
|
|
439 |
start_timer(); |
start_timer(); |
440 |
image_interpolate(pRef, |
image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
441 |
&pEnc->vInterH, |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
|
vInterV, vInterVf, |
|
|
vInterHV, vInterHVf, |
|
|
pEnc->mbParam.edged_width, |
|
|
pEnc->mbParam.edged_height, |
|
442 |
pEnc->mbParam.rounding_type); |
pEnc->mbParam.rounding_type); |
443 |
stop_inter_timer(); |
stop_inter_timer(); |
444 |
} |
} |
445 |
|
|
446 |
start_timer(); |
start_timer(); |
447 |
bIntra = MotionEstimation(pEnc->pMBs, |
bIntra = MotionEstimation(pEnc->pMBs, &pEnc->mbParam, &pEnc->sReference, |
448 |
&pEnc->mbParam, |
&pEnc->vInterH, &pEnc->vInterV, |
449 |
&pEnc->sReference, |
&pEnc->vInterHV, &pEnc->sCurrent, iLimit); |
|
&pEnc->vInterH, |
|
|
&pEnc->vInterV, &pEnc->vInterVf, |
|
|
&pEnc->vInterHV, &pEnc->vInterHVf, |
|
|
&pEnc->sCurrent, |
|
|
iLimit); |
|
450 |
stop_motion_timer(); |
stop_motion_timer(); |
451 |
|
|
452 |
if (bIntra == 1) |
if (bIntra == 1) |
481 |
x, y, |
x, y, |
482 |
&pEnc->sReference, |
&pEnc->sReference, |
483 |
&pEnc->vInterH, |
&pEnc->vInterH, |
484 |
&pEnc->vInterV, &pEnc->vInterVf, |
&pEnc->vInterV, |
485 |
&pEnc->vInterHV, &pEnc->vInterHVf, |
&pEnc->vInterHV, |
486 |
&pEnc->sCurrent, |
&pEnc->sCurrent, |
487 |
dct_codes, |
dct_codes, |
488 |
pEnc->mbParam.width, |
pEnc->mbParam.width, |