summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2023-04-25 23:24:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-26 11:59:34 +0000
commitf6b8ce3e4ea815a2d5e93fe555f83f1de15025c7 (patch)
treef1ec72eef7ea6fbbe2baa4edc2ab1b264860eee4
parente95692cbfc2771c50b2413a4ac0bdb9015cc7821 (diff)
downloadqtmultimedia-f6b8ce3e4ea815a2d5e93fe555f83f1de15025c7.tar.gz
AVFVideo: Set color range to video frame format
Set the color range based on the pixel format. This ensures the correct color matrix is chosen. Task-number: QTBUG-108083 Change-Id: I6b599d702384f479d8efee0673fe3eadcf9c12c2 Reviewed-by: Lars Knoll <lars@knoll.priv.no> (cherry picked from commit 8262be7eda8a4f72418e3e0d527936505de073fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/darwin/qavfhelpers.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/multimedia/darwin/qavfhelpers.mm b/src/plugins/multimedia/darwin/qavfhelpers.mm
index c8195a81e..74d0c9b9c 100644
--- a/src/plugins/multimedia/darwin/qavfhelpers.mm
+++ b/src/plugins/multimedia/darwin/qavfhelpers.mm
@@ -7,6 +7,23 @@
#import <CoreVideo/CoreVideo.h>
+static QVideoFrameFormat::ColorRange colorRangeForPixelFormat(unsigned avPixelFormat)
+{
+ switch (avPixelFormat) {
+ case kCVPixelFormatType_420YpCbCr8PlanarFullRange:
+ case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
+ case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange:
+ return QVideoFrameFormat::ColorRange_Full;
+ case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
+ case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange:
+ case kCVPixelFormatType_422YpCbCr8:
+ case kCVPixelFormatType_422YpCbCr8_yuvs:
+ return QVideoFrameFormat::ColorRange_Video;
+ default:
+ return QVideoFrameFormat::ColorRange_Unknown;
+ }
+}
+
QVideoFrameFormat::PixelFormat QAVFHelpers::fromCVPixelFormat(unsigned avPixelFormat)
{
switch (avPixelFormat) {
@@ -149,6 +166,7 @@ QVideoFrameFormat QAVFHelpers::videoFormatForImageBuffer(CVImageBufferRef buffer
}
}
+ format.setColorRange(colorRangeForPixelFormat(avPixelFormat));
format.setColorSpace(colorSpace);
format.setColorTransfer(colorTransfer);
return format;