49 |
|
|
50 |
#include <windows.h> |
#include <windows.h> |
51 |
#include <vfw.h> |
#include <vfw.h> |
52 |
|
#include <stdio.h> |
53 |
#include "vfwext.h" |
#include "vfwext.h" |
54 |
|
|
55 |
#include <xvid.h> |
#include <xvid.h> |
56 |
#include "debug.h" |
#include "debug.h" |
57 |
#include "codec.h" |
#include "codec.h" |
58 |
|
#include "status.h" |
59 |
|
|
60 |
|
|
61 |
static const int pmvfast_presets[7] = { |
static const int pmvfast_presets[7] = { |
209 |
|
|
210 |
if (lpbiOutput == NULL) |
if (lpbiOutput == NULL) |
211 |
{ |
{ |
212 |
return sizeof(BITMAPV4HEADER); |
return sizeof(BITMAPINFOHEADER); |
213 |
} |
} |
214 |
|
|
215 |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
245 |
|
|
246 |
LRESULT compress_frames_info(CODEC * codec, ICCOMPRESSFRAMES * icf) |
LRESULT compress_frames_info(CODEC * codec, ICCOMPRESSFRAMES * icf) |
247 |
{ |
{ |
248 |
//DPRINTF("%i %i", icf->lStartFrame, icf->lFrameCount); |
#if 0 |
249 |
|
DPRINTF("%i %i", icf->lStartFrame, icf->lFrameCount); |
250 |
|
#endif |
251 |
codec->fincr = icf->dwScale; |
codec->fincr = icf->dwScale; |
252 |
codec->fbase = icf->dwRate; |
codec->fbase = icf->dwRate; |
253 |
return ICERR_OK; |
return ICERR_OK; |
281 |
{ |
{ |
282 |
xvid_plg_data_t *data = (xvid_plg_data_t *) param1; |
xvid_plg_data_t *data = (xvid_plg_data_t *) param1; |
283 |
|
|
284 |
DPRINTF("[%5i] type=%c Q:%2i length:%6i", |
/* We don't use DPRINTF here because it's active only for _DEBUG |
285 |
|
* builds and that activates lot of other debug printfs. We only |
286 |
|
* want these all the time */ |
287 |
|
char buf[1024]; |
288 |
|
sprintf(buf, "[%6i] type=%c Q:%2i length:%6i", |
289 |
data->frame_num, |
data->frame_num, |
290 |
type2char(data->type), |
type2char(data->type), |
291 |
data->quant, |
data->quant, |
292 |
data->length); |
data->length); |
293 |
|
OutputDebugString(buf); |
294 |
|
|
295 |
return 0; |
return 0; |
296 |
} |
} |
297 |
} |
} |
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;*/ |
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 |
|
|
366 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
367 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
368 |
init.cpu_flags = codec->config.cpu; |
init.cpu_flags = codec->config.cpu; |
369 |
xvid_global(0, XVID_GBL_INIT, &init, NULL); |
init.debug = codec->config.debug; |
370 |
|
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; |
374 |
|
|
375 |
// zones |
/* zones */ |
376 |
create.zones = malloc(sizeof(xvid_enc_zone_t) * codec->config.num_zones); |
create.zones = malloc(sizeof(xvid_enc_zone_t) * codec->config.num_zones); |
377 |
create.num_zones = codec->config.num_zones; |
create.num_zones = codec->config.num_zones; |
378 |
for (i=0; i < create.num_zones; i++) { |
for (i=0; i < create.num_zones; i++) { |
379 |
create.zones[i].frame = codec->config.zones[i].frame; |
create.zones[i].frame = codec->config.zones[i].frame; |
380 |
if (create.zones[i].mode = RC_ZONE_QUANT) { |
if (codec->config.zones[i].mode == RC_ZONE_QUANT) { |
381 |
create.zones[i].mode = XVID_ZONE_QUANT; |
create.zones[i].mode = XVID_ZONE_QUANT; |
382 |
create.zones[i].increment = codec->config.zones[i].quant; |
create.zones[i].increment = codec->config.zones[i].quant; |
383 |
}else{ |
}else{ |
387 |
create.zones[i].base = 100; |
create.zones[i].base = 100; |
388 |
} |
} |
389 |
|
|
390 |
// plugins |
/* plugins */ |
391 |
create.plugins = plugins; |
create.plugins = plugins; |
392 |
switch (codec->config.mode) |
switch (codec->config.mode) |
393 |
{ |
{ |
394 |
case RC_MODE_1PASS : |
case RC_MODE_1PASS : |
395 |
memset(&single, 0, sizeof(single)); |
memset(&single, 0, sizeof(single)); |
396 |
single.version = XVID_VERSION; |
single.version = XVID_VERSION; |
397 |
single.bitrate = codec->config.bitrate; |
single.bitrate = codec->config.bitrate * CONFIG_KBPS; |
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; |
405 |
|
|
406 |
case RC_MODE_2PASS1 : |
case RC_MODE_2PASS1 : |
407 |
memset(&pass1, 0, sizeof(pass1)); |
memset(&pass1, 0, sizeof(pass1)); |
408 |
pass1.version = XVID_VERSION; |
pass1.version = XVID_VERSION; |
409 |
|
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; |
416 |
case RC_MODE_2PASS2 : |
case RC_MODE_2PASS2 : |
417 |
memset(&pass2, 0, sizeof(pass2)); |
memset(&pass2, 0, sizeof(pass2)); |
418 |
pass2.version = XVID_VERSION; |
pass2.version = XVID_VERSION; |
419 |
pass2.bitrate = codec->config.bitrate; |
if (codec->config.use_2pass_bitrate) { |
420 |
|
pass2.bitrate = codec->config.bitrate * CONFIG_KBPS; |
421 |
|
}else{ |
422 |
|
pass2.bitrate = -codec->config.desired_size; /* kilobytes */ |
423 |
|
} |
424 |
pass2.filename = codec->config.stats; |
pass2.filename = codec->config.stats; |
425 |
|
|
426 |
plugins[create.num_plugins].func = xvid_plugin_2pass2; |
pass2.keyframe_boost = codec->config.keyframe_boost; /* keyframe boost percentage: [0..100...]; */ |
427 |
|
pass2.curve_compression_high = codec->config.curve_compression_high; |
428 |
|
pass2.curve_compression_low = codec->config.curve_compression_low; |
429 |
|
pass2.overflow_control_strength = codec->config.overflow_control_strength; |
430 |
|
pass2.max_overflow_improvement = codec->config.twopass_max_overflow_improvement; |
431 |
|
pass2.max_overflow_degradation = codec->config.twopass_max_overflow_degradation; |
432 |
|
pass2.kfreduction = codec->config.kfreduction; |
433 |
|
pass2.kfthreshold = codec->config.kfthreshold; |
434 |
|
pass2.container_frame_overhead = 24; /* AVI */ |
435 |
|
|
436 |
|
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; |
507 |
codec->framenum = 0; |
codec->framenum = 0; |
508 |
codec->keyspacing = 0; |
codec->keyspacing = 0; |
509 |
|
|
510 |
|
if (codec->config.display_status) { |
511 |
|
status_destroy_always(&codec->status); |
512 |
|
status_create(&codec->status, codec->fincr, codec->fbase); |
513 |
|
} |
514 |
|
|
515 |
return ICERR_OK; |
return ICERR_OK; |
516 |
} |
} |
517 |
|
|
518 |
|
|
519 |
LRESULT compress_end(CODEC * codec) |
LRESULT compress_end(CODEC * codec) |
520 |
{ |
{ |
521 |
if (codec->ehandle != NULL) |
if (m_hdll != NULL) { |
522 |
{ |
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) |
531 |
|
status_destroy(&codec->status); |
532 |
|
|
533 |
return ICERR_OK; |
return ICERR_OK; |
534 |
} |
} |
539 |
int i; |
int i; |
540 |
|
|
541 |
for (i=0; i<config->num_zones && config->zones[i].frame <= framenum; i++) ; |
for (i=0; i<config->num_zones && config->zones[i].frame <= framenum; i++) ; |
542 |
i--; |
|
543 |
|
if (--i < 0) return; /* there are no zones, or we're before the first zone */ |
544 |
|
|
545 |
|
if (framenum == config->zones[i].frame) |
546 |
|
frame->type = config->zones[i].type; |
547 |
|
|
548 |
if (config->zones[i].greyscale) { |
if (config->zones[i].greyscale) { |
549 |
frame->vop_flags |= XVID_VOP_GREYSCALE; |
frame->vop_flags |= XVID_VOP_GREYSCALE; |
599 |
frame.motion |= XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE8; |
frame.motion |= XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE8; |
600 |
} |
} |
601 |
|
|
602 |
if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) |
if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) { |
603 |
frame.vol_flags |= XVID_VOL_GMC; |
frame.vol_flags |= XVID_VOL_GMC; |
604 |
|
frame.motion |= XVID_ME_GME_REFINE; |
605 |
|
} |
606 |
|
|
607 |
if ((profiles[codec->config.profile].flags & PROFILE_INTERLACE) && codec->config.interlacing) |
if ((profiles[codec->config.profile].flags & PROFILE_INTERLACE) && codec->config.interlacing) |
608 |
frame.vol_flags |= XVID_VOL_INTERLACING; |
frame.vol_flags |= XVID_VOL_INTERLACING; |
609 |
|
|
610 |
|
if (codec->config.ar_mode == 0) { /* PAR */ |
611 |
|
if (codec->config.display_aspect_ratio != 5) { |
612 |
|
frame.par = codec->config.display_aspect_ratio + 1; |
613 |
|
} else { |
614 |
|
frame.par = XVID_PAR_EXT; |
615 |
|
frame.par_width = codec->config.par_x; |
616 |
|
frame.par_height= codec->config.par_y; |
617 |
|
} |
618 |
|
} else { /* AR */ |
619 |
|
/* custom pixel aspect ratio -> calculated from DAR */ |
620 |
|
frame.par = XVID_PAR_EXT; |
621 |
|
frame.par_width = (100 * inhdr->biHeight) / codec->config.ar_y; |
622 |
|
frame.par_height= (100 * inhdr->biWidth) / codec->config.ar_x; |
623 |
|
} |
624 |
|
|
625 |
/* vop stuff */ |
/* vop stuff */ |
626 |
|
|
627 |
frame.vop_flags |= XVID_VOP_HALFPEL; |
frame.vop_flags |= XVID_VOP_HALFPEL; |
628 |
frame.vop_flags |= XVID_VOP_HQACPRED; |
frame.vop_flags |= XVID_VOP_HQACPRED; |
629 |
|
|
630 |
if (codec->config.debug) |
if (codec->config.vop_debug) |
631 |
frame.vop_flags |= XVID_VOP_DEBUG; |
frame.vop_flags |= XVID_VOP_DEBUG; |
632 |
|
|
633 |
if (codec->config.trellis_quant) { |
if (codec->config.trellis_quant) { |
638 |
frame.vop_flags |= XVID_VOP_INTER4V; |
frame.vop_flags |= XVID_VOP_INTER4V; |
639 |
|
|
640 |
if (codec->config.chromame) |
if (codec->config.chromame) |
641 |
frame.vop_flags |= XVID_ME_CHROMA16 + XVID_ME_CHROMA8; |
frame.motion |= XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP; |
642 |
|
|
643 |
|
if (codec->config.cartoon_mode) { |
644 |
|
frame.vop_flags |= XVID_VOP_CARTOON; |
645 |
|
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) |
656 |
{ |
{ |
657 |
case VHQ_MODE_DECISION : |
case VHQ_MODE_DECISION : |
658 |
frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; |
frame.vop_flags |= XVID_VOP_MODEDECISION_RD; |
659 |
break; |
break; |
660 |
|
|
661 |
case VHQ_LIMITED_SEARCH : |
case VHQ_LIMITED_SEARCH : |
662 |
frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; |
frame.vop_flags |= XVID_VOP_MODEDECISION_RD; |
663 |
frame.motion |= XVID_ME_HALFPELREFINE16_BITS; |
frame.motion |= XVID_ME_HALFPELREFINE16_RD; |
664 |
frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; |
frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; |
665 |
break; |
break; |
666 |
|
|
667 |
case VHQ_MEDIUM_SEARCH : |
case VHQ_MEDIUM_SEARCH : |
668 |
frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; |
frame.vop_flags |= XVID_VOP_MODEDECISION_RD; |
669 |
frame.motion |= XVID_ME_HALFPELREFINE16_BITS; |
frame.motion |= XVID_ME_HALFPELREFINE16_RD; |
670 |
frame.motion |= XVID_ME_HALFPELREFINE8_BITS; |
frame.motion |= XVID_ME_HALFPELREFINE8_RD; |
671 |
frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; |
frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; |
672 |
frame.motion |= XVID_ME_QUARTERPELREFINE8_BITS; |
frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; |
673 |
frame.motion |= XVID_ME_CHECKPREDICTION_BITS; |
frame.motion |= XVID_ME_CHECKPREDICTION_RD; |
674 |
break; |
break; |
675 |
|
|
676 |
case VHQ_WIDE_SEARCH : |
case VHQ_WIDE_SEARCH : |
677 |
frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; |
frame.vop_flags |= XVID_VOP_MODEDECISION_RD; |
678 |
frame.motion |= XVID_ME_HALFPELREFINE16_BITS; |
frame.motion |= XVID_ME_HALFPELREFINE16_RD; |
679 |
frame.motion |= XVID_ME_HALFPELREFINE8_BITS; |
frame.motion |= XVID_ME_HALFPELREFINE8_RD; |
680 |
frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; |
frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; |
681 |
frame.motion |= XVID_ME_QUARTERPELREFINE8_BITS; |
frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; |
682 |
frame.motion |= XVID_ME_CHECKPREDICTION_BITS; |
frame.motion |= XVID_ME_CHECKPREDICTION_RD; |
683 |
frame.motion |= XVID_ME_EXTSEARCH_BITS; |
frame.motion |= XVID_ME_EXTSEARCH_RD; |
684 |
break; |
break; |
685 |
|
|
686 |
default : |
default : |
709 |
|
|
710 |
// force keyframe spacing in 2-pass 1st pass |
// force keyframe spacing in 2-pass 1st pass |
711 |
if (codec->config.motion_search == 0) |
if (codec->config.motion_search == 0) |
|
{ |
|
712 |
frame.type = XVID_TYPE_IVOP; |
frame.type = XVID_TYPE_IVOP; |
|
} |
|
|
else if (codec->keyspacing < codec->config.min_key_interval && codec->framenum) |
|
|
{ |
|
|
DPRINTF("current frame forced to p-frame"); |
|
|
frame.type = XVID_TYPE_PVOP; |
|
|
} |
|
713 |
|
|
714 |
/* frame-based stuff */ |
/* frame-based stuff */ |
715 |
apply_zone_modifiers(&frame, &codec->config, codec->framenum); |
apply_zone_modifiers(&frame, &codec->config, codec->framenum); |
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 : |
735 |
return ICERR_UNSUPPORTED; |
return ICERR_UNSUPPORTED; |
736 |
} |
} |
737 |
|
|
738 |
|
if (codec->config.display_status && stats.type>0) { |
739 |
|
status_update(&codec->status, stats.type, stats.length, stats.quant); |
740 |
|
} |
741 |
|
|
742 |
DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); |
DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); |
743 |
|
|
744 |
if (length == 0) /* no encoder output */ |
if (length == 0) /* no encoder output */ |
822 |
|
|
823 |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
824 |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
825 |
// XXX: should we set outhdr->biSize ?? |
/* XXX: should we set outhdr->biSize ?? */ |
826 |
return ICERR_OK; |
return ICERR_OK; |
827 |
} |
} |
828 |
/* --- yv12 --- */ |
/* --- yv12 --- */ |
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; |