summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2023-04-25 23:24:46 +0200
committerDoris Verria <doris.verria@qt.io>2023-04-26 08:52:35 +0000
commit8262be7eda8a4f72418e3e0d527936505de073fc (patch)
treeda0edfaa3ddfad7a80dd89deac939b7c6606e237
parent1689940a061235545d6cc316fcc924284e7c3f1b (diff)
downloadqtmultimedia-8262be7eda8a4f72418e3e0d527936505de073fc.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 Pick-to: 6.5 Change-Id: I6b599d702384f479d8efee0673fe3eadcf9c12c2 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
-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;