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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 weak_this_, error)); | 426 weak_this_, error)); |
427 return; | 427 return; |
428 } | 428 } |
429 | 429 |
430 if (client_) { | 430 if (client_) { |
431 client_->NotifyError(error); | 431 client_->NotifyError(error); |
432 client_ptr_factory_.reset(); | 432 client_ptr_factory_.reset(); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
| 436 // static |
| 437 std::vector<media::VideoDecodeAccelerator::SupportedProfile> |
| 438 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { |
| 439 std::vector<SupportedProfile> profiles; |
| 440 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 441 if (!device) |
| 442 return profiles; |
| 443 |
| 444 SupportedProfile profile; |
| 445 profile.min_resolution.SetSize(16, 16); |
| 446 // NOTE: additional autodetection logic may require updating input buffer size |
| 447 // selection. |
| 448 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 449 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) |
| 450 profile.max_resolution.SetSize(4096, 2160); |
| 451 else |
| 452 profile.max_resolution.SetSize(1920, 1088); |
| 453 |
| 454 v4l2_fmtdesc fmtdesc; |
| 455 memset(&fmtdesc, 0, sizeof(fmtdesc)); |
| 456 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 457 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { |
| 458 switch (fmtdesc.pixelformat) { |
| 459 case V4L2_PIX_FMT_H264_SLICE: |
| 460 profile.profile = media::H264PROFILE_MAIN; |
| 461 profiles.push_back(profile); |
| 462 break; |
| 463 case V4L2_PIX_FMT_VP8_FRAME: |
| 464 profile.profile = media::VP8PROFILE_ANY; |
| 465 profiles.push_back(profile); |
| 466 break; |
| 467 } |
| 468 } |
| 469 |
| 470 return profiles; |
| 471 } |
| 472 |
436 bool V4L2SliceVideoDecodeAccelerator::Initialize( | 473 bool V4L2SliceVideoDecodeAccelerator::Initialize( |
437 media::VideoCodecProfile profile, | 474 media::VideoCodecProfile profile, |
438 VideoDecodeAccelerator::Client* client) { | 475 VideoDecodeAccelerator::Client* client) { |
439 DVLOGF(3) << "profile: " << profile; | 476 DVLOGF(3) << "profile: " << profile; |
440 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); | 477 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
441 DCHECK_EQ(state_, kUninitialized); | 478 DCHECK_EQ(state_, kUninitialized); |
442 | 479 |
443 client_ptr_factory_.reset( | 480 client_ptr_factory_.reset( |
444 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); | 481 new base::WeakPtrFactory<VideoDecodeAccelerator::Client>(client)); |
445 client_ = client_ptr_factory_->GetWeakPtr(); | 482 client_ = client_ptr_factory_->GetWeakPtr(); |
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 DCHECK_GT(picture_clearing_count_, 0); | 2508 DCHECK_GT(picture_clearing_count_, 0); |
2472 picture_clearing_count_--; | 2509 picture_clearing_count_--; |
2473 SendPictureReady(); | 2510 SendPictureReady(); |
2474 } | 2511 } |
2475 | 2512 |
2476 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { | 2513 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { |
2477 return true; | 2514 return true; |
2478 } | 2515 } |
2479 | 2516 |
2480 } // namespace content | 2517 } // namespace content |
OLD | NEW |