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 <ssilkin@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27816}
This commit is contained in:
Johannes Kron
2019-05-01 01:16:34 +02:00
committed by Commit Bot
parent 3c4a69f103
commit 2ad2fabdcf

View File

@ -299,6 +299,10 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
rtc::scoped_refptr<VideoFrameBuffer> 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())