Skip to content

Commit

Permalink
H264Libav: Handle colour space conversion
Browse files Browse the repository at this point in the history
The scaler is now informed of the colour space encoded into the stream
so that it may do the proper conversion.
  • Loading branch information
any1 committed Aug 19, 2024
1 parent e6fb057 commit 28cc17e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common/rfb/H264LibavDecoderContext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
frame->width, frame->height, AV_PIX_FMT_RGB32,
0, nullptr, nullptr, nullptr);

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);

Expand Down

0 comments on commit 28cc17e

Please sign in to comment.