19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 |
* |
* |
22 |
* $Id: codec.c,v 1.28 2010-12-21 16:56:42 Isibaar Exp $ |
* $Id: codec.c,v 1.32 2011-01-27 13:13:06 Isibaar Exp $ |
23 |
* |
* |
24 |
*************************************************************************/ |
*************************************************************************/ |
25 |
|
|
433 |
else |
else |
434 |
create.num_threads = info.num_threads; /* Autodetect */ |
create.num_threads = info.num_threads; /* Autodetect */ |
435 |
|
|
436 |
|
/* Encoder slices */ |
437 |
|
if ((profiles[codec->config.profile].flags & PROFILE_RESYNCMARKER) && codec->config.num_slices != 1) { |
438 |
|
|
439 |
|
if (codec->config.num_slices == 0) { /* auto */ |
440 |
|
int mb_width = (lpbiInput->bmiHeader.biWidth + 15) / 16; |
441 |
|
int mb_height = (lpbiInput->bmiHeader.biHeight + 15) / 16; |
442 |
|
|
443 |
|
int slices = (int)((mb_width*mb_height) / 811); /* use multiple slices only above SD resolutions for now */ |
444 |
|
|
445 |
|
if (slices > 1) { |
446 |
|
if (create.num_threads <= 1) |
447 |
|
slices &= ~1; /* make even */ |
448 |
|
else if (create.num_threads <= slices) |
449 |
|
slices = (slices / create.num_threads) * create.num_threads; /* multiple of threads */ |
450 |
|
else if (create.num_threads % slices) |
451 |
|
slices = (!(create.num_threads%2)) ? (create.num_threads/2) : (create.num_threads/3); |
452 |
|
} |
453 |
|
|
454 |
|
create.num_slices = slices; |
455 |
|
} |
456 |
|
else { |
457 |
|
create.num_slices = codec->config.num_slices; /* force manual value - by registry edit */ |
458 |
|
} |
459 |
|
|
460 |
|
} |
461 |
|
|
462 |
/* plugins */ |
/* plugins */ |
463 |
create.plugins = plugins; |
create.plugins = plugins; |
464 |
switch (codec->config.mode) |
switch (codec->config.mode) |
919 |
{ |
{ |
920 |
BITMAPINFOHEADER * inhdr = &lpbiInput->bmiHeader; |
BITMAPINFOHEADER * inhdr = &lpbiInput->bmiHeader; |
921 |
BITMAPINFOHEADER * outhdr = &lpbiOutput->bmiHeader; |
BITMAPINFOHEADER * outhdr = &lpbiOutput->bmiHeader; |
922 |
|
int in_csp = XVID_CSP_NULL, out_csp = XVID_CSP_NULL; |
923 |
|
|
924 |
if (lpbiInput == NULL) |
if (lpbiInput == NULL) |
925 |
{ |
{ |
926 |
return ICERR_ERROR; |
return ICERR_ERROR; |
927 |
} |
} |
928 |
|
|
929 |
if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && get_colorspace(inhdr) == XVID_CSP_NULL) |
if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && (in_csp = get_colorspace(inhdr)) != XVID_CSP_YV12) |
930 |
{ |
{ |
931 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
932 |
} |
} |
936 |
return ICERR_OK; |
return ICERR_OK; |
937 |
} |
} |
938 |
|
|
939 |
|
out_csp = get_colorspace(outhdr); |
940 |
|
|
941 |
if (inhdr->biWidth != outhdr->biWidth || |
if (inhdr->biWidth != outhdr->biWidth || |
942 |
inhdr->biHeight != outhdr->biHeight || |
inhdr->biHeight != outhdr->biHeight || |
943 |
get_colorspace(outhdr) == XVID_CSP_NULL) |
out_csp == XVID_CSP_NULL || |
944 |
|
(in_csp == XVID_CSP_YV12 && in_csp != out_csp)) |
945 |
{ |
{ |
946 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
947 |
} |
} |