OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <linux/videodev2.h> | 6 #include <linux/videodev2.h> |
7 #include <poll.h> | 7 #include <poll.h> |
8 #include <sys/eventfd.h> | 8 #include <sys/eventfd.h> |
9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 io_client_(io_client), | 387 io_client_(io_client), |
388 device_(device), | 388 device_(device), |
389 decoder_thread_("V4L2SliceVideoDecodeAcceleratorThread"), | 389 decoder_thread_("V4L2SliceVideoDecodeAcceleratorThread"), |
390 device_poll_thread_("V4L2SliceVideoDecodeAcceleratorDevicePollThread"), | 390 device_poll_thread_("V4L2SliceVideoDecodeAcceleratorDevicePollThread"), |
391 input_streamon_(false), | 391 input_streamon_(false), |
392 input_buffer_queued_count_(0), | 392 input_buffer_queued_count_(0), |
393 output_streamon_(false), | 393 output_streamon_(false), |
394 output_buffer_queued_count_(0), | 394 output_buffer_queued_count_(0), |
395 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), | 395 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), |
396 output_format_fourcc_(0), | 396 output_format_fourcc_(0), |
| 397 min_picture_count_(0), |
397 state_(kUninitialized), | 398 state_(kUninitialized), |
398 decoder_flushing_(false), | 399 decoder_flushing_(false), |
399 decoder_resetting_(false), | 400 decoder_resetting_(false), |
400 surface_set_change_pending_(false), | 401 surface_set_change_pending_(false), |
401 picture_clearing_count_(0), | 402 picture_clearing_count_(0), |
402 pictures_assigned_(false, false), | 403 pictures_assigned_(false, false), |
403 make_context_current_(make_context_current), | 404 make_context_current_(make_context_current), |
404 egl_display_(egl_display), | 405 egl_display_(egl_display), |
405 egl_context_(egl_context), | 406 egl_context_(egl_context), |
406 weak_this_factory_(this) { | 407 weak_this_factory_(this) { |
(...skipping 20 matching lines...) Expand all Loading... |
427 } | 428 } |
428 | 429 |
429 if (client_) { | 430 if (client_) { |
430 client_->NotifyError(error); | 431 client_->NotifyError(error); |
431 client_ptr_factory_.reset(); | 432 client_ptr_factory_.reset(); |
432 } | 433 } |
433 } | 434 } |
434 | 435 |
435 bool V4L2SliceVideoDecodeAccelerator::Initialize( | 436 bool V4L2SliceVideoDecodeAccelerator::Initialize( |
436 media::VideoCodecProfile profile, | 437 media::VideoCodecProfile profile, |
| 438 uint32_t min_picture_count, |
437 VideoDecodeAccelerator::Client* client) { | 439 VideoDecodeAccelerator::Client* client) { |
438 DVLOGF(3) << "profile: " << profile; | 440 DVLOGF(3) << "profile: " << profile; |
439 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 441 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
440 DCHECK_EQ(state_, kUninitialized); | 442 DCHECK_EQ(state_, kUninitialized); |
441 | 443 |
442 client_ptr_factory_.reset( | 444 client_ptr_factory_.reset( |
443 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); | 445 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); |
444 client_ = client_ptr_factory_->GetWeakPtr(); | 446 client_ = client_ptr_factory_->GetWeakPtr(); |
445 | 447 |
446 video_profile_ = profile; | 448 video_profile_ = profile; |
| 449 min_picture_count_ = min_picture_count; |
447 | 450 |
448 if (video_profile_ >= media::H264PROFILE_MIN && | 451 if (video_profile_ >= media::H264PROFILE_MIN && |
449 video_profile_ <= media::H264PROFILE_MAX) { | 452 video_profile_ <= media::H264PROFILE_MAX) { |
450 h264_accelerator_.reset(new V4L2H264Accelerator(this)); | 453 h264_accelerator_.reset(new V4L2H264Accelerator(this)); |
451 decoder_.reset(new H264Decoder(h264_accelerator_.get())); | 454 decoder_.reset(new H264Decoder(h264_accelerator_.get())); |
452 } else if (video_profile_ >= media::VP8PROFILE_MIN && | 455 } else if (video_profile_ >= media::VP8PROFILE_MIN && |
453 video_profile_ <= media::VP8PROFILE_MAX) { | 456 video_profile_ <= media::VP8PROFILE_MAX) { |
454 vp8_accelerator_.reset(new V4L2VP8Accelerator(this)); | 457 vp8_accelerator_.reset(new V4L2VP8Accelerator(this)); |
455 decoder_.reset(new VP8Decoder(vp8_accelerator_.get())); | 458 decoder_.reset(new VP8Decoder(vp8_accelerator_.get())); |
456 } else { | 459 } else { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 679 |
677 bool V4L2SliceVideoDecodeAccelerator::CreateOutputBuffers() { | 680 bool V4L2SliceVideoDecodeAccelerator::CreateOutputBuffers() { |
678 DVLOGF(3); | 681 DVLOGF(3); |
679 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); | 682 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); |
680 DCHECK(!output_streamon_); | 683 DCHECK(!output_streamon_); |
681 DCHECK(output_buffer_map_.empty()); | 684 DCHECK(output_buffer_map_.empty()); |
682 DCHECK(surfaces_at_display_.empty()); | 685 DCHECK(surfaces_at_display_.empty()); |
683 DCHECK(surfaces_at_device_.empty()); | 686 DCHECK(surfaces_at_device_.empty()); |
684 | 687 |
685 visible_size_ = decoder_->GetPicSize(); | 688 visible_size_ = decoder_->GetPicSize(); |
686 size_t num_pictures = decoder_->GetRequiredNumOfPictures(); | 689 size_t num_pictures = std::max(min_picture_count_, |
| 690 static_cast<uint32_t>( |
| 691 decoder_->GetRequiredNumOfPictures())); |
687 | 692 |
688 DCHECK_GT(num_pictures, 0u); | 693 DCHECK_GT(num_pictures, 0u); |
689 DCHECK(!visible_size_.IsEmpty()); | 694 DCHECK(!visible_size_.IsEmpty()); |
690 | 695 |
691 struct v4l2_format format; | 696 struct v4l2_format format; |
692 memset(&format, 0, sizeof(format)); | 697 memset(&format, 0, sizeof(format)); |
693 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 698 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
694 format.fmt.pix_mp.pixelformat = output_format_fourcc_; | 699 format.fmt.pix_mp.pixelformat = output_format_fourcc_; |
695 format.fmt.pix_mp.width = visible_size_.width(); | 700 format.fmt.pix_mp.width = visible_size_.width(); |
696 format.fmt.pix_mp.height = visible_size_.height(); | 701 format.fmt.pix_mp.height = visible_size_.height(); |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2511 if (!device) | 2516 if (!device) |
2512 return SupportedProfiles(); | 2517 return SupportedProfiles(); |
2513 | 2518 |
2514 const uint32_t supported_formats[] = { | 2519 const uint32_t supported_formats[] = { |
2515 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME}; | 2520 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME}; |
2516 return device->GetSupportedDecodeProfiles(arraysize(supported_formats), | 2521 return device->GetSupportedDecodeProfiles(arraysize(supported_formats), |
2517 supported_formats); | 2522 supported_formats); |
2518 } | 2523 } |
2519 | 2524 |
2520 } // namespace content | 2525 } // namespace content |
OLD | NEW |