magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "api/video/video_frame_buffer.h" |
magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
Ilya Nikolaevskiy | a8507e3 | 2019-05-03 11:39:26 +0200 | [diff] [blame] | 17 | const I420BufferInterface* VideoFrameBuffer::GetI420() const { |
| 18 | // Overridden by subclasses that can return an I420 buffer without any |
| 19 | // conversion, in particular, I420BufferInterface. |
| 20 | return nullptr; |
Emircan Uysaler | 574eaa4 | 2017-11-09 12:33:24 -0800 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | const I420ABufferInterface* VideoFrameBuffer::GetI420A() const { |
| 24 | RTC_CHECK(type() == Type::kI420A); |
| 25 | return static_cast<const I420ABufferInterface*>(this); |
| 26 | } |
| 27 | |
magjed | 3f07549 | 2017-06-01 10:02:26 -0700 | [diff] [blame] | 28 | const I444BufferInterface* VideoFrameBuffer::GetI444() const { |
| 29 | RTC_CHECK(type() == Type::kI444); |
| 30 | return static_cast<const I444BufferInterface*>(this); |
| 31 | } |
| 32 | |
Emircan Uysaler | 901e0ff | 2018-06-26 12:22:38 -0700 | [diff] [blame] | 33 | const I010BufferInterface* VideoFrameBuffer::GetI010() const { |
| 34 | RTC_CHECK(type() == Type::kI010); |
| 35 | return static_cast<const I010BufferInterface*>(this); |
| 36 | } |
| 37 | |
magjed | eaf4a1e | 2017-05-30 01:21:59 -0700 | [diff] [blame] | 38 | VideoFrameBuffer::Type I420BufferInterface::type() const { |
| 39 | return Type::kI420; |
magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 40 | } |
| 41 | |
magjed | eaf4a1e | 2017-05-30 01:21:59 -0700 | [diff] [blame] | 42 | int I420BufferInterface::ChromaWidth() const { |
| 43 | return (width() + 1) / 2; |
magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 44 | } |
| 45 | |
magjed | eaf4a1e | 2017-05-30 01:21:59 -0700 | [diff] [blame] | 46 | int I420BufferInterface::ChromaHeight() const { |
| 47 | return (height() + 1) / 2; |
| 48 | } |
| 49 | |
| 50 | rtc::scoped_refptr<I420BufferInterface> I420BufferInterface::ToI420() { |
| 51 | return this; |
| 52 | } |
| 53 | |
Ilya Nikolaevskiy | a8507e3 | 2019-05-03 11:39:26 +0200 | [diff] [blame] | 54 | const I420BufferInterface* I420BufferInterface::GetI420() const { |
| 55 | return this; |
| 56 | } |
| 57 | |
Emircan Uysaler | 574eaa4 | 2017-11-09 12:33:24 -0800 | [diff] [blame] | 58 | VideoFrameBuffer::Type I420ABufferInterface::type() const { |
| 59 | return Type::kI420A; |
| 60 | } |
| 61 | |
magjed | eaf4a1e | 2017-05-30 01:21:59 -0700 | [diff] [blame] | 62 | VideoFrameBuffer::Type I444BufferInterface::type() const { |
| 63 | return Type::kI444; |
| 64 | } |
| 65 | |
| 66 | int I444BufferInterface::ChromaWidth() const { |
| 67 | return width(); |
| 68 | } |
| 69 | |
| 70 | int I444BufferInterface::ChromaHeight() const { |
| 71 | return height(); |
| 72 | } |
| 73 | |
Emircan Uysaler | 901e0ff | 2018-06-26 12:22:38 -0700 | [diff] [blame] | 74 | VideoFrameBuffer::Type I010BufferInterface::type() const { |
| 75 | return Type::kI010; |
| 76 | } |
| 77 | |
| 78 | int I010BufferInterface::ChromaWidth() const { |
| 79 | return (width() + 1) / 2; |
| 80 | } |
| 81 | |
| 82 | int I010BufferInterface::ChromaHeight() const { |
| 83 | return (height() + 1) / 2; |
| 84 | } |
| 85 | |
magjed | 712338e | 2017-05-11 05:11:57 -0700 | [diff] [blame] | 86 | } // namespace webrtc |