172 |
} |
} |
173 |
|
|
174 |
if (inhdr->biWidth != outhdr->biWidth || inhdr->biHeight != outhdr->biHeight || |
if (inhdr->biWidth != outhdr->biWidth || inhdr->biHeight != outhdr->biHeight || |
175 |
(outhdr->biCompression != FOURCC_XVID && outhdr->biCompression != FOURCC_DIVX)) |
(outhdr->biCompression != FOURCC_XVID && outhdr->biCompression != FOURCC_DIVX && outhdr->biCompression != FOURCC_DX50)) |
176 |
{ |
{ |
177 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
178 |
} |
} |
309 |
if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG; |
if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG; |
310 |
param.max_bframes = codec->config.max_bframes; |
param.max_bframes = codec->config.max_bframes; |
311 |
param.bquant_ratio = codec->config.bquant_ratio; |
param.bquant_ratio = codec->config.bquant_ratio; |
312 |
|
param.bquant_offset = codec->config.bquant_offset; |
313 |
param.frame_drop_ratio = codec->config.frame_drop_ratio; |
param.frame_drop_ratio = codec->config.frame_drop_ratio; |
314 |
#endif |
#endif |
315 |
|
|
401 |
if (codec->config.interlacing) |
if (codec->config.interlacing) |
402 |
frame.general |= XVID_INTERLACING; |
frame.general |= XVID_INTERLACING; |
403 |
|
|
404 |
|
if (codec->config.qpel) { |
405 |
|
frame.general |= XVID_QUARTERPEL; |
406 |
|
frame.motion |= PMV_QUARTERPELREFINE16 | PMV_QUARTERPELREFINE8; |
407 |
|
|
408 |
|
} |
409 |
|
|
410 |
|
if (codec->config.gmc) |
411 |
|
frame.general |= XVID_GMC; |
412 |
|
|
413 |
|
if (codec->config.chromame) |
414 |
|
frame.general |= XVID_ME_COLOUR; |
415 |
|
|
416 |
// added by koepi for credits greyscale |
// added by koepi for credits greyscale |
417 |
|
|
459 |
} |
} |
460 |
} |
} |
461 |
|
|
462 |
frame.motion = pmvfast_presets[codec->config.motion_search]; |
frame.motion |= pmvfast_presets[codec->config.motion_search]; |
463 |
|
|
464 |
frame.image = icc->lpInput; |
frame.image = icc->lpInput; |
465 |
|
// dev-api-3 |
466 |
|
frame.stride = (((icc->lpbiInput->biWidth * icc->lpbiInput->biBitCount) + 31) & ~31) >> 3; |
467 |
|
|
468 |
if ((frame.colorspace = get_colorspace(inhdr)) == XVID_CSP_NULL) |
if ((frame.colorspace = get_colorspace(inhdr)) == XVID_CSP_NULL) |
469 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
561 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
562 |
} |
} |
563 |
|
|
564 |
if (frame.intra) |
if (frame.intra==1) |
565 |
{ |
{ |
566 |
codec->keyspacing = 0; |
codec->keyspacing = 0; |
567 |
*icc->lpdwFlags = AVIIF_KEYFRAME; |
*icc->lpdwFlags = AVIIF_KEYFRAME; |
600 |
} |
} |
601 |
} |
} |
602 |
|
|
603 |
|
//quick fix for delayed frames |
604 |
|
// if (frame.intra != 5) |
605 |
codec_2pass_update(codec, &frame, &stats); |
codec_2pass_update(codec, &frame, &stats); |
606 |
|
|
607 |
++codec->framenum; |
++codec->framenum; |
624 |
return ICERR_ERROR; |
return ICERR_ERROR; |
625 |
} |
} |
626 |
|
|
627 |
if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX) |
if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && get_colorspace(inhdr) == XVID_CSP_NULL) |
628 |
{ |
{ |
629 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
630 |
} |
} |
656 |
return sizeof(BITMAPINFOHEADER); |
return sizeof(BITMAPINFOHEADER); |
657 |
} |
} |
658 |
|
|
659 |
|
/* --- yv12 --- */ |
660 |
|
|
661 |
|
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
662 |
|
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
663 |
|
// XXX: should we set outhdr->biSize ?? |
664 |
|
return ICERR_OK; |
665 |
|
} |
666 |
|
/* --- yv12 --- */ |
667 |
|
|
668 |
result = decompress_query(codec, lpbiInput, lpbiOutput); |
result = decompress_query(codec, lpbiInput, lpbiOutput); |
669 |
if (result != ICERR_OK) |
if (result != ICERR_OK) |
670 |
{ |
{ |
736 |
frame.length = icd->lpbiInput->biSizeImage; |
frame.length = icd->lpbiInput->biSizeImage; |
737 |
|
|
738 |
frame.image = icd->lpOutput; |
frame.image = icd->lpOutput; |
739 |
frame.stride = icd->lpbiOutput->biWidth; |
// frame.stride = icd->lpbiOutput->biWidth; |
740 |
|
// dev-api-3: |
741 |
|
frame.stride = (((icd->lpbiOutput->biWidth * icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; |
742 |
|
|
743 |
|
/* --- yv12 --- */ |
744 |
|
if (icd->lpbiInput->biCompression != FOURCC_XVID && |
745 |
|
icd->lpbiInput->biCompression != FOURCC_DIVX && |
746 |
|
icd->lpbiInput->biCompression != FOURCC_DX50) |
747 |
|
{ |
748 |
|
XVID_INIT_CONVERTINFO convert; |
749 |
|
DEBUGFOURCC("input", icd->lpbiInput->biCompression); |
750 |
|
DEBUGFOURCC("output", icd->lpbiOutput->biCompression); |
751 |
|
convert.input.colorspace = get_colorspace(icd->lpbiInput); |
752 |
|
convert.input.y = icd->lpInput; |
753 |
|
convert.input.y_stride = (((icd->lpbiInput->biWidth *icd->lpbiInput->biBitCount) + 31) & ~31) >> 3; |
754 |
|
convert.output.colorspace = get_colorspace(icd->lpbiOutput); |
755 |
|
convert.output.y = icd->lpOutput; |
756 |
|
convert.output.y_stride = (((icd->lpbiOutput->biWidth *icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; |
757 |
|
convert.width = icd->lpbiInput->biWidth; |
758 |
|
convert.height = icd->lpbiInput->biHeight; |
759 |
|
convert.interlacing = 0; |
760 |
|
if (convert.input.colorspace == XVID_CSP_NULL || |
761 |
|
convert.output.colorspace == XVID_CSP_NULL || |
762 |
|
xvid_init(NULL, XVID_INIT_CONVERT, &convert, NULL) != XVID_ERR_OK) |
763 |
|
{ |
764 |
|
return ICERR_BADFORMAT; |
765 |
|
} |
766 |
|
return ICERR_OK; |
767 |
|
} |
768 |
|
/* --- yv12 --- */ |
769 |
|
|
770 |
|
|
771 |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL))) |
if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL))) |
772 |
{ |
{ |