299 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
300 |
} |
} |
301 |
|
|
302 |
|
#define XVID_DLL_NAME "xvidcore.dll" |
303 |
|
|
304 |
|
static int init_dll() |
305 |
|
{ |
306 |
|
if (m_hdll != NULL) return 0; |
307 |
|
|
308 |
|
DPRINTF("init_dll"); |
309 |
|
m_hdll = LoadLibrary(XVID_DLL_NAME); |
310 |
|
if (m_hdll == NULL) { |
311 |
|
DPRINTF("dll load failed"); |
312 |
|
MessageBox(0, XVID_DLL_NAME " not found","Error", 0); |
313 |
|
return XVID_ERR_FAIL; |
314 |
|
} |
315 |
|
|
316 |
|
xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"); |
317 |
|
if (xvid_global_func == NULL) { |
318 |
|
MessageBox(0, "xvid_global() not found", "Error", 0); |
319 |
|
return XVID_ERR_FAIL; |
320 |
|
} |
321 |
|
|
322 |
|
xvid_encore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_encore"); |
323 |
|
if (xvid_encore_func == NULL) { |
324 |
|
MessageBox(0, "xvid_encore() not found", "Error", 0); |
325 |
|
return XVID_ERR_FAIL; |
326 |
|
} |
327 |
|
|
328 |
|
xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore"); |
329 |
|
if (xvid_decore_func == NULL) { |
330 |
|
MessageBox(0, "xvid_decore() not found", "Error", 0); |
331 |
|
return XVID_ERR_FAIL; |
332 |
|
} |
333 |
|
|
334 |
|
xvid_plugin_single_func = |
335 |
|
(int (__cdecl *)(void *, int, void *, void *))(GetProcAddress(m_hdll, "xvid_plugin_single")); |
336 |
|
xvid_plugin_2pass1_func = |
337 |
|
(int (__cdecl *)(void *, int, void *, void *))(GetProcAddress(m_hdll, "xvid_plugin_2pass1")); |
338 |
|
xvid_plugin_2pass2_func = |
339 |
|
(int (__cdecl *)(void *, int, void *, void *))(GetProcAddress(m_hdll, "xvid_plugin_2pass2")); |
340 |
|
xvid_plugin_lumimasking_func = |
341 |
|
(int (__cdecl *)(void *, int, void *, void *))(GetProcAddress(m_hdll, "xvid_plugin_lumimasking")); |
342 |
|
xvid_plugin_psnr_func = |
343 |
|
(int (__cdecl *)(void *, int, void *, void *))(GetProcAddress(m_hdll, "xvid_plugin_psnr")); |
344 |
|
|
345 |
|
return 0; |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
356 |
xvid_plugin_2pass2_t pass2; |
xvid_plugin_2pass2_t pass2; |
357 |
int i; |
int i; |
358 |
|
|
359 |
|
if (init_dll() != 0) return ICERR_ERROR; |
360 |
/* destroy previously created codec */ |
/* destroy previously created codec */ |
361 |
if(codec->ehandle) { |
if(codec->ehandle) { |
362 |
xvid_encore(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
xvid_encore_func(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
363 |
codec->ehandle = NULL; |
codec->ehandle = NULL; |
364 |
} |
} |
365 |
|
|
367 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
368 |
init.cpu_flags = codec->config.cpu; |
init.cpu_flags = codec->config.cpu; |
369 |
init.debug = codec->config.debug; |
init.debug = codec->config.debug; |
370 |
xvid_global(0, XVID_GBL_INIT, &init, NULL); |
xvid_global_func(0, XVID_GBL_INIT, &init, NULL); |
371 |
|
|
372 |
memset(&create, 0, sizeof(create)); |
memset(&create, 0, sizeof(create)); |
373 |
create.version = XVID_VERSION; |
create.version = XVID_VERSION; |
398 |
single.reaction_delay_factor = codec->config.rc_reaction_delay_factor; |
single.reaction_delay_factor = codec->config.rc_reaction_delay_factor; |
399 |
single.averaging_period = codec->config.rc_averaging_period; |
single.averaging_period = codec->config.rc_averaging_period; |
400 |
single.buffer = codec->config.rc_buffer; |
single.buffer = codec->config.rc_buffer; |
401 |
plugins[create.num_plugins].func = xvid_plugin_single; |
plugins[create.num_plugins].func = xvid_plugin_single_func; |
402 |
plugins[create.num_plugins].param = &single; |
plugins[create.num_plugins].param = &single; |
403 |
create.num_plugins++; |
create.num_plugins++; |
404 |
break; |
break; |
408 |
pass1.version = XVID_VERSION; |
pass1.version = XVID_VERSION; |
409 |
pass1.filename = codec->config.stats; |
pass1.filename = codec->config.stats; |
410 |
|
|
411 |
plugins[create.num_plugins].func = xvid_plugin_2pass1; |
plugins[create.num_plugins].func = xvid_plugin_2pass1_func; |
412 |
plugins[create.num_plugins].param = &pass1; |
plugins[create.num_plugins].param = &pass1; |
413 |
create.num_plugins++; |
create.num_plugins++; |
414 |
break; |
break; |
433 |
pass2.kfthreshold = codec->config.kfthreshold; |
pass2.kfthreshold = codec->config.kfthreshold; |
434 |
pass2.container_frame_overhead = 24; /* AVI */ |
pass2.container_frame_overhead = 24; /* AVI */ |
435 |
|
|
436 |
plugins[create.num_plugins].func = xvid_plugin_2pass2; |
plugins[create.num_plugins].func = xvid_plugin_2pass2_func; |
437 |
plugins[create.num_plugins].param = &pass2; |
plugins[create.num_plugins].param = &pass2; |
438 |
create.num_plugins++; |
create.num_plugins++; |
439 |
break; |
break; |
446 |
} |
} |
447 |
|
|
448 |
if ((profiles[codec->config.profile].flags & PROFILE_ADAPTQUANT) && codec->config.lum_masking) { |
if ((profiles[codec->config.profile].flags & PROFILE_ADAPTQUANT) && codec->config.lum_masking) { |
449 |
plugins[create.num_plugins].func = xvid_plugin_lumimasking; |
plugins[create.num_plugins].func = xvid_plugin_lumimasking_func; |
450 |
plugins[create.num_plugins].param = NULL; |
plugins[create.num_plugins].param = NULL; |
451 |
create.num_plugins++; |
create.num_plugins++; |
452 |
} |
} |
488 |
|
|
489 |
create.num_threads = codec->config.num_threads; |
create.num_threads = codec->config.num_threads; |
490 |
|
|
491 |
switch(xvid_encore(0, XVID_ENC_CREATE, &create, NULL)) |
switch(xvid_encore_func(0, XVID_ENC_CREATE, &create, NULL)) |
492 |
{ |
{ |
493 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
494 |
return ICERR_ERROR; |
return ICERR_ERROR; |
518 |
|
|
519 |
LRESULT compress_end(CODEC * codec) |
LRESULT compress_end(CODEC * codec) |
520 |
{ |
{ |
521 |
|
if (m_hdll != NULL) { |
522 |
if (codec->ehandle != NULL) { |
if (codec->ehandle != NULL) { |
523 |
xvid_encore(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
xvid_encore_func(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
524 |
codec->ehandle = NULL; |
codec->ehandle = NULL; |
525 |
} |
} |
526 |
|
FreeLibrary(m_hdll); |
527 |
|
m_hdll = NULL; |
528 |
|
} |
529 |
|
|
530 |
if (codec->config.display_status) |
if (codec->config.display_status) |
531 |
status_destroy(&codec->status); |
status_destroy(&codec->status); |
645 |
frame.motion |= XVID_ME_DETECT_STATIC_MOTION; |
frame.motion |= XVID_ME_DETECT_STATIC_MOTION; |
646 |
} |
} |
647 |
|
|
648 |
|
if (codec->config.turbo) |
649 |
|
frame.motion |= XVID_ME_FASTREFINE16 | XVID_ME_FASTREFINE8 | |
650 |
|
XVID_ME_SKIP_DELTASEARCH | XVID_ME_FAST_MODEINTERPOLATE | |
651 |
|
XVID_ME_BFRAME_EARLYSTOP; |
652 |
|
|
653 |
frame.motion |= pmvfast_presets[codec->config.motion_search]; |
frame.motion |= pmvfast_presets[codec->config.motion_search]; |
654 |
|
|
655 |
switch (codec->config.vhq_mode) |
switch (codec->config.vhq_mode) |
719 |
memset(&stats, 0, sizeof(stats)); |
memset(&stats, 0, sizeof(stats)); |
720 |
stats.version = XVID_VERSION; |
stats.version = XVID_VERSION; |
721 |
|
|
722 |
length = xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats); |
length = xvid_encore_func(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats); |
723 |
switch (length) |
switch (length) |
724 |
{ |
{ |
725 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
854 |
xvid_gbl_init_t init; |
xvid_gbl_init_t init; |
855 |
xvid_dec_create_t create; |
xvid_dec_create_t create; |
856 |
|
|
857 |
|
if (init_dll() != 0) return ICERR_ERROR; |
858 |
|
|
859 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
860 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
861 |
init.cpu_flags = codec->config.cpu; |
init.cpu_flags = codec->config.cpu; |
862 |
xvid_global(0, XVID_GBL_INIT, &init, NULL); |
xvid_global_func(0, XVID_GBL_INIT, &init, NULL); |
863 |
|
|
864 |
memset(&create, 0, sizeof(create)); |
memset(&create, 0, sizeof(create)); |
865 |
create.version = XVID_VERSION; |
create.version = XVID_VERSION; |
866 |
create.width = lpbiInput->bmiHeader.biWidth; |
create.width = lpbiInput->bmiHeader.biWidth; |
867 |
create.height = lpbiInput->bmiHeader.biHeight; |
create.height = lpbiInput->bmiHeader.biHeight; |
868 |
|
|
869 |
switch(xvid_decore(0, XVID_DEC_CREATE, &create, NULL)) |
switch(xvid_decore_func(0, XVID_DEC_CREATE, &create, NULL)) |
870 |
{ |
{ |
871 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
872 |
return ICERR_ERROR; |
return ICERR_ERROR; |
889 |
|
|
890 |
LRESULT decompress_end(CODEC * codec) |
LRESULT decompress_end(CODEC * codec) |
891 |
{ |
{ |
892 |
if (codec->dhandle != NULL) |
if (m_hdll != NULL) { |
893 |
{ |
if (codec->dhandle != NULL) { |
894 |
xvid_decore(codec->dhandle, XVID_DEC_DESTROY, NULL, NULL); |
xvid_decore_func(codec->dhandle, XVID_DEC_DESTROY, NULL, NULL); |
895 |
codec->dhandle = NULL; |
codec->dhandle = NULL; |
896 |
} |
} |
897 |
|
FreeLibrary(m_hdll); |
898 |
|
m_hdll = NULL; |
899 |
|
} |
900 |
|
|
901 |
return ICERR_OK; |
return ICERR_OK; |
902 |
} |
} |
903 |
|
|
943 |
convert.interlacing = 0; |
convert.interlacing = 0; |
944 |
if (convert.input.csp == XVID_CSP_NULL || |
if (convert.input.csp == XVID_CSP_NULL || |
945 |
convert.output.csp == XVID_CSP_NULL || |
convert.output.csp == XVID_CSP_NULL || |
946 |
xvid_global(0, XVID_GBL_CONVERT, &convert, NULL) < 0) |
xvid_global_func(0, XVID_GBL_CONVERT, &convert, NULL) < 0) |
947 |
{ |
{ |
948 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
949 |
} |
} |
973 |
frame.output.csp = XVID_CSP_NULL; |
frame.output.csp = XVID_CSP_NULL; |
974 |
} |
} |
975 |
|
|
976 |
switch (xvid_decore(codec->dhandle, XVID_DEC_DECODE, &frame, NULL)) |
switch (xvid_decore_func(codec->dhandle, XVID_DEC_DECODE, &frame, NULL)) |
977 |
{ |
{ |
978 |
case XVID_ERR_FAIL : |
case XVID_ERR_FAIL : |
979 |
return ICERR_ERROR; |
return ICERR_ERROR; |