23 |
* |
* |
24 |
* History: |
* History: |
25 |
* |
* |
26 |
|
* 25.04.2002 ICDECOMPRESS_PREROLL |
27 |
|
* 17.04.2002 re-enabled lumi masking for 1st pass |
28 |
|
* 15.04.2002 updated cbr support |
29 |
* 04.04.2002 separated 2-pass code to 2pass.c |
* 04.04.2002 separated 2-pass code to 2pass.c |
30 |
* interlacing support |
* interlacing support |
31 |
* hinted ME support |
* hinted ME support |
239 |
switch (codec->config.mode) |
switch (codec->config.mode) |
240 |
{ |
{ |
241 |
case DLG_MODE_CBR : |
case DLG_MODE_CBR : |
242 |
param.bitrate = codec->config.bitrate; |
param.rc_bitrate = codec->config.rc_bitrate; |
243 |
param.rc_buffersize = codec->config.rc_buffersize; |
param.rc_reaction_delay_factor = codec->config.rc_reaction_delay_factor; |
244 |
|
param.rc_averaging_period = codec->config.rc_averaging_period; |
245 |
|
param.rc_buffer = codec->config.rc_buffer; |
246 |
break; |
break; |
247 |
|
|
248 |
case DLG_MODE_VBR_QUAL : |
case DLG_MODE_VBR_QUAL : |
249 |
codec->config.fquant = 0; |
codec->config.fquant = 0; |
250 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
251 |
break; |
break; |
252 |
|
|
253 |
case DLG_MODE_VBR_QUANT : |
case DLG_MODE_VBR_QUANT : |
254 |
codec->config.fquant = (float) codec->config.quant; |
codec->config.fquant = (float) codec->config.quant; |
255 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
256 |
break; |
break; |
257 |
|
|
258 |
case DLG_MODE_2PASS_1 : |
case DLG_MODE_2PASS_1 : |
259 |
case DLG_MODE_2PASS_2_INT : |
case DLG_MODE_2PASS_2_INT : |
260 |
case DLG_MODE_2PASS_2_EXT : |
case DLG_MODE_2PASS_2_EXT : |
261 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
262 |
|
codec->twopass.max_framesize = (int)((double)codec->config.twopass_max_bitrate / 8.0 / ((double)codec->fbase / (double)codec->fincr)); |
263 |
break; |
break; |
264 |
|
|
265 |
case DLG_MODE_NULL : |
case DLG_MODE_NULL : |
285 |
param.fincr = codec->fincr; |
param.fincr = codec->fincr; |
286 |
param.fbase = codec->fbase; |
param.fbase = codec->fbase; |
287 |
|
|
|
param.rc_buffersize = codec->config.rc_buffersize; |
|
|
|
|
288 |
param.min_quantizer = codec->config.min_pquant; |
param.min_quantizer = codec->config.min_pquant; |
289 |
param.max_quantizer = codec->config.max_pquant; |
param.max_quantizer = codec->config.max_pquant; |
290 |
param.max_key_interval = codec->config.max_key_interval; |
param.max_key_interval = codec->config.max_key_interval; |
336 |
} |
} |
337 |
|
|
338 |
codec->ehandle = NULL; |
codec->ehandle = NULL; |
339 |
|
|
340 |
|
codec_2pass_finish(codec); |
341 |
} |
} |
342 |
|
|
343 |
return ICERR_OK; |
return ICERR_OK; |
369 |
if(codec->config.motion_search > 4) |
if(codec->config.motion_search > 4) |
370 |
frame.general |= XVID_INTER4V; |
frame.general |= XVID_INTER4V; |
371 |
|
|
372 |
if(((codec->config.mode == DLG_MODE_2PASS_1) ? 0 : codec->config.lum_masking) == 1) |
if (codec->config.lum_masking) |
373 |
frame.general |= XVID_LUMIMASKING; |
frame.general |= XVID_LUMIMASKING; |
374 |
|
|
375 |
if (codec->config.interlacing) |
if (codec->config.interlacing) |
376 |
frame.general |= XVID_INTERLACING; |
frame.general |= XVID_INTERLACING; |
377 |
|
// fix 1pass modes/hinted MV by koepi |
378 |
|
if (codec->config.hinted_me && (codec->config.mode == DLG_MODE_CBR || codec->config.mode == DLG_MODE_VBR_QUAL || codec->config.mode == DLG_MODE_VBR_QUANT)) |
379 |
|
{ |
380 |
|
codec->config.hinted_me = 0; |
381 |
|
} |
382 |
|
// end of ugly hack |
383 |
|
|
384 |
if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1) |
if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1) |
385 |
{ |
{ |
387 |
frame.hint.rawhints = 0; |
frame.hint.rawhints = 0; |
388 |
frame.general |= XVID_HINTEDME_GET; |
frame.general |= XVID_HINTEDME_GET; |
389 |
} |
} |
390 |
else if (codec->config.mode == DLG_MODE_2PASS_2_EXT || codec->config.mode == DLG_MODE_2PASS_2_INT) |
else if (codec->config.hinted_me && (codec->config.mode == DLG_MODE_2PASS_2_EXT || codec->config.mode == DLG_MODE_2PASS_2_INT)) |
391 |
{ |
{ |
392 |
DWORD read; |
DWORD read; |
393 |
DWORD blocksize; |
DWORD blocksize; |
490 |
{ |
{ |
491 |
frame.intra = 1; |
frame.intra = 1; |
492 |
} |
} |
493 |
else if ((codec->keyspacing < codec->config.min_key_interval && codec->framenum) && |
else if (codec->keyspacing < codec->config.min_key_interval && codec->framenum) |
|
(codec->config.mode == DLG_MODE_2PASS_1)) |
|
494 |
{ |
{ |
495 |
DEBUG("current frame forced to p-frame"); |
DEBUG("current frame forced to p-frame"); |
496 |
frame.intra = 0; |
frame.intra = 0; |
674 |
frame.image = icd->lpOutput; |
frame.image = icd->lpOutput; |
675 |
frame.stride = icd->lpbiOutput->biWidth; |
frame.stride = icd->lpbiOutput->biWidth; |
676 |
|
|
677 |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE))) |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL))) |
678 |
{ |
{ |
679 |
if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL) |
if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL) |
680 |
{ |
{ |