Permalink
Browse files

tirsdag

  • Loading branch information...
HalfdanJ committed Oct 23, 2012
1 parent 2b050e6 commit eb15a365642d4f6689559f74e395de11b76503af
@@ -161,17 +161,17 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[inputs addObject:@{@"name":@"3 Main C"}];
[inputs addObject:@{@"name":@"4 Dolly"}];
[inputs addObject:@{@"name":@"5"}];
- [inputs addObject:@{@"name":@"6"}];
+ [inputs addObject:@{@"name":@"6 Cam 5 Model"}];
[inputs addObject:@{@"name":@"7 Lærred"}];
[inputs addObject:@{@"name":@"8 Ude"}];
[inputs addObject:@{@"name":@"9 Greenscreen"}];
[inputs addObject:@{@"name":@"10"}];
[inputs addObject:@{@"name":@"11 ---- "}];
[inputs addObject:@{@"name":@"12 PTZ"}];
[inputs addObject:@{@"name":@"13 Cam 5 kort "}];
- [inputs addObject:@{@"name":@"14"}];
+ [inputs addObject:@{@"name":@"14 Mercedes front"}];
[inputs addObject:@{@"name":@"15 Model (quad)"}];
- [inputs addObject:@{@"name":@"16"}];
+ [inputs addObject:@{@"name":@"16 Mercedes overshoulder"}];
self.cameraInputs = inputs;
self.decklink1input = -1;
@@ -220,11 +220,11 @@ -(void)setOutSelector:(int)outSelector{
-(void)updateChromaTransform{
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
-/* NSAffineTransform * transform = [NSAffineTransform transform];
+ /*NSAffineTransform * transform = [NSAffineTransform transform];
[transform translateXBy:[defaults floatForKey:@"chromaX"] yBy:[defaults floatForKey:@"chromaY"]];
[transform scaleXBy:[defaults floatForKey:@"chromaScale"] yBy:[defaults floatForKey:@"chromaScale"]];
[self.chromaTransform setValue:transform forKey:@"inputTransform"];
- */
+ */
CIVector * vec = [CIVector vectorWithX:[defaults floatForKey:@"chromaX"] Y:[defaults floatForKey:@"chromaY"] Z:720*[defaults floatForKey:@"chromaScale"] W:576*[defaults floatForKey:@"chromaScale"]];
[self.chromaCrop setValue:vec forKey:@"inputRectangle"];
@@ -327,7 +327,7 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS
//NSLog(@"%@",selection);
AVPlayerItem * item = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"file://%@",[selection valueForKey:@"path"]]]];
- NSNumber * inTime = [selection valueForKey:@"inTime"];
+ // NSNumber * inTime = [selection valueForKey:@"inTime"];
/* if(inTime){
[item seekToTime:CMTimeMake([inTime floatValue], 25)];
}
@@ -515,7 +515,8 @@ -(void)setPlayVideo:(bool)playVideo{
[self.constantColorFilter setValue:[CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] forKey:@"inputColor"];
[self.sourceOverFilter setValue:[self.constantColorFilter valueForKey:@"outputImage"] forKey:@"inputBackgroundImage"];
- avPlayerLayer.filters = @[self.deinterlaceFilter, self.colorControlsFilter, self.gammaAdjustFilter];//, self.perspectiveFilterMovie, self.sourceOverFilter];
+ [self.chromaFilter setInputBackgroundImage:[self imageForSelector:2]];
+ avPlayerLayer.filters = @[ self.deinterlaceFilter, self.colorControlsFilter, self.gammaAdjustFilter];//, self.perspectiveFilterMovie, self.sourceOverFilter];
} else {
[avPlayerLayer removeFromSuperlayer];
[self.mainOutput setWantsLayer:NO];
@@ -613,10 +614,11 @@ -(bool)recording{
static dispatch_once_t onceToken;
-(void) newFrame:(DecklinkCallback*)callback{
- dispatch_sync(dispatch_get_main_queue(), ^{
+ dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"%lld",[avPlayer currentTime].value);
-
+ //NSLog(@"New frame in %i",callback);
+
[callback->lock lock];
callback->delegateBusy = YES;
CVPixelBufferRef buffer = [self createCVImageBufferFromCallback:callback];
@@ -657,15 +659,20 @@ -(void) newFrame:(DecklinkCallback*)callback{
if(!self.recording){
+
+
+ if(num == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"chromaKey"] && self.decklink1input == 8){
+ image = [self chromaKey:image backgroundImage:cameras[1]];
+ }
if(num == 0 && [[NSUserDefaults standardUserDefaults] floatForKey:@"chromaScale"] != 1 && self.decklink1input == 8){
[self updateChromaTransform];
+ // [self.chromaTransform setValue:image forKey:@"inputImage"];
+ // image = [self.chromaTransform valueForKey:@"outputImage"];
+
[self.chromaCrop setValue:image forKey:@"inputImage"];
image = [self.chromaCrop valueForKey:@"outputImage"];
}
-
- if(num == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"chromaKey"] && self.decklink1input == 8){
- image = [self chromaKey:image backgroundImage:cameras[1]];
- }
+
image = [self filterCIImage:image];
@@ -757,6 +764,8 @@ -(void) newFrame:(DecklinkCallback*)callback{
callback->delegateBusy = NO;
[callback->lock unlock];
+// NSLog(@"New frame out %i",callback);
+
});
}
/*
@@ -803,7 +812,7 @@ -(CIImage*) imageForSelector:(int)selector{
if(selector == 3)
inputSelector = self.decklink3input;
- if(inputSelector == 5){ //6 Jonas
+ if(inputSelector == 15){ //6 Jonas
[self.widescreenFilter setValue:img forKey:@"inputImage"];
img = [self.widescreenFilter valueForKey:@"outputImage"];
}
@@ -953,7 +962,7 @@ -(CIImage*) chromaKey:(CIImage*)image backgroundImage:(CIImage*)background{
[self.chromaFilter setMinHueAngle:chromaMinSet maxHueAngle:chromaMaxSet minValue:chromaVal minSaturation:chromaSat];
}
- self.chromaFilter.backgroundImage = background;
+ self.chromaFilter.inputBackgroundImage = background;
self.chromaFilter.inputImage = image;
retImage = [self.chromaFilter outputImage];
@@ -1000,6 +1009,9 @@ -(CVPixelBufferRef) createCVImageBufferFromCallback:(DecklinkCallback*)callback{
int w = callback->w;
int h = callback->h;
unsigned char * bytes = callback->bytes;
+// unsigned char * bytes = (unsigned char * ) malloc(callback->w*callback->h*4 * sizeof(unsigned char)) ;
+ // memcpy(bytes, callback->bytes, callback->w*callback->h*4);
+
NSDictionary *d = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey, [NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey, nil];
CVPixelBufferRef buffer = NULL;
@@ -47,7 +47,7 @@ class DecklinkCallback : public IDeckLinkInputCallback{
void YuvToRgbChunk(unsigned char *yuv, unsigned char * rgb, unsigned int offset, unsigned int chunk_size);
unsigned char * YuvToRgb(IDeckLinkVideoInputFrame* pArrivedFrame);
- NSRecursiveLock * lock;
+ NSLock * lock;
id delegate;
bool delegateBusy;
@@ -152,7 +152,7 @@
int num_workers = 8;
int a;
- unsigned t0=clock(),t1;
+ //unsigned t0=clock(),t1;
// split up the image into memory-aligned chunks so they take advantage of
// the CPU cache
@@ -169,7 +169,7 @@
}
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
- t1=clock()-t0;
+ // t1=clock()-t0;
//printf("%i\n",t1);
return rgb;
@@ -192,7 +192,7 @@ void bwFrames(unsigned char * bytes, int size){
bytes = 0;
CreateLookupTables();
- lock = [[NSRecursiveLock alloc] init];
+ lock = [[NSLock alloc] init];
};
@@ -247,14 +247,15 @@ void bwFrames(unsigned char * bytes, int size){
{
@autoreleasepool {
if(!delegateBusy){
+ // NSLog(@"Frame in %i",this);
[lock lock];
// BMDPixelFormat pixelFormat = videoFrame->GetPixelFormat();
BMDTimeValue frameTime, frameDuration;
int hours, minutes, seconds, frames;
HRESULT theResult;
videoFrame->GetStreamTime(&frameTime, &frameDuration, 600);
- theResult = decklinkOutput->ScheduleVideoFrame(videoFrame, frameTime, frameDuration, 600);
+ decklinkOutput->ScheduleVideoFrame(videoFrame, frameTime, frameDuration, 600);
//if (theResult != S_OK)
// printf("Scheduling failed with error = %08x\n", (unsigned int)theResult);
@@ -281,12 +282,12 @@ void bwFrames(unsigned char * bytes, int size){
newFrame = true;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
- dispatch_async(queue, ^{
+ dispatch_sync(queue, ^{
[delegate newFrame:this];
});
[lock unlock];
-
+ // NSLog(@"Frame out %i",this);
} else {
// NSLog(@"busy delegate");
}
Oops, something went wrong.

0 comments on commit eb15a36

Please sign in to comment.