Skip to content

Commit

Permalink
Fixed bug where calling forceProcessingAtSize: will change all subseq…
Browse files Browse the repository at this point in the history
…uent forceProcessingAtSize: calls to undesired sizes. Can now also access the AVCaptureConnection of a GPUImageVideoCamera
  • Loading branch information
rileytestut committed Sep 2, 2012
1 parent 09dcd46 commit 223ff9b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
18 changes: 18 additions & 0 deletions framework/Source/GPUImageFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,15 @@ - (void)forceProcessingAtSize:(CGSize)frameSize;
inputTextureSize = frameSize;
forcedMaximumSize = CGSizeZero;
}

[self destroyFilterFBO];

for (id<GPUImageInput> currentTarget in targets)
{
if ([currentTarget respondsToSelector:@selector(destroyFilterFBO)]) {
[currentTarget performSelector:@selector(destroyFilterFBO)];
}
}
}

- (void)forceProcessingAtSizeRespectingAspectRatio:(CGSize)frameSize;
Expand All @@ -847,6 +856,15 @@ - (void)forceProcessingAtSizeRespectingAspectRatio:(CGSize)frameSize;
overrideInputSize = YES;
forcedMaximumSize = frameSize;
}

[self destroyFilterFBO];

for (id<GPUImageInput> currentTarget in targets)
{
if ([currentTarget respondsToSelector:@selector(destroyFilterFBO)]) {
[currentTarget performSelector:@selector(destroyFilterFBO)];
}
}
}

- (CGSize)maximumOutputSize;
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/GPUImageOpenGLESContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef enum { kGPUImageNoRotation, kGPUImageRotateLeft, kGPUImageRotateRight, k

@end

@protocol GPUImageInput
@protocol GPUImageInput <NSObject>
- (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex;
- (void)setInputTexture:(GLuint)newInputTexture atIndex:(NSInteger)textureIndex;
- (NSInteger)nextAvailableTextureIndex;
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/GPUImageStillCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void GPUImageCreateResizedSampleBuffer(CVPixelBufferRef cameraFrame, CGSize fina
@interface GPUImageStillCamera : GPUImageVideoCamera

// Photography controls
//- (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBufferRef imageSampleBuffer, NSError *error))block;
- (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBufferRef imageSampleBuffer, NSError *error))block;
- (void)capturePhotoAsImageProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(UIImage *processedImage, NSError *error))block;
- (void)capturePhotoAsJPEGProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(NSData *processedJPEG, NSError *error))block;
- (void)capturePhotoAsPNGProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(NSData *processedPNG, NSError *error))block;
Expand Down
11 changes: 7 additions & 4 deletions framework/Source/GPUImageStillCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ - (void)removeInputsAndOutputs;
#pragma mark -
#pragma mark Photography controls

/*- (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBufferRef imageSampleBuffer, NSError *error))block
- (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBufferRef imageSampleBuffer, NSError *error))block
{
NSLog(@"If you want to use the method capturePhotoAsSampleBufferWithCompletionHandler:, you must comment out the line in GPUImageStillCamera.m in the method initWithSessionPreset:cameraPosition: which sets the CVPixelBufferPixelFormatTypeKey, as well as uncomment the rest of the method capturePhotoAsSampleBufferWithCompletionHandler:. However, if you do this you cannot use any of the photo capture methods to take a photo if you also supply a filter.");

/*dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);
[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
#error If you want to use this method, you must comment out the line in initWithSessionPreset:cameraPosition: which sets the CVPixelBufferPixelFormatTypeKey. However, if you do this you cannot use any of the below methods to take a photo if you also supply a filter.
block(imageSampleBuffer, error);
}];
}];*/

return;
}*/
}

- (void)capturePhotoAsImageProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(UIImage *processedImage, NSError *error))block;
{
Expand Down
4 changes: 4 additions & 0 deletions framework/Source/GPUImageVideoCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
*/
- (AVCaptureDevicePosition)cameraPosition;

/** Get the AVCaptureConnection of the source camera
*/
- (AVCaptureConnection *)videoCaptureConnection;

/** This flips between the front and rear cameras
*/
- (void)rotateCamera;
Expand Down
12 changes: 12 additions & 0 deletions framework/Source/GPUImageVideoCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,18 @@ - (NSInteger)frameRate;
return _frameRate;
}

- (AVCaptureConnection *)videoCaptureConnection {
for (AVCaptureConnection *connection in [videoOutput connections] ) {
for ( AVCaptureInputPort *port in [connection inputPorts] ) {
if ( [[port mediaType] isEqual:AVMediaTypeVideo] ) {
return connection;
}
}
}

return nil;
}

#define INITIALFRAMESTOIGNOREFORBENCHMARK 5

- (void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;
Expand Down

0 comments on commit 223ff9b

Please sign in to comment.