From 2ad2fabdcf5017a4a5ccdc9c20ab955117498e9c Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Wed, 1 May 2019 01:16:34 +0200 Subject: [PATCH] Determine if it's HDR color space based on VUI or RTP header extension The color space can either be specified in the VUI of the H264 bitstream or using an RTP header extension. The color space set through the RTP header extension overrides the color space in the VUI. The check for HDR should look at the resulting color space. Bug: webrtc:10575 Change-Id: I0ca6262d76d56dea938de169f55ad3894e6c4f8f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134860 Reviewed-by: Sergey Silkin Commit-Queue: Johannes Kron Cr-Commit-Position: refs/heads/master@{#27816} --- .../video_coding/codecs/h264/h264_decoder_impl.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc index 7b32852c1e..5c83d694e3 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -299,6 +299,10 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, rtc::scoped_refptr decoded_buffer; + // Pass on color space from input frame if explicitly specified. + const ColorSpace& color_space = + input_image.ColorSpace() ? *input_image.ColorSpace() + : ExtractH264ColorSpace(av_context_.get()); // 8-bit HDR is currently not being rendered correctly in Chrome on Windows. // If the ColorSpace transfer function is set to ST2084, convert the 8-bit // buffer to a 10-bit buffer. This way 8-bit HDR content is rendered correctly @@ -306,8 +310,7 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, // Chrome/WebRTC. // TODO(chromium:956468): Remove this code and fix the underlying problem. bool hdr_color_space = - input_image.ColorSpace() && input_image.ColorSpace()->transfer() == - ColorSpace::TransferID::kSMPTEST2084; + color_space.transfer() == ColorSpace::TransferID::kSMPTEST2084; if (kEnable8bitHdrFix_ && hdr_color_space) { auto i010_buffer = I010Buffer::Copy(*i420_buffer); // Crop image, see comment below. @@ -330,11 +333,6 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, decoded_buffer = input_frame->video_frame_buffer(); } - // Pass on color space from input frame if explicitly specified. - const ColorSpace& color_space = - input_image.ColorSpace() ? *input_image.ColorSpace() - : ExtractH264ColorSpace(av_context_.get()); - VideoFrame decoded_frame = VideoFrame::Builder() .set_video_frame_buffer(decoded_buffer) .set_timestamp_us(input_frame->timestamp_us())