removed some more dead code

+ minor cleanings along the way
This commit is contained in:
xant
2010-08-09 22:20:02 +02:00
parent 5157c0acc8
commit 60ec86c556
16 changed files with 63 additions and 217 deletions
+12 -8
View File
@@ -34,18 +34,21 @@ FACTORY_REGISTER_INSTANTIATOR(FilterInstance, FilterInstance, FilterInstance, co
FilterInstance::FilterInstance()
: Entry()
{
core = NULL;
intcore = 0;
outframe = NULL;
active = false;
layer = NULL;
core = NULL;
intcore = 0;
outframe = NULL;
active = false;
layer = NULL;
}
FilterInstance::FilterInstance(Filter *fr)
: Entry()
{
FilterInstance();
func("creating instance for filter %s",fr->name);
core = NULL;
intcore = 0;
outframe = NULL;
active = false;
layer = NULL;
init(fr);
}
@@ -62,6 +65,7 @@ FilterInstance::~FilterInstance() {
void FilterInstance::init(Filter *fr)
{
func("initializing instance for filter %s",fr->name);
proto = fr;
set_name(proto->name);
active = true;
-1
View File
@@ -22,7 +22,6 @@
#import <CFreej.h>
#import <CVLayerController.h>
#import <CVTexture.h>
#include <geometry.h>
@class CVLayerView;
-2
View File
@@ -26,8 +26,6 @@ class CVF0rLayer : public CVLayer
{
protected:
bool _init();
void *currentFrame;
CVPixelBufferRef pixelBuffer;
public:
CVF0rLayer(CVLayerController *controller);
+17 -26
View File
@@ -76,48 +76,39 @@ CVF0rLayer::CVF0rLayer(CVLayerController *controller)
generator = NULL;
type = Layer::GL_COCOA;
set_name([input name]);
currentFrame = NULL;
pixelBuffer = NULL;
[input setLayer:this];
}
CVF0rLayer::~CVF0rLayer()
{
close();
if (pixelBuffer)
CVPixelBufferRelease(pixelBuffer);
if (currentFrame)
free(currentFrame);
}
void *
CVF0rLayer::feed()
{
void *res;
CVPixelBufferRef pixelBuffer;
if (generator)
res = generator->process(fps.get(), NULL);
if (res) {
// TODO - handle geometry changes
if (!currentFrame) {
currentFrame = malloc(geo.bytesize);
CVReturn err = CVPixelBufferCreateWithBytes (
NULL,
geo.w,
geo.h,
k32ARGBPixelFormat,
currentFrame,
geo.w*4,
NULL,
NULL,
NULL,
&pixelBuffer
);
}
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
memcpy(currentFrame, res, geo.bytesize);
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
[(CVF0rLayerController *)input feedFrame:pixelBuffer];
CVReturn err = CVPixelBufferCreateWithBytes (
NULL,
geo.w,
geo.h,
k32ARGBPixelFormat,
res,
geo.w*4,
NULL,
NULL,
NULL,
&pixelBuffer
);
if (err == noErr) {
[(CVF0rLayerController *)input feedFrame:pixelBuffer];
CVPixelBufferRelease(pixelBuffer);
}
}
return CVLayer::feed();
}
+3 -3
View File
@@ -25,7 +25,6 @@
#import <CFreej.h>
#import <CVLayerController.h>
#import <CVTexture.h>
#import <CVCocoaLayer.h>
@@ -52,9 +51,10 @@ public:
virtual void *do_filters(void *buf);
protected:
virtual void *feed();
CVPixelBufferRef pixelBuffer;
private:
void *frame[2]; // double buffer
void *frame;
unsigned int num;
};
+27 -31
View File
@@ -23,17 +23,15 @@ CVLayer::CVLayer() : CVCocoaLayer(this), Layer()
{
type = Layer::GL_COCOA;
buffer = NULL;
memset(frame, 0, sizeof(void *) * 2);
num = 0;
frame = NULL;
}
CVLayer::CVLayer(CVLayerController *vin) : Layer(), CVCocoaLayer(this, vin)
{
type = Layer::GL_COCOA;
buffer = NULL;
memset(frame, 0, sizeof(void *) * 2);
num = 0;
set_name([input name]);
frame = NULL;
set_name([input name]);
[input setLayer:this];
}
@@ -41,11 +39,8 @@ CVLayer::~CVLayer()
{
stop();
close();
// release the double buffer if present
for (int i = 0; i < 2; i++) {
if (frame[i])
free(frame[i]);
}
if (frame)
free(frame);
}
bool
@@ -115,27 +110,16 @@ CVLayer::feed()
void *output = NULL;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CVPixelBufferRef pixelBuffer = [input currentFrame];
if (pixelBuffer) {
num++;
int idx = num % 2;
//lock();
// ensure providing the pixelbuffer to upper cocoa-related layers
CVPixelBufferRef newPixelBuffer = [input currentFrame];
if (newPixelBuffer) {
if (pixelBuffer)
CVPixelBufferRelease(pixelBuffer);
pixelBuffer = newPixelBuffer;
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
output = CVPixelBufferGetBaseAddress(pixelBuffer);
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
}
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
//void *frame = CVPixelBufferGetBaseAddress(pixelBuffer);
if (!frame[idx])
frame[idx] = malloc(CVPixelBufferGetDataSize(pixelBuffer));
// TODO - try to avoid this copy!!
//lock();
memcpy(frame[idx], CVPixelBufferGetBaseAddress(pixelBuffer), CVPixelBufferGetDataSize(pixelBuffer));
//unlock();
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
output = frame[idx];
CVPixelBufferRelease(pixelBuffer);
//unlock();
}
[pool release];
return output;
}
@@ -144,6 +128,8 @@ void *CVLayer::do_filters(void *buf) {
bool no_opt = false;
if( filters.len() ) {
// If we have filters to apply , we don't need to copy the frame
// since we will get a different buffer out of the filter chain
FilterInstance *filt;
filters.lock();
filt = (FilterInstance *)filters.begin();
@@ -154,7 +140,17 @@ void *CVLayer::do_filters(void *buf) {
filt = (FilterInstance *)filt->next;
}
filters.unlock();
}
} else {
// We are now at the end of video pipeline for a layer
// if there is no filter to apply we are still referencing
// the storage from the underlying CVLayerController.
// Note that the controller could reuse the buffer to render
// next frame and we need to make a copy here.
if (!frame)
frame = malloc(geo.bytesize);
memcpy(frame, buf, geo.bytesize);
buf = frame;
}
if ([input respondsToSelector:@selector(frameFiltered:)])
[input frameFiltered:(void *)buf];
-2
View File
@@ -36,9 +36,7 @@ class CVCocoaLayer;
NSRecursiveLock *lock;
CVPixelBufferRef currentFrame; // the current frame from the movie
CVTexture *cvTexture;
CIImage *posterImage;
CVTexture *currentPreviewTexture;
CGLContextObj glContext;
// filters for CI rendering
CIFilter *colorCorrectionFilter; // hue saturation brightness control through one CI filter
-2
View File
@@ -72,9 +72,7 @@ static OSStatus SetNumberValue(CFMutableDictionaryRef inDict,
layer = NULL;
doFilters = true;
currentFrame = NULL;
cvTexture = NULL;
posterImage = NULL;
currentPreviewTexture = NULL;
doPreview = YES;
imageParams = [[NSMutableDictionary dictionary] retain];
-1
View File
@@ -21,7 +21,6 @@
#define __CVLAYERVIEW_H__
#import <CVLayerController.h>
#import <CVtexture.h>
#import <CFreeJ.h>
#include <QuartzCore/QuartzCore.h>
-2
View File
@@ -18,7 +18,6 @@
*/
#import <CVCocoaLayer.h>
#import <CVTexture.h>
@class CFreej;
@@ -26,7 +25,6 @@
CIContext *ciContext;
bool needsReshape;
NSRecursiveLock *lock;
CVTexture *texture;
IBOutlet CFreej *freej;
}
-1
View File
@@ -29,7 +29,6 @@
// Initialization code here.
lock = [[NSRecursiveLock alloc] init];
needsReshape = YES;
texture = nil;
[lock retain];
return self;
}
-1
View File
@@ -23,7 +23,6 @@
#import <CVScreen.h>
#import <CVTexture.h>
#import <Carbon/Carbon.h>
class CVScreen;
+4 -16
View File
@@ -84,7 +84,6 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
lastFrame = NULL;
exportedFrame = NULL;
streamerStatus = NO;
lastTextures = [[NSMutableArray array] retain];
lock = [[NSRecursiveLock alloc] init];
[lock retain];
[self setNeedsDisplay:NO];
@@ -433,14 +432,7 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
[lastFrame autorelease];
lastFrame = outFrame;
outFrame = NULL;
// release all textures
while ([lastTextures count]) {
CVTexture *texture = [lastTextures objectAtIndex:0];
[lastTextures removeObjectAtIndex:0];
// removing the texture from the array makes its refcnt reach 0
// so it will be automagically released
//[texture release];
}
} else {
needsReshape = YES;
}
@@ -464,7 +456,6 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CIFilter *blendFilter = nil;
CVTexture *texture = nil;
CVPixelBufferRef pixelBufferOut = NULL;
//_BGRA2ARGB(layer->buffer, layer->geo.w*layer->geo.h); // XXX - expensive conversion
@@ -495,7 +486,6 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
if (!pixelBufferOut) // return if we don't have anything to draw
return;
CIImage *inputImage = [CIImage imageWithCVImageBuffer:pixelBufferOut];
texture = [CVTexture textureWithCIImage:inputImage pixelBuffer:pixelBufferOut];
// we can release our reference to the pixelBuffer now.
// The CVTexture will retain it as long as it is needed
CVPixelBufferRelease(pixelBufferOut);
@@ -516,18 +506,16 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
}
[blendFilter setDefaults];
[lock lock];
if (texture) {
if (inputImage) {
if (!outFrame) {
outFrame = [[texture image] retain];
outFrame = [inputImage retain];
} else {
[blendFilter setValue:outFrame forKey:@"inputImage"];
[blendFilter setValue:[texture image] forKey:@"inputBackgroundImage"];
[blendFilter setValue:inputImage forKey:@"inputBackgroundImage"];
CIImage *temp = [blendFilter valueForKey:@"outputImage"];
[outFrame release];
outFrame = [temp retain];
}
[lastTextures addObject:texture]; // Note: we use this to keep the texture refcnt'd until necessary
// once removed from the array it will be free'd
}
[lock unlock];
[pool release];
-34
View File
@@ -1,34 +0,0 @@
/* FreeJ
* (c) Copyright 2009 Andrea Guzzo <xant@dyne.org>
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Public License as published
* by the Free Software Foundation; either version 3 of the License,
* or (at your option) any later version.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please refer to the GNU Public License for more details.
*
* You should have received a copy of the GNU Public License along with
* this source code; if not, write to:
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#import <QuartzCore/QuartzCore.h>
#import <Appkit/NSImage.h>
#import <Cocoa/Cocoa.h>
@interface CVTexture : NSObject {
CVPixelBufferRef _pixelBuffer;
CIImage *_image;
}
+ (id)alloc;
+ (id)textureWithCIImage:(CIImage *)image pixelBuffer:(CVPixelBufferRef)pixelBuffer;
- (id)initWithCIImage:(CIImage *)image pixelBuffer:(CVPixelBufferRef)pixelBuffer;
- (CIImage *)image;
- (CVPixelBufferRef)pixelBuffer;
- (void)dealloc;
@end
-81
View File
@@ -1,81 +0,0 @@
/* FreeJ
* (c) Copyright 2009 Andrea Guzzo <xant@dyne.org>
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Public License as published
* by the Free Software Foundation; either version 3 of the License,
* or (at your option) any later version.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please refer to the GNU Public License for more details.
*
* You should have received a copy of the GNU Public License along with
* this source code; if not, write to:
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#import <CVTexture.h>
@implementation CVTexture
+ (id)alloc
{
return [super alloc];
}
+ (id)textureWithCIImage:(CIImage *)image pixelBuffer:(CVPixelBufferRef)pixelBuffer
{
id obj = [self alloc];
[obj autorelease];
return [obj initWithCIImage:image pixelBuffer:pixelBuffer];
}
- (id)initWithCIImage:(CIImage *)image pixelBuffer:(CVPixelBufferRef)pixelBuffer
{
_pixelBuffer = CVPixelBufferRetain(pixelBuffer);
_image = [image retain];
return self;
}
- (void) dealloc
{
if (_pixelBuffer) {
//NSLog(@"%d", [_image retainCount]);
[_image release];
CVPixelBufferRelease(_pixelBuffer);
}
[super dealloc];
}
- (CIImage *)image
{
return _image;
}
- (CVPixelBufferRef)pixelBuffer
{
return _pixelBuffer;
}
#if 0
- (void)applyFilter:(FilterInstance *)filter
{
CVPixelBufferLockBaseAddress(_pixelBuffer, 0);
void *inframe = CVPixelBufferGetBaseAddress(_pixelBuffer);
filter->process(filter->layer.fps.fps, (uint32_t *)inframe);
//filter->update(FilterInstance *inst, <#double time#>, <#uint32_t *inframe#>, <#uint32_t *outframe#>);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[filter setValue:_image forKey:@"inputImage"];
CIImage *outputImage = [filter valueForKey:@"outputImage"];
[_image release];
_image = [outputImage retain];
[pool release];
}
#endif
@end
-6
View File
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
AA00100D0F77FD9200719D5B /* callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA00100C0F77FD9200719D5B /* callback.cpp */; };
AA0E39820FBECC1E00123D3F /* CVPreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA0E39810FBECC1E00123D3F /* CVPreview.mm */; };
AA0E3E760FBF3C0100123D3F /* CVTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = AA0E3E750FBF3C0100123D3F /* CVTexture.m */; };
AA1009DC120D49C0004389B5 /* cam_layer_js.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA1009DB120D49C0004389B5 /* cam_layer_js.cpp */; };
AA134AC01047B6D500BA39EB /* CKbdController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA134ABF1047B6D500BA39EB /* CKbdController.mm */; };
AA183B651186C3BC00E82D70 /* CVGeoLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA183B641186C3BC00E82D70 /* CVGeoLayer.mm */; };
@@ -189,8 +188,6 @@
AA00100E0F77FDA000719D5B /* callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = callback.h; path = include/callback.h; sourceTree = "<group>"; };
AA0E39800FBECC1E00123D3F /* CVPreview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CVPreview.h; sourceTree = "<group>"; };
AA0E39810FBECC1E00123D3F /* CVPreview.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CVPreview.mm; sourceTree = "<group>"; };
AA0E3E740FBF3C0100123D3F /* CVTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CVTexture.h; sourceTree = "<group>"; };
AA0E3E750FBF3C0100123D3F /* CVTexture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CVTexture.m; sourceTree = "<group>"; };
AA1009DB120D49C0004389B5 /* cam_layer_js.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cam_layer_js.cpp; sourceTree = "<group>"; };
AA134ABE1047B6D500BA39EB /* CKbdController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKbdController.h; sourceTree = "<group>"; };
AA134ABF1047B6D500BA39EB /* CKbdController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CKbdController.mm; sourceTree = "<group>"; };
@@ -563,8 +560,6 @@
AACBE4820F641605001B610F /* FrameRate.m */,
AA0E39800FBECC1E00123D3F /* CVPreview.h */,
AA0E39810FBECC1E00123D3F /* CVPreview.mm */,
AA0E3E740FBF3C0100123D3F /* CVTexture.h */,
AA0E3E750FBF3C0100123D3F /* CVTexture.m */,
AA5846540FE162C60059D860 /* CVTextLayerController.h */,
AA5846550FE162C60059D860 /* CVTextLayerController.mm */,
AAB47C9E10EB44AF00B0E8D2 /* CVTextLayerView.h */,
@@ -1105,7 +1100,6 @@
AA8858810F631E3C00778C03 /* CVGenerator.m in Sources */,
AACBE4830F641605001B610F /* FrameRate.m in Sources */,
AA0E39820FBECC1E00123D3F /* CVPreview.mm in Sources */,
AA0E3E760FBF3C0100123D3F /* CVTexture.m in Sources */,
AA5846530FE1626E0059D860 /* GLString.m in Sources */,
AA63CF8E102DAED400FDA024 /* QTExporter.mm in Sources */,
AA134AC01047B6D500BA39EB /* CKbdController.mm in Sources */,