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 |
// dev-api-3 |
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 && |
if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && get_colorspace(inhdr) == XVID_CSP_NULL) |
|
inhdr->biCompression != FOURCC_DIVX && |
|
|
inhdr->biCompression != FOURCC_DX50 && |
|
|
get_colorspace(inhdr) == XVID_CSP_NULL) |
|
628 |
{ |
{ |
629 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
630 |
} |
} |
657 |
} |
} |
658 |
|
|
659 |
/* --- yv12 --- */ |
/* --- yv12 --- */ |
660 |
|
|
661 |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
662 |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
663 |
// XXX: should we set outhdr->biSize ?? |
// XXX: should we set outhdr->biSize ?? |
746 |
icd->lpbiInput->biCompression != FOURCC_DX50) |
icd->lpbiInput->biCompression != FOURCC_DX50) |
747 |
{ |
{ |
748 |
XVID_INIT_CONVERTINFO convert; |
XVID_INIT_CONVERTINFO convert; |
|
|
|
749 |
DEBUGFOURCC("input", icd->lpbiInput->biCompression); |
DEBUGFOURCC("input", icd->lpbiInput->biCompression); |
750 |
DEBUGFOURCC("output", icd->lpbiOutput->biCompression); |
DEBUGFOURCC("output", icd->lpbiOutput->biCompression); |
|
|
|
751 |
convert.input.colorspace = get_colorspace(icd->lpbiInput); |
convert.input.colorspace = get_colorspace(icd->lpbiInput); |
752 |
convert.input.y = icd->lpInput; |
convert.input.y = icd->lpInput; |
753 |
convert.input.y_stride = (((icd->lpbiInput->biWidth * icd->lpbiInput->biBitCount) + 31) & ~31) >> 3; |
convert.input.y_stride = (((icd->lpbiInput->biWidth * icd->lpbiInput->biBitCount) + 31) & ~31) >> 3; |
|
|
|
754 |
convert.output.colorspace = get_colorspace(icd->lpbiOutput); |
convert.output.colorspace = get_colorspace(icd->lpbiOutput); |
755 |
convert.output.y = icd->lpOutput; |
convert.output.y = icd->lpOutput; |
756 |
convert.output.y_stride = (((icd->lpbiOutput->biWidth * icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; |
convert.output.y_stride = (((icd->lpbiOutput->biWidth * icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; |
|
|
|
757 |
convert.width = icd->lpbiInput->biWidth; |
convert.width = icd->lpbiInput->biWidth; |
758 |
convert.height = icd->lpbiInput->biHeight; |
convert.height = icd->lpbiInput->biHeight; |
759 |
convert.interlacing = 0; |
convert.interlacing = 0; |
|
|
|
760 |
if (convert.input.colorspace == XVID_CSP_NULL || |
if (convert.input.colorspace == XVID_CSP_NULL || |
761 |
convert.output.colorspace == XVID_CSP_NULL || |
convert.output.colorspace == XVID_CSP_NULL || |
762 |
xvid_init(NULL, XVID_INIT_CONVERT, &convert, NULL) != XVID_ERR_OK) |
xvid_init(NULL, XVID_INIT_CONVERT, &convert, NULL) != XVID_ERR_OK) |
763 |
{ |
{ |
764 |
return ICERR_BADFORMAT; |
return ICERR_BADFORMAT; |
765 |
} |
} |
|
|
|
766 |
return ICERR_OK; |
return ICERR_OK; |
767 |
} |
} |
768 |
/* --- yv12 --- */ |
/* --- yv12 --- */ |