summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2011-12-11 11:48:33 +0100
committerUoti Urpala <uau@mplayer2.org>2012-04-26 21:03:10 +0300
commit237f44db44b5479c78c90c1a045e0123a2f9c2b8 (patch)
tree601b628c871848d9f3c2c1ee664ab8a53e2df3a9 /libvo
parent9ba3e1ddb25a780f31ad2ed3e2fbb6682c098456 (diff)
downloadmpv-237f44db44b5479c78c90c1a045e0123a2f9c2b8.tar.bz2
mpv-237f44db44b5479c78c90c1a045e0123a2f9c2b8.tar.xz
vo_corevideo: use soft tabs (4 spaces)
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_corevideo.m1368
1 files changed, 684 insertions, 684 deletions
diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m
index e937460636..5e1dd71259 100644
--- a/libvo/vo_corevideo.m
+++ b/libvo/vo_corevideo.m
@@ -92,68 +92,68 @@ static BOOL isLeopardOrLater;
static vo_info_t info =
{
- "Mac OS X Core Video",
- "corevideo",
- "Nicolas Plourde <nicolas.plourde@gmail.com>",
- ""
+ "Mac OS X Core Video",
+ "corevideo",
+ "Nicolas Plourde <nicolas.plourde@gmail.com>",
+ ""
};
LIBVO_EXTERN(corevideo)
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
{
- switch (image_format)
- {
- case IMGFMT_RGB24:
- vo_draw_alpha_rgb24(w,h,src,srca,stride,image_data+3*(y0*image_width+x0),3*image_width);
- break;
- case IMGFMT_ARGB:
- case IMGFMT_BGRA:
- vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width);
- break;
- case IMGFMT_YUY2:
- vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2);
- break;
- }
+ switch (image_format)
+ {
+ case IMGFMT_RGB24:
+ vo_draw_alpha_rgb24(w,h,src,srca,stride,image_data+3*(y0*image_width+x0),3*image_width);
+ break;
+ case IMGFMT_ARGB:
+ case IMGFMT_BGRA:
+ vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width);
+ break;
+ case IMGFMT_YUY2:
+ vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2);
+ break;
+ }
}
static void update_screen_info(void)
{
- if (screen_id == -1 && xinerama_screen > -1)
- screen_id = xinerama_screen;
-
- screen_array = [NSScreen screens];
- if(screen_id >= (int)[screen_array count])
- {
- mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] Device ID %d does not exist, falling back to main device\n", screen_id);
- screen_id = -1;
- }
- if (screen_id < 0 && [mpGLView window])
- screen_handle = [[mpGLView window] screen];
- else
- screen_handle = [screen_array objectAtIndex:(screen_id < 0 ? 0 : screen_id)];
-
- screen_frame = [screen_handle frame];
- vo_screenwidth = screen_frame.size.width;
- vo_screenheight = screen_frame.size.height;
- xinerama_x = xinerama_y = 0;
- aspect_save_screenres(vo_screenwidth, vo_screenheight);
+ if (screen_id == -1 && xinerama_screen > -1)
+ screen_id = xinerama_screen;
+
+ screen_array = [NSScreen screens];
+ if(screen_id >= (int)[screen_array count])
+ {
+ mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] Device ID %d does not exist, falling back to main device\n", screen_id);
+ screen_id = -1;
+ }
+ if (screen_id < 0 && [mpGLView window])
+ screen_handle = [[mpGLView window] screen];
+ else
+ screen_handle = [screen_array objectAtIndex:(screen_id < 0 ? 0 : screen_id)];
+
+ screen_frame = [screen_handle frame];
+ vo_screenwidth = screen_frame.size.width;
+ vo_screenheight = screen_frame.size.height;
+ xinerama_x = xinerama_y = 0;
+ aspect_save_screenres(vo_screenwidth, vo_screenheight);
}
static void free_file_specific(void)
{
- if(shared_buffer)
- {
- [mplayerosxProto stop];
- mplayerosxProto = nil;
- [mplayerosxProxy release];
- mplayerosxProxy = nil;
-
- if (munmap(image_data, image_width*image_height*image_bytes) == -1)
- mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno));
-
- if (shm_unlink(buffer_name) == -1)
- mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno));
+ if(shared_buffer)
+ {
+ [mplayerosxProto stop];
+ mplayerosxProto = nil;
+ [mplayerosxProxy release];
+ mplayerosxProxy = nil;
+
+ if (munmap(image_data, image_width*image_height*image_bytes) == -1)
+ mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno));
+
+ if (shm_unlink(buffer_name) == -1)
+ mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno));
} else {
free(image_datas[0]);
if (vo_doublebuffering)
@@ -166,165 +166,165 @@ static void free_file_specific(void)
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
- free_file_specific();
-
- //misc mplayer setup
- image_width = width;
- image_height = height;
- switch (image_format)
- {
- case IMGFMT_RGB24:
- image_depth = 24;
- break;
- case IMGFMT_ARGB:
- case IMGFMT_BGRA:
- image_depth = 32;
- break;
- case IMGFMT_YUY2:
- image_depth = 16;
- break;
- }
- image_bytes = (image_depth + 7) / 8;
-
- if(!shared_buffer)
- {
- config_movie_aspect((float)d_width/d_height);
-
- vo_dwidth = d_width *= mpGLView->winSizeMult;
- vo_dheight = d_height *= mpGLView->winSizeMult;
-
- image_data = malloc(image_width*image_height*image_bytes);
- image_datas[0] = image_data;
- if (vo_doublebuffering)
- image_datas[1] = malloc(image_width*image_height*image_bytes);
- image_page = 0;
-
- vo_fs = flags & VOFLAG_FULLSCREEN;
-
- //config OpenGL View
- [mpGLView config];
- [mpGLView reshape];
- }
- else
- {
- int shm_fd;
- mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] writing output to a shared buffer "
- "named \"%s\"\n",buffer_name);
-
- // create shared memory
- shm_fd = shm_open(buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
- if (shm_fd == -1)
- {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "[vo_corevideo] failed to open shared memory. Error: %s\n", strerror(errno));
- return 1;
- }
-
-
- if (ftruncate(shm_fd, image_width*image_height*image_bytes) == -1)
- {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "[vo_corevideo] failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno));
- close(shm_fd);
- shm_unlink(buffer_name);
- return 1;
- }
-
- image_data = mmap(NULL, image_width*image_height*image_bytes,
- PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
- close(shm_fd);
-
- if (image_data == MAP_FAILED)
- {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "[vo_corevideo] failed to map shared memory. Error: %s\n", strerror(errno));
- shm_unlink(buffer_name);
- return 1;
- }
-
- //connect to mplayerosx
- mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:[NSString stringWithCString:buffer_name] host:nil];
- if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) {
- [mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)];
- mplayerosxProto = (id <MPlayerOSXVOProto>)mplayerosxProxy;
- [mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:d_width*100/d_height];
- }
- else {
- [mplayerosxProxy release];
- mplayerosxProxy = nil;
- mplayerosxProto = nil;
- }
- }
- return 0;
+ free_file_specific();
+
+ //misc mplayer setup
+ image_width = width;
+ image_height = height;
+ switch (image_format)
+ {
+ case IMGFMT_RGB24:
+ image_depth = 24;
+ break;
+ case IMGFMT_ARGB:
+ case IMGFMT_BGRA:
+ image_depth = 32;
+ break;
+ case IMGFMT_YUY2:
+ image_depth = 16;
+ break;
+ }
+ image_bytes = (image_depth + 7) / 8;
+
+ if(!shared_buffer)
+ {
+ config_movie_aspect((float)d_width/d_height);
+
+ vo_dwidth = d_width *= mpGLView->winSizeMult;
+ vo_dheight = d_height *= mpGLView->winSizeMult;
+
+ image_data = malloc(image_width*image_height*image_bytes);
+ image_datas[0] = image_data;
+ if (vo_doublebuffering)
+ image_datas[1] = malloc(image_width*image_height*image_bytes);
+ image_page = 0;
+
+ vo_fs = flags & VOFLAG_FULLSCREEN;
+
+ //config OpenGL View
+ [mpGLView config];
+ [mpGLView reshape];
+ }
+ else
+ {
+ int shm_fd;
+ mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] writing output to a shared buffer "
+ "named \"%s\"\n",buffer_name);
+
+ // create shared memory
+ shm_fd = shm_open(buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
+ if (shm_fd == -1)
+ {
+ mp_msg(MSGT_VO, MSGL_FATAL,
+ "[vo_corevideo] failed to open shared memory. Error: %s\n", strerror(errno));
+ return 1;
+ }
+
+
+ if (ftruncate(shm_fd, image_width*image_height*image_bytes) == -1)
+ {
+ mp_msg(MSGT_VO, MSGL_FATAL,
+ "[vo_corevideo] failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno));
+ close(shm_fd);
+ shm_unlink(buffer_name);
+ return 1;
+ }
+
+ image_data = mmap(NULL, image_width*image_height*image_bytes,
+ PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
+ close(shm_fd);
+
+ if (image_data == MAP_FAILED)
+ {
+ mp_msg(MSGT_VO, MSGL_FATAL,
+ "[vo_corevideo] failed to map shared memory. Error: %s\n", strerror(errno));
+ shm_unlink(buffer_name);
+ return 1;
+ }
+
+ //connect to mplayerosx
+ mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:[NSString stringWithCString:buffer_name] host:nil];
+ if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) {
+ [mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)];
+ mplayerosxProto = (id <MPlayerOSXVOProto>)mplayerosxProxy;
+ [mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:d_width*100/d_height];
+ }
+ else {
+ [mplayerosxProxy release];
+ mplayerosxProxy = nil;
+ mplayerosxProto = nil;
+ }
+ }
+ return 0;
}
static void check_events(void)
{
- if (mpGLView)
- [mpGLView check_events];
+ if (mpGLView)
+ [mpGLView check_events];
}
static void draw_osd(void)
{
- vo_draw_text(image_width, image_height, draw_alpha);
+ vo_draw_text(image_width, image_height, draw_alpha);
}
static void flip_page(void)
{
- if(shared_buffer) {
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [mplayerosxProto render];
- [pool release];
- } else {
- [mpGLView setCurrentTexture];
- [mpGLView render];
- if (vo_doublebuffering) {
- image_page = 1 - image_page;
- image_data = image_datas[image_page];
- }
- }
+ if(shared_buffer) {
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ [mplayerosxProto render];
+ [pool release];
+ } else {
+ [mpGLView setCurrentTexture];
+ [mpGLView render];
+ if (vo_doublebuffering) {
+ image_page = 1 - image_page;
+ image_data = image_datas[image_page];
+ }
+ }
}
static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
{
- return 0;
+ return 0;
}
static int draw_frame(uint8_t *src[])
{
- return 0;
+ return 0;
}
static uint32_t draw_image(mp_image_t *mpi)
{
- memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_width*image_bytes, mpi->stride[0]);
+ memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_width*image_bytes, mpi->stride[0]);
- return 0;
+ return 0;
}
static int query_format(uint32_t format)
{
const int supportflags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
- image_format = format;
+ image_format = format;
switch(format)
- {
- case IMGFMT_YUY2:
- pixelFormat = kYUVSPixelFormat;
- return supportflags;
-
- case IMGFMT_RGB24:
- pixelFormat = k24RGBPixelFormat;
- return supportflags;
-
- case IMGFMT_ARGB:
- pixelFormat = k32ARGBPixelFormat;
- return supportflags;
-
- case IMGFMT_BGRA:
- pixelFormat = k32BGRAPixelFormat;
- return supportflags;
+ {
+ case IMGFMT_YUY2:
+ pixelFormat = kYUVSPixelFormat;
+ return supportflags;
+
+ case IMGFMT_RGB24:
+ pixelFormat = k24RGBPixelFormat;
+ return supportflags;
+
+ case IMGFMT_ARGB:
+ pixelFormat = k32ARGBPixelFormat;
+ return supportflags;
+
+ case IMGFMT_BGRA:
+ pixelFormat = k32BGRAPixelFormat;
+ return supportflags;
}
return 0;
}
@@ -360,81 +360,81 @@ static const opt_t subopts[] = {
static int preinit(const char *arg)
{
- // set defaults
- screen_id = -1;
- shared_buffer = false;
- buffer_name = NULL;
-
- if (subopt_parse(arg, subopts) != 0) {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "\n-vo corevideo command line help:\n"
- "Example: mplayer -vo corevideo:device_id=1:shared_buffer:buffer_name=mybuff\n"
- "\nOptions:\n"
- " device_id=<0-...>\n"
- " Set screen device ID for fullscreen.\n"
- " shared_buffer\n"
- " Write output to a shared memory buffer instead of displaying it.\n"
- " buffer_name=<name>\n"
- " Name of the shared buffer created with shm_open() as well as\n"
- " the name of the NSConnection MPlayer will try to open.\n"
- " Setting buffer_name implicitly enables shared_buffer.\n"
- "\n" );
- return -1;
- }
-
- autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- if (!buffer_name)
- buffer_name = strdup(DEFAULT_BUFFER_NAME);
- else
- shared_buffer = true;
-
- if(!shared_buffer)
- {
- NSApplicationLoad();
- NSApp = [NSApplication sharedApplication];
- isLeopardOrLater = floor(NSAppKitVersionNumber) > 824;
-
- osx_foreground_hack();
-
- if(!mpGLView)
- {
- mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
- [mpGLView autorelease];
- }
- // Install an event handler so the Quit menu entry works
- // The proper way using NSApp setDelegate: and
- // applicationShouldTerminate: does not work,
- // probably NSApplication never installs its handler.
- [[NSAppleEventManager sharedAppleEventManager]
- setEventHandler:mpGLView
- andSelector:@selector(handleQuitEvent:withReplyEvent:)
- forEventClass:kCoreEventClass
- andEventID:kAEQuitApplication];
-
- [mpGLView display];
- [mpGLView preinit];
- }
+ // set defaults
+ screen_id = -1;
+ shared_buffer = false;
+ buffer_name = NULL;
+
+ if (subopt_parse(arg, subopts) != 0) {
+ mp_msg(MSGT_VO, MSGL_FATAL,
+ "\n-vo corevideo command line help:\n"
+ "Example: mplayer -vo corevideo:device_id=1:shared_buffer:buffer_name=mybuff\n"
+ "\nOptions:\n"
+ " device_id=<0-...>\n"
+ " Set screen device ID for fullscreen.\n"
+ " shared_buffer\n"
+ " Write output to a shared memory buffer instead of displaying it.\n"
+ " buffer_name=<name>\n"
+ " Name of the shared buffer created with shm_open() as well as\n"
+ " the name of the NSConnection MPlayer will try to open.\n"
+ " Setting buffer_name implicitly enables shared_buffer.\n"
+ "\n" );
+ return -1;
+ }
+
+ autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ if (!buffer_name)
+ buffer_name = strdup(DEFAULT_BUFFER_NAME);
+ else
+ shared_buffer = true;
+
+ if(!shared_buffer)
+ {
+ NSApplicationLoad();
+ NSApp = [NSApplication sharedApplication];
+ isLeopardOrLater = floor(NSAppKitVersionNumber) > 824;
+
+ osx_foreground_hack();
+
+ if(!mpGLView)
+ {
+ mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
+ [mpGLView autorelease];
+ }
+ // Install an event handler so the Quit menu entry works
+ // The proper way using NSApp setDelegate: and
+ // applicationShouldTerminate: does not work,
+ // probably NSApplication never installs its handler.
+ [[NSAppleEventManager sharedAppleEventManager]
+ setEventHandler:mpGLView
+ andSelector:@selector(handleQuitEvent:withReplyEvent:)
+ forEventClass:kCoreEventClass
+ andEventID:kAEQuitApplication];
+
+ [mpGLView display];
+ [mpGLView preinit];
+ }
return 0;
}
static int control(uint32_t request, void *data)
{
- switch (request)
- {
- case VOCTRL_DRAW_IMAGE: return draw_image(data);
- case VOCTRL_PAUSE: return int_pause = 1;
- case VOCTRL_RESUME: return int_pause = 0;
- case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data);
- case VOCTRL_ONTOP: vo_ontop = !vo_ontop; if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE;
- case VOCTRL_ROOTWIN: vo_rootwin = !vo_rootwin; [mpGLView rootwin]; return VO_TRUE;
- case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE;
- case VOCTRL_GET_PANSCAN: return VO_TRUE;
- case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE;
- case VOCTRL_UPDATE_SCREENINFO: update_screen_info(); return VO_TRUE;
- }
- return VO_NOTIMPL;
+ switch (request)
+ {
+ case VOCTRL_DRAW_IMAGE: return draw_image(data);
+ case VOCTRL_PAUSE: return int_pause = 1;
+ case VOCTRL_RESUME: return int_pause = 0;
+ case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data);
+ case VOCTRL_ONTOP: vo_ontop = !vo_ontop; if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE;
+ case VOCTRL_ROOTWIN: vo_rootwin = !vo_rootwin; [mpGLView rootwin]; return VO_TRUE;
+ case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE;
+ case VOCTRL_GET_PANSCAN: return VO_TRUE;
+ case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE;
+ case VOCTRL_UPDATE_SCREENINFO: update_screen_info(); return VO_TRUE;
+ }
+ return VO_NOTIMPL;
}
//////////////////////////////////////////////////////////////////////////
@@ -443,167 +443,167 @@ static int control(uint32_t request, void *data)
@implementation MPlayerOpenGLView
- (void) preinit
{
- NSOpenGLContext *glContext;
- GLint swapInterval = 1;
- CVReturn error;
-
- //init menu
- [self initMenu];
-
- //create window
- window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
- styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
- backing:NSBackingStoreBuffered defer:NO];
-
- [window autorelease];
- [window setDelegate:mpGLView];
- [window setContentView:mpGLView];
- [window setInitialFirstResponder:mpGLView];
- [window setAcceptsMouseMovedEvents:YES];
- [window setTitle:@"MPlayer - The Movie Player"];
-
- isFullscreen = 0;
- winSizeMult = 1;
-
- //create OpenGL Context
- glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
-
- [self setOpenGLContext:glContext];
- [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
- [glContext setView:self];
- [glContext makeCurrentContext];
- [glContext release];
-
- error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
- if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
+ NSOpenGLContext *glContext;
+ GLint swapInterval = 1;
+ CVReturn error;
+
+ //init menu
+ [self initMenu];
+
+ //create window
+ window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
+ styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
+ backing:NSBackingStoreBuffered defer:NO];
+
+ [window autorelease];
+ [window setDelegate:mpGLView];
+ [window setContentView:mpGLView];
+ [window setInitialFirstResponder:mpGLView];
+ [window setAcceptsMouseMovedEvents:YES];
+ [window setTitle:@"MPlayer - The Movie Player"];
+
+ isFullscreen = 0;
+ winSizeMult = 1;
+
+ //create OpenGL Context
+ glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
+
+ [self setOpenGLContext:glContext];
+ [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
+ [glContext setView:self];
+ [glContext makeCurrentContext];
+ [glContext release];
+
+ error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
+ if(error != kCVReturnSuccess)
+ mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
}
- (void) releaseVideoSpecific
{
- CVPixelBufferRelease(frameBuffers[0]);
- frameBuffers[0] = NULL;
- CVPixelBufferRelease(frameBuffers[1]);
- frameBuffers[1] = NULL;
- CVOpenGLTextureRelease(texture);
- texture = NULL;
+ CVPixelBufferRelease(frameBuffers[0]);
+ frameBuffers[0] = NULL;
+ CVPixelBufferRelease(frameBuffers[1]);
+ frameBuffers[1] = NULL;
+ CVOpenGLTextureRelease(texture);
+ texture = NULL;
}
- (void) dealloc
{
- [self releaseVideoSpecific];
- CVOpenGLTextureCacheRelease(textureCache);
- textureCache = NULL;
- [self setOpenGLContext:nil];
- [super dealloc];
+ [self releaseVideoSpecific];
+ CVOpenGLTextureCacheRelease(textureCache);
+ textureCache = NULL;
+ [self setOpenGLContext:nil];
+ [super dealloc];
}
- (void) config
{
- NSRect visibleFrame;
- CVReturn error = kCVReturnSuccess;
-
- //config window
- [window setContentSize:NSMakeSize(vo_dwidth, vo_dheight)];
-
- // Use visibleFrame to position the window taking the menu bar and dock into account.
- // Also flip vo_dy since the screen origin is in the bottom left on OSX.
- update_screen_info();
- visibleFrame = [screen_handle visibleFrame];
- [window setFrameTopLeftPoint:NSMakePoint(
- visibleFrame.origin.x + vo_dx,
- visibleFrame.origin.y + visibleFrame.size.height - vo_dy)];
-
- [self releaseVideoSpecific];
- error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]);
- if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error);
- if (vo_doublebuffering) {
- error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[1]);
- if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error);
- }
-
- error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
- if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
-
- //show window
- [window makeKeyAndOrderFront:mpGLView];
-
- if(vo_rootwin)
- [mpGLView rootwin];
-
- if(vo_fs)
- [mpGLView fullscreen: NO];
-
- if(vo_ontop)
- [mpGLView ontop];
+ NSRect visibleFrame;
+ CVReturn error = kCVReturnSuccess;
+
+ //config window
+ [window setContentSize:NSMakeSize(vo_dwidth, vo_dheight)];
+
+ // Use visibleFrame to position the window taking the menu bar and dock into account.
+ // Also flip vo_dy since the screen origin is in the bottom left on OSX.
+ update_screen_info();
+ visibleFrame = [screen_handle visibleFrame];
+ [window setFrameTopLeftPoint:NSMakePoint(
+ visibleFrame.origin.x + vo_dx,
+ visibleFrame.origin.y + visibleFrame.size.height - vo_dy)];
+
+ [self releaseVideoSpecific];
+ error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]);
+ if(error != kCVReturnSuccess)
+ mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error);
+ if (vo_doublebuffering) {
+ error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[1]);
+ if(error != kCVReturnSuccess)
+ mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error);
+ }
+
+ error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
+ if(error != kCVReturnSuccess)
+ mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
+
+ //show window
+ [window makeKeyAndOrderFront:mpGLView];
+
+ if(vo_rootwin)
+ [mpGLView rootwin];
+
+ if(vo_fs)
+ [mpGLView fullscreen: NO];
+
+ if(vo_ontop)
+ [mpGLView ontop];
}
/*
- Init Menu
+ Init Menu
*/
- (void)initMenu
{
- NSMenu *menu, *aspectMenu;
- NSMenuItem *menuItem;
+ NSMenu *menu, *aspectMenu;
+ NSMenuItem *menuItem;
- menu = [[NSMenu new] autorelease];
- menuItem = [[NSMenuItem new] autorelease];
- [menu addItem: menuItem];
- [NSApp setMainMenu: menu];
+ menu = [[NSMenu new] autorelease];
+ menuItem = [[NSMenuItem new] autorelease];
+ [menu addItem: menuItem];
+ [NSApp setMainMenu: menu];
//Create Movie Menu
- menu = [[NSMenu alloc] initWithTitle:@"Movie"];
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem];
- kHalfScreenCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem];
- kNormalScreenCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem];
- kDoubleScreenCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem];
- kFullScreenCmd = menuItem;
- menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem];
-
- aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"];
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
- if(vo_keepaspect) [menuItem setState:NSOnState];
- kKeepAspectCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
- if(vo_panscan) [menuItem setState:NSOnState];
- kPanScanCmd = menuItem;
- menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem];
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
- kAspectOrgCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
- kAspectFullCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
- kAspectWideCmd = menuItem;
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:aspectMenu];
- [menu addItem:menuItem];
- [aspectMenu release];
-
- //Add to menubar
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:menu];
- [[NSApp mainMenu] addItem:menuItem];
+ menu = [[NSMenu alloc] initWithTitle:@"Movie"];
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem];
+ kHalfScreenCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem];
+ kNormalScreenCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem];
+ kDoubleScreenCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem];
+ kFullScreenCmd = menuItem;
+ menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem];
+
+ aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"];
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+ if(vo_keepaspect) [menuItem setState:NSOnState];
+ kKeepAspectCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+ if(vo_panscan) [menuItem setState:NSOnState];
+ kPanScanCmd = menuItem;
+ menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem];
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+ kAspectOrgCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+ kAspectFullCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+ kAspectWideCmd = menuItem;
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""];
+ [menuItem setSubmenu:aspectMenu];
+ [menu addItem:menuItem];
+ [aspectMenu release];
+
+ //Add to menubar
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""];
+ [menuItem setSubmenu:menu];
+ [[NSApp mainMenu] addItem:menuItem];
//Create Window Menu
- menu = [[NSMenu alloc] initWithTitle:@"Window"];
+ menu = [[NSMenu alloc] initWithTitle:@"Window"];
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem];
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem];
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem];
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem];
- //Add to menubar
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:menu];
- [[NSApp mainMenu] addItem:menuItem];
- [NSApp setWindowsMenu:menu];
+ //Add to menubar
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
+ [menuItem setSubmenu:menu];
+ [[NSApp mainMenu] addItem:menuItem];
+ [NSApp setWindowsMenu:menu];
- [menu release];
- [menuItem release];
+ [menu release];
+ [menuItem release];
}
- (void)set_winSizeMult:(float)mult
@@ -625,452 +625,452 @@ static int control(uint32_t request, void *data)
}
/*
- Menu Action
+ Menu Action
*/
- (void)menuAction:(id)sender
{
- if(sender == kHalfScreenCmd)
- [self set_winSizeMult: 0.5];
- if(sender == kNormalScreenCmd)
- [self set_winSizeMult: 1];
- if(sender == kDoubleScreenCmd)
- [self set_winSizeMult: 2];
- if(sender == kFullScreenCmd)
- {
- vo_fs = !vo_fs;
- [self fullscreen:NO];
- }
-
- if(sender == kKeepAspectCmd)
- {
- vo_keepaspect = !vo_keepaspect;
- if(vo_keepaspect)
- [kKeepAspectCmd setState:NSOnState];
- else
- [kKeepAspectCmd setState:NSOffState];
-
- [self reshape];
- }
-
- if(sender == kPanScanCmd)
- {
- vo_panscan = !vo_panscan;
- if(vo_panscan)
- [kPanScanCmd setState:NSOnState];
- else
- [kPanScanCmd setState:NSOffState];
-
- [self panscan];
- }
-
- if(sender == kAspectOrgCmd)
- change_movie_aspect(-1);
-
- if(sender == kAspectFullCmd)
- change_movie_aspect(4.0f/3.0f);
-
- if(sender == kAspectWideCmd)
- change_movie_aspect(16.0f/9.0f);
+ if(sender == kHalfScreenCmd)
+ [self set_winSizeMult: 0.5];
+ if(sender == kNormalScreenCmd)
+ [self set_winSizeMult: 1];
+ if(sender == kDoubleScreenCmd)
+ [self set_winSizeMult: 2];
+ if(sender == kFullScreenCmd)
+ {
+ vo_fs = !vo_fs;
+ [self fullscreen:NO];
+ }
+
+ if(sender == kKeepAspectCmd)
+ {
+ vo_keepaspect = !vo_keepaspect;
+ if(vo_keepaspect)
+ [kKeepAspectCmd setState:NSOnState];
+ else
+ [kKeepAspectCmd setState:NSOffState];
+
+ [self reshape];
+ }
+
+ if(sender == kPanScanCmd)
+ {
+ vo_panscan = !vo_panscan;
+ if(vo_panscan)
+ [kPanScanCmd setState:NSOnState];
+ else
+ [kPanScanCmd setState:NSOffState];
+
+ [self panscan];
+ }
+
+ if(sender == kAspectOrgCmd)
+ change_movie_aspect(-1);
+
+ if(sender == kAspectFullCmd)
+ change_movie_aspect(4.0f/3.0f);
+
+ if(sender == kAspectWideCmd)
+ change_movie_aspect(16.0f/9.0f);
}
/*
- Setup OpenGL
+ Setup OpenGL
*/
- (void)prepareOpenGL
{
- glEnable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_FALSE);
- glDisable(GL_CULL_FACE);
- [self reshape];
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glDisable(GL_CULL_FACE);
+ [self reshape];
}
/*
- reshape OpenGL viewport
+ reshape OpenGL viewport
*/
- (void)reshape
{
- int d_width, d_height;
-
- NSRect frame = [self frame];
- vo_dwidth = frame.size.width;
- vo_dheight = frame.size.height;
-
- glViewport(0, 0, frame.size.width, frame.size.height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- //set texture frame
- if(vo_keepaspect)
- {
- aspect(&d_width, &d_height, A_WINZOOM);
-
- textureFrame = NSMakeRect((vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height);
- }
- els