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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 bool seen_sps_; | 563 bool seen_sps_; |
564 bool seen_pps_; | 564 bool seen_pps_; |
565 bool seen_idr_; | 565 bool seen_idr_; |
566 | 566 |
567 H264Parser h264_parser_; | 567 H264Parser h264_parser_; |
568 }; | 568 }; |
569 | 569 |
570 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) { | 570 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) { |
571 h264_parser_.SetStream(stream, static_cast<off_t>(size)); | 571 h264_parser_.SetStream(stream, static_cast<off_t>(size)); |
572 | 572 |
573 // Run |frame_cb_| for only first nalu. | |
574 bool frame_cb_called = false; | |
575 | |
573 while (1) { | 576 while (1) { |
574 H264NALU nalu; | 577 H264NALU nalu; |
575 H264Parser::Result result; | 578 H264Parser::Result result; |
576 | 579 |
577 result = h264_parser_.AdvanceToNextNALU(&nalu); | 580 result = h264_parser_.AdvanceToNextNALU(&nalu); |
578 if (result == H264Parser::kEOStream) | 581 if (result == H264Parser::kEOStream) |
579 break; | 582 break; |
580 | 583 |
581 ASSERT_EQ(H264Parser::kOk, result); | 584 ASSERT_EQ(H264Parser::kOk, result); |
582 | 585 |
583 bool keyframe = false; | 586 bool keyframe = false; |
584 | 587 |
585 switch (nalu.nal_unit_type) { | 588 switch (nalu.nal_unit_type) { |
586 case H264NALU::kIDRSlice: | 589 case H264NALU::kIDRSlice: |
587 ASSERT_TRUE(seen_sps_); | 590 ASSERT_TRUE(seen_sps_); |
588 ASSERT_TRUE(seen_pps_); | 591 ASSERT_TRUE(seen_pps_); |
589 seen_idr_ = true; | 592 seen_idr_ = true; |
590 keyframe = true; | 593 keyframe = true; |
591 // fallthrough | 594 // fallthrough |
592 case H264NALU::kNonIDRSlice: { | 595 case H264NALU::kNonIDRSlice: { |
596 // Stream may contain at most one frame. | |
Pawel Osciak
2016/08/26 02:00:45
If we require that, I think we should ASSERT on it
| |
593 ASSERT_TRUE(seen_idr_); | 597 ASSERT_TRUE(seen_idr_); |
594 seen_sps_ = seen_pps_ = false; | 598 seen_sps_ = seen_pps_ = false; |
595 if (!frame_cb_.Run(keyframe)) | 599 if (!frame_cb_called) { |
596 return; | 600 frame_cb_called = true; |
601 if (!frame_cb_.Run(keyframe)) | |
602 return; | |
603 } | |
597 break; | 604 break; |
598 } | 605 } |
599 | 606 |
600 case H264NALU::kSPS: { | 607 case H264NALU::kSPS: { |
601 int sps_id; | 608 int sps_id; |
602 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); | 609 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); |
603 seen_sps_ = true; | 610 seen_sps_ = true; |
604 break; | 611 break; |
605 } | 612 } |
606 | 613 |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1836 VideoEncodeAcceleratorTest, | 1843 VideoEncodeAcceleratorTest, |
1837 ::testing::Values(std::make_tuple(3, | 1844 ::testing::Values(std::make_tuple(3, |
1838 false, | 1845 false, |
1839 0, | 1846 0, |
1840 false, | 1847 false, |
1841 false, | 1848 false, |
1842 false, | 1849 false, |
1843 false, | 1850 false, |
1844 false, | 1851 false, |
1845 false))); | 1852 false))); |
1853 | |
1854 #if defined(OS_MACOSX) | |
1855 INSTANTIATE_TEST_CASE_P( | |
1856 VerifyTimestamp, | |
1857 VideoEncodeAcceleratorTest, | |
1858 ::testing::Values( | |
1859 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | |
1860 #endif // defined(OS_MACOSX) | |
1861 | |
1846 #if defined(OS_WIN) | 1862 #if defined(OS_WIN) |
1847 INSTANTIATE_TEST_CASE_P( | 1863 INSTANTIATE_TEST_CASE_P( |
1848 ForceBitrate, | 1864 ForceBitrate, |
1849 VideoEncodeAcceleratorTest, | 1865 VideoEncodeAcceleratorTest, |
1850 ::testing::Values( | 1866 ::testing::Values( |
1851 std::make_tuple(1, false, 0, true, false, false, false, false, false))); | 1867 std::make_tuple(1, false, 0, true, false, false, false, false, false))); |
1852 #endif // defined(OS_WIN) | 1868 #endif // defined(OS_WIN) |
1853 | 1869 |
1854 #endif // defined(OS_CHROMEOS) | 1870 #endif // defined(OS_CHROMEOS) |
1855 | 1871 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1941 | 1957 |
1942 media::g_env = | 1958 media::g_env = |
1943 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 1959 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
1944 testing::AddGlobalTestEnvironment( | 1960 testing::AddGlobalTestEnvironment( |
1945 new media::VideoEncodeAcceleratorTestEnvironment( | 1961 new media::VideoEncodeAcceleratorTestEnvironment( |
1946 std::move(test_stream_data), log_path, run_at_fps, | 1962 std::move(test_stream_data), log_path, run_at_fps, |
1947 needs_encode_latency, verify_all_output))); | 1963 needs_encode_latency, verify_all_output))); |
1948 | 1964 |
1949 return RUN_ALL_TESTS(); | 1965 return RUN_ALL_TESTS(); |
1950 } | 1966 } |
OLD | NEW |