ffmpeg: avoid assert in ffmpeg
The input colorspace must be set.
This commit is contained in:
@@ -273,6 +273,15 @@ AVCodecEncoder::_Setup()
|
|||||||
|
|
||||||
if (fInputFormat.type == B_MEDIA_RAW_VIDEO) {
|
if (fInputFormat.type == B_MEDIA_RAW_VIDEO) {
|
||||||
TRACE(" B_MEDIA_RAW_VIDEO\n");
|
TRACE(" B_MEDIA_RAW_VIDEO\n");
|
||||||
|
|
||||||
|
// Check input parameters
|
||||||
|
AVPixelFormat pixFmt = colorspace_to_pixfmt(
|
||||||
|
fInputFormat.u.raw_video.display.format);
|
||||||
|
if (pixFmt == AV_PIX_FMT_NONE) {
|
||||||
|
TRACE("Invalid input colorspace");
|
||||||
|
return B_BAD_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
// frame rate
|
// frame rate
|
||||||
fCodecContext->time_base = (AVRational){1, (int)fInputFormat.u.raw_video.field_rate};
|
fCodecContext->time_base = (AVRational){1, (int)fInputFormat.u.raw_video.field_rate};
|
||||||
fCodecContext->framerate = (AVRational){(int)fInputFormat.u.raw_video.field_rate, 1};
|
fCodecContext->framerate = (AVRational){(int)fInputFormat.u.raw_video.field_rate, 1};
|
||||||
@@ -336,8 +345,8 @@ AVCodecEncoder::_Setup()
|
|||||||
fFrame->linesize[2] = fDstFrame.linesize[2];
|
fFrame->linesize[2] = fDstFrame.linesize[2];
|
||||||
fFrame->linesize[3] = fDstFrame.linesize[3];
|
fFrame->linesize[3] = fDstFrame.linesize[3];
|
||||||
|
|
||||||
fSwsContext = sws_getContext(fCodecContext->width, fCodecContext->height,
|
fSwsContext = sws_getContext(fCodecContext->width,
|
||||||
colorspace_to_pixfmt(fInputFormat.u.raw_video.display.format),
|
fCodecContext->height, pixFmt,
|
||||||
fCodecContext->width, fCodecContext->height,
|
fCodecContext->width, fCodecContext->height,
|
||||||
fCodecContext->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
fCodecContext->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user