From 8a8b0cf3fa72ea523648601685ccbaad172fda7a Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 23 May 2020 23:10:25 +0200 Subject: [PATCH] ffmpeg/tools: Fix incorrect colors for sRGB --- source/ffmpeg/tools.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index 5a9007cf..51394280 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -250,17 +250,22 @@ void tools::setup_obs_color(video_colorspace colorspace, video_range_type range, { std::map> colorspaces = { - {VIDEO_CS_DEFAULT, {AVCOL_SPC_BT470BG, AVCOL_PRI_BT470BG, AVCOL_TRC_SMPTE170M}}, {VIDEO_CS_601, {AVCOL_SPC_BT470BG, AVCOL_PRI_BT470BG, AVCOL_TRC_SMPTE170M}}, {VIDEO_CS_709, {AVCOL_SPC_BT709, AVCOL_PRI_BT709, AVCOL_TRC_BT709}}, - {VIDEO_CS_SRGB, {AVCOL_SPC_RGB, AVCOL_PRI_BT709, AVCOL_TRC_BT709}}, + {VIDEO_CS_SRGB, {AVCOL_SPC_RGB, AVCOL_PRI_BT709, AVCOL_TRC_IEC61966_2_1}}, }; std::map colorranges = { - {VIDEO_RANGE_DEFAULT, AVCOL_RANGE_MPEG}, {VIDEO_RANGE_PARTIAL, AVCOL_RANGE_MPEG}, {VIDEO_RANGE_FULL, AVCOL_RANGE_JPEG}, }; + { + if (colorspace == VIDEO_CS_DEFAULT) + colorspace = VIDEO_CS_601; + if (range == VIDEO_RANGE_DEFAULT) + range = VIDEO_RANGE_PARTIAL; + } + { auto found = colorspaces.find(colorspace); if (found != colorspaces.end()) {