mirror of
https://github.com/dyne/FreeJ.git
synced 2026-06-16 12:59:33 +02:00
linz hacks.
This commit is contained in:
@@ -258,9 +258,12 @@ static OSStatus SetNumberValue(CFMutableDictionaryRef inDict,
|
||||
return NO;
|
||||
uint64_t ts = CVGetCurrentHostTime();
|
||||
QTTime now = [qtMovie currentTime];
|
||||
|
||||
#ifdef __BIG_ENDIAN__ // 10.5 || PPC ?! Q&D
|
||||
now.timeValue+=(now.timeScale/layer->fps.fps);
|
||||
#else // NEW good implementation
|
||||
now.timeValue +=(((lastPTS?ts-lastPTS:0) * 600)/1000000000);
|
||||
now.timeScale = 600;
|
||||
#endif
|
||||
|
||||
QTTime duration = [qtMovie duration];
|
||||
if (QTTimeCompare(now, duration) == NSOrderedAscending)
|
||||
|
||||
@@ -52,12 +52,14 @@ class CVScreen;
|
||||
void *exportBuffer;
|
||||
QTExporter *exporter;
|
||||
QTStreamer *streamer;
|
||||
bool streamerStatus;
|
||||
bool initialized;
|
||||
IBOutlet CFreej *freej;
|
||||
IBOutlet NSTextField *showFps;
|
||||
IBOutlet NSTableView *layerList;
|
||||
IBOutlet NSWindow *window;
|
||||
IBOutlet NSTableView *streamerSettings;
|
||||
IBOutlet NSButton *streamerButton;
|
||||
NSMutableArray *streamerKeys;
|
||||
NSMutableDictionary *streamerDict;
|
||||
}
|
||||
|
||||
+49
-5
@@ -1,3 +1,4 @@
|
||||
#define MYCGL
|
||||
/* FreeJ
|
||||
* (c) Copyright 2009 Andrea Guzzo <xant@dyne.org>
|
||||
*
|
||||
@@ -80,6 +81,7 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
outFrame = NULL;
|
||||
lastFrame = NULL;
|
||||
exportedFrame = NULL;
|
||||
streamerStatus = NO;
|
||||
lock = [[NSRecursiveLock alloc] init];
|
||||
[lock retain];
|
||||
[self setNeedsDisplay:NO];
|
||||
@@ -102,6 +104,7 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
CVPixelBufferLockBaseAddress(pixelBuffer, NULL);
|
||||
exportBuffer = CVPixelBufferGetBaseAddress(pixelBuffer);
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
#ifdef MYCGL
|
||||
exportCGContextRef = CGBitmapContextCreate (NULL,
|
||||
ctx->screen->geo.w,
|
||||
ctx->screen->geo.h,
|
||||
@@ -109,20 +112,43 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
ctx->screen->geo.w*4,
|
||||
colorSpace,
|
||||
kCGImageAlphaPremultipliedLast);
|
||||
|
||||
#else
|
||||
CGLPixelFormatObj pFormat;
|
||||
GLint npix;
|
||||
const int attrs[2] = { kCGLPFADoubleBuffer, NULL};
|
||||
CGLError err = CGLChoosePixelFormat (
|
||||
(CGLPixelFormatAttribute *)attrs,
|
||||
&pFormat,
|
||||
&npix
|
||||
);
|
||||
CGLCreateContext (pFormat, NULL, exportCGContextRef);
|
||||
#endif
|
||||
if (exportCGContextRef == NULL)
|
||||
NSLog(@"Context not created!");
|
||||
|
||||
#ifdef MYCGL
|
||||
exportContext = [[CIContext contextWithCGContext:exportCGContextRef
|
||||
options:[NSDictionary dictionaryWithObject: (NSString*) kCGColorSpaceGenericRGB
|
||||
forKey: kCIContextOutputColorSpace]] retain];
|
||||
#else
|
||||
|
||||
//exportContext = [[CIContext contextWithCGLContext:(CGLContextObj)[currentContext CGLContextObj]
|
||||
exportContext = [[CIContext contextWithCGContext:exportCGContextRef
|
||||
// pixelFormat:(CGLPixelFormatObj)[[self pixelFormat] CGLPixelFormatObj]
|
||||
options:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
(id)colorSpace,kCIContextOutputColorSpace,
|
||||
(id)colorSpace,kCIContextWorkingColorSpace,nil]] retain];
|
||||
#endif
|
||||
CGColorSpaceRelease( colorSpace );
|
||||
exporter = [[[QTExporter alloc] initWithScreen:self] retain];
|
||||
streamer = [[[QTStreamer alloc] initWithScreen:self] retain];
|
||||
|
||||
streamerKeys = [[NSMutableArray arrayWithObjects:@"Title", @"Tags", @"Author", @"Description", @"Server", @"Port", @"Password", nil] retain];
|
||||
NSMutableArray *objects = [NSMutableArray arrayWithObjects:@"MyTitle", @"Remix,Video", @"me", @"playing with the flowmixer", @"theartcollider.net", @"8002", @"inoutsource", nil];
|
||||
streamerKeys = [[NSMutableArray arrayWithObjects:@"Title", @"Tags", @"Author", @"Description", @"Server", @"Port", @"Password", @"Framerate", @"Bitrate", @"Quality", nil] retain];
|
||||
NSMutableArray *objects = [NSMutableArray arrayWithObjects:@"MyTitle", @"Remix,Video", @"me", @"playing with the flowmixer", @"theartcollider.net", @"8002", @"inoutsource", @"15", @"128000", @"24", nil];
|
||||
streamerDict = [[NSMutableDictionary dictionaryWithObjects:objects forKeys:streamerKeys] retain];
|
||||
|
||||
[streamerDict setValue:[NSString stringWithFormat:@"MyTitle-%02d",rand()%99] forKey:[streamerKeys objectAtIndex:0]];
|
||||
|
||||
NSArray *columnArray = [streamerSettings tableColumns];
|
||||
[[columnArray objectAtIndex:0] setIdentifier:[NSNumber numberWithInt:0]];
|
||||
[[columnArray objectAtIndex:1] setIdentifier:[NSNumber numberWithInt:1]];
|
||||
@@ -147,7 +173,11 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
[lastFrame release];
|
||||
[lock release];
|
||||
[exportContext release];
|
||||
#ifdef MYCGL
|
||||
CGContextRelease( exportCGContextRef );
|
||||
#else
|
||||
CGLContextRelease( exportCGContextRef );
|
||||
#endif
|
||||
// TODO: free streamer Keys&Array
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -351,7 +381,10 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
if (CVDisplayLinkGetCurrentTime(displayLink, &now) == kCVReturnSuccess) {
|
||||
// if (exporter && [exporter isRunning])
|
||||
// [exporter addImage:[self exportSurface] atTime:&now];
|
||||
|
||||
if (streamer && streamerStatus != [streamer isRunning]) {
|
||||
streamerStatus=[streamer isRunning];
|
||||
[streamerButton setTitle:@"Start"];
|
||||
}
|
||||
if (rateCalc) {
|
||||
[rateCalc tick:now.videoTime];
|
||||
NSString *toRelease = nil;
|
||||
@@ -578,16 +611,28 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
contextInfo:sender];
|
||||
}
|
||||
|
||||
#if 0 // TODO
|
||||
extern "C" {
|
||||
void tac_tell(int del, char *me, char *src);
|
||||
}
|
||||
- (IBAction)announceStreamer:(id)sender
|
||||
{
|
||||
;// [streamer setParams: streamerDict];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (IBAction)toggleStreamer:(id)sender
|
||||
{
|
||||
if (streamer) {
|
||||
if ([streamer isRunning]) {
|
||||
[streamer stopStream];
|
||||
[sender setTitle:@"Start"];
|
||||
streamerStatus=[streamer isRunning];
|
||||
} else {
|
||||
[streamer setParams: streamerDict];
|
||||
if ([streamer startStream])
|
||||
[sender setTitle:@"Stop"];
|
||||
streamerStatus=[streamer isRunning];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -642,7 +687,6 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
|
||||
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
|
||||
{
|
||||
if (aTableView == streamerSettings && [aTableColumn identifier] == [NSNumber numberWithInt:1]) {
|
||||
NSLog(@"changed: %d %@", rowIndex, anObject);
|
||||
[streamerDict setValue:anObject forKey:[streamerKeys objectAtIndex:rowIndex]];
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -12,13 +12,13 @@
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="2737"/>
|
||||
<integer value="379"/>
|
||||
<integer value="2212"/>
|
||||
<integer value="3020"/>
|
||||
<integer value="57"/>
|
||||
<integer value="1887"/>
|
||||
<integer value="1576"/>
|
||||
<integer value="2737"/>
|
||||
<integer value="2878"/>
|
||||
<integer value="1887"/>
|
||||
<integer value="3020"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -5859,6 +5859,14 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
</object>
|
||||
<int key="connectionID">3038</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">streamerButton</string>
|
||||
<reference key="source" ref="575023888"/>
|
||||
<reference key="destination" ref="412275430"/>
|
||||
</object>
|
||||
<int key="connectionID">3039</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -9779,7 +9787,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">3038</int>
|
||||
<int key="maxID">3039</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -10138,6 +10146,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
<string>freej</string>
|
||||
<string>layerList</string>
|
||||
<string>showFps</string>
|
||||
<string>streamerButton</string>
|
||||
<string>streamerSettings</string>
|
||||
<string>window</string>
|
||||
</object>
|
||||
@@ -10146,6 +10155,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
<string>CFreej</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSButton</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSWindow</string>
|
||||
</object>
|
||||
|
||||
BIN
Binary file not shown.
@@ -20,6 +20,8 @@
|
||||
#ifndef __QTSTREAMER_H__
|
||||
#define __QTSTREAMER_H__
|
||||
|
||||
#define STREAMSTATS // print fps statistics
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QTKit/QTKit.h>
|
||||
@class CVScreenView;
|
||||
@@ -29,12 +31,22 @@
|
||||
@interface QTStreamer : NSObject {
|
||||
int active;
|
||||
int firstTime;
|
||||
int outQuality;
|
||||
int outBitrate;
|
||||
int outFramerate;
|
||||
int iceConnected;
|
||||
CVScreenView *screen;
|
||||
NSMutableDictionary *streamerProperties;
|
||||
NSRecursiveLock *lock;
|
||||
CVTimeStamp lastTimestamp;
|
||||
NSImage *lastImage;
|
||||
timeval calc_tv, prev_tv;
|
||||
#ifdef STREAMSTATS // statistics
|
||||
#define MAX_FPS_STATISTICS (50)
|
||||
double fps_sum;
|
||||
double fps_data[MAX_FPS_STATISTICS];
|
||||
int fps_i;
|
||||
#endif
|
||||
}
|
||||
- (id)initWithScreen:(CVScreenView *)cvscreen;
|
||||
- (void)addImage:(CIImage *)image;
|
||||
|
||||
+71
-20
@@ -140,9 +140,6 @@ extern "C" {
|
||||
firstTime=1;
|
||||
int vidW = lastImage.size.width;
|
||||
int vidH = lastImage.size.height;
|
||||
int outQuality = 24;
|
||||
int outFramerate = 12;
|
||||
int outBitrate = 20000;
|
||||
encoder_example_init(vidW, vidH, outFramerate, outBitrate, outQuality) ;
|
||||
firstTime=2;
|
||||
}
|
||||
@@ -151,6 +148,11 @@ extern "C" {
|
||||
CVPixelBufferRef givenBuff = [self fastImageFromNSImage:lastImage];
|
||||
int res = encoder_example_loop( givenBuff ) ;
|
||||
[givenBuff release];
|
||||
if (!res) {
|
||||
if (lastImage)
|
||||
[lastImage release];
|
||||
[self stopStream];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastImage)
|
||||
@@ -171,22 +173,48 @@ bail:
|
||||
//
|
||||
- (void)addPixelBuffer:(CVPixelBufferRef)pixelBuffer
|
||||
{
|
||||
timeval done, now_tv;
|
||||
if (!pixelBuffer) return;
|
||||
|
||||
if (firstTime==0 && iceConnected) {
|
||||
firstTime=1;
|
||||
int vidW = CVPixelBufferGetWidth(pixelBuffer);
|
||||
int vidH = CVPixelBufferGetHeight(pixelBuffer);
|
||||
int outQuality = 24;
|
||||
int outFramerate = 12;
|
||||
int outBitrate = 20000;
|
||||
encoder_example_init(vidW, vidH, outFramerate, outBitrate, outQuality) ;
|
||||
firstTime=2;
|
||||
gettimeofday(&calc_tv, NULL);
|
||||
gettimeofday(&prev_tv, NULL);
|
||||
}
|
||||
|
||||
if (firstTime==2 && iceConnected) {
|
||||
int res = encoder_example_loop( pixelBuffer ) ;
|
||||
gettimeofday(&now_tv, NULL);
|
||||
timersub(&now_tv, &calc_tv, &done);
|
||||
int rate = 1000000 / (outFramerate);
|
||||
if ( (done.tv_sec > 0) || (done.tv_usec >= rate) ) {
|
||||
if (firstTime==2 && iceConnected) {
|
||||
int res = encoder_example_loop( pixelBuffer ) ;
|
||||
if (!res) [self stopStream];
|
||||
|
||||
#ifdef STREAMSTATS // statistics
|
||||
timeval stats;
|
||||
timersub(&now_tv, &prev_tv, &stats);
|
||||
double curr_fps = 1000000.0 / stats.tv_usec;
|
||||
fps_sum = fps_sum - fps_data[fps_i] + curr_fps;
|
||||
fps_data[fps_i] = curr_fps;
|
||||
if (++fps_i >= MAX_FPS_STATISTICS) { fps_i = 0;
|
||||
printf("stream fps: %.1f\n", fps_sum/((double)MAX_FPS_STATISTICS));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
calc_tv.tv_sec = now_tv.tv_sec - done.tv_sec;
|
||||
calc_tv.tv_usec = now_tv.tv_usec - done.tv_usec + rate;
|
||||
|
||||
#ifdef STREAMSTATS // statistics
|
||||
prev_tv.tv_sec = now_tv.tv_sec;
|
||||
prev_tv.tv_usec = now_tv.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
CVPixelBufferRelease(pixelBuffer);
|
||||
}
|
||||
|
||||
@@ -195,7 +223,7 @@ bail:
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
FPS fps;
|
||||
fps.init(2*12); // XXX
|
||||
fps.init(2*outFramerate); // XXX
|
||||
while ([self isRunning]) {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
#if 0
|
||||
@@ -211,9 +239,24 @@ bail:
|
||||
|
||||
- (BOOL)startStream
|
||||
{
|
||||
if (active) return NO;
|
||||
[lock lock];
|
||||
if (active) {
|
||||
[lock unlock];
|
||||
return NO;
|
||||
}
|
||||
active =1;
|
||||
firstTime =0;
|
||||
outFramerate = [[streamerProperties objectForKey:@"Framerate" ] intValue];
|
||||
outBitrate = [[streamerProperties objectForKey:@"Bitrate" ] intValue];
|
||||
outQuality = [[streamerProperties objectForKey:@"Quality" ] intValue];
|
||||
if (outFramerate < 1 || outFramerate > 30) outFramerate=12;
|
||||
if (outQuality < 2 || outQuality > 32) outQuality=16;
|
||||
if (outBitrate < 8000 || outBitrate > 1048576) outBitrate=128000;
|
||||
|
||||
#ifdef STREAMSTATS // statistics
|
||||
for (int i=0; i<MAX_FPS_STATISTICS; i++) { fps_data[i] = 0; }
|
||||
fps_sum=0; fps_i=0;
|
||||
#endif
|
||||
|
||||
[NSThread detachNewThreadSelector:@selector(streamerThread:)
|
||||
toTarget:self withObject:nil];
|
||||
@@ -222,6 +265,7 @@ bail:
|
||||
#else
|
||||
NSString * mount = [NSString stringWithFormat:@"%@.ogg", [streamerProperties objectForKey:@"Title" ]];
|
||||
#endif
|
||||
|
||||
NSString * author = [NSString stringWithFormat:@"http://wiki.citu.fr/users/%@", [streamerProperties objectForKey:@"Author" ]];
|
||||
//iceConnected = myOggfwd_init("theartcollider.net", 8002, "inoutsource", "/test.ogg", "desc", "tags", "title", "me");
|
||||
iceConnected = myOggfwd_init(
|
||||
@@ -233,6 +277,8 @@ bail:
|
||||
[[streamerProperties objectForKey:@"Tags" ] UTF8String],
|
||||
[[streamerProperties objectForKey:@"Title" ] UTF8String],
|
||||
[author UTF8String]);
|
||||
|
||||
[lock unlock];
|
||||
if (iceConnected)
|
||||
return YES;
|
||||
active=0;
|
||||
@@ -242,26 +288,31 @@ bail:
|
||||
- (void)stopStream
|
||||
{
|
||||
[lock lock];
|
||||
if (!active) return;
|
||||
myOggfwd_close() ;
|
||||
encoder_example_end() ;
|
||||
active=0;
|
||||
if (!active) {
|
||||
[lock unlock];
|
||||
return;
|
||||
}
|
||||
iceConnected = 0;
|
||||
struct timespec delay = { 0, 1000000000/outFramerate };
|
||||
nanosleep(&delay,NULL); // wait for current encoder.
|
||||
encoder_example_end() ;
|
||||
myOggfwd_close() ;
|
||||
active=0;
|
||||
[lock unlock];
|
||||
}
|
||||
|
||||
- (void)setParams:(NSDictionary *) params
|
||||
{
|
||||
if (active) return;
|
||||
[lock lock];
|
||||
if (active) {
|
||||
[lock unlock];
|
||||
return;
|
||||
}
|
||||
[streamerProperties release];
|
||||
#if 0
|
||||
[[streamerProperties initWithDictionary:params copyItems:true] retain];
|
||||
#else
|
||||
streamerProperties= (NSMutableDictionary*) CFPropertyListCreateDeepCopy (
|
||||
kCFAllocatorDefault, params, kCFPropertyListMutableContainersAndLeaves
|
||||
);
|
||||
#endif
|
||||
NSLog(@"TXX: %@", [streamerProperties objectForKey:@"Title" ] );
|
||||
[lock unlock];
|
||||
}
|
||||
|
||||
- (BOOL)isRunning
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@
|
||||
|
||||
#define WITH_FREI0R 1
|
||||
|
||||
#define BUILD_NUMBER 31
|
||||
#define BUILD_NUMBER 37
|
||||
|
||||
#define OSX_VERSION 0.10
|
||||
|
||||
|
||||
+20
-19
@@ -65,7 +65,7 @@ int myOggfwd_process(ogg_page inputVideoPage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OGGERR(error) { fprintf(stderr, MNL "OGGFWD - Error - %s (%s)\n", error, shout_get_error(myShout)); return -1;}
|
||||
#define OGGERR(error,param) { fprintf(stderr, MNL "OGGFWD - Error - %s [%s] (%s)\n", error, param, shout_get_error(myShout)); return -1;}
|
||||
int myOggfwd_init( const char* outIceIp, int outIcePort, const char* outIcePass, const char* outIceMount,
|
||||
const char *description, const char *genre, const char *name, const char *url ) {
|
||||
|
||||
@@ -75,10 +75,10 @@ int myOggfwd_init( const char* outIceIp, int outIcePort, const char* outIcePass,
|
||||
printf(MNL "OGGFWD - Error - allocate failed.\n") ;
|
||||
return 0;
|
||||
}
|
||||
if (shout_set_host(myShout, outIceIp) != SHOUTERR_SUCCESS) OGGERR("set host pb");
|
||||
if (shout_set_port(myShout, port) != SHOUTERR_SUCCESS) OGGERR("invalid portnumber");
|
||||
if (shout_set_password(myShout, outIcePass) != SHOUTERR_SUCCESS) OGGERR("invalid password");
|
||||
if (shout_set_mount(myShout, outIceMount) != SHOUTERR_SUCCESS) OGGERR("invalid mountpoint");
|
||||
if (shout_set_host(myShout, outIceIp) != SHOUTERR_SUCCESS) OGGERR("invalid hostname", outIceIp);
|
||||
if (shout_set_port(myShout, port) != SHOUTERR_SUCCESS) OGGERR("invalid portnumber", "");
|
||||
if (shout_set_password(myShout, outIcePass) != SHOUTERR_SUCCESS) OGGERR("invalid password", "");
|
||||
if (shout_set_mount(myShout, outIceMount) != SHOUTERR_SUCCESS) OGGERR("invalid mountpoint", outIceMount);
|
||||
|
||||
shout_set_format(myShout, SHOUT_FORMAT_OGG);
|
||||
shout_set_public(myShout, 1);
|
||||
@@ -144,7 +144,7 @@ void encoder_init(int inW, int inH, int inFramerate, int in_video_r, int in_vide
|
||||
myGlob_ti.quality= in_video_q ;
|
||||
|
||||
myGlob_ti.dropframes_p=0;
|
||||
//myGlob_ti.quick_p=1;
|
||||
myGlob_ti.quick_p=1;
|
||||
myGlob_ti.keyframe_auto_p=1;
|
||||
myGlob_ti.keyframe_frequency=30;
|
||||
myGlob_ti.keyframe_frequency_force=myGlob_ti.keyframe_frequency;
|
||||
@@ -166,7 +166,7 @@ void encoder_init(int inW, int inH, int inFramerate, int in_video_r, int in_vide
|
||||
|
||||
if(ogg_stream_pageout(&myGlob_to, &myGlob_og)!=1){
|
||||
fprintf(stderr, "Internal Ogg library error.\n");
|
||||
exit(1); // XXX
|
||||
return; // XXX FATAL
|
||||
}
|
||||
|
||||
/* send header to icecas t*/
|
||||
@@ -192,7 +192,7 @@ void encoder_init(int inW, int inH, int inFramerate, int in_video_r, int in_vide
|
||||
int result = ogg_stream_flush(&myGlob_to, &myGlob_og);
|
||||
if(result<0){
|
||||
fprintf(stderr, MNL "THEORA - OGG stream flush error.\n");
|
||||
exit(1);
|
||||
return; // XXX FATAL.
|
||||
}
|
||||
if(result==0) break ;
|
||||
myOggfwd_process(myGlob_og) ;
|
||||
@@ -250,28 +250,28 @@ int yuv_copy__argb_to_420(void *b_rgb, SInt32 b_rgb_stride, size_t width, size_t
|
||||
#define _CG ((float)((bptr[(4*i)+2])&0xff))
|
||||
#define _CB ((float)((bptr[(4*i)+3])&0xff))
|
||||
|
||||
#define _CRX ((float)( ( ((bptr[(4*i)+1])&0xff) + ((bptr[(4*(i+1))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) )>>2))
|
||||
#define _CGX ((float)( ( ((bptr[(4*i)+2])&0xff) + ((bptr[(4*(i+1))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) )>>2))
|
||||
#define _CBX ((float)( ( ((bptr[(4*i)+3])&0xff) + ((bptr[(4*(i+1))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) )>>2))
|
||||
#define _XCR ((float)( ( ((bptr[(4*i)+1])&0xff) + ((bptr[(4*(i+1))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) )>>2))
|
||||
#define _XCG ((float)( ( ((bptr[(4*i)+2])&0xff) + ((bptr[(4*(i+1))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) )>>2))
|
||||
#define _XCB ((float)( ( ((bptr[(4*i)+3])&0xff) + ((bptr[(4*(i+1))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) )>>2))
|
||||
|
||||
uint8_t *bptr = (uint8_t*) b_rgb;
|
||||
int i; int c=0;
|
||||
for (i=0;i<width*height;i++) {
|
||||
double Y = (0.299 * _CR) + (0.587 * _CG) + (0.114 * _CB);
|
||||
if (Y<0) dst->y[i]=0;
|
||||
if (Y<1) dst->y[i]=0;
|
||||
else if (Y>255) dst->y[i]=255;
|
||||
else dst->y[i]=(uint8_t) floor(Y+.5);
|
||||
#if 1
|
||||
if (i%2==0 && ((i/width)%2)==0 && i < (width-1)*height) {
|
||||
double V = (0.500 * _CRX) - (0.419 * _CGX) - (0.081 * _CBX) + 128;
|
||||
double U = -(0.169 * _CRX) - (0.331 * _CGX) + (0.500 * _CBX) + 128;
|
||||
double V = (0.500 * _XCR) - (0.419 * _XCG) - (0.081 * _XCB) + 128;
|
||||
double U = -(0.169 * _XCR) - (0.331 * _XCG) + (0.500 * _XCB) + 128;
|
||||
|
||||
if (U<0) dst->u[c]=0;
|
||||
else if (U>255) dst->u[c]=255;
|
||||
if (U<1) dst->u[c]=0;
|
||||
else if (U>254) dst->u[c]=255;
|
||||
else dst->u[c]=(uint8_t) floor(U+.5);
|
||||
|
||||
if (V<0) dst->v[c]=0;
|
||||
else if (V>255) dst->v[c]=255;
|
||||
if (V<1) dst->v[c]=0;
|
||||
else if (V>254) dst->v[c]=255;
|
||||
else dst->v[c]=(uint8_t) floor(V+.5);
|
||||
c++;
|
||||
}
|
||||
@@ -299,12 +299,13 @@ int encoder_example_loop( CVPixelBufferRef theBuffer ) {
|
||||
&myGlob_yuv);
|
||||
|
||||
CVPixelBufferUnlockBaseAddress( theBuffer, 0 );
|
||||
encoder_loop(myGlob_yuv.y);
|
||||
return encoder_loop(myGlob_yuv.y)?0:1;
|
||||
}
|
||||
|
||||
int encoder_example_end() {
|
||||
encoder_close();
|
||||
if (myGlob_yuv.y) free(myGlob_yuv.y);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@
|
||||
AAD0A4CC0FDEC08100968886 /* libavcodec.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C00FDEC08100968886 /* libavcodec.dylib */; };
|
||||
AAD0A4CD0FDEC08100968886 /* libavformat.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C10FDEC08100968886 /* libavformat.dylib */; };
|
||||
AAD0A4CE0FDEC08100968886 /* libfftw3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C20FDEC08100968886 /* libfftw3.dylib */; };
|
||||
AAD0A4CF0FDEC08100968886 /* libjs.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C30FDEC08100968886 /* libjs.dylib */; };
|
||||
AAD0A4D00FDEC08100968886 /* libogg.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C40FDEC08100968886 /* libogg.dylib */; };
|
||||
AAD0A4D10FDEC08100968886 /* libSDL.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C50FDEC08100968886 /* libSDL.dylib */; };
|
||||
AAD0A4D20FDEC08100968886 /* libSDL_ttf.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4C60FDEC08100968886 /* libSDL_ttf.dylib */; };
|
||||
@@ -164,7 +163,9 @@
|
||||
AAEE689F0FC893BC007FB46B /* frei0r.png in Resources */ = {isa = PBXBuildFile; fileRef = AAEE689E0FC893BC007FB46B /* frei0r.png */; };
|
||||
B52891A21139ABA80053A203 /* live_r.png in Resources */ = {isa = PBXBuildFile; fileRef = B52891A01139ABA80053A203 /* live_r.png */; };
|
||||
B52891A31139ABA80053A203 /* live_w.png in Resources */ = {isa = PBXBuildFile; fileRef = B52891A11139ABA80053A203 /* live_w.png */; };
|
||||
B56D8F4E113BD3760092D922 /* libjs.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B56D8F4D113BD3760092D922 /* libjs.dylib */; };
|
||||
B56DCB85113AEF2900EF3F10 /* flowmixer-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B56DCB84113AEF2900EF3F10 /* flowmixer-Info.plist */; };
|
||||
B5792A63113E5B6A00CC49B0 /* tactell.c in Sources */ = {isa = PBXBuildFile; fileRef = B5792A62113E5B6A00CC49B0 /* tactell.c */; };
|
||||
B5BD93471133ED770063C358 /* encoder_example.c in Sources */ = {isa = PBXBuildFile; fileRef = B5BD93451133ED770063C358 /* encoder_example.c */; };
|
||||
B5BD934A1133ED890063C358 /* QTStreamer.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5BD93491133ED890063C358 /* QTStreamer.mm */; };
|
||||
B5BD95551134C2000063C358 /* FFInputController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5BD95521134C2000063C358 /* FFInputController.mm */; };
|
||||
@@ -428,7 +429,6 @@
|
||||
AAD0A4C00FDEC08100968886 /* libavcodec.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libavcodec.dylib; path = /opt/local/lib/libavcodec.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C10FDEC08100968886 /* libavformat.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libavformat.dylib; path = /opt/local/lib/libavformat.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C20FDEC08100968886 /* libfftw3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfftw3.dylib; path = /opt/local/lib/libfftw3.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C30FDEC08100968886 /* libjs.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libjs.dylib; path = /opt/local/lib/libjs.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C40FDEC08100968886 /* libogg.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libogg.dylib; path = /opt/local/lib/libogg.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C50FDEC08100968886 /* libSDL.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSDL.dylib; path = /opt/local/lib/libSDL.dylib; sourceTree = "<absolute>"; };
|
||||
AAD0A4C60FDEC08100968886 /* libSDL_ttf.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSDL_ttf.dylib; path = /opt/local/lib/libSDL_ttf.dylib; sourceTree = "<absolute>"; };
|
||||
@@ -453,7 +453,9 @@
|
||||
AAEE689E0FC893BC007FB46B /* frei0r.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = frei0r.png; sourceTree = "<group>"; };
|
||||
B52891A01139ABA80053A203 /* live_r.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_r.png; sourceTree = "<group>"; };
|
||||
B52891A11139ABA80053A203 /* live_w.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_w.png; sourceTree = "<group>"; };
|
||||
B56D8F4D113BD3760092D922 /* libjs.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libjs.dylib; path = /usr/local/lib/libjs.dylib; sourceTree = "<absolute>"; };
|
||||
B56DCB84113AEF2900EF3F10 /* flowmixer-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "flowmixer-Info.plist"; sourceTree = "<group>"; };
|
||||
B5792A62113E5B6A00CC49B0 /* tactell.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tactell.c; sourceTree = SOURCE_ROOT; };
|
||||
B5BD93451133ED770063C358 /* encoder_example.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = encoder_example.c; sourceTree = SOURCE_ROOT; };
|
||||
B5BD93461133ED770063C358 /* encoder_example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = encoder_example.h; sourceTree = SOURCE_ROOT; };
|
||||
B5BD93481133ED890063C358 /* QTStreamer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QTStreamer.h; sourceTree = SOURCE_ROOT; };
|
||||
@@ -484,7 +486,6 @@
|
||||
AAD0A4CC0FDEC08100968886 /* libavcodec.dylib in Frameworks */,
|
||||
AAD0A4CD0FDEC08100968886 /* libavformat.dylib in Frameworks */,
|
||||
AAD0A4CE0FDEC08100968886 /* libfftw3.dylib in Frameworks */,
|
||||
AAD0A4CF0FDEC08100968886 /* libjs.dylib in Frameworks */,
|
||||
AAD0A4D00FDEC08100968886 /* libogg.dylib in Frameworks */,
|
||||
AAD0A4D10FDEC08100968886 /* libSDL.dylib in Frameworks */,
|
||||
AAD0A4D20FDEC08100968886 /* libSDL_ttf.dylib in Frameworks */,
|
||||
@@ -502,6 +503,7 @@
|
||||
AAA7DA9A101A4F79009B32FD /* libsamplerate.dylib in Frameworks */,
|
||||
AAD181D3104964FB0053F8A6 /* liblo.dylib in Frameworks */,
|
||||
AAD181D5104965120053F8A6 /* libshout.dylib in Frameworks */,
|
||||
B56D8F4E113BD3760092D922 /* libjs.dylib in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -569,6 +571,7 @@
|
||||
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B56D8F4D113BD3760092D922 /* libjs.dylib */,
|
||||
AAD181D4104965120053F8A6 /* libshout.dylib */,
|
||||
AAD181D2104964FB0053F8A6 /* liblo.dylib */,
|
||||
AAA7DA99101A4F79009B32FD /* libsamplerate.dylib */,
|
||||
@@ -581,7 +584,6 @@
|
||||
AAD0A4C00FDEC08100968886 /* libavcodec.dylib */,
|
||||
AAD0A4C10FDEC08100968886 /* libavformat.dylib */,
|
||||
AAD0A4C20FDEC08100968886 /* libfftw3.dylib */,
|
||||
AAD0A4C30FDEC08100968886 /* libjs.dylib */,
|
||||
AAD0A4C40FDEC08100968886 /* libogg.dylib */,
|
||||
AAD0A4C50FDEC08100968886 /* libSDL.dylib */,
|
||||
AAD0A4C60FDEC08100968886 /* libSDL_ttf.dylib */,
|
||||
@@ -662,6 +664,7 @@
|
||||
AA3C44100F3EEBE0007C7E8B /* C++ */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B5792A62113E5B6A00CC49B0 /* tactell.c */,
|
||||
B5BD95B4113581AD0063C358 /* ffdec.c */,
|
||||
B5BD95B5113581AD0063C358 /* ffdec.h */,
|
||||
B5BD95511134C2000063C358 /* FFInputController.h */,
|
||||
@@ -1133,6 +1136,7 @@
|
||||
B5BD95561134C2000063C358 /* FFInputView.mm in Sources */,
|
||||
B5BD95B6113581AD0063C358 /* ffdec.c in Sources */,
|
||||
B5BD96A711386CFC0063C358 /* FFInputPanel.mm in Sources */,
|
||||
B5792A63113E5B6A00CC49B0 /* tactell.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1318,7 +1322,7 @@
|
||||
/usr/local/lib,
|
||||
/opt/local/lib,
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
OTHER_CFLAGS = (
|
||||
"-fexceptions",
|
||||
"-headerpad_max_install_names",
|
||||
|
||||
Reference in New Issue
Block a user