Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm

Issue 2695203004: Clean up RTCVideoFrame (Closed)
Patch Set: Fix memory leak. Add ObjC rotation enum. Add space in pointer types. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
index d325840cf5d5853e8c019e16b3c4bc622e39f5d9..7a09c41a848c6ec7eb116a6472f7c2833783ff93 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
@@ -15,7 +15,6 @@
#import "RTCShader+Private.h"
#import "WebRTC/RTCVideoFrame.h"
-#include "webrtc/api/video/video_rotation.h"
#include "webrtc/base/optional.h"
// |kNumTextures| must not exceed 8, which is the limit in OpenGLES2. Two sets
@@ -62,7 +61,7 @@ static const char kI420FragmentShaderSource[] =
GLint _vSampler;
// Store current rotation and only upload new vertex data when rotation
// changes.
- rtc::Optional<webrtc::VideoRotation> _currentRotation;
+ rtc::Optional<RTCVideoRotation> _currentRotation;
// Used to create a non-padded plane for GPU upload when we receive padded
// frames.
std::vector<uint8_t> _planeBuffer;
@@ -126,8 +125,7 @@ static const char kI420FragmentShaderSource[] =
#endif
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
if (!_currentRotation || frame.rotation != *_currentRotation) {
- _currentRotation = rtc::Optional<webrtc::VideoRotation>(
- static_cast<webrtc::VideoRotation>(frame.rotation));
+ _currentRotation = rtc::Optional<RTCVideoRotation>(frame.rotation);
RTCSetVertexData(*_currentRotation);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -188,32 +186,34 @@ static const char kI420FragmentShaderSource[] =
GLint textureOffset = _currentTextureSet * 3;
NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset");
- if (frame.yPitch != static_cast<int32_t>(frame.width) ||
- frame.uPitch != static_cast<int32_t>(frame.chromaWidth) ||
- frame.vPitch != static_cast<int32_t>(frame.chromaWidth)) {
+ const int chromaWidth = (frame.width + 1) / 2;
+ const int chromaHeight = (frame.height + 1) / 2;
+ if (frame.strideY != frame.width ||
+ frame.strideU != chromaWidth ||
+ frame.strideV != chromaWidth) {
_planeBuffer.resize(frame.width * frame.height);
}
- [self uploadPlane:frame.yPlane
+ [self uploadPlane:frame.dataY
sampler:_ySampler
offset:textureOffset
width:frame.width
height:frame.height
- stride:frame.yPitch];
+ stride:frame.strideY];
- [self uploadPlane:frame.uPlane
+ [self uploadPlane:frame.dataU
sampler:_uSampler
offset:textureOffset + 1
- width:frame.chromaWidth
- height:frame.chromaHeight
- stride:frame.uPitch];
+ width:chromaWidth
+ height:chromaHeight
+ stride:frame.strideU];
- [self uploadPlane:frame.vPlane
+ [self uploadPlane:frame.dataV
sampler:_vSampler
offset:textureOffset + 2
- width:frame.chromaWidth
- height:frame.chromaHeight
- stride:frame.vPitch];
+ width:chromaWidth
+ height:chromaHeight
+ stride:frame.strideV];
_currentTextureSet = (_currentTextureSet + 1) % kNumTextureSets;
return YES;
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m ('k') | webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698