23 |
* |
* |
24 |
* History: |
* History: |
25 |
* |
* |
26 |
|
* 23.06.2002 XVID_CPU_CHKONLY; loading speed up |
27 |
|
* 25.04.2002 ICDECOMPRESS_PREROLL |
28 |
|
* 17.04.2002 re-enabled lumi masking for 1st pass |
29 |
|
* 15.04.2002 updated cbr support |
30 |
* 04.04.2002 separated 2-pass code to 2pass.c |
* 04.04.2002 separated 2-pass code to 2pass.c |
31 |
* interlacing support |
* interlacing support |
32 |
* hinted ME support |
* hinted ME support |
219 |
|
|
220 |
LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
221 |
{ |
{ |
222 |
return lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3; |
return |
223 |
|
#ifdef BFRAMES |
224 |
|
2 * |
225 |
|
#endif |
226 |
|
lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3; |
227 |
} |
} |
228 |
|
|
229 |
|
|
244 |
switch (codec->config.mode) |
switch (codec->config.mode) |
245 |
{ |
{ |
246 |
case DLG_MODE_CBR : |
case DLG_MODE_CBR : |
247 |
param.bitrate = codec->config.bitrate; |
param.rc_bitrate = codec->config.rc_bitrate; |
248 |
param.rc_buffersize = codec->config.rc_buffersize; |
param.rc_reaction_delay_factor = codec->config.rc_reaction_delay_factor; |
249 |
|
param.rc_averaging_period = codec->config.rc_averaging_period; |
250 |
|
param.rc_buffer = codec->config.rc_buffer; |
251 |
break; |
break; |
252 |
|
|
253 |
case DLG_MODE_VBR_QUAL : |
case DLG_MODE_VBR_QUAL : |
254 |
codec->config.fquant = 0; |
codec->config.fquant = 0; |
255 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
256 |
break; |
break; |
257 |
|
|
258 |
case DLG_MODE_VBR_QUANT : |
case DLG_MODE_VBR_QUANT : |
259 |
codec->config.fquant = (float) codec->config.quant; |
codec->config.fquant = (float) codec->config.quant; |
260 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
261 |
break; |
break; |
262 |
|
|
263 |
case DLG_MODE_2PASS_1 : |
case DLG_MODE_2PASS_1 : |
264 |
case DLG_MODE_2PASS_2_INT : |
case DLG_MODE_2PASS_2_INT : |
265 |
case DLG_MODE_2PASS_2_EXT : |
case DLG_MODE_2PASS_2_EXT : |
266 |
param.bitrate = 0; |
param.rc_bitrate = 0; |
267 |
|
codec->twopass.max_framesize = (int)((double)codec->config.twopass_max_bitrate / 8.0 / ((double)codec->fbase / (double)codec->fincr)); |
268 |
break; |
break; |
269 |
|
|
270 |
case DLG_MODE_NULL : |
case DLG_MODE_NULL : |
290 |
param.fincr = codec->fincr; |
param.fincr = codec->fincr; |
291 |
param.fbase = codec->fbase; |
param.fbase = codec->fbase; |
292 |
|
|
|
param.rc_buffersize = codec->config.rc_buffersize; |
|
|
|
|
293 |
param.min_quantizer = codec->config.min_pquant; |
param.min_quantizer = codec->config.min_pquant; |
294 |
param.max_quantizer = codec->config.max_pquant; |
param.max_quantizer = codec->config.max_pquant; |
295 |
param.max_key_interval = codec->config.max_key_interval; |
param.max_key_interval = codec->config.max_key_interval; |
296 |
|
|
297 |
|
#ifdef BFRAMES |
298 |
|
param.global = 0; |
299 |
|
if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED; |
300 |
|
if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP; |
301 |
|
if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG; |
302 |
|
param.max_bframes = codec->config.max_bframes; |
303 |
|
param.bquant_ratio = codec->config.bquant_ratio; |
304 |
|
#endif |
305 |
|
|
306 |
switch(xvid_encore(0, XVID_ENC_CREATE, ¶m, NULL)) |
switch(xvid_encore(0, XVID_ENC_CREATE, ¶m, NULL)) |
307 |
{ |
{ |
308 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
383 |
if(codec->config.motion_search > 4) |
if(codec->config.motion_search > 4) |
384 |
frame.general |= XVID_INTER4V; |
frame.general |= XVID_INTER4V; |
385 |
|
|
386 |
if(((codec->config.mode == DLG_MODE_2PASS_1) ? 0 : codec->config.lum_masking) == 1) |
if (codec->config.lum_masking) |
387 |
frame.general |= XVID_LUMIMASKING; |
frame.general |= XVID_LUMIMASKING; |
388 |
|
|
389 |
if (codec->config.interlacing) |
if (codec->config.interlacing) |
390 |
frame.general |= XVID_INTERLACING; |
frame.general |= XVID_INTERLACING; |
391 |
|
// fix 1pass modes/hinted MV by koepi |
392 |
|
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)) |
393 |
|
{ |
394 |
|
codec->config.hinted_me = 0; |
395 |
|
} |
396 |
|
// end of ugly hack |
397 |
|
|
398 |
if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1) |
if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1) |
399 |
{ |
{ |
504 |
{ |
{ |
505 |
frame.intra = 1; |
frame.intra = 1; |
506 |
} |
} |
507 |
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 || codec->config.mode == DLG_MODE_CBR || codec->config.mode == DLG_MODE_VBR_QUANT || |
|
|
codec->config.mode == DLG_MODE_VBR_QUAL || codec->config.mode == DLG_MODE_NULL)) |
|
508 |
{ |
{ |
509 |
DEBUG("current frame forced to p-frame"); |
DEBUG("current frame forced to p-frame"); |
510 |
frame.intra = 0; |
frame.intra = 0; |
511 |
} |
} |
512 |
|
|
513 |
|
OutputDebugString(" "); |
514 |
switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats)) |
switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats)) |
515 |
{ |
{ |
516 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
689 |
frame.image = icd->lpOutput; |
frame.image = icd->lpOutput; |
690 |
frame.stride = icd->lpbiOutput->biWidth; |
frame.stride = icd->lpbiOutput->biWidth; |
691 |
|
|
692 |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE))) |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL))) |
693 |
{ |
{ |
694 |
if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL) |
if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL) |
695 |
{ |
{ |