Skip to content

Commit

Permalink
fix(yuvRender): uvWidth may not right in some iOS simulators.
Browse files Browse the repository at this point in the history
  • Loading branch information
I-m-SuperMan authored and pingkai committed Apr 3, 2020
1 parent 3ec4d21 commit e4f89ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions framework/render/video/glRender/YUVProgramContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,15 @@ void YUVProgramContext::fillDataToYUVTextures(uint8_t **data, int *pLineSize, in
uvHeight = mFrameHeight / 2;
}

int yWidth = pLineSize[0];
int uvWidth = yWidth / 2; //uvWidth may not right in some iOS simulators.

//use linesize to fill data with texture. some android phones which below 4.4 are not performed as excepted.
// crop the extra data when draw.
//update y
glBindTexture(GL_TEXTURE_2D, mYUVTextures[0]);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pLineSize[0] );
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pLineSize[0], mFrameHeight,
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, yWidth, mFrameHeight,
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data[0]);
GLint yLocation = glGetUniformLocation(mProgram, "y_tex");
glUniform1i(yLocation, 0);
Expand All @@ -486,7 +489,7 @@ void YUVProgramContext::fillDataToYUVTextures(uint8_t **data, int *pLineSize, in
//update u
glBindTexture(GL_TEXTURE_2D, mYUVTextures[1]);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pLineSize[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pLineSize[1], uvHeight ,
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, uvWidth, uvHeight ,
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data[1]);
GLint uLocation = glGetUniformLocation(mProgram, "u_tex");
glUniform1i(uLocation, 1);
Expand All @@ -495,7 +498,7 @@ void YUVProgramContext::fillDataToYUVTextures(uint8_t **data, int *pLineSize, in
//update v
glBindTexture(GL_TEXTURE_2D, mYUVTextures[2]);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pLineSize[2]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pLineSize[2], uvHeight ,
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, uvWidth, uvHeight ,
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data[2]);
GLint vLocation = glGetUniformLocation(mProgram, "v_tex");
glUniform1i(vLocation, 2);
Expand Down

0 comments on commit e4f89ca

Please sign in to comment.