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

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

Issue 2707793002: Revert of Detect H264 slices of the same frame in VEAUnittest (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « media/gpu/h264_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28 matching lines...) Expand all
39 #include "media/base/cdm_context.h" 39 #include "media/base/cdm_context.h"
40 #include "media/base/decoder_buffer.h" 40 #include "media/base/decoder_buffer.h"
41 #include "media/base/media_util.h" 41 #include "media/base/media_util.h"
42 #include "media/base/test_data_util.h" 42 #include "media/base/test_data_util.h"
43 #include "media/base/video_decoder.h" 43 #include "media/base/video_decoder.h"
44 #include "media/base/video_frame.h" 44 #include "media/base/video_frame.h"
45 #include "media/filters/ffmpeg_glue.h" 45 #include "media/filters/ffmpeg_glue.h"
46 #include "media/filters/ffmpeg_video_decoder.h" 46 #include "media/filters/ffmpeg_video_decoder.h"
47 #include "media/filters/h264_parser.h" 47 #include "media/filters/h264_parser.h"
48 #include "media/filters/ivf_parser.h" 48 #include "media/filters/ivf_parser.h"
49 #include "media/gpu/h264_decoder.h"
50 #include "media/gpu/h264_dpb.h"
51 #include "media/gpu/video_accelerator_unittest_helpers.h" 49 #include "media/gpu/video_accelerator_unittest_helpers.h"
52 #include "media/video/fake_video_encode_accelerator.h" 50 #include "media/video/fake_video_encode_accelerator.h"
53 #include "media/video/video_encode_accelerator.h" 51 #include "media/video/video_encode_accelerator.h"
54 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
55 53
56 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
57 #if defined(USE_V4L2_CODEC) 55 #if defined(USE_V4L2_CODEC)
58 #include "base/threading/thread_task_runner_handle.h" 56 #include "base/threading/thread_task_runner_handle.h"
59 #include "media/gpu/v4l2_video_encode_accelerator.h" 57 #include "media/gpu/v4l2_video_encode_accelerator.h"
60 #endif 58 #endif
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 public: 598 public:
601 explicit H264Validator(const FrameFoundCallback& frame_cb) 599 explicit H264Validator(const FrameFoundCallback& frame_cb)
602 : StreamValidator(frame_cb), 600 : StreamValidator(frame_cb),
603 seen_sps_(false), 601 seen_sps_(false),
604 seen_pps_(false), 602 seen_pps_(false),
605 seen_idr_(false) {} 603 seen_idr_(false) {}
606 604
607 void ProcessStreamBuffer(const uint8_t* stream, size_t size) override; 605 void ProcessStreamBuffer(const uint8_t* stream, size_t size) override;
608 606
609 private: 607 private:
610 bool IsNewPicture(const H264SliceHeader& slice_hdr);
611 bool UpdateCurrentPicture(const H264SliceHeader& slice_hdr);
612
613 // Set to true when encoder provides us with the corresponding NALU type. 608 // Set to true when encoder provides us with the corresponding NALU type.
614 bool seen_sps_; 609 bool seen_sps_;
615 bool seen_pps_; 610 bool seen_pps_;
616 bool seen_idr_; 611 bool seen_idr_;
617 612
618 scoped_refptr<H264Picture> curr_pic_;
619 int curr_sps_id_ = -1;
620 int curr_pps_id_ = -1;
621
622 H264Parser h264_parser_; 613 H264Parser h264_parser_;
623 }; 614 };
624 615
625 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) { 616 void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) {
626 h264_parser_.SetStream(stream, static_cast<off_t>(size)); 617 h264_parser_.SetStream(stream, static_cast<off_t>(size));
627 618
628 while (1) { 619 while (1) {
629 H264NALU nalu; 620 H264NALU nalu;
630 H264Parser::Result result; 621 H264Parser::Result result;
631 622
632 result = h264_parser_.AdvanceToNextNALU(&nalu); 623 result = h264_parser_.AdvanceToNextNALU(&nalu);
633 if (result == H264Parser::kEOStream) 624 if (result == H264Parser::kEOStream)
634 break; 625 break;
635 626
636 ASSERT_EQ(H264Parser::kOk, result); 627 ASSERT_EQ(H264Parser::kOk, result);
637 628
638 bool keyframe = false; 629 bool keyframe = false;
639 630
640 switch (nalu.nal_unit_type) { 631 switch (nalu.nal_unit_type) {
641 case H264NALU::kIDRSlice: 632 case H264NALU::kIDRSlice:
642 ASSERT_TRUE(seen_sps_); 633 ASSERT_TRUE(seen_sps_);
643 ASSERT_TRUE(seen_pps_); 634 ASSERT_TRUE(seen_pps_);
644 seen_idr_ = true; 635 seen_idr_ = true;
645 keyframe = true; 636 keyframe = true;
646 // fallthrough 637 // fallthrough
647 case H264NALU::kNonIDRSlice: { 638 case H264NALU::kNonIDRSlice: {
648 ASSERT_TRUE(seen_idr_); 639 ASSERT_TRUE(seen_idr_);
649 H264SliceHeader slice_hdr; 640 seen_sps_ = seen_pps_ = false;
650 ASSERT_EQ(H264Parser::kOk, 641 if (!frame_cb_.Run(keyframe))
651 h264_parser_.ParseSliceHeader(nalu, &slice_hdr)); 642 return;
652 if (IsNewPicture(slice_hdr)) {
653 if (!frame_cb_.Run(keyframe))
654 return;
655 ASSERT_TRUE(UpdateCurrentPicture(slice_hdr));
656 }
657 break; 643 break;
658 } 644 }
659 645
660 case H264NALU::kSPS: { 646 case H264NALU::kSPS: {
661 int sps_id; 647 int sps_id;
662 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); 648 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParseSPS(&sps_id));
663 seen_sps_ = true; 649 seen_sps_ = true;
664 break; 650 break;
665 } 651 }
666 652
667 case H264NALU::kPPS: { 653 case H264NALU::kPPS: {
668 ASSERT_TRUE(seen_sps_); 654 ASSERT_TRUE(seen_sps_);
669 int pps_id; 655 int pps_id;
670 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParsePPS(&pps_id)); 656 ASSERT_EQ(H264Parser::kOk, h264_parser_.ParsePPS(&pps_id));
671 seen_pps_ = true; 657 seen_pps_ = true;
672 break; 658 break;
673 } 659 }
674 660
675 default: 661 default:
676 break; 662 break;
677 } 663 }
678 } 664 }
679 } 665 }
680 666
681 bool H264Validator::IsNewPicture(const H264SliceHeader& slice_hdr) {
682 if (!curr_pic_)
683 return true;
684 return H264Decoder::IsNewPrimaryCodedPicture(
685 curr_pic_, curr_pps_id_, h264_parser_.GetSPS(curr_sps_id_), slice_hdr);
686 }
687
688 bool H264Validator::UpdateCurrentPicture(const H264SliceHeader& slice_hdr) {
689 curr_pps_id_ = slice_hdr.pic_parameter_set_id;
690 const H264PPS* pps = h264_parser_.GetPPS(curr_pps_id_);
691 if (!pps) {
692 LOG(ERROR) << "Cannot parse pps.";
693 return false;
694 }
695
696 curr_sps_id_ = pps->seq_parameter_set_id;
697 const H264SPS* sps = h264_parser_.GetSPS(curr_sps_id_);
698 if (!sps) {
699 LOG(ERROR) << "Cannot parse sps.";
700 return false;
701 }
702
703 curr_pic_ = H264Decoder::CreateH264PictureFromSliceHeader(sps, slice_hdr);
704 if (!curr_pic_) {
705 LOG(FATAL) << "Cannot initialize current frame.";
706 return false;
707 }
708 return true;
709 }
710
711 class VP8Validator : public StreamValidator { 667 class VP8Validator : public StreamValidator {
712 public: 668 public:
713 explicit VP8Validator(const FrameFoundCallback& frame_cb) 669 explicit VP8Validator(const FrameFoundCallback& frame_cb)
714 : StreamValidator(frame_cb), seen_keyframe_(false) {} 670 : StreamValidator(frame_cb), seen_keyframe_(false) {}
715 671
716 void ProcessStreamBuffer(const uint8_t* stream, size_t size) override; 672 void ProcessStreamBuffer(const uint8_t* stream, size_t size) override;
717 673
718 private: 674 private:
719 // Have we already got a keyframe in the stream? 675 // Have we already got a keyframe in the stream?
720 bool seen_keyframe_; 676 bool seen_keyframe_;
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 VideoEncodeAcceleratorTest, 2226 VideoEncodeAcceleratorTest,
2271 ::testing::Values(std::make_tuple(3, 2227 ::testing::Values(std::make_tuple(3,
2272 false, 2228 false,
2273 0, 2229 0,
2274 false, 2230 false,
2275 false, 2231 false,
2276 false, 2232 false,
2277 false, 2233 false,
2278 false, 2234 false,
2279 false))); 2235 false)));
2280
2281 INSTANTIATE_TEST_CASE_P(
2282 VerifyTimestamp,
2283 VideoEncodeAcceleratorTest,
2284 ::testing::Values(
2285 std::make_tuple(1, false, 0, false, false, false, false, false, true)));
2286
2287 #if defined(OS_WIN) 2236 #if defined(OS_WIN)
2288 INSTANTIATE_TEST_CASE_P( 2237 INSTANTIATE_TEST_CASE_P(
2289 ForceBitrate, 2238 ForceBitrate,
2290 VideoEncodeAcceleratorTest, 2239 VideoEncodeAcceleratorTest,
2291 ::testing::Values( 2240 ::testing::Values(
2292 std::make_tuple(1, false, 0, true, false, false, false, false, false))); 2241 std::make_tuple(1, false, 0, true, false, false, false, false, false)));
2293 #endif // defined(OS_WIN) 2242 #endif // defined(OS_WIN)
2294 2243
2295 #endif // defined(OS_CHROMEOS) 2244 #endif // defined(OS_CHROMEOS)
2296 2245
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 2331
2383 media::g_env = 2332 media::g_env =
2384 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( 2333 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
2385 testing::AddGlobalTestEnvironment( 2334 testing::AddGlobalTestEnvironment(
2386 new media::VideoEncodeAcceleratorTestEnvironment( 2335 new media::VideoEncodeAcceleratorTestEnvironment(
2387 std::move(test_stream_data), log_path, run_at_fps, 2336 std::move(test_stream_data), log_path, run_at_fps,
2388 needs_encode_latency, verify_all_output))); 2337 needs_encode_latency, verify_all_output)));
2389 2338
2390 return RUN_ALL_TESTS(); 2339 return RUN_ALL_TESTS();
2391 } 2340 }
OLDNEW
« no previous file with comments | « media/gpu/h264_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698