mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

This partially reverts these 2 CLs: 1) Reland "Copy video frames metadata between encoded and plain frames in one place" https://webrtc.googlesource.com/src/+/2ebf5239782bf6b46d4aa812f34fa9f9e5a02be9 2) Don't copy video frame metadata in each encoder/decoder https://webrtc.googlesource.com/src/+/ab62b2ee51e622be6d0aade15e87e927fa60e6f2 The problem with them were that ColorSpace was made to always be copied from the EncodedImage in the GenericDecoder, which overwrote ColorSpace information from the decoder. If decoder applied color space transition or bitstream color space information was different from the WebRTC signaled one, the incorrect color space data were passed to the renderer. This CL removes introduced change regarding color space data: GenericDecoder doesn't copy or store it and software decoders are restored to copy it. Relevant tests are also removed. Bug: chromium:982486 Change-Id: I989e01476ff7f7df376c05578ab8f540b95a1dd2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145323 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28556}
119 lines
3.7 KiB
C++
119 lines
3.7 KiB
C++
/*
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "modules/video_coding/generic_decoder.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/task_queue/default_task_queue_factory.h"
|
|
#include "common_video/test/utilities.h"
|
|
#include "modules/video_coding/timing.h"
|
|
#include "rtc_base/critical_section.h"
|
|
#include "rtc_base/event.h"
|
|
#include "system_wrappers/include/clock.h"
|
|
#include "test/fake_decoder.h"
|
|
#include "test/gmock.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
namespace video_coding {
|
|
|
|
class ReceiveCallback : public VCMReceiveCallback {
|
|
public:
|
|
int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT
|
|
absl::optional<uint8_t> qp,
|
|
int32_t decode_time_ms,
|
|
VideoContentType content_type) override {
|
|
{
|
|
rtc::CritScope cs(&lock_);
|
|
last_frame_ = videoFrame;
|
|
}
|
|
received_frame_event_.Set();
|
|
return 0;
|
|
}
|
|
|
|
absl::optional<VideoFrame> GetLastFrame() {
|
|
rtc::CritScope cs(&lock_);
|
|
return last_frame_;
|
|
}
|
|
|
|
absl::optional<VideoFrame> WaitForFrame(int64_t wait_ms) {
|
|
if (received_frame_event_.Wait(wait_ms)) {
|
|
rtc::CritScope cs(&lock_);
|
|
return last_frame_;
|
|
} else {
|
|
return absl::nullopt;
|
|
}
|
|
}
|
|
|
|
private:
|
|
rtc::CriticalSection lock_;
|
|
rtc::Event received_frame_event_;
|
|
absl::optional<VideoFrame> last_frame_ RTC_GUARDED_BY(lock_);
|
|
};
|
|
|
|
class GenericDecoderTest : public ::testing::Test {
|
|
protected:
|
|
GenericDecoderTest()
|
|
: clock_(0),
|
|
timing_(&clock_),
|
|
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
|
decoder_(task_queue_factory_.get()),
|
|
vcm_callback_(&timing_, &clock_),
|
|
generic_decoder_(&decoder_, /*isExternal=*/true) {}
|
|
|
|
void SetUp() override {
|
|
generic_decoder_.RegisterDecodeCompleteCallback(&vcm_callback_);
|
|
vcm_callback_.SetUserReceiveCallback(&user_callback_);
|
|
VideoCodec settings;
|
|
settings.codecType = kVideoCodecVP8;
|
|
settings.width = 10;
|
|
settings.height = 10;
|
|
generic_decoder_.InitDecode(&settings, /*numberOfCores=*/4);
|
|
}
|
|
|
|
SimulatedClock clock_;
|
|
VCMTiming timing_;
|
|
std::unique_ptr<TaskQueueFactory> task_queue_factory_;
|
|
webrtc::test::FakeDecoder decoder_;
|
|
VCMDecodedFrameCallback vcm_callback_;
|
|
VCMGenericDecoder generic_decoder_;
|
|
ReceiveCallback user_callback_;
|
|
};
|
|
|
|
TEST_F(GenericDecoderTest, PassesPacketInfos) {
|
|
RtpPacketInfos packet_infos = CreatePacketInfos(3);
|
|
VCMEncodedFrame encoded_frame;
|
|
encoded_frame.SetPacketInfos(packet_infos);
|
|
generic_decoder_.Decode(encoded_frame, clock_.TimeInMilliseconds());
|
|
absl::optional<VideoFrame> decoded_frame = user_callback_.WaitForFrame(10);
|
|
ASSERT_TRUE(decoded_frame.has_value());
|
|
EXPECT_EQ(decoded_frame->packet_infos().size(), 3U);
|
|
}
|
|
|
|
TEST_F(GenericDecoderTest, PassesPacketInfosForDelayedDecoders) {
|
|
RtpPacketInfos packet_infos = CreatePacketInfos(3);
|
|
decoder_.SetDelayedDecoding(100);
|
|
|
|
{
|
|
// Ensure the original frame is destroyed before the decoding is completed.
|
|
VCMEncodedFrame encoded_frame;
|
|
encoded_frame.SetPacketInfos(packet_infos);
|
|
generic_decoder_.Decode(encoded_frame, clock_.TimeInMilliseconds());
|
|
}
|
|
|
|
absl::optional<VideoFrame> decoded_frame = user_callback_.WaitForFrame(200);
|
|
ASSERT_TRUE(decoded_frame.has_value());
|
|
EXPECT_EQ(decoded_frame->packet_infos().size(), 3U);
|
|
}
|
|
|
|
} // namespace video_coding
|
|
} // namespace webrtc
|