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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/memory_mapped_file.h" | 9 #include "base/files/memory_mapped_file.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 }; | 388 }; |
389 | 389 |
390 class H264Validator : public StreamValidator { | 390 class H264Validator : public StreamValidator { |
391 public: | 391 public: |
392 explicit H264Validator(const FrameFoundCallback& frame_cb) | 392 explicit H264Validator(const FrameFoundCallback& frame_cb) |
393 : StreamValidator(frame_cb), | 393 : StreamValidator(frame_cb), |
394 seen_sps_(false), | 394 seen_sps_(false), |
395 seen_pps_(false), | 395 seen_pps_(false), |
396 seen_idr_(false) {} | 396 seen_idr_(false) {} |
397 | 397 |
398 virtual void ProcessStreamBuffer(const uint8* stream, size_t size) override; | 398 void ProcessStreamBuffer(const uint8* stream, size_t size) override; |
399 | 399 |
400 private: | 400 private: |
401 // Set to true when encoder provides us with the corresponding NALU type. | 401 // Set to true when encoder provides us with the corresponding NALU type. |
402 bool seen_sps_; | 402 bool seen_sps_; |
403 bool seen_pps_; | 403 bool seen_pps_; |
404 bool seen_idr_; | 404 bool seen_idr_; |
405 | 405 |
406 media::H264Parser h264_parser_; | 406 media::H264Parser h264_parser_; |
407 }; | 407 }; |
408 | 408 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } | 455 } |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
459 class VP8Validator : public StreamValidator { | 459 class VP8Validator : public StreamValidator { |
460 public: | 460 public: |
461 explicit VP8Validator(const FrameFoundCallback& frame_cb) | 461 explicit VP8Validator(const FrameFoundCallback& frame_cb) |
462 : StreamValidator(frame_cb), | 462 : StreamValidator(frame_cb), |
463 seen_keyframe_(false) {} | 463 seen_keyframe_(false) {} |
464 | 464 |
465 virtual void ProcessStreamBuffer(const uint8* stream, size_t size) override; | 465 void ProcessStreamBuffer(const uint8* stream, size_t size) override; |
466 | 466 |
467 private: | 467 private: |
468 // Have we already got a keyframe in the stream? | 468 // Have we already got a keyframe in the stream? |
469 bool seen_keyframe_; | 469 bool seen_keyframe_; |
470 }; | 470 }; |
471 | 471 |
472 void VP8Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { | 472 void VP8Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { |
473 bool keyframe = !(stream[0] & 0x01); | 473 bool keyframe = !(stream[0] & 0x01); |
474 if (keyframe) | 474 if (keyframe) |
475 seen_keyframe_ = true; | 475 seen_keyframe_ = true; |
(...skipping 27 matching lines...) Expand all Loading... |
503 public: | 503 public: |
504 VEAClient(TestStream* test_stream, | 504 VEAClient(TestStream* test_stream, |
505 ClientStateNotification<ClientState>* note, | 505 ClientStateNotification<ClientState>* note, |
506 bool save_to_file, | 506 bool save_to_file, |
507 unsigned int keyframe_period, | 507 unsigned int keyframe_period, |
508 bool force_bitrate, | 508 bool force_bitrate, |
509 bool test_perf, | 509 bool test_perf, |
510 bool mid_stream_bitrate_switch, | 510 bool mid_stream_bitrate_switch, |
511 bool mid_stream_framerate_switch, | 511 bool mid_stream_framerate_switch, |
512 bool run_at_fps); | 512 bool run_at_fps); |
513 virtual ~VEAClient(); | 513 ~VEAClient() override; |
514 void CreateEncoder(); | 514 void CreateEncoder(); |
515 void DestroyEncoder(); | 515 void DestroyEncoder(); |
516 | 516 |
517 // Return the number of encoded frames per second. | 517 // Return the number of encoded frames per second. |
518 double frames_per_second(); | 518 double frames_per_second(); |
519 | 519 |
520 // VideoDecodeAccelerator::Client implementation. | 520 // VideoDecodeAccelerator::Client implementation. |
521 virtual void RequireBitstreamBuffers(unsigned int input_count, | 521 void RequireBitstreamBuffers(unsigned int input_count, |
522 const gfx::Size& input_coded_size, | 522 const gfx::Size& input_coded_size, |
523 size_t output_buffer_size) override; | 523 size_t output_buffer_size) override; |
524 virtual void BitstreamBufferReady(int32 bitstream_buffer_id, | 524 void BitstreamBufferReady(int32 bitstream_buffer_id, |
525 size_t payload_size, | 525 size_t payload_size, |
526 bool key_frame) override; | 526 bool key_frame) override; |
527 virtual void NotifyError(VideoEncodeAccelerator::Error error) override; | 527 void NotifyError(VideoEncodeAccelerator::Error error) override; |
528 | 528 |
529 private: | 529 private: |
530 bool has_encoder() { return encoder_.get(); } | 530 bool has_encoder() { return encoder_.get(); } |
531 | 531 |
532 scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); | 532 scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); |
533 scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); | 533 scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); |
534 | 534 |
535 void SetState(ClientState new_state); | 535 void SetState(ClientState new_state); |
536 | 536 |
537 // Set current stream parameters to given |bitrate| at |framerate|. | 537 // Set current stream parameters to given |bitrate| at |framerate|. |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 } | 1366 } |
1367 | 1367 |
1368 content::g_env = | 1368 content::g_env = |
1369 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( | 1369 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( |
1370 testing::AddGlobalTestEnvironment( | 1370 testing::AddGlobalTestEnvironment( |
1371 new content::VideoEncodeAcceleratorTestEnvironment( | 1371 new content::VideoEncodeAcceleratorTestEnvironment( |
1372 test_stream_data.Pass(), run_at_fps))); | 1372 test_stream_data.Pass(), run_at_fps))); |
1373 | 1373 |
1374 return RUN_ALL_TESTS(); | 1374 return RUN_ALL_TESTS(); |
1375 } | 1375 } |
OLD | NEW |