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 <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <linux/videodev2.h> | 7 #include <linux/videodev2.h> |
8 #include <poll.h> | 8 #include <poll.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 IOCTL_OR_ERROR_RETURN_VALUE(type, arg, false, #type) | 48 IOCTL_OR_ERROR_RETURN_VALUE(type, arg, false, #type) |
49 | 49 |
50 #define IOCTL_OR_LOG_ERROR(type, arg) \ | 50 #define IOCTL_OR_LOG_ERROR(type, arg) \ |
51 do { \ | 51 do { \ |
52 if (device_->Ioctl(type, arg) != 0) \ | 52 if (device_->Ioctl(type, arg) != 0) \ |
53 PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << #type; \ | 53 PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << #type; \ |
54 } while (0) | 54 } while (0) |
55 | 55 |
56 namespace content { | 56 namespace content { |
57 | 57 |
| 58 // static |
| 59 const uint32_t V4L2SliceVideoDecodeAccelerator::supported_input_fourccs_[] = { |
| 60 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME, |
| 61 }; |
| 62 |
58 class V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface | 63 class V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface |
59 : public base::RefCounted<V4L2DecodeSurface> { | 64 : public base::RefCounted<V4L2DecodeSurface> { |
60 public: | 65 public: |
61 using ReleaseCB = base::Callback<void(int)>; | 66 using ReleaseCB = base::Callback<void(int)>; |
62 | 67 |
63 V4L2DecodeSurface(int32_t bitstream_id, | 68 V4L2DecodeSurface(int32_t bitstream_id, |
64 int input_record, | 69 int input_record, |
65 int output_record, | 70 int output_record, |
66 const ReleaseCB& release_cb); | 71 const ReleaseCB& release_cb); |
67 | 72 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 434 |
430 if (client_) { | 435 if (client_) { |
431 client_->NotifyError(error); | 436 client_->NotifyError(error); |
432 client_ptr_factory_.reset(); | 437 client_ptr_factory_.reset(); |
433 } | 438 } |
434 } | 439 } |
435 | 440 |
436 bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config, | 441 bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config, |
437 Client* client) { | 442 Client* client) { |
438 DVLOGF(3) << "profile: " << config.profile; | 443 DVLOGF(3) << "profile: " << config.profile; |
| 444 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 445 DCHECK_EQ(state_, kUninitialized); |
| 446 |
439 if (config.is_encrypted) { | 447 if (config.is_encrypted) { |
440 NOTREACHED() << "Encrypted streams are not supported for this VDA"; | 448 NOTREACHED() << "Encrypted streams are not supported for this VDA"; |
441 return false; | 449 return false; |
442 } | 450 } |
443 | 451 |
444 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 452 if (!device_->SupportsDecodeProfileForV4L2PixelFormats( |
445 DCHECK_EQ(state_, kUninitialized); | 453 config.profile, arraysize(supported_input_fourccs_), |
| 454 supported_input_fourccs_)) { |
| 455 DVLOGF(1) << "unsupported profile " << config.profile; |
| 456 return false; |
| 457 } |
446 | 458 |
447 client_ptr_factory_.reset( | 459 client_ptr_factory_.reset( |
448 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); | 460 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); |
449 client_ = client_ptr_factory_->GetWeakPtr(); | 461 client_ = client_ptr_factory_->GetWeakPtr(); |
450 | 462 |
451 video_profile_ = config.profile; | 463 video_profile_ = config.profile; |
452 | 464 |
453 if (video_profile_ >= media::H264PROFILE_MIN && | 465 if (video_profile_ >= media::H264PROFILE_MIN && |
454 video_profile_ <= media::H264PROFILE_MAX) { | 466 video_profile_ <= media::H264PROFILE_MAX) { |
455 h264_accelerator_.reset(new V4L2H264Accelerator(this)); | 467 h264_accelerator_.reset(new V4L2H264Accelerator(this)); |
456 decoder_.reset(new H264Decoder(h264_accelerator_.get())); | 468 decoder_.reset(new H264Decoder(h264_accelerator_.get())); |
457 } else if (video_profile_ >= media::VP8PROFILE_MIN && | 469 } else if (video_profile_ >= media::VP8PROFILE_MIN && |
458 video_profile_ <= media::VP8PROFILE_MAX) { | 470 video_profile_ <= media::VP8PROFILE_MAX) { |
459 vp8_accelerator_.reset(new V4L2VP8Accelerator(this)); | 471 vp8_accelerator_.reset(new V4L2VP8Accelerator(this)); |
460 decoder_.reset(new VP8Decoder(vp8_accelerator_.get())); | 472 decoder_.reset(new VP8Decoder(vp8_accelerator_.get())); |
461 } else { | 473 } else { |
462 DLOG(ERROR) << "Unsupported profile " << video_profile_; | 474 NOTREACHED() << "Unsupported profile " << video_profile_; |
463 return false; | 475 return false; |
464 } | 476 } |
465 | 477 |
466 // TODO(posciak): This needs to be queried once supported. | 478 // TODO(posciak): This needs to be queried once supported. |
467 input_planes_count_ = 1; | 479 input_planes_count_ = 1; |
468 output_planes_count_ = 1; | 480 output_planes_count_ = 1; |
469 | 481 |
470 if (egl_display_ == EGL_NO_DISPLAY) { | 482 if (egl_display_ == EGL_NO_DISPLAY) { |
471 LOG(ERROR) << "Initialize(): could not get EGLDisplay"; | 483 LOG(ERROR) << "Initialize(): could not get EGLDisplay"; |
472 return false; | 484 return false; |
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 return true; | 2548 return true; |
2537 } | 2549 } |
2538 | 2550 |
2539 // static | 2551 // static |
2540 media::VideoDecodeAccelerator::SupportedProfiles | 2552 media::VideoDecodeAccelerator::SupportedProfiles |
2541 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { | 2553 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { |
2542 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 2554 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
2543 if (!device) | 2555 if (!device) |
2544 return SupportedProfiles(); | 2556 return SupportedProfiles(); |
2545 | 2557 |
2546 const uint32_t supported_formats[] = { | 2558 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), |
2547 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME}; | 2559 supported_input_fourccs_); |
2548 return device->GetSupportedDecodeProfiles(arraysize(supported_formats), | |
2549 supported_formats); | |
2550 } | 2560 } |
2551 | 2561 |
2552 } // namespace content | 2562 } // namespace content |
OLD | NEW |