Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/video_codec_test.cc

Issue 2833493003: Don't re-randomize picture_id/tl0_pic_idx when re-initializing internal encoders. (Closed)
Patch Set: asapersson comments 1: increment timestamp and push more frames through. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 15 matching lines...) Expand all
26 26
27 namespace webrtc { 27 namespace webrtc {
28 28
29 EncodedImageCallback::Result 29 EncodedImageCallback::Result
30 VideoCodecTest::FakeEncodeCompleteCallback::OnEncodedImage( 30 VideoCodecTest::FakeEncodeCompleteCallback::OnEncodedImage(
31 const EncodedImage& frame, 31 const EncodedImage& frame,
32 const CodecSpecificInfo* codec_specific_info, 32 const CodecSpecificInfo* codec_specific_info,
33 const RTPFragmentationHeader* fragmentation) { 33 const RTPFragmentationHeader* fragmentation) {
34 rtc::CritScope lock(&test_->encoded_frame_section_); 34 rtc::CritScope lock(&test_->encoded_frame_section_);
35 test_->encoded_frame_.emplace(frame); 35 test_->encoded_frame_.emplace(frame);
36 RTC_DCHECK(codec_specific_info);
37 test_->codec_specific_info_.codecType = codec_specific_info->codecType;
38 // Skip |codec_name|, to avoid allocating.
39 test_->codec_specific_info_.codecSpecific =
40 codec_specific_info->codecSpecific;
36 test_->encoded_frame_event_.Set(); 41 test_->encoded_frame_event_.Set();
37 return Result(Result::OK); 42 return Result(Result::OK);
38 } 43 }
39 44
40 void VideoCodecTest::FakeDecodeCompleteCallback::Decoded( 45 void VideoCodecTest::FakeDecodeCompleteCallback::Decoded(
41 VideoFrame& frame, 46 VideoFrame& frame,
42 rtc::Optional<int32_t> decode_time_ms, 47 rtc::Optional<int32_t> decode_time_ms,
43 rtc::Optional<uint8_t> qp) { 48 rtc::Optional<uint8_t> qp) {
44 rtc::CritScope lock(&test_->decoded_frame_section_); 49 rtc::CritScope lock(&test_->decoded_frame_section_);
45 test_->decoded_frame_.emplace(frame); 50 test_->decoded_frame_.emplace(frame);
(...skipping 12 matching lines...) Expand all
58 fclose(source_file_); 63 fclose(source_file_);
59 64
60 encoder_.reset(CreateEncoder()); 65 encoder_.reset(CreateEncoder());
61 decoder_.reset(CreateDecoder()); 66 decoder_.reset(CreateDecoder());
62 encoder_->RegisterEncodeCompleteCallback(&encode_complete_callback_); 67 encoder_->RegisterEncodeCompleteCallback(&encode_complete_callback_);
63 decoder_->RegisterDecodeCompleteCallback(&decode_complete_callback_); 68 decoder_->RegisterDecodeCompleteCallback(&decode_complete_callback_);
64 69
65 InitCodecs(); 70 InitCodecs();
66 } 71 }
67 72
68 bool VideoCodecTest::WaitForEncodedFrame(EncodedImage* frame) { 73 bool VideoCodecTest::WaitForEncodedFrame(
74 EncodedImage* frame,
75 CodecSpecificInfo* codec_specific_info) {
69 bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs); 76 bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs);
70 EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame."; 77 EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame.";
71 // This becomes unsafe if there are multiple threads waiting for frames. 78 // This becomes unsafe if there are multiple threads waiting for frames.
72 rtc::CritScope lock(&encoded_frame_section_); 79 rtc::CritScope lock(&encoded_frame_section_);
73 EXPECT_TRUE(encoded_frame_); 80 EXPECT_TRUE(encoded_frame_);
74 if (encoded_frame_) { 81 if (encoded_frame_) {
75 *frame = std::move(*encoded_frame_); 82 *frame = std::move(*encoded_frame_);
76 encoded_frame_.reset(); 83 encoded_frame_.reset();
84 RTC_DCHECK(codec_specific_info);
85 codec_specific_info->codecType = codec_specific_info_.codecType;
86 codec_specific_info->codecSpecific = codec_specific_info_.codecSpecific;
77 return true; 87 return true;
78 } else { 88 } else {
79 return false; 89 return false;
80 } 90 }
81 } 91 }
82 92
83 bool VideoCodecTest::WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame, 93 bool VideoCodecTest::WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
84 rtc::Optional<uint8_t>* qp) { 94 rtc::Optional<uint8_t>* qp) {
85 bool ret = decoded_frame_event_.Wait(kDecodeTimeoutMs); 95 bool ret = decoded_frame_event_.Wait(kDecodeTimeoutMs);
86 EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame."; 96 EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame.";
87 // This becomes unsafe if there are multiple threads waiting for frames. 97 // This becomes unsafe if there are multiple threads waiting for frames.
88 rtc::CritScope lock(&decoded_frame_section_); 98 rtc::CritScope lock(&decoded_frame_section_);
89 EXPECT_TRUE(decoded_frame_); 99 EXPECT_TRUE(decoded_frame_);
90 if (decoded_frame_) { 100 if (decoded_frame_) {
91 frame->reset(new VideoFrame(std::move(*decoded_frame_))); 101 frame->reset(new VideoFrame(std::move(*decoded_frame_)));
92 *qp = decoded_qp_; 102 *qp = decoded_qp_;
93 decoded_frame_.reset(); 103 decoded_frame_.reset();
94 return true; 104 return true;
95 } else { 105 } else {
96 return false; 106 return false;
97 } 107 }
98 } 108 }
99 109
100 void VideoCodecTest::InitCodecs() { 110 void VideoCodecTest::InitCodecs() {
101 VideoCodec codec_inst = codec_settings(); 111 codec_inst_ = codec_settings();
102 codec_inst.startBitrate = kStartBitrate; 112 codec_inst_.startBitrate = kStartBitrate;
103 codec_inst.targetBitrate = kTargetBitrate; 113 codec_inst_.targetBitrate = kTargetBitrate;
104 codec_inst.maxBitrate = kMaxBitrate; 114 codec_inst_.maxBitrate = kMaxBitrate;
105 codec_inst.maxFramerate = kMaxFramerate; 115 codec_inst_.maxFramerate = kMaxFramerate;
106 codec_inst.width = kWidth; 116 codec_inst_.width = kWidth;
107 codec_inst.height = kHeight; 117 codec_inst_.height = kHeight;
108 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 118 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
109 encoder_->InitEncode(&codec_inst, 1 /* number of cores */, 119 encoder_->InitEncode(&codec_inst_, 1 /* number of cores */,
110 0 /* max payload size (unused) */)); 120 0 /* max payload size (unused) */));
111 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 121 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
112 decoder_->InitDecode(&codec_inst, 1 /* number of cores */)); 122 decoder_->InitDecode(&codec_inst_, 1 /* number of cores */));
113 } 123 }
114 124
115 } // namespace webrtc 125 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698