|
| 1 | +/* |
| 2 | + * Copyright 2016 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 | + |
| 11 | +#import "RTCYUVHelper.h" |
| 12 | + |
| 13 | +#include "third_party/libyuv/include/libyuv.h" |
| 14 | + |
| 15 | +@implementation RTC_OBJC_TYPE (RTCYUVHelper) |
| 16 | + |
| 17 | ++ (void)I420Rotate:(const uint8_t*)srcY |
| 18 | + srcStrideY:(int)srcStrideY |
| 19 | + srcU:(const uint8_t*)srcU |
| 20 | + srcStrideU:(int)srcStrideU |
| 21 | + srcV:(const uint8_t*)srcV |
| 22 | + srcStrideV:(int)srcStrideV |
| 23 | + dstY:(uint8_t*)dstY |
| 24 | + dstStrideY:(int)dstStrideY |
| 25 | + dstU:(uint8_t*)dstU |
| 26 | + dstStrideU:(int)dstStrideU |
| 27 | + dstV:(uint8_t*)dstV |
| 28 | + dstStrideV:(int)dstStrideV |
| 29 | + width:(int)width |
| 30 | + width:(int)height |
| 31 | + mode:(RTCVideoRotation)mode { |
| 32 | + libyuv::I420Rotate(srcY, |
| 33 | + srcStrideY, |
| 34 | + srcU, |
| 35 | + srcStrideU, |
| 36 | + srcV, |
| 37 | + srcStrideV, |
| 38 | + dstY, |
| 39 | + dstStrideY, |
| 40 | + dstU, |
| 41 | + dstStrideU, |
| 42 | + dstV, |
| 43 | + dstStrideV, |
| 44 | + width, |
| 45 | + height, |
| 46 | + (libyuv::RotationMode)mode); |
| 47 | +} |
| 48 | + |
| 49 | ++ (int)I420ToNV12:(const uint8_t*)srcY |
| 50 | + srcStrideY:(int)srcStrideY |
| 51 | + srcU:(const uint8_t*)srcU |
| 52 | + srcStrideU:(int)srcStrideU |
| 53 | + srcV:(const uint8_t*)srcV |
| 54 | + srcStrideV:(int)srcStrideV |
| 55 | + dstY:(uint8_t*)dstY |
| 56 | + dstStrideY:(int)dstStrideY |
| 57 | + dstUV:(uint8_t*)dstUV |
| 58 | + dstStrideUV:(int)dstStrideUV |
| 59 | + width:(int)width |
| 60 | + width:(int)height { |
| 61 | + return libyuv::I420ToNV12(srcY, |
| 62 | + srcStrideY, |
| 63 | + srcU, |
| 64 | + srcStrideU, |
| 65 | + srcV, |
| 66 | + srcStrideV, |
| 67 | + dstY, |
| 68 | + dstStrideY, |
| 69 | + dstUV, |
| 70 | + dstStrideUV, |
| 71 | + width, |
| 72 | + height); |
| 73 | +} |
| 74 | + |
| 75 | ++ (int)I420ToNV21:(const uint8_t*)srcY |
| 76 | + srcStrideY:(int)srcStrideY |
| 77 | + srcU:(const uint8_t*)srcU |
| 78 | + srcStrideU:(int)srcStrideU |
| 79 | + srcV:(const uint8_t*)srcV |
| 80 | + srcStrideV:(int)srcStrideV |
| 81 | + dstY:(uint8_t*)dstY |
| 82 | + dstStrideY:(int)dstStrideY |
| 83 | + dstUV:(uint8_t*)dstUV |
| 84 | + dstStrideUV:(int)dstStrideUV |
| 85 | + width:(int)width |
| 86 | + width:(int)height { |
| 87 | + return libyuv::I420ToNV21(srcY, |
| 88 | + srcStrideY, |
| 89 | + srcU, |
| 90 | + srcStrideU, |
| 91 | + srcV, |
| 92 | + srcStrideV, |
| 93 | + dstY, |
| 94 | + dstStrideY, |
| 95 | + dstUV, |
| 96 | + dstStrideUV, |
| 97 | + width, |
| 98 | + height); |
| 99 | +} |
| 100 | + |
| 101 | ++ (int)I420ToARGB:(const uint8_t*)srcY |
| 102 | + srcStrideY:(int)srcStrideY |
| 103 | + srcU:(const uint8_t*)srcU |
| 104 | + srcStrideU:(int)srcStrideU |
| 105 | + srcV:(const uint8_t*)srcV |
| 106 | + srcStrideV:(int)srcStrideV |
| 107 | + dstARGB:(uint8_t*)dstARGB |
| 108 | + dstStrideARGB:(int)dstStrideARGB |
| 109 | + width:(int)width |
| 110 | + height:(int)height { |
| 111 | + return libyuv::I420ToARGB( |
| 112 | + srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstARGB, dstStrideARGB, width, height); |
| 113 | +} |
| 114 | + |
| 115 | ++ (int)I420ToBGRA:(const uint8_t*)srcY |
| 116 | + srcStrideY:(int)srcStrideY |
| 117 | + srcU:(const uint8_t*)srcU |
| 118 | + srcStrideU:(int)srcStrideU |
| 119 | + srcV:(const uint8_t*)srcV |
| 120 | + srcStrideV:(int)srcStrideV |
| 121 | + dstBGRA:(uint8_t*)dstBGRA |
| 122 | + dstStrideBGRA:(int)dstStrideBGRA |
| 123 | + width:(int)width |
| 124 | + height:(int)height { |
| 125 | + return libyuv::I420ToBGRA( |
| 126 | + srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstBGRA, dstStrideBGRA, width, height); |
| 127 | +} |
| 128 | + |
| 129 | ++ (int)I420ToABGR:(const uint8_t*)srcY |
| 130 | + srcStrideY:(int)srcStrideY |
| 131 | + srcU:(const uint8_t*)srcU |
| 132 | + srcStrideU:(int)srcStrideU |
| 133 | + srcV:(const uint8_t*)srcV |
| 134 | + srcStrideV:(int)srcStrideV |
| 135 | + dstABGR:(uint8_t*)dstABGR |
| 136 | + dstStrideABGR:(int)dstStrideABGR |
| 137 | + width:(int)width |
| 138 | + height:(int)height { |
| 139 | + return libyuv::I420ToABGR( |
| 140 | + srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstABGR, dstStrideABGR, width, height); |
| 141 | +} |
| 142 | + |
| 143 | ++ (int)I420ToRGBA:(const uint8_t*)srcY |
| 144 | + srcStrideY:(int)srcStrideY |
| 145 | + srcU:(const uint8_t*)srcU |
| 146 | + srcStrideU:(int)srcStrideU |
| 147 | + srcV:(const uint8_t*)srcV |
| 148 | + srcStrideV:(int)srcStrideV |
| 149 | + dstRGBA:(uint8_t*)dstRGBA |
| 150 | + dstStrideRGBA:(int)dstStrideRGBA |
| 151 | + width:(int)width |
| 152 | + height:(int)height { |
| 153 | + return libyuv::I420ToRGBA( |
| 154 | + srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstRGBA, dstStrideRGBA, width, height); |
| 155 | +} |
| 156 | + |
| 157 | ++ (int)I420ToRGB24:(const uint8_t*)srcY |
| 158 | + srcStrideY:(int)srcStrideY |
| 159 | + srcU:(const uint8_t*)srcU |
| 160 | + srcStrideU:(int)srcStrideU |
| 161 | + srcV:(const uint8_t*)srcV |
| 162 | + srcStrideV:(int)srcStrideV |
| 163 | + dstRGB24:(uint8_t*)dstRGB24 |
| 164 | + dstStrideRGB24:(int)dstStrideRGB24 |
| 165 | + width:(int)width |
| 166 | + height:(int)height { |
| 167 | + return libyuv::I420ToRGB24(srcY, |
| 168 | + srcStrideY, |
| 169 | + srcU, |
| 170 | + srcStrideU, |
| 171 | + srcV, |
| 172 | + srcStrideV, |
| 173 | + dstRGB24, |
| 174 | + dstStrideRGB24, |
| 175 | + width, |
| 176 | + height); |
| 177 | +} |
| 178 | + |
| 179 | +@end |
0 commit comments