blob: 867f249fe637ee832f4dc46fa2d9ea0201f6a9b5 [file] [log] [blame]
magjed712338e2017-05-11 05:11:57 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "api/video/video_frame_buffer.h"
magjed712338e2017-05-11 05:11:57 -070012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/checks.h"
magjed712338e2017-05-11 05:11:57 -070014
15namespace webrtc {
16
magjedeaf4a1e2017-05-30 01:21:59 -070017rtc::scoped_refptr<I420BufferInterface> VideoFrameBuffer::GetI420() {
magjed712338e2017-05-11 05:11:57 -070018 RTC_CHECK(type() == Type::kI420);
Magnus Jedvert224e6592017-06-30 12:14:42 +000019 return static_cast<I420BufferInterface*>(this);
magjed712338e2017-05-11 05:11:57 -070020}
21
magjed3f075492017-06-01 10:02:26 -070022rtc::scoped_refptr<const I420BufferInterface> VideoFrameBuffer::GetI420()
23 const {
24 RTC_CHECK(type() == Type::kI420);
Magnus Jedvert224e6592017-06-30 12:14:42 +000025 return static_cast<const I420BufferInterface*>(this);
magjed3f075492017-06-01 10:02:26 -070026}
27
Emircan Uysaler574eaa42017-11-09 12:33:24 -080028I420ABufferInterface* VideoFrameBuffer::GetI420A() {
29 RTC_CHECK(type() == Type::kI420A);
30 return static_cast<I420ABufferInterface*>(this);
31}
32
33const I420ABufferInterface* VideoFrameBuffer::GetI420A() const {
34 RTC_CHECK(type() == Type::kI420A);
35 return static_cast<const I420ABufferInterface*>(this);
36}
37
magjed3f075492017-06-01 10:02:26 -070038I444BufferInterface* VideoFrameBuffer::GetI444() {
magjed712338e2017-05-11 05:11:57 -070039 RTC_CHECK(type() == Type::kI444);
magjedeaf4a1e2017-05-30 01:21:59 -070040 return static_cast<I444BufferInterface*>(this);
magjed712338e2017-05-11 05:11:57 -070041}
42
magjed3f075492017-06-01 10:02:26 -070043const I444BufferInterface* VideoFrameBuffer::GetI444() const {
44 RTC_CHECK(type() == Type::kI444);
45 return static_cast<const I444BufferInterface*>(this);
46}
47
magjedeaf4a1e2017-05-30 01:21:59 -070048VideoFrameBuffer::Type I420BufferInterface::type() const {
49 return Type::kI420;
magjed712338e2017-05-11 05:11:57 -070050}
51
magjedeaf4a1e2017-05-30 01:21:59 -070052int I420BufferInterface::ChromaWidth() const {
53 return (width() + 1) / 2;
magjed712338e2017-05-11 05:11:57 -070054}
55
magjedeaf4a1e2017-05-30 01:21:59 -070056int I420BufferInterface::ChromaHeight() const {
57 return (height() + 1) / 2;
58}
59
60rtc::scoped_refptr<I420BufferInterface> I420BufferInterface::ToI420() {
61 return this;
62}
63
Emircan Uysaler574eaa42017-11-09 12:33:24 -080064VideoFrameBuffer::Type I420ABufferInterface::type() const {
65 return Type::kI420A;
66}
67
magjedeaf4a1e2017-05-30 01:21:59 -070068VideoFrameBuffer::Type I444BufferInterface::type() const {
69 return Type::kI444;
70}
71
72int I444BufferInterface::ChromaWidth() const {
73 return width();
74}
75
76int I444BufferInterface::ChromaHeight() const {
77 return height();
78}
79
magjed712338e2017-05-11 05:11:57 -070080} // namespace webrtc