From a0b9684504929323783e62b05ffa6a058794b8b4 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 21 Mar 2021 21:43:57 -0500 Subject: [PATCH] Continue refactoring for non-NV12 support in EGLRenderer --- .../video/ffmpeg-renderers/eglvid.cpp | 20 +++++++++---------- app/streaming/video/ffmpeg-renderers/eglvid.h | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/eglvid.cpp b/app/streaming/video/ffmpeg-renderers/eglvid.cpp index bb6efc1b..1e25ff85 100644 --- a/app/streaming/video/ffmpeg-renderers/eglvid.cpp +++ b/app/streaming/video/ffmpeg-renderers/eglvid.cpp @@ -250,7 +250,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type) glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[type]); - glUniform1i(m_OverlayShaderProgramParams[PARAM_TEXTURE], 0); + glUniform1i(m_OverlayShaderProgramParams[OVERLAY_PARAM_TEXTURE], 0); glDrawArrays(GL_TRIANGLES, 0, 6); } @@ -379,10 +379,10 @@ bool EGLRenderer::compileShaders() { return false; } - m_ShaderProgramParams[PARAM_YUVMAT] = glGetUniformLocation(m_ShaderProgram, "yuvmat"); - m_ShaderProgramParams[PARAM_OFFSET] = glGetUniformLocation(m_ShaderProgram, "offset"); - m_ShaderProgramParams[PARAM_PLANE1] = glGetUniformLocation(m_ShaderProgram, "plane1"); - m_ShaderProgramParams[PARAM_PLANE2] = glGetUniformLocation(m_ShaderProgram, "plane2"); + m_ShaderProgramParams[NV12_PARAM_YUVMAT] = glGetUniformLocation(m_ShaderProgram, "yuvmat"); + m_ShaderProgramParams[NV12_PARAM_OFFSET] = glGetUniformLocation(m_ShaderProgram, "offset"); + m_ShaderProgramParams[NV12_PARAM_PLANE1] = glGetUniformLocation(m_ShaderProgram, "plane1"); + m_ShaderProgramParams[NV12_PARAM_PLANE2] = glGetUniformLocation(m_ShaderProgram, "plane2"); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, @@ -397,7 +397,7 @@ bool EGLRenderer::compileShaders() { return false; } - m_OverlayShaderProgramParams[PARAM_TEXTURE] = glGetUniformLocation(m_OverlayShaderProgram, "uTexture"); + m_OverlayShaderProgramParams[OVERLAY_PARAM_TEXTURE] = glGetUniformLocation(m_OverlayShaderProgram, "uTexture"); return true; } @@ -787,10 +787,10 @@ void EGLRenderer::renderFrame(AVFrame* frame) // Bind parameters for the NV12 shaders if (m_EGLImagePixelFormat == AV_PIX_FMT_NV12) { - glUniformMatrix3fv(m_ShaderProgramParams[PARAM_YUVMAT], 1, GL_FALSE, getColorMatrix()); - glUniform3fv(m_ShaderProgramParams[PARAM_OFFSET], 1, getColorOffsets()); - glUniform1i(m_ShaderProgramParams[PARAM_PLANE1], 0); - glUniform1i(m_ShaderProgramParams[PARAM_PLANE2], 1); + glUniformMatrix3fv(m_ShaderProgramParams[NV12_PARAM_YUVMAT], 1, GL_FALSE, getColorMatrix()); + glUniform3fv(m_ShaderProgramParams[NV12_PARAM_OFFSET], 1, getColorOffsets()); + glUniform1i(m_ShaderProgramParams[NV12_PARAM_PLANE1], 0); + glUniform1i(m_ShaderProgramParams[NV12_PARAM_PLANE2], 1); } glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); diff --git a/app/streaming/video/ffmpeg-renderers/eglvid.h b/app/streaming/video/ffmpeg-renderers/eglvid.h index 1cce8350..aff5adb1 100644 --- a/app/streaming/video/ffmpeg-renderers/eglvid.h +++ b/app/streaming/video/ffmpeg-renderers/eglvid.h @@ -51,13 +51,13 @@ private: PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES; PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES; -#define PARAM_YUVMAT 0 -#define PARAM_OFFSET 1 -#define PARAM_PLANE1 2 -#define PARAM_PLANE2 3 +#define NV12_PARAM_YUVMAT 0 +#define NV12_PARAM_OFFSET 1 +#define NV12_PARAM_PLANE1 2 +#define NV12_PARAM_PLANE2 3 int m_ShaderProgramParams[4]; -#define PARAM_TEXTURE 0 +#define OVERLAY_PARAM_TEXTURE 0 int m_OverlayShaderProgramParams[1]; int m_OldContextProfileMask;