Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 unsigned int num_required_input_buffers_; | 957 unsigned int num_required_input_buffers_; |
| 958 size_t output_buffer_size_; | 958 size_t output_buffer_size_; |
| 959 | 959 |
| 960 // Number of frames to encode. This may differ from the number of frames in | 960 // Number of frames to encode. This may differ from the number of frames in |
| 961 // stream if we need more frames for bitrate tests. | 961 // stream if we need more frames for bitrate tests. |
| 962 unsigned int num_frames_to_encode_; | 962 unsigned int num_frames_to_encode_; |
| 963 | 963 |
| 964 // Number of encoded frames we've got from the encoder thus far. | 964 // Number of encoded frames we've got from the encoder thus far. |
| 965 unsigned int num_encoded_frames_; | 965 unsigned int num_encoded_frames_; |
| 966 | 966 |
| 967 // Number of encoded nal units. | |
| 968 unsigned int num_encoded_nalus_; | |
| 969 | |
| 967 // Frames since last bitrate verification. | 970 // Frames since last bitrate verification. |
| 968 unsigned int num_frames_since_last_check_; | 971 unsigned int num_frames_since_last_check_; |
| 969 | 972 |
| 970 // True if received a keyframe while processing current bitstream buffer. | 973 // True if received a keyframe while processing current bitstream buffer. |
| 971 bool seen_keyframe_in_this_buffer_; | 974 bool seen_keyframe_in_this_buffer_; |
| 972 | 975 |
| 973 // True if we are to save the encoded stream to a file. | 976 // True if we are to save the encoded stream to a file. |
| 974 bool save_to_file_; | 977 bool save_to_file_; |
| 975 | 978 |
| 976 // Request a keyframe every keyframe_period_ frames. | 979 // Request a keyframe every keyframe_period_ frames. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 : state_(CS_CREATED), | 1057 : state_(CS_CREATED), |
| 1055 test_stream_(test_stream), | 1058 test_stream_(test_stream), |
| 1056 note_(note), | 1059 note_(note), |
| 1057 next_input_id_(0), | 1060 next_input_id_(0), |
| 1058 next_output_buffer_id_(0), | 1061 next_output_buffer_id_(0), |
| 1059 pos_in_input_stream_(0), | 1062 pos_in_input_stream_(0), |
| 1060 num_required_input_buffers_(0), | 1063 num_required_input_buffers_(0), |
| 1061 output_buffer_size_(0), | 1064 output_buffer_size_(0), |
| 1062 num_frames_to_encode_(0), | 1065 num_frames_to_encode_(0), |
| 1063 num_encoded_frames_(0), | 1066 num_encoded_frames_(0), |
| 1067 num_encoded_nalus_(0), | |
| 1064 num_frames_since_last_check_(0), | 1068 num_frames_since_last_check_(0), |
| 1065 seen_keyframe_in_this_buffer_(false), | 1069 seen_keyframe_in_this_buffer_(false), |
| 1066 save_to_file_(save_to_file), | 1070 save_to_file_(save_to_file), |
| 1067 keyframe_period_(keyframe_period), | 1071 keyframe_period_(keyframe_period), |
| 1068 num_keyframes_requested_(0), | 1072 num_keyframes_requested_(0), |
| 1069 next_keyframe_at_(0), | 1073 next_keyframe_at_(0), |
| 1070 force_bitrate_(force_bitrate), | 1074 force_bitrate_(force_bitrate), |
| 1071 current_requested_bitrate_(0), | 1075 current_requested_bitrate_(0), |
| 1072 current_framerate_(0), | 1076 current_framerate_(0), |
| 1073 encoded_stream_size_since_last_check_(0), | 1077 encoded_stream_size_since_last_check_(0), |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1526 | 1530 |
| 1527 last_frame_ready_time_ = base::TimeTicks::Now(); | 1531 last_frame_ready_time_ = base::TimeTicks::Now(); |
| 1528 | 1532 |
| 1529 if (g_env->needs_encode_latency()) { | 1533 if (g_env->needs_encode_latency()) { |
| 1530 LOG_ASSERT(num_encoded_frames_ < encode_start_time_.size()); | 1534 LOG_ASSERT(num_encoded_frames_ < encode_start_time_.size()); |
| 1531 base::TimeTicks start_time = encode_start_time_[num_encoded_frames_]; | 1535 base::TimeTicks start_time = encode_start_time_[num_encoded_frames_]; |
| 1532 LOG_ASSERT(!start_time.is_null()); | 1536 LOG_ASSERT(!start_time.is_null()); |
| 1533 encode_latencies_.push_back(last_frame_ready_time_ - start_time); | 1537 encode_latencies_.push_back(last_frame_ready_time_ - start_time); |
| 1534 } | 1538 } |
| 1535 | 1539 |
| 1536 ++num_encoded_frames_; | 1540 // H264 encoder sends multiple NAL units, 2 per frame. |
| 1541 if (test_stream_->requested_profile == H264PROFILE_BASELINE) { | |
| 1542 ++num_encoded_nalus_; | |
| 1543 num_encoded_frames_ = num_encoded_nalus_ / 2; | |
|
wuchengli
2016/08/03 14:03:57
Hmm. Maybe we should increase num_encoded_frames_
wuchengli
2016/08/05 02:10:28
I discussed with Pawel. Normally we get one slice
| |
| 1544 } else { | |
| 1545 ++num_encoded_frames_; | |
| 1546 } | |
| 1537 ++num_frames_since_last_check_; | 1547 ++num_frames_since_last_check_; |
| 1538 | 1548 |
| 1539 // Because the keyframe behavior requirements are loose, we give | 1549 // Because the keyframe behavior requirements are loose, we give |
| 1540 // the encoder more freedom here. It could either deliver a keyframe | 1550 // the encoder more freedom here. It could either deliver a keyframe |
| 1541 // immediately after we requested it, which could be for a frame number | 1551 // immediately after we requested it, which could be for a frame number |
| 1542 // before the one we requested it for (if the keyframe request | 1552 // before the one we requested it for (if the keyframe request |
| 1543 // is asynchronous, i.e. not bound to any concrete frame, and because | 1553 // is asynchronous, i.e. not bound to any concrete frame, and because |
| 1544 // the pipeline can be deeper than one frame), at that frame, or after. | 1554 // the pipeline can be deeper than one frame), at that frame, or after. |
| 1545 // So the only constraints we put here is that we get a keyframe not | 1555 // So the only constraints we put here is that we get a keyframe not |
| 1546 // earlier than we requested one (in time), and not later than | 1556 // earlier than we requested one (in time), and not later than |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1829 VideoEncodeAcceleratorTest, | 1839 VideoEncodeAcceleratorTest, |
| 1830 ::testing::Values(std::make_tuple(3, | 1840 ::testing::Values(std::make_tuple(3, |
| 1831 false, | 1841 false, |
| 1832 0, | 1842 0, |
| 1833 false, | 1843 false, |
| 1834 false, | 1844 false, |
| 1835 false, | 1845 false, |
| 1836 false, | 1846 false, |
| 1837 false, | 1847 false, |
| 1838 false))); | 1848 false))); |
| 1849 | |
| 1850 #if defined(OS_MACOSX) | |
| 1851 INSTANTIATE_TEST_CASE_P( | |
| 1852 VerifyTimestamp, | |
| 1853 VideoEncodeAcceleratorTest, | |
| 1854 ::testing::Values( | |
| 1855 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | |
| 1856 #endif // defined(OS_MACOSX) | |
| 1857 | |
| 1839 #if defined(OS_WIN) | 1858 #if defined(OS_WIN) |
| 1840 INSTANTIATE_TEST_CASE_P( | 1859 INSTANTIATE_TEST_CASE_P( |
| 1841 ForceBitrate, | 1860 ForceBitrate, |
| 1842 VideoEncodeAcceleratorTest, | 1861 VideoEncodeAcceleratorTest, |
| 1843 ::testing::Values( | 1862 ::testing::Values( |
| 1844 std::make_tuple(1, false, 0, true, false, false, false, false, false))); | 1863 std::make_tuple(1, false, 0, true, false, false, false, false, false))); |
| 1845 #endif // defined(OS_WIN) | 1864 #endif // defined(OS_WIN) |
| 1846 | 1865 |
| 1847 #endif // defined(OS_CHROMEOS) | 1866 #endif // defined(OS_CHROMEOS) |
| 1848 | 1867 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1934 | 1953 |
| 1935 media::g_env = | 1954 media::g_env = |
| 1936 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 1955 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 1937 testing::AddGlobalTestEnvironment( | 1956 testing::AddGlobalTestEnvironment( |
| 1938 new media::VideoEncodeAcceleratorTestEnvironment( | 1957 new media::VideoEncodeAcceleratorTestEnvironment( |
| 1939 std::move(test_stream_data), log_path, run_at_fps, | 1958 std::move(test_stream_data), log_path, run_at_fps, |
| 1940 needs_encode_latency, verify_all_output))); | 1959 needs_encode_latency, verify_all_output))); |
| 1941 | 1960 |
| 1942 return RUN_ALL_TESTS(); | 1961 return RUN_ALL_TESTS(); |
| 1943 } | 1962 } |
| OLD | NEW |