Skip to content

Commit

Permalink
Merge pull request BradLarson#2145 from DavidSannier/patch-1
Browse files Browse the repository at this point in the history
Fixed computation mistake in GPUImageAverageColor
  • Loading branch information
BradLarson committed Dec 3, 2015
2 parents c5f0914 + 1d0cd4f commit 57047fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
10 changes: 2 additions & 8 deletions framework/Source/GPUImageAverageColor.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ - (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates
for (NSUInteger currentReduction = 0; currentReduction < reductionsToHitSideLimit; currentReduction++)
{
CGSize currentStageSize = CGSizeMake(floor(inputTextureSize.width / pow(4.0, currentReduction + 1.0)), floor(inputTextureSize.height / pow(4.0, currentReduction + 1.0)));
if ( (currentStageSize.height < 2.0) || (currentStageSize.width < 2.0) )
{
// A really small last stage seems to cause significant errors in the average, so I abort and leave the rest to the CPU at this point
break;
// currentStageSize.height = 2.0; // TODO: Rotate the image to account for this case, which causes FBO construction to fail
}

[outputFramebuffer unlock];
outputFramebuffer = [[GPUImageContext sharedFramebufferCache] fetchFramebufferForSize:currentStageSize textureOptions:self.outputTextureOptions onlyTexture:NO];
Expand All @@ -150,8 +144,8 @@ - (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates

glUniform1i(filterInputTextureUniform, 2);

glUniform1f(texelWidthUniform, 0.5 / currentStageSize.width);
glUniform1f(texelHeightUniform, 0.5 / currentStageSize.height);
glUniform1f(texelWidthUniform, 0.25 / currentStageSize.width);
glUniform1f(texelHeightUniform, 0.25 / currentStageSize.height);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

Expand Down
8 changes: 4 additions & 4 deletions framework/Source/iOS/GPUImageMovieWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ - (void)initializeMovieWithOutputSettings:(NSDictionary *)outputSettings;
// custom output settings specified
else
{
NSString *videoCodec = [outputSettings objectForKey:AVVideoCodecKey];
NSNumber *width = [outputSettings objectForKey:AVVideoWidthKey];
NSNumber *height = [outputSettings objectForKey:AVVideoHeightKey];
__unused NSString *videoCodec = [outputSettings objectForKey:AVVideoCodecKey];
__unused NSNumber *width = [outputSettings objectForKey:AVVideoWidthKey];
__unused NSNumber *height = [outputSettings objectForKey:AVVideoHeightKey];

NSAssert(videoCodec && width && height, @"OutputSettings is missing required parameters.");

Expand Down Expand Up @@ -579,7 +579,7 @@ - (void)createDataFBO;
}


GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
__unused GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

NSAssert(status == GL_FRAMEBUFFER_COMPLETE, @"Incomplete filter FBO: %d", status);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/iOS/GPUImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ - (void)createDisplayFramebuffer;

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, displayRenderbuffer);

GLuint framebufferCreationStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
__unused GLuint framebufferCreationStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
NSAssert(framebufferCreationStatus == GL_FRAMEBUFFER_COMPLETE, @"Failure with display framebuffer generation for display of size: %f, %f", self.bounds.size.width, self.bounds.size.height);
boundsSizeAtFrameBufferEpoch = self.bounds.size;
}
Expand Down

0 comments on commit 57047fd

Please sign in to comment.