mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Promote colorspace information from decoder to swscale in FFmpeg backend.
This commit is contained in:
parent
157b0e7760
commit
7c740f555a
@ -1636,6 +1636,7 @@ bool CvCapture_FFMPEG::retrieveFrame(int flag, unsigned char** data, int* step,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
CV_LOG_DEBUG(NULL, "Input picture format: " << av_get_pix_fmt_name((AVPixelFormat)sw_picture->format));
|
CV_LOG_DEBUG(NULL, "Input picture format: " << av_get_pix_fmt_name((AVPixelFormat)sw_picture->format));
|
||||||
|
CV_LOG_DEBUG(NULL, "Input picture colorspace: " << av_get_colorspace_name(sw_picture->colorspace));
|
||||||
const AVPixelFormat result_format = convertRGB ? AV_PIX_FMT_BGR24 : (AVPixelFormat)sw_picture->format;
|
const AVPixelFormat result_format = convertRGB ? AV_PIX_FMT_BGR24 : (AVPixelFormat)sw_picture->format;
|
||||||
switch (result_format)
|
switch (result_format)
|
||||||
{
|
{
|
||||||
@ -1695,6 +1696,12 @@ bool CvCapture_FFMPEG::retrieveFrame(int flag, unsigned char** data, int* step,
|
|||||||
frame.height = video_st->CV_FFMPEG_CODEC_FIELD->height;
|
frame.height = video_st->CV_FFMPEG_CODEC_FIELD->height;
|
||||||
frame.data = rgb_picture.data[0];
|
frame.data = rgb_picture.data[0];
|
||||||
frame.step = rgb_picture.linesize[0];
|
frame.step = rgb_picture.linesize[0];
|
||||||
|
|
||||||
|
const int* colorspace_coeffs = sws_getCoefficients(sw_picture->colorspace);
|
||||||
|
sws_setColorspaceDetails(img_convert_ctx,
|
||||||
|
colorspace_coeffs, sw_picture->color_range,
|
||||||
|
colorspace_coeffs, convertRGB? 0: sw_picture->color_range,
|
||||||
|
0, 1<<16, 1<<16);
|
||||||
}
|
}
|
||||||
|
|
||||||
sws_scale(
|
sws_scale(
|
||||||
|
Loading…
Reference in New Issue
Block a user