OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 0, | 181 0, |
182 RTC_PIXEL_FORMAT, | 182 RTC_PIXEL_FORMAT, |
183 GL_UNSIGNED_BYTE, | 183 GL_UNSIGNED_BYTE, |
184 uploadPlane); | 184 uploadPlane); |
185 } | 185 } |
186 | 186 |
187 - (BOOL)updateTextureDataForFrame:(RTCVideoFrame *)frame { | 187 - (BOOL)updateTextureDataForFrame:(RTCVideoFrame *)frame { |
188 GLint textureOffset = _currentTextureSet * 3; | 188 GLint textureOffset = _currentTextureSet * 3; |
189 NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset"); | 189 NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset"); |
190 | 190 |
191 if (frame.yPitch != static_cast<int32_t>(frame.width) || | 191 const int chromaWidth = (frame.width + 1) / 2; |
192 frame.uPitch != static_cast<int32_t>(frame.chromaWidth) || | 192 const int chromaHeight = (frame.height + 1) / 2; |
193 frame.vPitch != static_cast<int32_t>(frame.chromaWidth)) { | 193 if (frame.strideY != frame.width || |
| 194 frame.strideU != chromaWidth || |
| 195 frame.strideV != chromaWidth) { |
194 _planeBuffer.resize(frame.width * frame.height); | 196 _planeBuffer.resize(frame.width * frame.height); |
195 } | 197 } |
196 | 198 |
197 [self uploadPlane:frame.yPlane | 199 [self uploadPlane:frame.dataY |
198 sampler:_ySampler | 200 sampler:_ySampler |
199 offset:textureOffset | 201 offset:textureOffset |
200 width:frame.width | 202 width:frame.width |
201 height:frame.height | 203 height:frame.height |
202 stride:frame.yPitch]; | 204 stride:frame.strideY]; |
203 | 205 |
204 [self uploadPlane:frame.uPlane | 206 [self uploadPlane:frame.dataU |
205 sampler:_uSampler | 207 sampler:_uSampler |
206 offset:textureOffset + 1 | 208 offset:textureOffset + 1 |
207 width:frame.chromaWidth | 209 width:chromaWidth |
208 height:frame.chromaHeight | 210 height:chromaHeight |
209 stride:frame.uPitch]; | 211 stride:frame.strideU]; |
210 | 212 |
211 [self uploadPlane:frame.vPlane | 213 [self uploadPlane:frame.dataV |
212 sampler:_vSampler | 214 sampler:_vSampler |
213 offset:textureOffset + 2 | 215 offset:textureOffset + 2 |
214 width:frame.chromaWidth | 216 width:chromaWidth |
215 height:frame.chromaHeight | 217 height:chromaHeight |
216 stride:frame.vPitch]; | 218 stride:frame.strideV]; |
217 | 219 |
218 _currentTextureSet = (_currentTextureSet + 1) % kNumTextureSets; | 220 _currentTextureSet = (_currentTextureSet + 1) % kNumTextureSets; |
219 return YES; | 221 return YES; |
220 } | 222 } |
221 | 223 |
222 @end | 224 @end |
OLD | NEW |