OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } else { | 437 } else { |
438 // Otherwise, call the destroy task directly. | 438 // Otherwise, call the destroy task directly. |
439 DestroyTask(); | 439 DestroyTask(); |
440 } | 440 } |
441 | 441 |
442 delete this; | 442 delete this; |
443 } | 443 } |
444 | 444 |
445 bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } | 445 bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } |
446 | 446 |
| 447 // static |
| 448 std::vector<media::VideoDecodeAccelerator::SupportedProfile> |
| 449 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { |
| 450 std::vector<SupportedProfile> profiles; |
| 451 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 452 if (!device) |
| 453 return profiles; |
| 454 |
| 455 SupportedProfile profile; |
| 456 profile.min_resolution.SetSize(16, 16); |
| 457 // NOTE: additional autodetection logic may require updating input buffer size |
| 458 // selection. |
| 459 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 460 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) |
| 461 profile.max_resolution.SetSize(4096, 2160); |
| 462 else |
| 463 profile.max_resolution.SetSize(1920, 1088); |
| 464 |
| 465 v4l2_fmtdesc fmtdesc; |
| 466 memset(&fmtdesc, 0, sizeof(fmtdesc)); |
| 467 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 468 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { |
| 469 switch (fmtdesc.pixelformat) { |
| 470 case V4L2_PIX_FMT_H264: |
| 471 profile.profile = media::H264PROFILE_MAIN; |
| 472 profiles.push_back(profile); |
| 473 break; |
| 474 case V4L2_PIX_FMT_VP8: |
| 475 profile.profile = media::VP8PROFILE_ANY; |
| 476 profiles.push_back(profile); |
| 477 break; |
| 478 case V4L2_PIX_FMT_VP9: |
| 479 profile.profile = media::VP9PROFILE_ANY; |
| 480 profiles.push_back(profile); |
| 481 break; |
| 482 } |
| 483 } |
| 484 |
| 485 return profiles; |
| 486 } |
| 487 |
447 void V4L2VideoDecodeAccelerator::DecodeTask( | 488 void V4L2VideoDecodeAccelerator::DecodeTask( |
448 const media::BitstreamBuffer& bitstream_buffer) { | 489 const media::BitstreamBuffer& bitstream_buffer) { |
449 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); | 490 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); |
450 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 491 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
451 DCHECK_NE(decoder_state_, kUninitialized); | 492 DCHECK_NE(decoder_state_, kUninitialized); |
452 TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id", | 493 TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id", |
453 bitstream_buffer.id()); | 494 bitstream_buffer.id()); |
454 | 495 |
455 scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( | 496 scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( |
456 io_client_, io_message_loop_proxy_, | 497 io_client_, io_message_loop_proxy_, |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), | 2053 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), |
2013 base::checked_cast<int>(format.fmt.pix_mp.height)); | 2054 base::checked_cast<int>(format.fmt.pix_mp.height)); |
2014 if (coded_size_ != new_coded_size) { | 2055 if (coded_size_ != new_coded_size) { |
2015 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | 2056 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
2016 return true; | 2057 return true; |
2017 } | 2058 } |
2018 return false; | 2059 return false; |
2019 } | 2060 } |
2020 | 2061 |
2021 } // namespace content | 2062 } // namespace content |
OLD | NEW |