You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "api/video/video_frame_buffer.h"
  11. #include "rtc_base/checks.h"
  12. namespace webrtc {
  13. const I420BufferInterface* VideoFrameBuffer::GetI420() const {
  14. // Overridden by subclasses that can return an I420 buffer without any
  15. // conversion, in particular, I420BufferInterface.
  16. return nullptr;
  17. }
  18. const I420ABufferInterface* VideoFrameBuffer::GetI420A() const {
  19. RTC_CHECK(type() == Type::kI420A);
  20. return static_cast<const I420ABufferInterface*>(this);
  21. }
  22. const I444BufferInterface* VideoFrameBuffer::GetI444() const {
  23. RTC_CHECK(type() == Type::kI444);
  24. return static_cast<const I444BufferInterface*>(this);
  25. }
  26. const I010BufferInterface* VideoFrameBuffer::GetI010() const {
  27. RTC_CHECK(type() == Type::kI010);
  28. return static_cast<const I010BufferInterface*>(this);
  29. }
  30. VideoFrameBuffer::Type I420BufferInterface::type() const {
  31. return Type::kI420;
  32. }
  33. int I420BufferInterface::ChromaWidth() const {
  34. return (width() + 1) / 2;
  35. }
  36. int I420BufferInterface::ChromaHeight() const {
  37. return (height() + 1) / 2;
  38. }
  39. rtc::scoped_refptr<I420BufferInterface> I420BufferInterface::ToI420() {
  40. return this;
  41. }
  42. const I420BufferInterface* I420BufferInterface::GetI420() const {
  43. return this;
  44. }
  45. VideoFrameBuffer::Type I420ABufferInterface::type() const {
  46. return Type::kI420A;
  47. }
  48. VideoFrameBuffer::Type I444BufferInterface::type() const {
  49. return Type::kI444;
  50. }
  51. int I444BufferInterface::ChromaWidth() const {
  52. return width();
  53. }
  54. int I444BufferInterface::ChromaHeight() const {
  55. return height();
  56. }
  57. VideoFrameBuffer::Type I010BufferInterface::type() const {
  58. return Type::kI010;
  59. }
  60. int I010BufferInterface::ChromaWidth() const {
  61. return (width() + 1) / 2;
  62. }
  63. int I010BufferInterface::ChromaHeight() const {
  64. return (height() + 1) / 2;
  65. }
  66. } // namespace webrtc