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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 bool seen_sps_; | 557 bool seen_sps_; |
558 bool seen_pps_; | 558 bool seen_pps_; |
559 bool seen_idr_; | 559 bool seen_idr_; |
560 | 560 |
561 H264Parser h264_parser_; | 561 H264Parser h264_parser_; |
562 }; | 562 }; |
563 | 563 |
564 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) { | 564 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) { |
565 h264_parser_.SetStream(stream, static_cast<off_t>(size)); | 565 h264_parser_.SetStream(stream, static_cast<off_t>(size)); |
566 | 566 |
567 // Run |frame_cb_| for only first nalu. | |
568 bool seen_nonidr = false; | |
569 | |
567 while (1) { | 570 while (1) { |
568 H264NALU nalu; | 571 H264NALU nalu; |
569 H264Parser::Result result; | 572 H264Parser::Result result; |
570 | 573 |
571 result = h264_parser_.AdvanceToNextNALU(&nalu); | 574 result = h264_parser_.AdvanceToNextNALU(&nalu); |
572 if (result == H264Parser::kEOStream) | 575 if (result == H264Parser::kEOStream) |
573 break; | 576 break; |
574 | 577 |
575 ASSERT_EQ(H264Parser::kOk, result); | 578 ASSERT_EQ(H264Parser::kOk, result); |
576 | 579 |
577 bool keyframe = false; | 580 bool keyframe = false; |
578 | 581 |
579 switch (nalu.nal_unit_type) { | 582 switch (nalu.nal_unit_type) { |
580 case H264NALU::kIDRSlice: | 583 case H264NALU::kIDRSlice: |
581 ASSERT_TRUE(seen_sps_); | 584 ASSERT_TRUE(seen_sps_); |
582 ASSERT_TRUE(seen_pps_); | 585 ASSERT_TRUE(seen_pps_); |
583 seen_idr_ = true; | 586 seen_idr_ = true; |
584 keyframe = true; | 587 keyframe = true; |
585 // fallthrough | 588 // fallthrough |
wuchengli
2016/08/11 06:06:04
This is fallthough. If there's only one kIDRSlice
| |
586 case H264NALU::kNonIDRSlice: { | 589 case H264NALU::kNonIDRSlice: { |
587 ASSERT_TRUE(seen_idr_); | 590 ASSERT_TRUE(seen_idr_); |
wuchengli
2016/08/12 15:12:24
Please add some comments to explain the assumption
emircan
2016/08/24 21:29:17
I am adding a comment about the assumption.
| |
588 if (!frame_cb_.Run(keyframe)) | 591 if (!seen_nonidr) { |
589 return; | 592 seen_nonidr = true; |
593 if (!frame_cb_.Run(keyframe)) | |
wuchengli
2016/08/11 06:06:04
If we only call frame_cb_ once, we should probably
emircan
2016/08/11 16:49:15
I thought of that case, but |seen_idr_| is only se
wuchengli
2016/08/12 15:12:25
Yes. You are right. I didn't see the assertion.
S
emircan
2016/08/24 21:29:17
I agree |frame_cb_called| sounds better. Done.
| |
594 return; | |
595 } | |
590 break; | 596 break; |
591 } | 597 } |
592 | 598 |
593 case H264NALU::kSPS: { | 599 case H264NALU::kSPS: { |
594 int sps_id; | 600 int sps_id; |
595 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); | 601 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); |
596 seen_sps_ = true; | 602 seen_sps_ = true; |
597 break; | 603 break; |
598 } | 604 } |
599 | 605 |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1829 VideoEncodeAcceleratorTest, | 1835 VideoEncodeAcceleratorTest, |
1830 ::testing::Values(std::make_tuple(3, | 1836 ::testing::Values(std::make_tuple(3, |
1831 false, | 1837 false, |
1832 0, | 1838 0, |
1833 false, | 1839 false, |
1834 false, | 1840 false, |
1835 false, | 1841 false, |
1836 false, | 1842 false, |
1837 false, | 1843 false, |
1838 false))); | 1844 false))); |
1845 | |
1846 #if defined(OS_MACOSX) | |
1847 INSTANTIATE_TEST_CASE_P( | |
1848 VerifyTimestamp, | |
1849 VideoEncodeAcceleratorTest, | |
1850 ::testing::Values( | |
1851 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | |
1852 #endif // defined(OS_MACOSX) | |
1853 | |
1839 #if defined(OS_WIN) | 1854 #if defined(OS_WIN) |
1840 INSTANTIATE_TEST_CASE_P( | 1855 INSTANTIATE_TEST_CASE_P( |
1841 ForceBitrate, | 1856 ForceBitrate, |
1842 VideoEncodeAcceleratorTest, | 1857 VideoEncodeAcceleratorTest, |
1843 ::testing::Values( | 1858 ::testing::Values( |
1844 std::make_tuple(1, false, 0, true, false, false, false, false, false))); | 1859 std::make_tuple(1, false, 0, true, false, false, false, false, false))); |
1845 #endif // defined(OS_WIN) | 1860 #endif // defined(OS_WIN) |
1846 | 1861 |
1847 #endif // defined(OS_CHROMEOS) | 1862 #endif // defined(OS_CHROMEOS) |
1848 | 1863 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1934 | 1949 |
1935 media::g_env = | 1950 media::g_env = |
1936 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 1951 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
1937 testing::AddGlobalTestEnvironment( | 1952 testing::AddGlobalTestEnvironment( |
1938 new media::VideoEncodeAcceleratorTestEnvironment( | 1953 new media::VideoEncodeAcceleratorTestEnvironment( |
1939 std::move(test_stream_data), log_path, run_at_fps, | 1954 std::move(test_stream_data), log_path, run_at_fps, |
1940 needs_encode_latency, verify_all_output))); | 1955 needs_encode_latency, verify_all_output))); |
1941 | 1956 |
1942 return RUN_ALL_TESTS(); | 1957 return RUN_ALL_TESTS(); |
1943 } | 1958 } |
OLD | NEW |