57 |
#include "codec.h" |
#include "codec.h" |
58 |
#include "status.h" |
#include "status.h" |
59 |
|
|
60 |
|
HINSTANCE m_hdll; |
61 |
|
int (*xvid_global_func)(void *handle, int opt, void *param1, void *param2); |
62 |
|
int (*xvid_encore_func)(void *handle, int opt, void *param1, void *param2); |
63 |
|
int (*xvid_decore_func)(void *handle, int opt, void *param1, void *param2); |
64 |
|
|
65 |
|
xvid_plugin_func *xvid_plugin_single_func, |
66 |
|
*xvid_plugin_2pass1_func, |
67 |
|
*xvid_plugin_2pass2_func, |
68 |
|
*xvid_plugin_lumimasking_func, |
69 |
|
*xvid_plugin_psnr_func; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
static const int pmvfast_presets[7] = { |
static const int pmvfast_presets[7] = { |
74 |
0, 0, 0, 0, |
0, 0, 0, 0, |
358 |
return 0; |
return 0; |
359 |
} |
} |
360 |
|
|
361 |
|
/* constant-quant zones for fixed quant encoding */ |
362 |
static void |
static void |
363 |
prepare_cquant_zones(CONFIG * config) { |
prepare_cquant_zones(CONFIG * config) { |
364 |
|
|
390 |
} |
} |
391 |
} |
} |
392 |
|
|
393 |
|
/* full first pass zones */ |
394 |
|
static void |
395 |
|
prepare_full1pass_zones(CONFIG * config) { |
396 |
|
|
397 |
|
int i = 0; |
398 |
|
if (config->num_zones == 0 || config->zones[0].frame != 0) { |
399 |
|
/* first zone does not start at frame 0 or doesn't exist */ |
400 |
|
|
401 |
|
if (config->num_zones >= MAX_ZONES) config->num_zones--; /* we scrifice last zone */ |
402 |
|
|
403 |
|
config->zones[config->num_zones].frame = 0; |
404 |
|
config->zones[config->num_zones].mode = RC_ZONE_QUANT; |
405 |
|
config->zones[config->num_zones].weight = 100; |
406 |
|
config->zones[config->num_zones].quant = 200; |
407 |
|
config->zones[config->num_zones].type = XVID_TYPE_AUTO; |
408 |
|
config->zones[config->num_zones].greyscale = 0; |
409 |
|
config->zones[config->num_zones].chroma_opt = 0; |
410 |
|
config->zones[config->num_zones].bvop_threshold = 0; |
411 |
|
config->num_zones++; |
412 |
|
|
413 |
|
sort_zones(config->zones, config->num_zones, &i); |
414 |
|
} |
415 |
|
|
416 |
|
/* step 2: let's change all weight zones into quant zones */ |
417 |
|
|
418 |
|
for(i = 0; i < config->num_zones; i++) |
419 |
|
if (config->zones[i].mode == RC_ZONE_WEIGHT) { |
420 |
|
config->zones[i].mode = RC_ZONE_QUANT; |
421 |
|
config->zones[i].quant = 200; |
422 |
|
} |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) |
427 |
{ |
{ |
475 |
memset(&pass1, 0, sizeof(pass1)); |
memset(&pass1, 0, sizeof(pass1)); |
476 |
pass1.version = XVID_VERSION; |
pass1.version = XVID_VERSION; |
477 |
pass1.filename = codec->config.stats; |
pass1.filename = codec->config.stats; |
478 |
|
if (codec->config.full1pass) |
479 |
|
prepare_full1pass_zones(&tmpCfg); |
480 |
plugins[create.num_plugins].func = xvid_plugin_2pass1_func; |
plugins[create.num_plugins].func = xvid_plugin_2pass1_func; |
481 |
plugins[create.num_plugins].param = &pass1; |
plugins[create.num_plugins].param = &pass1; |
482 |
create.num_plugins++; |
create.num_plugins++; |
788 |
if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL) |
if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL) |
789 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
790 |
|
|
791 |
if (frame.input.csp == XVID_CSP_I420 || frame.input.csp == XVID_CSP_YV12) |
if (frame.input.csp == XVID_CSP_I420 || frame.input.csp == XVID_CSP_YV12) { |
792 |
frame.input.stride[0] = (frame.input.stride[0]*2)/3; |
frame.input.stride[0] = (4 * icc->lpbiInput->biWidth + 3) / 4; |
793 |
|
frame.input.stride[1] = frame.input.stride[2] = frame.input.stride[0] / 2 ; |
794 |
|
} |
795 |
|
|
796 |
frame.bitstream = icc->lpOutput; |
frame.bitstream = icc->lpOutput; |
797 |
frame.length = icc->lpbiOutput->biSizeImage; |
frame.length = icc->lpbiOutput->biSizeImage; |