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

Side by Side Diff: media/gpu/video_encode_accelerator_unittest.cc

Issue 1996453003: RTC Video Encoder: Use capturer timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <inttypes.h> 5 #include <inttypes.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 ~VEAClient() override; 767 ~VEAClient() override;
768 void CreateEncoder(); 768 void CreateEncoder();
769 void DestroyEncoder(); 769 void DestroyEncoder();
770 770
771 // VideoDecodeAccelerator::Client implementation. 771 // VideoDecodeAccelerator::Client implementation.
772 void RequireBitstreamBuffers(unsigned int input_count, 772 void RequireBitstreamBuffers(unsigned int input_count,
773 const gfx::Size& input_coded_size, 773 const gfx::Size& input_coded_size,
774 size_t output_buffer_size) override; 774 size_t output_buffer_size) override;
775 void BitstreamBufferReady(int32_t bitstream_buffer_id, 775 void BitstreamBufferReady(int32_t bitstream_buffer_id,
776 size_t payload_size, 776 size_t payload_size,
777 bool key_frame) override; 777 bool key_frame,
778 base::TimeDelta timestamp) override;
778 void NotifyError(VideoEncodeAccelerator::Error error) override; 779 void NotifyError(VideoEncodeAccelerator::Error error) override;
779 780
780 private: 781 private:
781 bool has_encoder() { return encoder_.get(); } 782 bool has_encoder() { return encoder_.get(); }
782 783
783 // Return the number of encoded frames per second. 784 // Return the number of encoded frames per second.
784 double frames_per_second(); 785 double frames_per_second();
785 786
786 std::unique_ptr<media::VideoEncodeAccelerator> CreateFakeVEA(); 787 std::unique_ptr<media::VideoEncodeAccelerator> CreateFakeVEA();
787 std::unique_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); 788 std::unique_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 unsigned int requested_framerate_; 949 unsigned int requested_framerate_;
949 950
950 // Bitrate to switch to in the middle of the stream. 951 // Bitrate to switch to in the middle of the stream.
951 unsigned int requested_subsequent_bitrate_; 952 unsigned int requested_subsequent_bitrate_;
952 953
953 // Framerate to switch to in the middle of the stream. 954 // Framerate to switch to in the middle of the stream.
954 unsigned int requested_subsequent_framerate_; 955 unsigned int requested_subsequent_framerate_;
955 956
956 // The timer used to feed the encoder with the input frames. 957 // The timer used to feed the encoder with the input frames.
957 std::unique_ptr<base::RepeatingTimer> input_timer_; 958 std::unique_ptr<base::RepeatingTimer> input_timer_;
959
960 // The timestamps for each frame in the order of CreateFrame() invocation.
961 std::queue<base::TimeDelta> frame_timestamps_;
958 }; 962 };
959 963
960 VEAClient::VEAClient(TestStream* test_stream, 964 VEAClient::VEAClient(TestStream* test_stream,
961 ClientStateNotification<ClientState>* note, 965 ClientStateNotification<ClientState>* note,
962 bool save_to_file, 966 bool save_to_file,
963 unsigned int keyframe_period, 967 unsigned int keyframe_period,
964 bool force_bitrate, 968 bool force_bitrate,
965 bool test_perf, 969 bool test_perf,
966 bool mid_stream_bitrate_switch, 970 bool mid_stream_bitrate_switch,
967 bool mid_stream_framerate_switch, 971 bool mid_stream_framerate_switch,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1213 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1210 } else { 1214 } else {
1211 while (inputs_at_client_.size() < 1215 while (inputs_at_client_.size() <
1212 num_required_input_buffers_ + kNumExtraInputFrames) 1216 num_required_input_buffers_ + kNumExtraInputFrames)
1213 FeedEncoderWithOneInput(); 1217 FeedEncoderWithOneInput();
1214 } 1218 }
1215 } 1219 }
1216 1220
1217 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, 1221 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id,
1218 size_t payload_size, 1222 size_t payload_size,
1219 bool key_frame) { 1223 bool key_frame,
1224 base::TimeDelta timestamp) {
1220 DCHECK(thread_checker_.CalledOnValidThread()); 1225 DCHECK(thread_checker_.CalledOnValidThread());
1221 ASSERT_LE(payload_size, output_buffer_size_); 1226 ASSERT_LE(payload_size, output_buffer_size_);
1222 1227
1223 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id); 1228 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id);
1224 ASSERT_NE(it, output_buffers_at_client_.end()); 1229 ASSERT_NE(it, output_buffers_at_client_.end());
1225 base::SharedMemory* shm = it->second; 1230 base::SharedMemory* shm = it->second;
1226 output_buffers_at_client_.erase(it); 1231 output_buffers_at_client_.erase(it);
1227 1232
1228 if (state_ == CS_FINISHED || state_ == CS_VALIDATED) 1233 if (state_ == CS_FINISHED || state_ == CS_VALIDATED)
1229 return; 1234 return;
1230 1235
1236 ASSERT_FALSE(frame_timestamps_.empty());
1237 ASSERT_EQ(timestamp, frame_timestamps_.front());
1238 frame_timestamps_.pop();
1239
1231 encoded_stream_size_since_last_check_ += payload_size; 1240 encoded_stream_size_since_last_check_ += payload_size;
1232 1241
1233 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory()); 1242 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory());
1234 if (payload_size > 0) { 1243 if (payload_size > 0) {
1235 if (stream_validator_) { 1244 if (stream_validator_) {
1236 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size); 1245 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size);
1237 } else { 1246 } else {
1238 HandleEncodedFrame(key_frame); 1247 HandleEncodedFrame(key_frame);
1239 } 1248 }
1240 1249
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 // we require for bitrate tests. 1369 // we require for bitrate tests.
1361 pos_in_input_stream_ = 0; 1370 pos_in_input_stream_ = 0;
1362 } 1371 }
1363 1372
1364 if (quality_validator_) 1373 if (quality_validator_)
1365 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_)); 1374 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_));
1366 1375
1367 int32_t input_id; 1376 int32_t input_id;
1368 scoped_refptr<media::VideoFrame> video_frame = 1377 scoped_refptr<media::VideoFrame> video_frame =
1369 PrepareInputFrame(pos_in_input_stream_, &input_id); 1378 PrepareInputFrame(pos_in_input_stream_, &input_id);
1379 frame_timestamps_.push(video_frame->timestamp());
1370 pos_in_input_stream_ += test_stream_->aligned_buffer_size; 1380 pos_in_input_stream_ += test_stream_->aligned_buffer_size;
1371 1381
1372 bool force_keyframe = false; 1382 bool force_keyframe = false;
1373 if (keyframe_period_ && input_id % keyframe_period_ == 0) { 1383 if (keyframe_period_ && input_id % keyframe_period_ == 0) {
1374 force_keyframe = true; 1384 force_keyframe = true;
1375 ++num_keyframes_requested_; 1385 ++num_keyframes_requested_;
1376 } 1386 }
1377 1387
1378 if (input_id == 0) { 1388 if (input_id == 0) {
1379 first_frame_start_time_ = base::TimeTicks::Now(); 1389 first_frame_start_time_ = base::TimeTicks::Now();
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 1793
1784 media::g_env = 1794 media::g_env =
1785 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( 1795 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
1786 testing::AddGlobalTestEnvironment( 1796 testing::AddGlobalTestEnvironment(
1787 new media::VideoEncodeAcceleratorTestEnvironment( 1797 new media::VideoEncodeAcceleratorTestEnvironment(
1788 std::move(test_stream_data), log_path, run_at_fps, 1798 std::move(test_stream_data), log_path, run_at_fps,
1789 needs_encode_latency, verify_all_output))); 1799 needs_encode_latency, verify_all_output)));
1790 1800
1791 return RUN_ALL_TESTS(); 1801 return RUN_ALL_TESTS();
1792 } 1802 }
OLDNEW
« no previous file with comments | « media/gpu/vaapi_video_encode_accelerator.cc ('k') | media/gpu/vt_video_encode_accelerator_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698