Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed pixellation and other filters by making sure they get uniforms …

…and aspect ratios set properly before running the first filter operation.
  • Loading branch information...
commit 99ef54a351f2f51693cb57a95a315403bc287178 1 parent f51b807
@BradLarson authored
View
18 framework/Source/GPUImageFilter.m
@@ -603,7 +603,7 @@ - (void)setFloatArray:(GLfloat *)array length:(GLsizei)count forUniform:(NSStrin
- (void)setMatrix3f:(GPUMatrix3x3)matrix forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniformMatrix3fv(uniform, 1, GL_FALSE, (GLfloat *)&matrix);
});
@@ -611,7 +611,7 @@ - (void)setMatrix3f:(GPUMatrix3x3)matrix forUniform:(GLint)uniform program:(GLPr
- (void)setMatrix4f:(GPUMatrix4x4)matrix forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniformMatrix4fv(uniform, 1, GL_FALSE, (GLfloat *)&matrix);
});
@@ -619,7 +619,7 @@ - (void)setMatrix4f:(GPUMatrix4x4)matrix forUniform:(GLint)uniform program:(GLPr
- (void)setFloat:(GLfloat)floatValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniform1f(uniform, floatValue);
});
@@ -627,7 +627,7 @@ - (void)setFloat:(GLfloat)floatValue forUniform:(GLint)uniform program:(GLProgra
- (void)setPoint:(CGPoint)pointValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
GLfloat positionArray[2];
@@ -640,7 +640,7 @@ - (void)setPoint:(CGPoint)pointValue forUniform:(GLint)uniform program:(GLProgra
- (void)setSize:(CGSize)sizeValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
GLfloat sizeArray[2];
@@ -653,7 +653,7 @@ - (void)setSize:(CGSize)sizeValue forUniform:(GLint)uniform program:(GLProgram *
- (void)setVec3:(GPUVector3)vectorValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniform3fv(uniform, 1, (GLfloat *)&vectorValue);
@@ -662,7 +662,7 @@ - (void)setVec3:(GPUVector3)vectorValue forUniform:(GLint)uniform program:(GLPro
- (void)setVec4:(GPUVector4)vectorValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniform4fv(uniform, 1, (GLfloat *)&vectorValue);
@@ -671,7 +671,7 @@ - (void)setVec4:(GPUVector4)vectorValue forUniform:(GLint)uniform program:(GLPro
- (void)setFloatArray:(GLfloat *)arrayValue length:(GLsizei)arrayLength forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniform1fv(uniform, arrayLength, arrayValue);
@@ -680,7 +680,7 @@ - (void)setFloatArray:(GLfloat *)arrayValue length:(GLsizei)arrayLength forUnifo
- (void)setInteger:(GLint)intValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;
{
- dispatch_async([GPUImageOpenGLESContext sharedOpenGLESQueue], ^{
+ runAsynchronouslyOnVideoProcessingQueue(^{
[GPUImageOpenGLESContext setActiveShaderProgram:shaderProgram];
glUniform1i(uniform, intValue);
});
View
1  framework/Source/GPUImageOutput.h
@@ -4,6 +4,7 @@
void runOnMainQueueWithoutDeadlocking(void (^block)(void));
void runSynchronouslyOnVideoProcessingQueue(void (^block)(void));
+void runAsynchronouslyOnVideoProcessingQueue(void (^block)(void));
void reportAvailableMemoryForGPUImage(NSString *tag);
@class GPUImageMovieWriter;
View
14 framework/Source/GPUImageOutput.m
@@ -29,6 +29,20 @@ void runSynchronouslyOnVideoProcessingQueue(void (^block)(void))
}
}
+void runAsynchronouslyOnVideoProcessingQueue(void (^block)(void))
+{
+ dispatch_queue_t videoProcessingQueue = [GPUImageOpenGLESContext sharedOpenGLESQueue];
+
+ if (dispatch_get_current_queue() == videoProcessingQueue)
@mabene
mabene added a note

How do you plan to do this once dispatch_get_current_queue (currently deprecated) is removed?

@BradLarson Owner

Hadn't even noticed that dispatch_get_current_queue() was deprecated with iOS 6.0. Oddly, it's only deprecated starting with that, and is not marked as deprecated in Mountain Lion. Thanks for pointing that out. I'm examining alternatives, and my main thread synchronous dispatch function uses a different identity check, so it won't be affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ {
+ block();
+ }
+ else
+ {
+ dispatch_async(videoProcessingQueue, block);
+ }
+}
+
void reportAvailableMemoryForGPUImage(NSString *tag)
{
if (!tag)
View
10 framework/Source/GPUImagePixellateFilter.m
@@ -63,9 +63,15 @@ - (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
[super setInputSize:newSize atIndex:textureIndex];
if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
-
{
- [self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
+ if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
+ {
+ [self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
+ }
+ else
+ {
+ [self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
+ }
}
}
View
9 framework/Source/GPUImageSphereRefractionFilter.m
@@ -83,7 +83,14 @@ - (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
if (!CGSizeEqualToSize(oldInputSize, inputTextureSize) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
- [self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
+ if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
+ {
+ [self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
+ }
+ else
+ {
+ [self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
+ }
}
}
View
6 framework/Source/GPUImageStillCamera.m
@@ -96,7 +96,11 @@ - (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBuffer
[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
block(imageSampleBuffer, error);
- }];*/
+ }];
+
+ dispatch_semaphore_signal(frameRenderingSemaphore);
+
+ */
return;
}
@mabene

How do you plan to do this once dispatch_get_current_queue (currently deprecated) is removed?

@BradLarson

Hadn't even noticed that dispatch_get_current_queue() was deprecated with iOS 6.0. Oddly, it's only deprecated starting with that, and is not marked as deprecated in Mountain Lion. Thanks for pointing that out. I'm examining alternatives, and my main thread synchronous dispatch function uses a different identity check, so it won't be affected.

Please sign in to comment.
Something went wrong with that request. Please try again.