aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndri Yngvason <andri@yngvason.is>2024-08-19 22:34:37 +0000
committerLinn Mattsson <linma@cendio.se>2024-10-22 12:41:33 +0200
commit2c4b0385a1b6138e8c28ebf1d656bfd5e8c05aa3 (patch)
treea1b609b016bb590fcd83e95ea830b127ef4d749b
parent1df8a64277b1d616151811a46e355069faba7958 (diff)
downloadtigervnc-2c4b0385a1b6138e8c28ebf1d656bfd5e8c05aa3.tar.gz
tigervnc-2c4b0385a1b6138e8c28ebf1d656bfd5e8c05aa3.zip
H264Libav: Handle colour space conversion
The scaler is now informed of the colour space encoded into the stream so that it may do the proper conversion. (cherry picked from commit 28cc17e309fc6117370b38ec11d803dc36e8ef01)
-rw-r--r--common/rfb/H264LibavDecoderContext.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/rfb/H264LibavDecoderContext.cxx b/common/rfb/H264LibavDecoderContext.cxx
index f1599f4c..a7c817bf 100644
--- a/common/rfb/H264LibavDecoderContext.cxx
+++ b/common/rfb/H264LibavDecoderContext.cxx
@@ -217,6 +217,21 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
frame->width, frame->height, AV_PIX_FMT_RGB32,
0, NULL, NULL, NULL);
+ int inFull, outFull, brightness, contrast, saturation;
+ const int* inTable;
+ const int* outTable;
+
+ sws_getColorspaceDetails(sws, (int**)&inTable, &inFull, (int**)&outTable,
+ &outFull, &brightness, &contrast, &saturation);
+ if (frame->colorspace != AVCOL_SPC_UNSPECIFIED) {
+ inTable = sws_getCoefficients(frame->colorspace);
+ }
+ if (frame->color_range != AVCOL_RANGE_UNSPECIFIED) {
+ inFull = frame->color_range == AVCOL_RANGE_JPEG;
+ }
+ sws_setColorspaceDetails(sws, inTable, inFull, outTable, outFull, brightness,
+ contrast, saturation);
+
if (rgbFrame && (rgbFrame->width != frame->width || rgbFrame->height != frame->height)) {
av_frame_free(&rgbFrame);