From 15abbc8c9e3acb5d9bee70fd8bec25242ec7abdd Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Fri, 21 Jun 2019 15:41:30 +0200 Subject: DirectShow: Map MEDIASUBTYPE_RGB24 to QVideoFrame::Format_BGR24 MEDIASUBTYPE_RGB24 inverts Red and Blue channels, i.e. on Little-Endian: BGR and thus Format_BGR24 should be used instead of Format_RGB24. To reproduce the bug: QCameraViewfinderSettings settings; settings.setPixelFormat(QVideoFrame::Format_RGB24); camera->setViewfinderSettings(settings); If the camera supports MEDIASUBTYPE_RGB24 it will show Red and Blue channels inverted. *NOTE* This fix causes ignoring MEDIASUBTYPE_RGB24 format and using MEDUASUBTYPE_RGB32 instead. Because the video surfaces currently do not support QVideoFrame::Format_BGR32. So it fixes the issue with inverted colors by ignoring RGB24 media type. If there is a need to use RGB24, it would require to implement custom surface which supports QVideoFrame::Format_BGR24 and swap colors manually. Change-Id: I0d77694ef688a05dc52d13f991a5088e00f72867 Fixes: QTBUG-75959 Reviewed-by: Timur Pocheptsov --- src/plugins/directshow/common/directshowmediatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/directshow/common/directshowmediatype.cpp b/src/plugins/directshow/common/directshowmediatype.cpp index fe86e0204..103f1ddc1 100644 --- a/src/plugins/directshow/common/directshowmediatype.cpp +++ b/src/plugins/directshow/common/directshowmediatype.cpp @@ -52,7 +52,7 @@ namespace { { QVideoFrame::Format_ARGB32, MEDIASUBTYPE_ARGB32 }, { QVideoFrame::Format_RGB32, MEDIASUBTYPE_RGB32 }, - { QVideoFrame::Format_RGB24, MEDIASUBTYPE_RGB24 }, + { QVideoFrame::Format_BGR24, MEDIASUBTYPE_RGB24 }, { QVideoFrame::Format_RGB565, MEDIASUBTYPE_RGB565 }, { QVideoFrame::Format_RGB555, MEDIASUBTYPE_RGB555 }, { QVideoFrame::Format_AYUV444, MEDIASUBTYPE_AYUV }, -- cgit v1.2.3