Skip to content

Commit

Permalink
fixed a bug that resulted in a crash when writing hap frames created …
Browse files Browse the repository at this point in the history
…from unpadded source buffers
  • Loading branch information
mrRay committed Jan 20, 2015
1 parent 3bcda49 commit c5defc1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/DXT/HapCodecGL.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct HapCodecGL {
GLuint width;
GLuint height;
GLenum format;
GLuint imgWidth;
GLuint imgHeight;
};

static bool openGLSupportsExtension(CGLContextObj cgl_ctx, const char *extension)
Expand Down Expand Up @@ -157,6 +159,8 @@ static HapCodecGLRef HapCodecGLCreate(unsigned int mode, unsigned int width, uns
GLint maxTexSize = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);

coder->imgWidth = width;
coder->imgHeight = height;
coder->texWidth = roundUpToMultipleOf4(width);
coder->texHeight = roundUpToMultipleOf4(height);

Expand Down Expand Up @@ -278,7 +282,7 @@ int HapCodecGLEncode(HapCodecGLRef coder, unsigned int source_bytes_per_row, Hap

for (int y = 0; y < coder->height; y += coder->texHeight) {

GLuint remaining_height = coder->height - y;
GLuint remaining_height = coder->imgHeight - y;
GLuint tile_height = MIN(remaining_height, coder->texHeight);

for (int x = 0; x < coder->width; x += coder->texWidth) {
Expand Down

0 comments on commit c5defc1

Please sign in to comment.