diff options
author | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-04-10 23:21:10 +0000 |
---|---|---|
committer | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-04-10 23:21:10 +0000 |
commit | 10646390347e49359afc75405462b0f032044591 (patch) | |
tree | 4c62b3f2382f4a976253e129ca71156d3c3fd119 /modules/video_render/android | |
parent | de1c434791e676f0bd4762b3dc16ae260c14b4b5 (diff) | |
download | webrtc-10646390347e49359afc75405462b0f032044591.tar.gz |
WebRTCDemo: handle stride!=width from first frame.
Previously only mid-stream frames handled stride!=width correctly.
BUG=1615
Review URL: https://webrtc-codereview.appspot.com/1304009
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3821 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'modules/video_render/android')
-rw-r--r-- | modules/video_render/android/video_render_opengles20.cc | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/modules/video_render/android/video_render_opengles20.cc b/modules/video_render/android/video_render_opengles20.cc index 22550056..8e59a250 100644 --- a/modules/video_render/android/video_render_opengles20.cc +++ b/modules/video_render/android/video_render_opengles20.cc @@ -230,9 +230,7 @@ int32_t VideoRenderOpenGles20::Render(const I420VideoFrame& frameToRender) { _textureHeight != (GLsizei) frameToRender.height()) { SetupTextures(frameToRender); } - else { - UpdateTextures(frameToRender); - } + UpdateTextures(frameToRender); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, g_indices); checkGlError("glDrawArrays"); @@ -326,6 +324,17 @@ void VideoRenderOpenGles20::checkGlError(const char* op) { #endif } +static void InitializeTexture(int name, int id, int width, int height) { + glActiveTexture(name); + glBindTexture(GL_TEXTURE_2D, id); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, + GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); +} + void VideoRenderOpenGles20::SetupTextures(const I420VideoFrame& frameToRender) { WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "%s: width %d, height %d", __FUNCTION__, @@ -335,46 +344,10 @@ void VideoRenderOpenGles20::SetupTextures(const I420VideoFrame& frameToRender) { const GLsizei height = frameToRender.height(); glGenTextures(3, _textureIds); //Generate the Y, U and V texture - GLuint currentTextureId = _textureIds[0]; // Y - glActiveTexture( GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, currentTextureId); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - (const GLvoid*) frameToRender.buffer(kYPlane)); - - currentTextureId = _textureIds[1]; // U - glActiveTexture( GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, currentTextureId); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - const uint8_t* uComponent = frameToRender.buffer(kUPlane); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width / 2, height / 2, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, (const GLvoid*) uComponent); - - currentTextureId = _textureIds[2]; // V - glActiveTexture( GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, currentTextureId); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + InitializeTexture(GL_TEXTURE0, _textureIds[0], width, height); + InitializeTexture(GL_TEXTURE1, _textureIds[1], width / 2, height / 2); + InitializeTexture(GL_TEXTURE2, _textureIds[2], width / 2, height / 2); - const uint8_t* vComponent = frameToRender.buffer(kVPlane); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width / 2, height / 2, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, (const GLvoid*) vComponent); checkGlError("SetupTextures"); _textureWidth = width; |