Extract color space from Vp8 decoder

Makes use of ColorSpace class to extract info from Vp8 stream.

Bug: webrtc:9522
Change-Id: Id9d46eeea5497c4da31db27bfcf2743612ae4157
Reviewed-on: https://webrtc-review.googlesource.com/90183
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Emircan Uysaler <emircan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24086}
This commit is contained in:
Emircan Uysaler
2018-07-23 18:07:01 -07:00
committed by Commit Bot
parent d4c16b131f
commit fad2aa23b4
2 changed files with 30 additions and 2 deletions

View File

@ -12,6 +12,7 @@
#include <string>
#include "absl/memory/memory.h"
#include "api/video/color_space.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h"
#include "rtc_base/checks.h"
@ -305,8 +306,29 @@ int LibvpxVp8Decoder::ReturnFrame(const vpx_image_t* img,
buffer->MutableDataV(), buffer->StrideV(), img->d_w,
img->d_h);
VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0);
decoded_image.set_ntp_time_ms(ntp_time_ms);
ColorSpace::RangeID range = ColorSpace::RangeID::kInvalid;
switch (img->range) {
case VPX_CR_STUDIO_RANGE:
range = ColorSpace::RangeID::kLimited;
break;
case VPX_CR_FULL_RANGE:
range = ColorSpace::RangeID::kFull;
break;
default:
break;
}
VideoFrame decoded_image =
VideoFrame::Builder()
.set_video_frame_buffer(buffer)
.set_timestamp_ms(0)
.set_timestamp_rtp(timestamp)
.set_ntp_time_ms(ntp_time_ms)
.set_rotation(webrtc::kVideoRotation_0)
.set_color_space(ColorSpace(ColorSpace::PrimaryID::kSMPTE170M,
ColorSpace::TransferID::kSMPTE170M,
ColorSpace::MatrixID::kSMPTE170M, range))
.build();
decode_complete_callback_->Decoded(decoded_image, absl::nullopt, qp);
return WEBRTC_VIDEO_CODEC_OK;

View File

@ -256,6 +256,12 @@ TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) {
EXPECT_GT(I420PSNR(input_frame, decoded_frame.get()), 36);
EXPECT_EQ(kInitialTimestampRtp, decoded_frame->timestamp());
EXPECT_EQ(kTestNtpTimeMs, decoded_frame->ntp_time_ms());
const ColorSpace color_space = decoded_frame->color_space().value();
EXPECT_EQ(ColorSpace::PrimaryID::kSMPTE170M, color_space.primaries());
EXPECT_EQ(ColorSpace::TransferID::kSMPTE170M, color_space.transfer());
EXPECT_EQ(ColorSpace::MatrixID::kSMPTE170M, color_space.matrix());
EXPECT_EQ(ColorSpace::RangeID::kLimited, color_space.range());
}
#if defined(WEBRTC_ANDROID)