diff options
Diffstat (limited to 'src/video_out')
| -rw-r--r-- | src/video_out/Makefile.am | 13 | ||||
| -rw-r--r-- | src/video_out/deinterlace.h | 2 | ||||
| -rw-r--r-- | src/video_out/macosx/XineOpenGLView.h | 155 | ||||
| -rw-r--r-- | src/video_out/macosx/XineOpenGLView.m | 1124 | ||||
| -rw-r--r-- | src/video_out/macosx/XineVideoWindow.m | 2 | ||||
| -rw-r--r-- | src/video_out/video_out_directfb.c | 34 | ||||
| -rw-r--r-- | src/video_out/video_out_directfb_fb.c | 25 | ||||
| -rw-r--r-- | src/video_out/video_out_directfb_x.c | 25 | ||||
| -rwxr-xr-x[-rw-r--r--] | src/video_out/video_out_directx.c | 0 | ||||
| -rw-r--r-- | src/video_out/video_out_fb.c | 81 | ||||
| -rw-r--r-- | src/video_out/video_out_macosx.m | 55 | ||||
| -rw-r--r-- | src/video_out/video_out_xcbshm.c | 29 | ||||
| -rw-r--r-- | src/video_out/video_out_xcbxv.c | 66 | ||||
| -rw-r--r-- | src/video_out/video_out_xshm.c | 40 | ||||
| -rw-r--r-- | src/video_out/video_out_xv.c | 87 | ||||
| -rw-r--r-- | src/video_out/video_out_xxmc.c | 251 |
16 files changed, 1020 insertions, 969 deletions
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index 34971377c..148eda84c 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -5,7 +5,7 @@ AM_LDFLAGS = $(xineplug_ldflags) SUBDIRS = libdha vidix macosx -EXTRA_DIST = video_out_directfb.c video_out_directx.c video_out_macosx.m +EXTRA_DIST = video_out_directfb.c video_out_directfb_fb.c video_out_directfb_x.c video_out_directx.c video_out_macosx.m VIDIX_CFLAGS = -I$(top_builddir)/src/video_out/vidix \ -I$(top_srcdir)/src/video_out/vidix @@ -64,6 +64,9 @@ endif if HAVE_DIRECTFB directfb_module = xineplug_vo_out_directfb.la +if HAVE_X11 +directfb_module += xineplug_vo_out_xdirectfb.la +endif endif if HAVE_SDL @@ -162,10 +165,14 @@ xineplug_vo_out_fb_la_SOURCES = yuv2rgb.c yuv2rgb_mmx.c yuv2rgb_mlib.c \ xineplug_vo_out_fb_la_LIBADD = $(MLIB_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) xineplug_vo_out_fb_la_CFLAGS = $(VISIBILITY_FLAG) $(MLIB_CFLAGS) -xineplug_vo_out_directfb_la_SOURCES = video_out_directfb.c $(X11OSD) -xineplug_vo_out_directfb_la_LIBADD = $(XINE_LIB) $(DIRECTFB_LIBS) $(X_LIBS) $(PTHREAD_LIBS) +xineplug_vo_out_directfb_la_SOURCES = video_out_directfb_fb.c +xineplug_vo_out_directfb_la_LIBADD = $(XINE_LIB) $(DIRECTFB_LIBS) $(PTHREAD_LIBS) xineplug_vo_out_directfb_la_CFLAGS = $(VISIBILITY_FLAG) $(DIRECTFB_CFLAGS) -fno-strict-aliasing +xineplug_vo_out_xdirectfb_la_SOURCES = video_out_directfb_x.c $(X11OSD) +xineplug_vo_out_xdirectfb_la_LIBADD = $(XINE_LIB) $(DIRECTFB_LIBS) $(X_LIBS) $(PTHREAD_LIBS) +xineplug_vo_out_xdirectfb_la_CFLAGS = $(VISIBILITY_FLAG) $(DIRECTFB_CFLAGS) -fno-strict-aliasing + xineplug_vo_out_sdl_la_SOURCES = video_out_sdl.c xineplug_vo_out_sdl_la_LIBADD = $(SDL_LIBS) $(X_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) xineplug_vo_out_sdl_la_CFLAGS = $(VISIBILITY_FLAG) $(X_CFLAGS) $(SDL_CFLAGS) diff --git a/src/video_out/deinterlace.h b/src/video_out/deinterlace.h index a9904b42a..6f398fcbd 100644 --- a/src/video_out/deinterlace.h +++ b/src/video_out/deinterlace.h @@ -41,7 +41,7 @@ void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc[], #define DEINTERLACE_ONEFIELDXV 5 #define DEINTERLACE_LINEARBLEND 6 -static const char *deinterlace_methods[] = { +static const char *const deinterlace_methods[] = { "none", "bob", "weave", diff --git a/src/video_out/macosx/XineOpenGLView.h b/src/video_out/macosx/XineOpenGLView.h index 063a33eb2..b63738047 100644 --- a/src/video_out/macosx/XineOpenGLView.h +++ b/src/video_out/macosx/XineOpenGLView.h @@ -23,6 +23,7 @@ #define __HAVE_XINE_OPENGL_VIEW_H__ #import <Cocoa/Cocoa.h> +#import <OpenGL/gl.h> #import "XineVideoWindow.h" @@ -32,74 +33,106 @@ extern NSString *XineViewDidResizeNotification; @interface XineOpenGLView : NSOpenGLView { + @private IBOutlet id <NSObject, XineOpenGLViewDelegate> delegate; - int video_width, video_height; - char *texture_buffer; - unsigned long i_texture; - BOOL initDone; - BOOL isFullScreen; - XineVideoWindowFullScreenMode fullscreen_mode; - NSOpenGLContext *fullScreenContext; - NSOpenGLContext *currentContext; - NSLock *mutex; - BOOL keepsVideoAspectRatio; - BOOL resizeViewOnVideoSizeChange; - NSCursor *currentCursor; - id <NSObject, XineOpenGLViewDelegate> _xineController; - NSColor *initialColor; - unsigned int initialColorYUV; - BOOL initialColorYUVIsSet; + IBOutlet id <NSObject, XineOpenGLViewDelegate> controller; + + NSRecursiveLock * mutex; + BOOL initDone; + + NSSize videoSize; + char * textureBuffer; + GLuint texture; + + BOOL keepsVideoAspectRatio; + BOOL resizeViewOnVideoSizeChange; + NSCursor * currentCursor; + + NSColor * initialColor; + unsigned int initialColorYUV; + BOOL initialColorYUVIsSet; + + BOOL isFullScreen; + BOOL isFullScreenPrepared; + XineVideoWindowFullScreenMode fullScreenMode; + NSOpenGLContext * fullScreenContext; } -- (void) displayTexture; -- (void) drawQuad; -- (void) drawRect: (NSRect) rect; -- (void) goFullScreen: (XineVideoWindowFullScreenMode) mode; -- (void) exitFullScreen; -- (BOOL) isFullScreen; -- (void) reshape; -- (void) initTextures; -- (void) reloadTexture; -- (char *) getTextureBuffer; -- (void) setViewSizeInMainThread:(NSSize)size; -// TODO: replace set...Size below with setSize:(double)videoSizeMultiplier -- (void) setNormalSize; -- (void) setHalfSize; -- (void) setDoubleSize; -- (void) setResizeViewOnVideoSizeChange:(BOOL)flag; -- (BOOL) resizeViewOnVideoSizeChange; -- (void) resetCursorRectsInMainThread; - -// Accessors -- (void) setVideoSize:(NSSize)size; -- (NSSize) videoSize; -- (void) setKeepsVideoAspectRatio:(BOOL)flag; -- (BOOL) keepsVideoAspectRatio; -- (void) setCurrentCursor:(NSCursor *)cursor; -- (NSCursor *) currentCursor; -- (void) setXineController:(id)controller; -- (id) xineController; -- (void) setInitialColor:(NSColor *)color; -- (NSColor *) initialColor; - -// Delegate Methods -- (id) delegate; -- (void) setDelegate:(id)aDelegate; ++ (NSOpenGLPixelFormat *)defaultPixelFormat; ++ (NSOpenGLPixelFormat *)fullScreenPixelFormat; -@end +- (id)initWithCoder:(NSCoder *)coder; +- (id)initWithFrame:(NSRect)frame; +- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat *)pixelFormat; -/* XineOpenGLView delegate methods */ +- (void)dealloc; + +- (void)encodeWithCoder:(NSCoder *)coder; + +- (NSOpenGLContext *)openGLContext; +- (void)prepareOpenGL; +- (void)reshape; +- (void)update; + +- (void)initTextures; +- (void)updateTexture; +- (void)drawRect:(NSRect)rect; + +- (NSColor *)initialColor; +- (void)setInitialColor:(NSColor *)color; + +- (void)setNormalSize; +- (void)setHalfSize; +- (void)setDoubleSize; -@interface NSObject (XineOpenGLViewDelegate) +- (NSSize)videoSize; -- (NSSize) xineViewWillResize:(NSSize)oldSize toSize:(NSSize)proposedSize; -- (void) xineViewDidResize:(NSNotification *)aNotification; -- (void) mouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (void) mouseMoved:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (void) otherMouseDown:(NSEvent *)theEvent - inXineView:(XineOpenGLView *)theView; -- (void) rightMouseDown:(NSEvent *)theEvent - inXineView:(XineOpenGLView *)theView; +- (BOOL)keepsVideoAspectRatio; +- (void)setKeepsVideoAspectRatio:(BOOL)flag; +- (BOOL)resizeViewOnVideoSizeChange; +- (void)setResizeViewOnVideoSizeChange:(BOOL)flag; + +- (void)setViewSize:(NSValue *)sizeWrapper; +- (void)setViewSizeInMainThread:(NSSize)size; + +- (NSCursor *)currentCursor; +- (void)setCurrentCursor:(NSCursor *)cursor; + +- (BOOL)isFullScreen; +- (void)goFullScreen:(XineVideoWindowFullScreenMode)mode; +- (void)exitFullScreen; + +- (id)delegate; +- (void)setDelegate:(id)aDelegate; +- (id)xineController; +- (void)setXineController:(id)aController; + +- (BOOL)acceptsFirstResponder; +- (BOOL)mouseDownCanMoveWindow; + +// Not intended for public use: +- (char *)textureBuffer; +- (void)setVideoSize:(NSSize)size; +- (void)resetCursorRects; +- (void)resetCursorRectsInMainThread; +- (void)calcFullScreenAspect; +- (void)releaseInMainThread; +- (void)passEventToDelegate:(NSEvent *)theEvent withSelector:(SEL)selector; + +- (BOOL)acceptsFirstResponder; +- (BOOL)mouseDownCanMoveWindow; + +@end + +/* XineOpenGLView delegate methods */ +@protocol XineOpenGLViewDelegate + +- (void)mouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; +- (void)mouseMoved:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; +- (void)otherMouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; +- (void)rightMouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; +- (NSSize)xineViewWillResize:(NSSize)oldSize toSize:(NSSize)proposedSize; +- (void)xineViewDidResize:(NSNotification *)note; @end diff --git a/src/video_out/macosx/XineOpenGLView.m b/src/video_out/macosx/XineOpenGLView.m index e939575a0..c29f95dc7 100644 --- a/src/video_out/macosx/XineOpenGLView.m +++ b/src/video_out/macosx/XineOpenGLView.m @@ -19,7 +19,6 @@ * */ - /* #define LOG */ @@ -37,700 +36,411 @@ # include <xine/xineutils.h> #endif +NSString *XineViewDidResizeNotification EXPORTED = @"XineViewDidResizeNotification"; -NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; - - -/* XineOpenGLView delegate methods */ - -@protocol XineOpenGLViewDelegate - -- (void) mouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (void) mouseMoved:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (void) otherMouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (void) rightMouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; -- (NSSize) xineViewWillResize:(NSSize)oldSize toSize:(NSSize)proposedSize; -- (void) xineViewDidResize:(NSNotification *)note; - -@end - +static uint32_t +NSColorToYUV(NSColor *color) +{ + float red, green, blue, alpha; + uint32_t yuv; + unsigned char r, g, b; + unsigned char y, u, v; -static uint32_t NSColorToYUV (NSColor *color); + NSColor *calibratedColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + [calibratedColor getRed:&red green:&green blue:&blue alpha:&alpha]; + r = red * 255; + g = green * 255; + b = blue * 255; -@implementation XineOpenGLView + init_yuv_conversion(); -- (void) setKeepsVideoAspectRatio:(BOOL)flag -{ - keepsVideoAspectRatio = flag; -} + y = COMPUTE_Y(r, g, b); + u = COMPUTE_U(r, g, b); + v = COMPUTE_V(r, g, b); -- (BOOL) keepsVideoAspectRatio -{ - return keepsVideoAspectRatio; + yuv = (y << 24) | (u << 16) | (y << 8) | v; + return yuv; } -- (void) setResizeViewOnVideoSizeChange:(BOOL)flag -{ - resizeViewOnVideoSizeChange = flag; -} +@implementation XineOpenGLView -- (BOOL) resizeViewOnVideoSizeChange ++ (NSOpenGLPixelFormat *)defaultPixelFormat { - return resizeViewOnVideoSizeChange; -} + NSOpenGLPixelFormatAttribute attributes[] = { + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAColorSize, 24, + NSOpenGLPFAAlphaSize, 8, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAWindow, + 0 + }; -- (BOOL)mouseDownCanMoveWindow -{ - return YES; + return [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease]; } -- (void)passEventToDelegate:(NSEvent *)theEvent withSelector:(SEL)selector ++ (NSOpenGLPixelFormat *)fullScreenPixelFormat { - NSPoint point = [self convertPoint:[theEvent locationInWindow] - fromView:nil]; - - if (!NSMouseInRect(point, [self bounds], [self isFlipped])) return; - - if ([delegate respondsToSelector:selector]) - { - [delegate performSelector:selector - withObject:theEvent - withObject:self]; - return; - } + NSOpenGLPixelFormatAttribute attributes[] = { + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAColorSize, 24, + NSOpenGLPFAAlphaSize, 8, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAFullScreen, + NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), + 0 + }; - if ([_xineController respondsToSelector:selector]) - { - [_xineController performSelector:selector - withObject:theEvent - withObject:self]; - return; - } + return [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease]; } -- (void)mouseMoved:(NSEvent *)theEvent +- (id)initWithCoder:(NSCoder *)coder { - [self passEventToDelegate:theEvent - withSelector:@selector(mouseMoved:inXineView:)]; - - [super mouseMoved:theEvent]; -} + NSColor *color; -- (void)mouseDown:(NSEvent *)theEvent -{ - [self passEventToDelegate:theEvent - withSelector:@selector(mouseDown:inXineView:)]; - - [super mouseDown:theEvent]; -} + if ((self = [super initWithCoder:coder]) != nil) { + videoSize = [self frame].size; + mutex = [[NSRecursiveLock alloc] init]; + currentCursor = [[NSCursor arrowCursor] retain]; -- (void)rightMouseDown:(NSEvent *)theEvent -{ - [self passEventToDelegate:theEvent - withSelector:@selector(rightMouseDown:inXineView:)]; - - [super rightMouseDown:theEvent]; -} + if ([coder allowsKeyedCoding]) { + keepsVideoAspectRatio = [coder decodeBoolForKey:@"keepsVideoAspectRatio"]; + resizeViewOnVideoSizeChange = [coder decodeBoolForKey:@"resizeViewOnVideoSizeChange"]; + color = [coder decodeObjectForKey:@"initialColor"]; + } + else { /* Must decode values in the same order as encodeWithCoder: */ + [coder decodeValueOfObjCType:@encode(BOOL) at:&keepsVideoAspectRatio]; + [coder decodeValueOfObjCType:@encode(BOOL) at:&resizeViewOnVideoSizeChange]; + color = [coder decodeObject]; + } + [self setInitialColor:color]; -- (void)otherMouseDown:(NSEvent *)theEvent -{ - [self passEventToDelegate:theEvent - withSelector:@selector(otherMouseDown:inXineView:)]; - - [super otherMouseDown:theEvent]; +#ifdef LOG + NSLog(@"XineOpenGLView: initWithCoder called"); +#endif + } + return self; } -- (NSSize)videoSize +- (id)initWithFrame:(NSRect)frame { - return NSMakeSize(video_width, video_height); -} - -- (void) displayTexture { - if ([self lockFocusIfCanDraw]) - { - [self drawRect: [self bounds]]; - [self reloadTexture]; - [self unlockFocus]; - } + return [self initWithFrame:frame pixelFormat:[[self class] defaultPixelFormat]]; } -- (id) initWithFrame: (NSRect) frame +- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat *)format { - NSOpenGLPixelFormatAttribute attribs[] = { - NSOpenGLPFAAccelerated, - NSOpenGLPFANoRecovery, - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAColorSize, 24, - NSOpenGLPFAAlphaSize, 8, - NSOpenGLPFADepthSize, 24, - NSOpenGLPFAWindow, - 0 - }; - - NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] - initWithAttributes: attribs]; - - if (!fmt) - { - NSLog (@"Cannot create NSOpenGLPixelFormat\n"); - return nil; - } - - self = [super initWithFrame:frame pixelFormat:fmt]; - - currentContext = [self openGLContext]; - [currentContext makeCurrentContext]; - [mutex lock]; - [currentContext update]; - [mutex unlock]; - - i_texture = 0; - initDone = NO; - isFullScreen = NO; - video_width = frame.size.width; - video_height = frame.size.height; - texture_buffer = nil; - mutex = [[NSLock alloc] init]; - currentCursor = [[NSCursor arrowCursor] retain]; - initialColor = nil; - initialColorYUV = 0; - initialColorYUVIsSet = NO; - _xineController = nil; - - [self initTextures]; - - /* Set GL_COLOR_BUFFER_BIT to black */ - glClearColor (0.0, 0.0, 0.0, 0.0); + format = (format ? : [[self class] defaultPixelFormat]); + if ((self = [super initWithFrame:frame pixelFormat:format]) != nil) { + videoSize = frame.size; + mutex = [[NSRecursiveLock alloc] init]; + currentCursor = [[NSCursor arrowCursor] retain]; + [self setInitialColor:nil]; #ifdef LOG - NSLog(@"XineOpenGLView: initWithFrame called"); + NSLog(@"XineOpenGLView: initWithFrame called"); #endif - + } return self; } -- (void) awakeFromNib -{ -#ifdef LOG - NSLog(@"XineOpenGLView: awakeFromNib called"); -#endif -} - -- (id) initWithCoder:(NSCoder *)coder +- (void)dealloc { - self = [super initWithCoder:coder]; - - self = [self initWithFrame:[self frame]]; - - if ([coder allowsKeyedCoding]) - { - keepsVideoAspectRatio = [coder decodeBoolForKey:@"keepsVideoAspectRatio"]; - resizeViewOnVideoSizeChange = [coder decodeBoolForKey: - @"resizeViewOnVideoSizeChange"]; - - NSColor *color = [coder decodeObjectForKey:@"initialColor"]; - if (color) - initialColor = [color copy]; + if (isFullScreen) { + [self exitFullScreen]; } - else - { - /* Must decode values in the same order as encodeWithCoder: */ - [coder decodeValueOfObjCType:@encode(BOOL) at:&keepsVideoAspectRatio]; - [coder decodeValueOfObjCType:@encode(BOOL) at:&resizeViewOnVideoSizeChange]; - NSColor *color = [coder decodeObject]; - if (color) - initialColor = [color copy]; + if (texture) { + [[self openGLContext] makeCurrentContext]; + glDeleteTextures(1, &texture); + texture = 0; } + free(textureBuffer); - [self initTextures]; + [currentCursor release], currentCursor = nil; + [initialColor release], initialColor = nil; + [delegate release], delegate = nil; + [controller release], controller = nil; + [mutex release], mutex = nil; -#ifdef LOG - NSLog(@"XineOpenGLView: initWithCoder called"); -#endif - - return self; + [super dealloc]; } -- (void) encodeWithCoder:(NSCoder *)coder +- (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - if ([coder allowsKeyedCoding]) - { + if ([coder allowsKeyedCoding]) { [coder encodeBool:keepsVideoAspectRatio forKey:@"keepsVideoAspectRatio"]; - [coder encodeBool:resizeViewOnVideoSizeChange - forKey:@"resizeViewOnVideoSizeChange"]; + [coder encodeBool:resizeViewOnVideoSizeChange forKey:@"resizeViewOnVideoSizeChange"]; [coder encodeObject:initialColor forKey:@"initialColor"]; } - else - { + else { [coder encodeValueOfObjCType:@encode(BOOL) at:&keepsVideoAspectRatio]; [coder encodeValueOfObjCType:@encode(BOOL) at:&resizeViewOnVideoSizeChange]; [coder encodeObject:initialColor]; } } -- (void) dealloc { - if (texture_buffer) - free (texture_buffer); - - if (fullScreenContext) - { - [NSOpenGLContext clearCurrentContext]; - [mutex lock]; - [fullScreenContext clearDrawable]; - [fullScreenContext release]; - [mutex unlock]; - if (currentContext == fullScreenContext) currentContext = nil; - fullScreenContext = nil; - } - - if (currentContext) - { - [NSOpenGLContext clearCurrentContext]; - [mutex lock]; - [currentContext clearDrawable]; - [currentContext release]; - [mutex unlock]; - currentContext = nil; - } - - [mutex dealloc]; +- (NSOpenGLContext *)openGLContext +{ + NSOpenGLContext *context; - if (currentCursor) - { - [currentCursor release]; - currentCursor = NULL; + [mutex lock]; + if (!(context = [[fullScreenContext retain] autorelease])) { + context = [[[super openGLContext] retain] autorelease]; } - - if (initialColor) - { - [initialColor release]; - initialColor = NULL; + else if (!isFullScreenPrepared) { + [self prepareOpenGL]; + isFullScreenPrepared = YES; } + [mutex unlock]; - // Enabling the [super dealloc] below (which should be correct behaviour) - // crashes -- not sure why ... - // - // [super dealloc]; - // - // Maybe dealloc in main thread? + return context; } -- (void) reshape +// NOTE: This does not exist prior to Panther (10.3) +- (void)prepareOpenGL { + long swapInterval = 1; + [mutex lock]; - - if (!initDone) - { - [mutex unlock]; - return; - } - - [currentContext makeCurrentContext]; - - NSRect bounds = [self bounds]; - glViewport (0, 0, bounds.size.width, bounds.size.height); - -#ifdef LOG - NSLog(@"XineOpenGLView: Reshape: %x%x%x%x%x%x%x%x", - texture_buffer[0], - texture_buffer[1], - texture_buffer[2], - texture_buffer[3], - texture_buffer[4], - texture_buffer[5], - texture_buffer[6], - texture_buffer[7] - ); -#endif + [super prepareOpenGL]; + + [[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; + + [self initTextures]; + + /* Set GL_COLOR_BUFFER_BIT to black */ + glClearColor (0.0, 0.0, 0.0, 0.0); [mutex unlock]; } -- (void) setNormalSize +- (void)reshape { - NSSize size; - - if (isFullScreen) - return; - - size.width = video_width; - size.height = video_height; - - [self setViewSizeInMainThread:size]; + [mutex lock]; + [super reshape]; + if (initDone) { + [[self openGLContext] makeCurrentContext]; + + NSRect bounds = [self bounds]; + glViewport(0, 0, bounds.size.width, bounds.size.height); + +#ifdef LOG + NSLog(@"XineOpenGLView: Reshape: %x%x%x%x%x%x%x%x", + textureBuffer[0], textureBuffer[1], textureBuffer[2], textureBuffer[3], + textureBuffer[4], textureBuffer[5], textureBuffer[6], textureBuffer[7]); +#endif + } + [mutex unlock]; } -- (void) setHalfSize +- (void)update { - NSSize size; - - if (isFullScreen) - return; - - size.width = video_width / 2; - size.height = video_height / 2; - - [self setViewSizeInMainThread:size]; + [mutex lock]; + [super update]; + [mutex unlock]; } -- (void) setDoubleSize +- (void)initTextures { - NSSize size; - - if (isFullScreen) - return; - - size.width = video_width * 2; - size.height = video_height * 2; - - [self setViewSizeInMainThread:size]; -} + uint32_t *p, *q, yuv; -- (void) initTextures -{ [mutex lock]; - [currentContext makeCurrentContext]; - /* Free previous texture if any */ - if (i_texture) - glDeleteTextures (1, &i_texture); + if (texture) { + glDeleteTextures(1, &texture); + texture = 0; + } - if (texture_buffer) - { - texture_buffer = realloc (texture_buffer, sizeof (char) * - video_width * video_height * 3); + if (!initialColorYUVIsSet && initialColor) { + initialColorYUV = NSColorToYUV(initialColor); + initialColorYUVIsSet = YES; } - else - { - texture_buffer = malloc (sizeof (char) * - video_width * video_height * 3); - - { - // There _has_ to be a better way of doing this ... - - uint32_t *p, *q; - p = (uint32_t *) texture_buffer; - q = (uint32_t *) (char *) (texture_buffer + (sizeof(char) * video_width * video_height * 3)); - - for (; p < q; p++) *p = initialColorYUV; - } + if (textureBuffer) { + textureBuffer = (char *)realloc(textureBuffer, videoSize.width * videoSize.height * 4); } + else { + textureBuffer = (char *)malloc(videoSize.width * videoSize.height * 4); - if (!initialColorYUVIsSet && initialColor) - { - initialColorYUV = NSColorToYUV(initialColor); - initialColorYUVIsSet = YES; + // There _has_ to be a better way of doing this ... + + yuv = OSSwapHostToBigInt32(initialColorYUV); + q = (uint32_t *)(char *)(textureBuffer + (int)(videoSize.width * videoSize.height * 4)); + for (p = (uint32_t *)textureBuffer; p < q; *p++ = yuv); } /* Create textures */ - glGenTextures (1, &i_texture); + glGenTextures(1, &texture); - glEnable (GL_TEXTURE_RECTANGLE_EXT); - glEnable (GL_UNPACK_CLIENT_STORAGE_APPLE); + glEnable(GL_TEXTURE_RECTANGLE_EXT); + glEnable(GL_UNPACK_CLIENT_STORAGE_APPLE); - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glPixelStorei (GL_UNPACK_ROW_LENGTH, video_width); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, videoSize.width); - glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texture); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); /* Use VRAM texturing */ - glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, + GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); /* Tell the driver not to make a copy of the texture but to use our buffer */ - glPixelStorei (GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); + glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); /* Linear interpolation */ - glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, + GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, + GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* I have no idea what this exactly does, but it seems to be necessary for scaling */ - glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, - video_width, video_height, 0, - GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, - texture_buffer); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, + GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, + GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, + videoSize.width, videoSize.height, 0, GL_YCBCR_422_APPLE, +#if WORDS_BIGENDIAN + GL_UNSIGNED_SHORT_8_8_APPLE, +#else + GL_UNSIGNED_SHORT_8_8_REV_APPLE, +#endif + textureBuffer); initDone = YES; [mutex unlock]; #ifdef LOG NSLog(@"XineOpenGLView: initTextures called: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx", - texture_buffer[0], - texture_buffer[1], - texture_buffer[2], - texture_buffer[3], - texture_buffer[4], - texture_buffer[5], - texture_buffer[6], - texture_buffer[7] - ); + textureBuffer[0], textureBuffer[1], textureBuffer[2], textureBuffer[3], + textureBuffer[4], textureBuffer[5], textureBuffer[6], textureBuffer[7]); #endif } -- (void) reloadTexture +- (void)updateTexture { - if (!initDone) - { - return; - } - [mutex lock]; - - [currentContext makeCurrentContext]; - - glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); - glPixelStorei (GL_UNPACK_ROW_LENGTH, video_width); - + [[self openGLContext] makeCurrentContext]; + + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texture); + glPixelStorei(GL_UNPACK_ROW_LENGTH, videoSize.width); + // glTexSubImage2D is faster than glTexImage2D // http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/TextureRange/MainOpenGLView.m.htm - glTexSubImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, - video_width, video_height, - GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, - texture_buffer); - - [mutex unlock]; - -#ifdef LOG - NSLog(@"reloadTexture called"); + glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, + videoSize.width, videoSize.height, GL_YCBCR_422_APPLE, +#if WORDS_BIG_ENDIAN + GL_UNSIGNED_SHORT_8_8_APPLE, +#else + GL_UNSIGNED_SHORT_8_8_REV_APPLE, #endif + textureBuffer); + + [self setNeedsDisplay:YES]; + [mutex unlock]; } -- (void) calcFullScreenAspect +- (void)drawRect:(NSRect)rect { - int fs_width, fs_height, x = 0, y = 0, w = 0, h = 0; - - fs_width = CGDisplayPixelsWide (kCGDirectMainDisplay); - fs_height = CGDisplayPixelsHigh (kCGDirectMainDisplay); - - switch (fullscreen_mode) { - case XINE_FULLSCREEN_OVERSCAN: - if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) - { - w = (float) video_width * ((float) fs_height / (float) video_height); - h = fs_height; - x = (fs_width - w) / 2; - y = 0; - } - else - { - w = fs_width; - h = (float) video_height * ((float) fs_width / (float) video_width); - x = 0; - y = (fs_height - h) / 2; - } - break; - - case XINE_FULLSCREEN_CROP: - if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) - { - w = fs_width; - h = (float) video_height * ((float) fs_width / (float) video_width); - x = 0; - y = (fs_height - h) / 2; - } - else - { - w = (float) video_width * ((float) fs_height / (float) video_height); - h = fs_height; - x = (fs_width - w) / 2; - y = 0; - } - break; - } - - NSLog(@"MacOSX fullscreen mode: %dx%d => %dx%d @ %d,%d\n", - video_width, video_height, w, h, x, y); - [mutex lock]; - glViewport (x, y, w, h); + if (initDone && texture) { + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texture); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, 1.0); // top left + glTexCoord2f(0.0, videoSize.height); glVertex2f(-1.0, -1.0); // bottom left + glTexCoord2f(videoSize.width, videoSize.height); glVertex2f( 1.0, -1.0); // bottom right + glTexCoord2f(videoSize.width, 0.0); glVertex2f( 1.0, 1.0); // top right + glEnd(); + [[self openGLContext] flushBuffer]; + } [mutex unlock]; } -- (void) goFullScreen: (XineVideoWindowFullScreenMode) mode +- (NSColor *)initialColor +{ + return initialColor; +} + +- (void) setInitialColor:(NSColor *)color +{ + [initialColor autorelease]; + initialColor = (color ? [color copy] : [[NSColor blackColor] retain]); +} + +- (void)setNormalSize { [mutex lock]; - - /* Create the new pixel format */ - NSOpenGLPixelFormatAttribute attribs[] = - { - NSOpenGLPFAAccelerated, - NSOpenGLPFANoRecovery, - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAColorSize, 24, - NSOpenGLPFAAlphaSize, 8, - NSOpenGLPFADepthSize, 24, - NSOpenGLPFAFullScreen, - NSOpenGLPFAScreenMask, - CGDisplayIDToOpenGLDisplayMask (kCGDirectMainDisplay), - 0 - }; - - NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] - initWithAttributes: attribs]; - - if (!fmt) - { - NSLog (@"Cannot create NSOpenGLPixelFormat\n"); - return; - } - - /* Create the new OpenGL context */ - fullScreenContext = [[NSOpenGLContext alloc] - initWithFormat: fmt shareContext: nil]; - - if (!fullScreenContext) - { - NSLog(@"Failed to create new NSOpenGLContext\n"); - return; + if (!isFullScreen) { + [self setViewSizeInMainThread:videoSize]; } - currentContext = fullScreenContext; - - /* Capture display, switch to fullscreen */ - if (CGCaptureAllDisplays() != CGDisplayNoErr) - { - NSLog(@"CGCaptureAllDisplays() failed\n"); - return; - } - - [fullScreenContext setFullScreen]; - [fullScreenContext makeCurrentContext]; [mutex unlock]; - - fullscreen_mode = mode; - - [self initTextures]; - [self calcFullScreenAspect]; - - /* Redraw the last picture */ - [self setNeedsDisplay: YES]; - - isFullScreen = YES; } -- (void) exitFullScreen +- (void)setHalfSize { - initDone = NO; - - currentContext = [self openGLContext]; - - /* Free current OpenGL context */ - [NSOpenGLContext clearCurrentContext]; + NSSize size; + [mutex lock]; - [fullScreenContext clearDrawable]; + if (!isFullScreen) { + size.width = trunc(videoSize.width / 2); + size.height = trunc(videoSize.height / 2); + [self setViewSizeInMainThread:size]; + } [mutex unlock]; - [fullScreenContext release]; - fullScreenContext = nil; - CGReleaseAllDisplays(); - - [self reshape]; - [self initTextures]; - - /* Redraw the last picture */ - [self setNeedsDisplay: YES]; - - isFullScreen = NO; - initDone = YES; } -- (void) drawQuad +- (void)setDoubleSize { - float f_x = 1.0, f_y = 1.0; - - glBegin (GL_QUADS); - /* Top left */ - glTexCoord2f (0.0, 0.0); - glVertex2f (-f_x, f_y); - /* Bottom left */ - glTexCoord2f (0.0, (float) video_height); - glVertex2f (-f_x, -f_y); - /* Bottom right */ - glTexCoord2f ((float) video_width, (float) video_height); - glVertex2f (f_x, -f_y); - /* Top right */ - glTexCoord2f ((float) video_width, 0.0); - glVertex2f (f_x, f_y); - glEnd(); -} - -- (void) drawRect: (NSRect) rect -{ - [currentContext makeCurrentContext]; - - if (!initDone) - return; - + NSSize size; + [mutex lock]; - - // Swap buffers only during the vertical retrace of the monitor. - // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL/chap5/chapter_5_section_44.html - - long params[] = { 1 }; - CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, params); - - /* Draw */ - glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); - [self drawQuad]; - - /* Wait for the job to be done */ - [currentContext flushBuffer]; - + if (!isFullScreen) { + size.width = videoSize.width * 2; + size.height = videoSize.height * 2; + [self setViewSizeInMainThread:size]; + } [mutex unlock]; } -- (char *) getTextureBuffer +- (NSSize)videoSize { - return texture_buffer; + return videoSize; } -- (void) setVideoSize:(NSSize)size +- (BOOL)keepsVideoAspectRatio { - video_width = size.width; - video_height = size.height; - - if (resizeViewOnVideoSizeChange) - [self setViewSizeInMainThread:size]; - - [self initTextures]; + return keepsVideoAspectRatio; } -- (void) setViewSizeInMainThread:(NSSize)size +- (void)setKeepsVideoAspectRatio:(BOOL)flag { - // Create an autorelease pool, since we're running in a xine thread that - // may not have a pool of its own */ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSValue *sizeWrapper = [NSValue valueWithBytes:&size - objCType:@encode(NSSize)]; - - [self performSelectorOnMainThread:@selector(setViewSize:) - withObject:sizeWrapper - waitUntilDone:NO]; - -#ifdef LOG - NSLog(@"setViewSizeInMainThread called"); -#endif - - [pool release]; + keepsVideoAspectRatio = flag; +} + +- (BOOL)resizeViewOnVideoSizeChange +{ + return resizeViewOnVideoSizeChange; +} + +- (void)setResizeViewOnVideoSizeChange:(BOOL)flag +{ + resizeViewOnVideoSizeChange = flag; } -- (void) setViewSize:(NSValue *)sizeWrapper +- (void)setViewSize:(NSValue *)sizeWrapper { - NSSize proposedSize, newSize, currentSize; + NSSize currentSize, newSize, proposedSize; [sizeWrapper getValue:&proposedSize]; newSize = proposedSize; @@ -742,19 +452,17 @@ static uint32_t NSColorToYUV (NSColor *color); return; } - /* If our controller handles xineViewWillResize:toSize:, send the - * message to him first. Note that the delegate still has a chance - * to override the controller's resize preference ... */ - if ([_xineController respondsToSelector:@selector(xineViewWillResize:toSize:)]) - { + // If our controller handles xineViewWillResize:toSize:, send the + // message to him first. Note that the delegate still has a chance + // to override the controller's resize preference ... + if ([controller respondsToSelector:@selector(xineViewWillResize:toSize:)]) { NSSize oldSize = [self frame].size; - newSize = [_xineController xineViewWillResize:oldSize toSize:proposedSize]; + newSize = [controller xineViewWillResize:oldSize toSize:proposedSize]; } - /* If our delegate handles xineViewWillResize:toSize:, send the - * message to him; otherwise, just resize ourselves */ - if ([delegate respondsToSelector:@selector(xineViewWillResize:toSize:)]) - { + // If our delegate handles xineViewWillResize:toSize:, send the + // message to him; otherwise, just resize ourselves + if ([delegate respondsToSelector:@selector(xineViewWillResize:toSize:)]) { NSSize oldSize = [self frame].size; newSize = [delegate xineViewWillResize:oldSize toSize:proposedSize]; } @@ -769,110 +477,294 @@ static uint32_t NSColorToYUV (NSColor *color); object:self]; [[NSNotificationCenter defaultCenter] postNotification:note]; - if ([_xineController respondsToSelector:@selector(xineViewDidResize:)]) - [_xineController xineViewDidResize:note]; + if ([controller respondsToSelector:@selector(xineViewDidResize:)]) { + [controller xineViewDidResize:note]; + } - if ([delegate respondsToSelector:@selector(xineViewDidResize:)]) + if ([delegate respondsToSelector:@selector(xineViewDidResize:)]) { [delegate xineViewDidResize:note]; - - if (isFullScreen) + } + + [mutex lock]; + [[self openGLContext] makeCurrentContext]; + if (isFullScreen) { [self calcFullScreenAspect]; - + } [self initTextures]; + [mutex unlock]; +} + +- (void)setViewSizeInMainThread:(NSSize)size +{ + // Create an autorelease pool, since we're running in a xine thread that + // may not have a pool of its own + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSValue *sizeWrapper = [NSValue valueWithBytes:&size + objCType:@encode(NSSize)]; + + [self performSelectorOnMainThread:@selector(setViewSize:) + withObject:sizeWrapper + waitUntilDone:NO]; + +#ifdef LOG + NSLog(@"setViewSizeInMainThread called"); +#endif + + [pool release]; +} + +- (NSCursor *)currentCursor +{ + return currentCursor; +} + +- (void)setCurrentCursor:(NSCursor *)cursor +{ + [currentCursor autorelease]; + currentCursor = [cursor retain]; + [self resetCursorRectsInMainThread]; } -- (BOOL) isFullScreen +- (BOOL)isFullScreen { return isFullScreen; } -- (id) delegate +- (void)goFullScreen:(XineVideoWindowFullScreenMode)mode { - return delegate; + NSOpenGLPixelFormat *pixelFormat; + + if (!(pixelFormat = [[self class] fullScreenPixelFormat])) { + NSLog(@"Cannot create NSOpenGLPixelFormat for full screen mode"); + return; + } + + if (!(fullScreenContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil])) { + NSLog(@"Cannot create NSOpenGLContext for full screen mode"); + return; + } + + if (CGCaptureAllDisplays() != CGDisplayNoErr) { + [fullScreenContext release], fullScreenContext = nil; + NSLog(@"CGCaptureAllDisplays() failed"); + return; + } + + [mutex lock]; + fullScreenMode = mode; + isFullScreenPrepared = NO; + + [fullScreenContext setFullScreen]; + [[self openGLContext] makeCurrentContext]; + + // Redraw the last picture + [self setNeedsDisplay:YES]; + + isFullScreen = YES; + [mutex unlock]; } -- (void) setDelegate:(id)aDelegate { - delegate = aDelegate; +- (void)exitFullScreen +{ + NSOpenGLContext *context; + + [mutex lock]; + if (isFullScreen) { + context = fullScreenContext; + fullScreenContext = nil; + [[self openGLContext] makeCurrentContext]; + + [context clearDrawable]; + [context release]; + + [self reshape]; + [self initTextures]; + + CGReleaseAllDisplays(); + [self setNeedsDisplay:YES]; + isFullScreen = NO; + } + [mutex unlock]; } -- (BOOL)acceptsFirstResponder { - return YES; +- (id)delegate +{ + return [[delegate retain] autorelease]; } -- (void) setCurrentCursor:(NSCursor *)cursor +- (void)setDelegate:(id)aDelegate { - currentCursor = cursor; - [currentCursor retain]; - [self resetCursorRectsInMainThread]; + [delegate autorelease]; + delegate = [aDelegate retain]; } -- (NSCursor *) currentCursor +- (id)xineController { - return currentCursor; + return controller; } -- (void) resetCursorRectsInMainThread +- (void)setXineController:(id)aController { - [self discardCursorRects]; - [self performSelectorOnMainThread:@selector(resetCursorRects) - withObject:nil - waitUntilDone:NO]; + [controller autorelease]; + controller = [aController retain]; } -- (void) resetCursorRects +- (char *)textureBuffer { - [self addCursorRect:[self visibleRect] cursor:currentCursor]; - [currentCursor set]; + return textureBuffer; } -- (void) setXineController:(id)controller +- (void)setVideoSize:(NSSize)size { - [_xineController autorelease]; - _xineController = controller; - [_xineController retain]; + [mutex lock]; + videoSize = size; + if (resizeViewOnVideoSizeChange) { + [self setViewSizeInMainThread:size]; + } + + if (initDone) { + [[self openGLContext] makeCurrentContext]; + [self initTextures]; + } + [mutex unlock]; } -- (id) xineController +- (void)resetCursorRects { - return _xineController; + [mutex lock]; + [self discardCursorRects]; + [self addCursorRect:[self visibleRect] cursor:currentCursor]; + [currentCursor set]; + [mutex unlock]; } -- (void) setInitialColor:(NSColor *)color +- (void)resetCursorRectsInMainThread { - [initialColor autorelease]; - initialColor = [color copy]; + [self performSelectorOnMainThread:@selector(resetCursorRects) + withObject:nil + waitUntilDone:NO]; } -- (NSColor *) initialColor +- (void)releaseInMainThread { - return initialColor; + [self performSelectorOnMainThread:@selector(release) + withObject:nil + waitUntilDone:NO]; } -@end /* XineOpenGLView */ +- (void)calcFullScreenAspect +{ + float fs_height, fs_width, h, w, x, y; + + // Feh, should go to main or should go to current display of window? + fs_width = CGDisplayPixelsWide(kCGDirectMainDisplay); + fs_height = CGDisplayPixelsHigh(kCGDirectMainDisplay); + + switch (fullScreenMode) { + case XINE_FULLSCREEN_OVERSCAN: + if ((fs_width / fs_height) > (videoSize.width / videoSize.height)) { + w = videoSize.width * (fs_height / videoSize.height); + h = fs_height; + x = (fs_width - w) / 2; + y = 0; + } + else { + w = fs_width; + h = videoSize.height * (fs_width / videoSize.width); + x = 0; + y = (fs_height - h) / 2; + } + break; + + case XINE_FULLSCREEN_CROP: + if ((fs_width / fs_height) > (videoSize.width / videoSize.height)) { + w = fs_width; + h = videoSize.height * (fs_width / videoSize.width); + x = 0; + y = (fs_height - h) / 2; + } + else { + w = videoSize.width * (fs_height / videoSize.height); + h = fs_height; + x = (fs_width - w) / 2; + y = 0; + } + break; + + default: + NSLog(@"Mac OS X fullscreen mode unrecognized: %d", fullScreenMode); + return; + } + +#ifdef LOG + NSLog(@"Mac OS X fullscreen mode: %fx%f => %fx%f @ %f,%f\n", + videoSize.width, videoSize.height, w, h, x, y); +#endif + // Assumes locked and current context set + glViewport(x, y, w, h); +} -static uint32_t NSColorToYUV (NSColor *color) +- (void)passEventToDelegate:(NSEvent *)theEvent withSelector:(SEL)selector { - float red, green, blue, alpha; - unsigned char r, g, b; - unsigned char y, u, v; - uint32_t yuv; + NSPoint point = [self convertPoint:[theEvent locationInWindow] + fromView:nil]; + + if (NSMouseInRect(point, [self bounds], [self isFlipped])) { + if ([delegate respondsToSelector:selector]) { + [delegate performSelector:selector + withObject:theEvent + withObject:self]; + } + else if ([controller respondsToSelector:selector]) { + [controller performSelector:selector + withObject:theEvent + withObject:self]; + } + } +} - NSColor *calibratedColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; - [calibratedColor getRed:&red green:&green blue:&blue alpha:&alpha]; +- (void)mouseMoved:(NSEvent *)theEvent +{ + [self passEventToDelegate:theEvent + withSelector:@selector(mouseMoved:inXineView:)]; + + [super mouseMoved:theEvent]; +} - r = red * 255; - g = green * 255; - b = blue * 255; +- (void)mouseDown:(NSEvent *)theEvent +{ + [self passEventToDelegate:theEvent + withSelector:@selector(mouseDown:inXineView:)]; + + [super mouseDown:theEvent]; +} - init_yuv_conversion(); +- (void)rightMouseDown:(NSEvent *)theEvent +{ + [self passEventToDelegate:theEvent + withSelector:@selector(rightMouseDown:inXineView:)]; + + [super rightMouseDown:theEvent]; +} - y = COMPUTE_Y(r, g, b); - u = COMPUTE_U(r, g, b); - v = COMPUTE_V(r, g, b); +- (void)otherMouseDown:(NSEvent *)theEvent +{ + [self passEventToDelegate:theEvent + withSelector:@selector(otherMouseDown:inXineView:)]; + + [super otherMouseDown:theEvent]; +} - yuv = y << 24 | u << 16 | y << 8 | v; +- (BOOL)acceptsFirstResponder +{ + return YES; +} - return yuv; +- (BOOL)mouseDownCanMoveWindow +{ + return YES; } +@end diff --git a/src/video_out/macosx/XineVideoWindow.m b/src/video_out/macosx/XineVideoWindow.m index b61a5b418..0dd2caa28 100644 --- a/src/video_out/macosx/XineVideoWindow.m +++ b/src/video_out/macosx/XineVideoWindow.m @@ -108,7 +108,7 @@ } -- (XineOpenGLView *) xineView +- (id) xineView { return xineView; } diff --git a/src/video_out/video_out_directfb.c b/src/video_out/video_out_directfb.c index a51940952..a374c56de 100644 --- a/src/video_out/video_out_directfb.c +++ b/src/video_out/video_out_directfb.c @@ -31,7 +31,7 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 # include <X11/Xlib.h> #endif @@ -44,7 +44,7 @@ #include "xineutils.h" #include "vo_scale.h" -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 # include "x11osd.h" #endif @@ -118,7 +118,7 @@ typedef struct directfb_driver_s { int flicker_filtering; int field_parity; -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 /* X11 related stuff */ Display *display; int screen; @@ -317,7 +317,7 @@ static void directfb_update_frame_format (vo_driver_t *this_gen, frame->ratio = ratio; } -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 static uint32_t directfb_colorkey_to_pixel (directfb_driver_t *this) { switch (this->depth) { case 8: @@ -343,7 +343,7 @@ static uint32_t directfb_colorkey_to_pixel (directfb_driver_t *this) { static void directfb_clean_output_area (directfb_driver_t *this) { if (this->visual_type == XINE_VISUAL_TYPE_X11 || this->visual_type == XINE_VISUAL_TYPE_X11_2) { -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->config.options & DLOP_DST_COLORKEY) { int i; @@ -410,7 +410,7 @@ static void directfb_overlay_begin (vo_driver_t *this_gen, this->ovl_changed += changed; if (this->ovl_changed) { -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->xoverlay) { LOCK_DISPLAY(); x11osd_clear (this->xoverlay); @@ -554,7 +554,7 @@ static void directfb_overlay_blend (vo_driver_t *this_gen, if (overlay->unscaled) { if (!this->ovl_changed) return; -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->xoverlay) { LOCK_DISPLAY(); x11osd_blend (this->xoverlay, overlay); @@ -586,7 +586,7 @@ static void directfb_overlay_end (vo_driver_t *this_gen, vo_frame_t *frame_gen) directfb_driver_t *this = (directfb_driver_t *) this_gen; if (this->ovl_changed) { -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->xoverlay) { LOCK_DISPLAY(); x11osd_expose (this->xoverlay); @@ -1120,7 +1120,7 @@ static int directfb_gui_data_exchange (vo_driver_t *this_gen, switch (data_type) { case XINE_GUI_SEND_DRAWABLE_CHANGED: lprintf ("drawable changed.\n"); -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->visual_type == XINE_VISUAL_TYPE_X11 || this->visual_type == XINE_VISUAL_TYPE_X11_2) { this->drawable = (Drawable) data; @@ -1140,7 +1140,7 @@ static int directfb_gui_data_exchange (vo_driver_t *this_gen, case XINE_GUI_SEND_EXPOSE_EVENT: lprintf ("expose event.\n"); -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->visual_type == XINE_VISUAL_TYPE_X11 || this->visual_type == XINE_VISUAL_TYPE_X11_2) { if (this->xoverlay) { @@ -1182,7 +1182,7 @@ static void directfb_dispose (vo_driver_t *this_gen) { if (this->cur_frame) this->cur_frame->vo_frame.dispose (&this->cur_frame->vo_frame); -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->visual_type == XINE_VISUAL_TYPE_X11 || this->visual_type == XINE_VISUAL_TYPE_X11_2) { LOCK_DISPLAY(); @@ -1280,7 +1280,7 @@ static void update_config_cb (void *data, xine_cfg_entry_t *entry) { this->layer->SetDstColorKey (this->layer, (this->colorkey & 0xff0000) >> 16, (this->colorkey & 0x00ff00) >> 8, (this->colorkey & 0x0000ff) >> 0); -#ifdef HAVE_X11 +#ifdef DIRECTFB_X11 if (this->xoverlay) { x11osd_colorkey (this->xoverlay, directfb_colorkey_to_pixel(this), &this->sc); @@ -1333,8 +1333,8 @@ static void update_config_cb (void *data, xine_cfg_entry_t *entry) { static void init_config (directfb_driver_t *this) { config_values_t *config = this->xine->config; - static const char *buffermode_enum[] = {"single", "double", "triple", 0}; - static const char *fieldparity_enum[] = {"none", "top", "bottom", 0}; + static const char *const buffermode_enum[] = {"single", "double", "triple", 0}; + static const char *const fieldparity_enum[] = {"none", "top", "bottom", 0}; this->buffermode = config->register_enum (config, "video.device.directfb_buffermode", this->buffermode, (char**)buffermode_enum, @@ -1893,6 +1893,7 @@ static void dispose_class_fb (video_driver_class_t *this_gen) { free (this); } +#ifndef DIRECTFB_X11 static void *init_class_fb (xine_t *xine, void *visual_gen) { directfb_class_t *this; const char *error; @@ -1925,7 +1926,7 @@ static const vo_info_t vo_info_directfb_fb = { /*** XDirectFB plugin functions ****/ -#ifdef HAVE_X11 +#else static vo_driver_t *open_plugin_x11 (video_driver_class_t *class_gen, const void *visual_gen) { directfb_class_t *class = (directfb_class_t *) class_gen; directfb_driver_t *this; @@ -2163,9 +2164,10 @@ static const vo_info_t vo_info_directfb_x11_2 = { const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ +#ifndef DIRECTFB_X11 { PLUGIN_VIDEO_OUT, VIDEO_OUT_DRIVER_IFACE_VERSION, "DirectFB", XINE_VERSION_CODE, &vo_info_directfb_fb, init_class_fb }, -#ifdef HAVE_X11 +#else { PLUGIN_VIDEO_OUT, VIDEO_OUT_DRIVER_IFACE_VERSION, "XDirectFB", XINE_VERSION_CODE, &vo_info_directfb_x11, init_class_x11 }, { PLUGIN_VIDEO_OUT, VIDEO_OUT_DRIVER_IFACE_VERSION, "XDirectFB", diff --git a/src/video_out/video_out_directfb_fb.c b/src/video_out/video_out_directfb_fb.c new file mode 100644 index 000000000..182a56941 --- /dev/null +++ b/src/video_out/video_out_directfb_fb.c @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * + * DirectFB output plugin (console version wrapper) + */ + +#undef DIRECTFB_X11 +#include "video_out_directfb.c" diff --git a/src/video_out/video_out_directfb_x.c b/src/video_out/video_out_directfb_x.c new file mode 100644 index 000000000..b3a1f53b7 --- /dev/null +++ b/src/video_out/video_out_directfb_x.c @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * + * DirectFB output plugin (X version wrapper) + */ + +#define DIRECTFB_X11 +#include "video_out_directfb.c" diff --git a/src/video_out/video_out_directx.c b/src/video_out/video_out_directx.c index 7c3e5a78c..7c3e5a78c 100644..100755 --- a/src/video_out/video_out_directx.c +++ b/src/video_out/video_out_directx.c diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c index e88def112..e2672e2a1 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project and Fredrik Noring + * Copyright (C) 2000-2007 the xine project and Fredrik Noring * * This file is part of xine, a free video player. * @@ -18,28 +18,28 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * $Id: video_out_fb.c,v 1.49 2006/12/19 19:10:51 dsalt Exp $ - * - * video_out_fb.c, frame buffer xine driver by Miguel Freitas + */ + +/** + * @file + * @brief Frame buffer xine driver * - * Contributors: + * @author Miguel Freitas * - * Fredrik Noring <noring@nocrew.org>: Zero copy buffers and clean up. + * @author Fredrik Noring <noring@nocrew.org>: + * Zero copy buffers and clean up. * - * based on xine's video_out_xshm.c... - * ...based on mpeg2dec code from - * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * @author Aaron Holtzman <aholtzma@ess.engr.uvic.ca>: + * Based on xine's video_out_xshm.c, based on mpeg2dec code from * - * ideas from ppmtofb - Display P?M graphics on framebuffer devices - * by Geert Uytterhoeven and Chris Lawrence + * @author Geert Uytterhoeven and Chris Lawrence: + * Ideas from ppmtofb - Display P?M graphics on framebuffer devices. * - * Note: Use this with fbxine. It may work with the regular xine too, - * provided the visual type is changed (see below). + * @note Use this with fbxine. * - * TODO: VT switching (configurable) + * @todo VT Switching (configurable) */ -/* #define USE_X11_VISUAL */ - #define RECOMMENDED_NUM_BUFFERS 5 #define MAXIMUM_NUM_BUFFERS 25 @@ -356,21 +356,10 @@ static void reset_dest_pointers(fb_frame_t *frame, int flags) static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, uint32_t width, uint32_t height, int format) { - if(frame->chunk[0]) - { - free(frame->chunk[0]); - frame->chunk[0] = NULL; - } - if(frame->chunk[1]) - { - free(frame->chunk[1]); - frame->chunk[1] = NULL; - } - if(frame->chunk[2]) - { - free(frame->chunk[2]); - frame->chunk[2] = NULL; - } + free(frame->chunk[0]); + free(frame->chunk[1]); + free(frame->chunk[2]); + memset(frame->chunk, 0, sizeof(frame->chunk[0])*3); if(this->use_zero_copy) { @@ -380,10 +369,9 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, } else { - if(frame->data) - free(frame->data); - frame->data = xine_xmalloc(frame->sc.output_width * - frame->sc.output_height * + free(frame->data); + frame->data = xine_xcalloc(frame->sc.output_width * + frame->sc.output_height, this->bytes_per_pixel); } @@ -842,7 +830,7 @@ static void register_callbacks(fb_driver_t *this) static int open_fb_device(config_values_t *config, xine_t *xine) { - static char devkey[] = "video.device.fb_device"; /* Why static? */ + static const char devkey[] = "video.device.fb_device"; char *device_name; int fd; @@ -924,7 +912,7 @@ static int mode_visual(fb_driver_t *this, config_values_t *config, } } - xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_fb: Your video mode was not recognized, sorry.\n")); + xprintf(this->xine, XINE_VERBOSITY_LOG, _("%s: Your video mode was not recognized, sorry.\n"), LOG_MODULE); return 0; } @@ -981,16 +969,16 @@ static void setup_buffers(fb_driver_t *this, this->cur_frame = this->old_frame = 0; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_fb: %d video RAM buffers are available.\n"), this->total_num_native_buffers); + _("%s: %d video RAM buffers are available.\n"), LOG_MODULE, this->total_num_native_buffers); if(this->total_num_native_buffers < RECOMMENDED_NUM_BUFFERS) { this->use_zero_copy = 0; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("WARNING: video_out_fb: Zero copy buffers are DISABLED because only %d buffers\n" + _("WARNING: %s: Zero copy buffers are DISABLED because only %d buffers\n" " are available which is less than the recommended %d buffers. Lowering\n" " the frame buffer resolution might help.\n"), - this->total_num_native_buffers, RECOMMENDED_NUM_BUFFERS); + LOG_MODULE, this->total_num_native_buffers, RECOMMENDED_NUM_BUFFERS); } else { @@ -998,8 +986,8 @@ static void setup_buffers(fb_driver_t *this, this->fb_var.yoffset = this->fb_var.yres; if(ioctl(this->fd, FBIOPAN_DISPLAY, &this->fb_var) == -1) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("WARNING: video_out_fb: Zero copy buffers are DISABLED because kernel driver\n" - " do not support screen panning (used for frame flips).\n")); + _("WARNING: %s: Zero copy buffers are DISABLED because kernel driver\n" + " do not support screen panning (used for frame flips).\n"), LOG_MODULE); } else { this->fb_var.yoffset = 0; ioctl(this->fd, FBIOPAN_DISPLAY, &this->fb_var); @@ -1067,12 +1055,13 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, if(this->depth > 16) xprintf(this->xine, XINE_VERBOSITY_LOG, - _("WARNING: video_out_fb: current display depth is %d. For better performance\n" - " a depth of 16 bpp is recommended!\n\n"), this->depth); + _("WARNING: %s: current display depth is %d. For better performance\n" + " a depth of 16 bpp is recommended!\n\n"), LOG_MODULE, this->depth); xprintf(class->xine, XINE_VERBOSITY_DEBUG, - "video_out_fb: video mode depth is %d (%d bpp),\n" + "%s: video mode depth is %d (%d bpp),\n" " red: %d/%d, green: %d/%d, blue: %d/%d\n", + LOG_MODULE, this->depth, this->bpp, this->fb_var.red.length, this->fb_var.red.offset, this->fb_var.green.length, this->fb_var.green.offset, @@ -1125,11 +1114,7 @@ static void *fb_init_class(xine_t *xine, void *visual_gen) static const vo_info_t vo_info_fb = { 1, /* priority */ -#ifdef USE_X11_VISUAL - XINE_VISUAL_TYPE_X11 /* visual type */ -#else XINE_VISUAL_TYPE_FB /* visual type */ -#endif }; /* exported plugin catalog entry */ diff --git a/src/video_out/video_out_macosx.m b/src/video_out/video_out_macosx.m index 1a8fb821d..845bd9b94 100644 --- a/src/video_out/video_out_macosx.m +++ b/src/video_out/video_out_macosx.m @@ -170,7 +170,9 @@ static void macosx_update_frame_format(vo_driver_t *vo_driver, vo_frame_t *vo_fr } + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [this->view setVideoSize:video_size]; + [pool release]; if((format == XINE_IMGFMT_YV12 && (frame->vo_frame.base[0] == NULL @@ -189,29 +191,35 @@ static void macosx_update_frame_format(vo_driver_t *vo_driver, vo_frame_t *vo_fr static void macosx_display_frame(vo_driver_t *vo_driver, vo_frame_t *vo_frame) { macosx_driver_t *driver = (macosx_driver_t *)vo_driver; macosx_frame_t *frame = (macosx_frame_t *)vo_frame; - char *texture_buffer = [driver->view getTextureBuffer]; - - switch (vo_frame->format) { - case XINE_IMGFMT_YV12: - yv12_to_yuy2 (vo_frame->base[0], vo_frame->pitches[0], - vo_frame->base[1], vo_frame->pitches[1], - vo_frame->base[2], vo_frame->pitches[2], - texture_buffer, vo_frame->width * 2, - vo_frame->width, vo_frame->height, 0); + char *texture_buffer; - [driver->view displayTexture]; - break; - case XINE_IMGFMT_YUY2: - xine_fast_memcpy (texture_buffer, vo_frame->base[0], - vo_frame->pitches[0] * vo_frame->height * 2); - [driver->view displayTexture]; - break; - default: - /* unsupported frame format, do nothing. */ - break; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + if ((texture_buffer = [driver->view textureBuffer]) != NULL) { + switch (vo_frame->format) { + case XINE_IMGFMT_YV12: + yv12_to_yuy2 (vo_frame->base[0], vo_frame->pitches[0], + vo_frame->base[1], vo_frame->pitches[1], + vo_frame->base[2], vo_frame->pitches[2], + (unsigned char *)texture_buffer, + vo_frame->width * 2, + vo_frame->width, vo_frame->height, 0); + + [driver->view updateTexture]; + break; + case XINE_IMGFMT_YUY2: + xine_fast_memcpy (texture_buffer, vo_frame->base[0], + vo_frame->pitches[0] * vo_frame->height * 2); + [driver->view updateTexture]; + break; + default: + /* unsupported frame format, do nothing. */ + break; + } } frame->vo_frame.free(&frame->vo_frame); + [pool release]; } static void macosx_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, @@ -228,11 +236,11 @@ static void macosx_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, if (frame->format == XINE_IMGFMT_YV12) /* TODO: It may be possible to accelerate the blending via Quartz * Extreme ... */ - blend_yuv(frame->vo_frame.base, overlay, + _x_blend_yuv(frame->vo_frame.base, overlay, frame->width, frame->height, frame->vo_frame.pitches, &this->alphablend_extra_data); else - blend_yuy2(frame->vo_frame.base[0], overlay, + _x_blend_yuy2(frame->vo_frame.base[0], overlay, frame->width, frame->height, frame->vo_frame.pitches[0], &this->alphablend_extra_data); } @@ -299,6 +307,7 @@ static void macosx_dispose(vo_driver_t *vo_driver) { macosx_driver_t *this = (macosx_driver_t *) vo_driver; _x_alphablend_free(&this->alphablend_extra_data); + [this->view releaseInMainThread]; free(this); } @@ -318,7 +327,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *driver_class, const void * driver->config = class->config; driver->xine = class->xine; driver->ratio = XINE_VO_ASPECT_AUTO; - driver->view = view; + driver->view = [view retain]; driver->vo_driver.get_capabilities = macosx_get_capabilities; driver->vo_driver.alloc_frame = macosx_alloc_frame; @@ -377,7 +386,7 @@ static const vo_info_t vo_info_macosx = { XINE_VISUAL_TYPE_MACOSX /* Visual type */ }; -plugin_info_t xine_plugin_info[] = { +plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ /* work around the problem that dlclose() is not allowed to * get rid of an image module which contains objective C code and simply diff --git a/src/video_out/video_out_xcbshm.c b/src/video_out/video_out_xcbshm.c index 5b4eb1fa3..a7c3b3028 100644 --- a/src/video_out/video_out_xcbshm.c +++ b/src/video_out/video_out_xcbshm.c @@ -154,8 +154,9 @@ static void create_ximage(xshm_driver_t *this, xshm_frame_t *frame, int width, i if (shmid < 0) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbshm: %s: allocating image\n" - "video_out_xcbshm: => not using MIT Shared Memory extension.\n"), strerror(errno)); + _("%s: %s: allocating image\n"), LOG_MODULE, strerror(errno)); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); goto shm_fail1; } @@ -163,8 +164,9 @@ static void create_ximage(xshm_driver_t *this, xshm_frame_t *frame, int width, i if (frame->image == ((void *) -1)) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbshm: shared memory error (address error) when allocating image \n" - "video_out_xcbshm: => not using MIT Shared Memory extension.\n")); + _("%s: shared memory error (address error) when allocating image \n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); goto shm_fail2; } @@ -174,8 +176,9 @@ static void create_ximage(xshm_driver_t *this, xshm_frame_t *frame, int width, i if (generic_error != NULL) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbshm: x11 error during shared memory XImage creation\n" - "video_out_xcbshm: => not using MIT Shared Memory extension.\n")); + _("%s: x11 error during shared memory XImage creation\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); free(generic_error); goto shm_fail3; } @@ -736,7 +739,7 @@ static int xshm_get_property (vo_driver_t *this_gen, int property) { return this->sc.gui_height; default: xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbshm: tried to get unsupported property %d\n", property); + LOG_MODULE ": tried to get unsupported property %d\n", property); } return 0; @@ -752,7 +755,7 @@ static int xshm_set_property (vo_driver_t *this_gen, value = XINE_VO_ASPECT_AUTO; this->sc.user_ratio = value; xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbshm: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value)); + LOG_MODULE ": aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value)); } else if (property == VO_PROP_BRIGHTNESS) { @@ -786,7 +789,7 @@ static int xshm_set_property (vo_driver_t *this_gen, } else { xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbshm: tried to set unsupported property %d\n", property); + LOG_MODULE ": tried to set unsupported property %d\n", property); } return value; @@ -1110,7 +1113,7 @@ static vo_driver_t *xshm_open_plugin(video_driver_class_t *class_gen, const void } else { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbshm: MIT shared memory extension not present on display.\n")); + _("%s: MIT shared memory extension not present on display.\n"), LOG_MODULE); this->use_shm = 0; } @@ -1148,8 +1151,8 @@ static vo_driver_t *xshm_open_plugin(video_driver_class_t *class_gen, const void swapped = cpu_byte_order != image_byte_order; xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbshm: video mode depth is %d (%d bpp), %s, %sswapped,\n" - "\tred: %08x, green: %08x, blue: %08x\n", + LOG_MODULE ": video mode depth is %d (%d bpp), %s, %sswapped,\n" + LOG_MODULE ": red: %08x, green: %08x, blue: %08x\n", this->depth, this->bpp, visual_class_name(visualtype), swapped ? "" : "not ", @@ -1209,7 +1212,7 @@ static vo_driver_t *xshm_open_plugin(video_driver_class_t *class_gen, const void if (!mode) { xprintf (this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbshm: your video mode was not recognized, sorry :-(\n")); + _("%s: your video mode was not recognized, sorry :-(\n"), LOG_MODULE); return NULL; } diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index db4be14fa..36d6de7a7 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -37,8 +37,6 @@ #include "config.h" #endif -#ifdef HAVE_XV - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -269,8 +267,9 @@ static void create_ximage(xv_driver_t *this, xv_frame_t *frame, int width, int h if (frame->xv_data_size == 0) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: XvShmCreateImage returned a zero size\n" - "video_out_xcbxv: => not using MIT Shared Memory extension.\n")); + _("%s: XvShmCreateImage returned a zero size\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); goto shm_fail1; } @@ -278,8 +277,9 @@ static void create_ximage(xv_driver_t *this, xv_frame_t *frame, int width, int h if (shmid < 0 ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: shared memory error in shmget: %s\n" - "video_out_xcbxv: => not using MIT Shared Memory extension.\n"), strerror(errno)); + _("%s: shared memory error in shmget: %s\n"), LOG_MODULE, strerror(errno)); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); goto shm_fail1; } @@ -287,7 +287,9 @@ static void create_ximage(xv_driver_t *this, xv_frame_t *frame, int width, int h if (frame->image == ((void *) -1)) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbxv: shared memory error (address error)\n"); + _("%s: shared memory error (address error)\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); goto shm_fail2; } @@ -297,8 +299,9 @@ static void create_ximage(xv_driver_t *this, xv_frame_t *frame, int width, int h if (generic_error != NULL) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: x11 error during shared memory XImage creation\n" - "video_out_xcbxv: => not using MIT Shared Memory extension.\n")); + _("%s: x11 error during shared memory XImage creation\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); free(generic_error); goto shm_fail3; } @@ -366,7 +369,7 @@ static void xv_update_frame_format (vo_driver_t *this_gen, || (frame->height != height) || (frame->format != format)) { - /* printf ("video_out_xcbxv: updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ + /* printf (LOG_MODULE ": updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ pthread_mutex_lock(&this->main_mutex); @@ -694,7 +697,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { xv_driver_t *this = (xv_driver_t *) this_gen; xv_frame_t *frame = (xv_frame_t *) frame_gen; /* - printf ("video_out_xcbxv: xv_display_frame...\n"); + printf (LOG_MODULE ": xv_display_frame...\n"); */ /* @@ -761,7 +764,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { pthread_mutex_unlock(&this->main_mutex); /* - printf ("video_out_xcbxv: xv_display_frame... done\n"); + printf (LOG_MODULE ": xv_display_frame... done\n"); */ } @@ -777,7 +780,7 @@ static int xv_get_property (vo_driver_t *this_gen, int property) { break; } - lprintf("video_out_xcbxv: property #%d = %d\n", property, this->props[property].value); + lprintf(LOG_MODULE ": property #%d = %d\n", property, this->props[property].value); return this->props[property].value; } @@ -826,7 +829,7 @@ static int xv_set_property (vo_driver_t *this_gen, case VO_PROP_INTERLACED: this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xcbxv: VO_PROP_INTERLACED(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_INTERLACED(%d)\n", this->props[property].value); this->deinterlace_enabled = value; if (this->deinterlace_method == DEINTERLACE_ONEFIELDXV) { xv_compute_ideal_size (this); @@ -840,7 +843,7 @@ static int xv_set_property (vo_driver_t *this_gen, this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xcbxv: VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); this->sc.user_ratio = value; xv_compute_ideal_size (this); @@ -852,7 +855,7 @@ static int xv_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xcbxv: VO_PROP_ZOOM_X = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_X = %d\n", this->props[property].value); this->sc.zoom_factor_x = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -866,7 +869,7 @@ static int xv_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xcbxv: VO_PROP_ZOOM_Y = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_Y = %d\n", this->props[property].value); this->sc.zoom_factor_y = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -1148,7 +1151,7 @@ static void xv_check_capability (xv_driver_t *this, free(get_attribute_reply); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbxv: port attribute %s (%d) value is %d\n", str_prop, property, int_default); + LOG_MODULE ": port attribute %s (%d) value is %d\n", str_prop, property, int_default); /* disable autopaint colorkey by default */ /* might be overridden using config entry */ @@ -1219,7 +1222,7 @@ static void xv_update_XV_FILTER(void *this_gen, xine_cfg_entry_t *entry) { pthread_mutex_unlock(&this->main_mutex); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbxv: bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); + LOG_MODULE ": bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); } static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) { @@ -1239,7 +1242,7 @@ static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) pthread_mutex_unlock(&this->main_mutex); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xcbxv: double buffering mode = %d\n", xv_double_buffer); + LOG_MODULE ": double buffering mode = %d\n", xv_double_buffer); } static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry) { @@ -1288,7 +1291,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis query_extension_reply = xcb_get_extension_data(this->connection, &xcb_xv_id); if (!query_extension_reply || !query_extension_reply->present) { - xprintf (class->xine, XINE_VERBOSITY_LOG, _("video_out_xcbxv: Xv extension not present.\n")); + xprintf (class->xine, XINE_VERBOSITY_LOG, _("%s: Xv extension not present.\n"), LOG_MODULE); return NULL; } @@ -1300,7 +1303,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis query_adaptors_reply = xcb_xv_query_adaptors_reply(this->connection, query_adaptors_cookie, NULL); if (!query_adaptors_reply) { - xprintf(class->xine, XINE_VERBOSITY_DEBUG, "video_out_xcbxv: XvQueryAdaptors failed.\n"); + xprintf(class->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": XvQueryAdaptors failed.\n"); return NULL; } @@ -1330,16 +1333,17 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: Xv extension is present but I couldn't find a usable yuv12 port.\n" - " Looks like your graphics hardware driver doesn't support Xv?!\n")); + _("%s: Xv extension is present but I couldn't find a usable yuv12 port.\n" + "\tLooks like your graphics hardware driver doesn't support Xv?!\n"), + LOG_MODULE); /* XvFreeAdaptorInfo (adaptor_info); this crashed on me (gb)*/ return NULL; } else xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: using Xv port %d from adaptor %s for hardware " - "colorspace conversion and scaling.\n"), xv_port, + _("%s: using Xv port %d from adaptor %s for hardware " + "colorspace conversion and scaling.\n"), LOG_MODULE, xv_port, xcb_xv_adaptor_info_name(adaptor_it.data)); this->xv_port = xv_port; @@ -1411,7 +1415,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis if(!strcmp(xcb_xv_attribute_info_name(attribute_it.data), "XV_HUE")) { if (!strncmp(xcb_xv_adaptor_info_name(adaptor_it.data), "NV", 2)) { - xprintf (this->xine, XINE_VERBOSITY_NONE, "video_out_xcbxv: ignoring broken XV_HUE settings on NVidia cards"); + xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards"); } else { xv_check_capability (this, VO_PROP_HUE, attribute_it.data, adaptor_it.data->base_id, @@ -1481,7 +1485,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis free(query_attributes_reply); } else - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xcbxv: no port attributes defined.\n"); + xprintf(this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": no port attributes defined.\n"); free(query_adaptors_reply); /* @@ -1506,12 +1510,12 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis this->xv_format_yv12 = format_it.data->id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: this adaptor supports the yv12 format.\n")); + _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); } else if (format_it.data->id == XINE_IMGFMT_YUY2) { this->xv_format_yuy2 = format_it.data->id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xcbxv: this adaptor supports the yuy2 format.\n")); + _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); } } @@ -1618,5 +1622,3 @@ const plugin_info_t xine_plugin_info[] EXPORTED = { { PLUGIN_VIDEO_OUT, 21, "xv", XINE_VERSION_CODE, &vo_info_xv, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; - -#endif diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 00d3bee1c..79ab41e00 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -148,7 +148,7 @@ static int HandleXError (Display *display, XErrorEvent *xevent) { char str [1024]; XGetErrorText (display, xevent->error_code, str, 1024); - printf ("video_out_xshm: received X error event: %s\n", str); + printf (LOG_MODULE ": received X error event: %s\n", str); gX11Fail = 1; return 0; @@ -199,8 +199,9 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, if (myimage == NULL ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: shared memory error when allocating image\n" - "video_out_xshm: => not using MIT Shared Memory extension.\n")); + _("%s: shared memory error when allocating image\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -215,8 +216,9 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, if (shminfo->shmid < 0 ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: %s: allocating image\n" - "video_out_xshm: => not using MIT Shared Memory extension.\n"), strerror(errno)); + _("%s: %s: allocating image\n"), LOG_MODULE, strerror(errno)); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -225,8 +227,9 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, if (shminfo->shmaddr == ((char *) -1)) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: shared memory error (address error) when allocating image \n" - "video_out_xshm: => not using MIT Shared Memory extension.\n")); + _("%s: shared memory error (address error) when allocating image \n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); shmctl (shminfo->shmid, IPC_RMID, 0); shminfo->shmid = -1; this->use_shm = 0; @@ -241,10 +244,11 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, XSync(this->display, False); if (gX11Fail) { - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: x11 error during shared memory XImage creation\n" - "video_out_xshm: => not using MIT Shared Memory extension.\n")); shmdt (shminfo->shmaddr); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: x11 error during shared memory XImage creation\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); shmctl (shminfo->shmid, IPC_RMID, 0); shminfo->shmid = -1; this->use_shm = 0; @@ -284,7 +288,7 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, this->bytes_per_pixel = this->bpp / 8; this->image_byte_order = myimage->byte_order; - myimage->data = xine_xmalloc (width * this->bytes_per_pixel * height); + myimage->data = xine_xcalloc (width * height, this->bytes_per_pixel); } return myimage; @@ -825,7 +829,7 @@ static int xshm_get_property (vo_driver_t *this_gen, int property) { return this->sc.gui_height; default: xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xshm: tried to get unsupported property %d\n", property); + LOG_MODULE ": tried to get unsupported property %d\n", property); } return 0; @@ -841,7 +845,7 @@ static int xshm_set_property (vo_driver_t *this_gen, value = XINE_VO_ASPECT_AUTO; this->sc.user_ratio = value; xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xshm: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value)); + LOG_MODULE ": aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value)); } else if (property == VO_PROP_BRIGHTNESS) { @@ -875,7 +879,7 @@ static int xshm_set_property (vo_driver_t *this_gen, } else { xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xshm: tried to set unsupported property %d\n", property); + LOG_MODULE ": tried to set unsupported property %d\n", property); } return value; @@ -1167,7 +1171,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v } else { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: MIT shared memory extension not present on display.\n")); + _("%s: MIT shared memory extension not present on display.\n"), LOG_MODULE); this->use_shm = 0; } @@ -1188,8 +1192,8 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v swapped = cpu_byte_order != this->image_byte_order; xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xshm: video mode depth is %d (%d bpp), %s, %sswapped,\n" - "\tred: %08lx, green: %08lx, blue: %08lx\n", + LOG_MODULE ": video mode depth is %d (%d bpp), %s, %sswapped,\n" + LOG_MODULE ": red: %08lx, green: %08lx, blue: %08lx\n", this->depth, this->bpp, visual_class_name(this->visual), swapped ? "" : "not ", @@ -1251,7 +1255,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v if (!mode) { xprintf (this->xine, XINE_VERBOSITY_LOG, - _("video_out_xshm: your video mode was not recognized, sorry :-(\n")); + _("%s: your video mode was not recognized, sorry :-(\n"), LOG_MODULE); return NULL; } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 55340a9e7..19c30e766 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -36,8 +36,6 @@ #include "config.h" #endif -#ifdef HAVE_XV - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -293,8 +291,9 @@ static XvImage *create_ximage (xv_driver_t *this, XShmSegmentInfo *shminfo, if (image == NULL ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: XvShmCreateImage failed\n" - "video_out_xv: => not using MIT Shared Memory extension.\n")); + _("%s: XvShmCreateImage failed\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -303,16 +302,18 @@ static XvImage *create_ximage (xv_driver_t *this, XShmSegmentInfo *shminfo, if (image->data_size==0) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: XvShmCreateImage returned a zero size\n" - "video_out_xv: => not using MIT Shared Memory extension.\n")); + _("%s: XvShmCreateImage returned a zero size\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } if (shminfo->shmid < 0 ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: shared memory error in shmget: %s\n" - "video_out_xv: => not using MIT Shared Memory extension.\n"), strerror(errno)); + _("%s: shared memory error in shmget: %s\n"), LOG_MODULE, strerror(errno)); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -321,14 +322,14 @@ static XvImage *create_ximage (xv_driver_t *this, XShmSegmentInfo *shminfo, if (shminfo->shmaddr == NULL) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xv: shared memory error (address error NULL)\n"); + LOG_MODULE ": shared memory error (address error NULL)\n"); this->use_shm = 0; goto finishShmTesting; } if (shminfo->shmaddr == ((char *) -1)) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xv: shared memory error (address error)\n"); + LOG_MODULE ": shared memory error (address error)\n"); this->use_shm = 0; goto finishShmTesting; } @@ -342,12 +343,13 @@ static XvImage *create_ximage (xv_driver_t *this, XShmSegmentInfo *shminfo, shmctl(shminfo->shmid, IPC_RMID, 0); if (gX11Fail) { - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: x11 error during shared memory XImage creation\n" - "video_out_xv: => not using MIT Shared Memory extension.\n")); shmdt (shminfo->shmaddr); shmctl (shminfo->shmid, IPC_RMID, 0); shminfo->shmid = -1; + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: x11 error during shared memory XImage creation\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -430,7 +432,7 @@ static void xv_update_frame_format (vo_driver_t *this_gen, || (frame->height != height) || (frame->format != format)) { - /* printf ("video_out_xv: updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ + /* printf (LOG_MODULE ": updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ LOCK_DISPLAY(this); @@ -514,17 +516,17 @@ static void xv_deinterlace_frame (xv_driver_t *this) { else recent_bitmaps[i] = NULL; - deinterlace_yuv( this->deinterlace_frame.image->data+frame->width*frame->height, - recent_bitmaps, frame->width/2, frame->height/2, this->deinterlace_method ); + deinterlace_yuv( this->deinterlace_frame.image->data+this->deinterlace_frame.image->width*frame->height, + recent_bitmaps, this->deinterlace_frame.image->width/2, frame->height/2, this->deinterlace_method ); for( i = 0; i < VO_NUM_RECENT_FRAMES; i++ ) if( this->recent_frames[i] && this->recent_frames[i]->width == frame->width && this->recent_frames[i]->height == frame->height ) - recent_bitmaps[i] = this->recent_frames[i]->image->data + frame->width*frame->height*5/4; + recent_bitmaps[i] = this->recent_frames[i]->image->data + this->deinterlace_frame.image->width*frame->height*5/4; else recent_bitmaps[i] = NULL; - deinterlace_yuv( this->deinterlace_frame.image->data+frame->width*frame->height*5/4, - recent_bitmaps, frame->width/2, frame->height/2, this->deinterlace_method ); + deinterlace_yuv( this->deinterlace_frame.image->data+this->deinterlace_frame.image->width*frame->height*5/4, + recent_bitmaps, this->deinterlace_frame.image->width/2, frame->height/2, this->deinterlace_method ); #else @@ -543,7 +545,7 @@ static void xv_deinterlace_frame (xv_driver_t *this) { recent_bitmaps[i] = NULL; deinterlace_yuv( this->deinterlace_frame.image->data, recent_bitmaps, - frame->width, frame->height, this->deinterlace_method ); + this->deinterlace_frame.image->width, frame->height, this->deinterlace_method ); } else { /* @@ -756,7 +758,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { xv_driver_t *this = (xv_driver_t *) this_gen; xv_frame_t *frame = (xv_frame_t *) frame_gen; /* - printf ("video_out_xv: xv_display_frame...\n"); + printf (LOG_MODULE ": xv_display_frame...\n"); */ /* @@ -820,7 +822,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { UNLOCK_DISPLAY(this); /* - printf ("video_out_xv: xv_display_frame... done\n"); + printf (LOG_MODULE ": xv_display_frame... done\n"); */ } @@ -836,7 +838,7 @@ static int xv_get_property (vo_driver_t *this_gen, int property) { break; } - lprintf("video_out_xv: property #%d = %d\n", property, this->props[property].value); + lprintf(LOG_MODULE ": property #%d = %d\n", property, this->props[property].value); return this->props[property].value; } @@ -881,7 +883,7 @@ static int xv_set_property (vo_driver_t *this_gen, case VO_PROP_INTERLACED: this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xv: VO_PROP_INTERLACED(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_INTERLACED(%d)\n", this->props[property].value); this->deinterlace_enabled = value; if (this->deinterlace_method == DEINTERLACE_ONEFIELDXV) { xv_compute_ideal_size (this); @@ -895,7 +897,7 @@ static int xv_set_property (vo_driver_t *this_gen, this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xv: VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); this->sc.user_ratio = value; xv_compute_ideal_size (this); @@ -907,7 +909,7 @@ static int xv_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xv: VO_PROP_ZOOM_X = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_X = %d\n", this->props[property].value); this->sc.zoom_factor_x = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -921,7 +923,7 @@ static int xv_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xv: VO_PROP_ZOOM_Y = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_Y = %d\n", this->props[property].value); this->sc.zoom_factor_y = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -1097,7 +1099,7 @@ static void xv_dispose (vo_driver_t *this_gen) { LOCK_DISPLAY(this); if(XvUngrabPort (this->display, this->xv_port, CurrentTime) != Success) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_out_xv: xv_exit: XvUngrabPort() failed.\n"); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": xv_exit: XvUngrabPort() failed.\n"); } XFreeGC(this->display, this->gc); UNLOCK_DISPLAY(this); @@ -1164,7 +1166,7 @@ static void xv_check_capability (xv_driver_t *this, this->props[property].atom, &int_default); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xv: port attribute %s (%d) value is %d\n", str_prop, property, int_default); + LOG_MODULE ": port attribute %s (%d) value is %d\n", str_prop, property, int_default); /* disable autopaint colorkey by default */ /* might be overridden using config entry */ @@ -1231,7 +1233,7 @@ static void xv_update_XV_FILTER(void *this_gen, xine_cfg_entry_t *entry) { UNLOCK_DISPLAY(this); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xv: bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); + LOG_MODULE ": bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); } static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) { @@ -1247,7 +1249,7 @@ static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) UNLOCK_DISPLAY(this); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xv: double buffering mode = %d\n", xv_double_buffer); + LOG_MODULE ": double buffering mode = %d\n", xv_double_buffer); } static void xv_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry) { @@ -1296,7 +1298,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * LOCK_DISPLAY(this); if (Success != XvQueryExtension(this->display, &ver,&rel, &req, &ev,&err)) { - xprintf (class->xine, XINE_VERBOSITY_LOG, _("video_out_xv: Xv extension not present.\n")); + xprintf (class->xine, XINE_VERBOSITY_LOG, _("%s: Xv extension not present.\n"), LOG_MODULE); UNLOCK_DISPLAY(this); return NULL; } @@ -1306,7 +1308,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * */ if (Success != XvQueryAdaptors(this->display,DefaultRootWindow(this->display), &adaptors, &adaptor_info)) { - xprintf(class->xine, XINE_VERBOSITY_DEBUG, "video_out_xv: XvQueryAdaptors failed.\n"); + xprintf(class->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": XvQueryAdaptors failed.\n"); UNLOCK_DISPLAY(this); return NULL; } @@ -1333,8 +1335,9 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: Xv extension is present but I couldn't find a usable yuv12 port.\n" - " Looks like your graphics hardware driver doesn't support Xv?!\n")); + _("%s: Xv extension is present but I couldn't find a usable yuv12 port.\n" + "\tLooks like your graphics hardware driver doesn't support Xv?!\n"), + LOG_MODULE); /* XvFreeAdaptorInfo (adaptor_info); this crashed on me (gb)*/ UNLOCK_DISPLAY(this); @@ -1342,8 +1345,8 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * } else xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: using Xv port %ld from adaptor %s for hardware " - "colorspace conversion and scaling.\n"), xv_port, + _("%s: using Xv port %ld from adaptor %s for hardware " + "colorspace conversion and scaling.\n"), LOG_MODULE, xv_port, adaptor_info[adaptor_num].name); UNLOCK_DISPLAY(this); @@ -1425,7 +1428,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * if(!strcmp(attr[k].name, "XV_HUE")) { if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { - xprintf (this->xine, XINE_VERBOSITY_NONE, "video_out_xv: ignoring broken XV_HUE settings on NVidia cards"); + xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards"); } else { xv_check_capability (this, VO_PROP_HUE, attr[k], adaptor_info[adaptor_num].base_id, @@ -1495,7 +1498,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * XFree(attr); } else - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xv: no port attributes defined.\n"); + xprintf(this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": no port attributes defined.\n"); XvFreeAdaptorInfo(adaptor_info); /* @@ -1517,12 +1520,12 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void * this->xv_format_yv12 = fo[i].id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: this adaptor supports the yv12 format.\n")); + _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); } else if (fo[i].id == XINE_IMGFMT_YUY2) { this->xv_format_yuy2 = fo[i].id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xv: this adaptor supports the yuy2 format.\n")); + _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); } } @@ -1676,5 +1679,3 @@ const plugin_info_t xine_plugin_info[] EXPORTED = { { PLUGIN_VIDEO_OUT, 21, "xv", XINE_VERSION_CODE, &vo_info_xv_2, init_class_2 }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; - -#endif diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index fd19f391b..9d4f89103 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -31,8 +31,8 @@ * * overlay support by James Courtier-Dutton <James@superbug.demon.co.uk> - July 2001 * X11 unscaled overlay support by Miguel Freitas - Nov 2003 - * XvMC VLD implementation by Thomas Hellström - 2004, 2005. - * XvMC merge by Thomas Hellström - Sep 2004 + * XvMC VLD implementation by Thomas Hellström - 2004, 2005. + * XvMC merge by Thomas Hellström - Sep 2004 * */ @@ -165,14 +165,10 @@ static void xxmc_xvmc_surface_handler_construct(xxmc_driver_t *this) xvmc_surface_handler_t *handler = &this->xvmc_surf_handler; pthread_mutex_init(&handler->mutex,NULL); - for (i=0; i<XVMC_MAX_SURFACES; ++i) { - handler->surfInUse[i] = 0; - handler->surfValid[i] = 0; - } - for (i=0; i<XVMC_MAX_SUBPICTURES; ++i) { - handler->subInUse[i] = 0; - handler->subValid[i] = 0; - } + memset(handler->surfInUse, 0, sizeof(*handler->surfInUse)*XVMC_MAX_SURFACES); + memset(handler->surfValid, 0, sizeof(*handler->surfValid)*XVMC_MAX_SURFACES); + memset(handler->subInUse, 0, sizeof(*handler->subInUse)*XVMC_MAX_SUBPICTURES); + memset(handler->subValid, 0, sizeof(*handler->subValid)*XVMC_MAX_SUBPICTURES); } static void xxmc_xvmc_destroy_surfaces(xxmc_driver_t *this) @@ -242,7 +238,7 @@ static XvMCSurface *xxmc_xvmc_alloc_surface(xxmc_driver_t *this, } XVMCUNLOCKDISPLAY( this->display ); xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Created surface %d\n",i); + LOG_MODULE ": Created surface %d\n",i); handler->surfInUse[i] = 1; handler->surfValid[i] = 1; pthread_mutex_unlock(&handler->mutex); @@ -262,7 +258,7 @@ static void xxmc_xvmc_free_surface(xxmc_driver_t *this, XvMCSurface *surf) if (index >= XVMC_MAX_SURFACES) return; pthread_mutex_lock(&handler->mutex); xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Disposing of surface %d\n",index); + LOG_MODULE ": Disposing of surface %d\n",index); handler->surfInUse[index]--; xxmc_xvmc_dump_surfaces(this); pthread_mutex_unlock(&handler->mutex); @@ -322,7 +318,7 @@ static XvMCSubpicture *xxmc_xvmc_alloc_subpicture } XVMCUNLOCKDISPLAY( this->display ); xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Created subpicture %d\n",i); + LOG_MODULE ": Created subpicture %d\n",i); handler->subInUse[i] = 1; handler->subValid[i] = 1; pthread_mutex_unlock(&handler->mutex); @@ -343,7 +339,7 @@ static void xxmc_xvmc_free_subpicture(xxmc_driver_t *this, XvMCSubpicture *sub) if (index >= XVMC_MAX_SUBPICTURES) return; pthread_mutex_lock(&handler->mutex); xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Disposing of subpicture %d\n",index); + LOG_MODULE ": Disposing of subpicture %d\n",index); handler->subInUse[index] = 0; xxmc_xvmc_dump_subpictures(this); pthread_mutex_unlock(&handler->mutex); @@ -647,8 +643,9 @@ static XvImage *create_ximage (xxmc_driver_t *this, XShmSegmentInfo *shminfo, if (image == NULL ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: XvShmCreateImage failed\n" - "video_out_xxmc: => not using MIT Shared Memory extension.\n")); + _("%s: XvShmCreateImage failed\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -657,16 +654,18 @@ static XvImage *create_ximage (xxmc_driver_t *this, XShmSegmentInfo *shminfo, if (image->data_size==0) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: XvShmCreateImage returned a zero size\n" - "video_out_xxmc: => not using MIT Shared Memory extension.\n")); + _("%s: XvShmCreateImage returned a zero size\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } if (shminfo->shmid < 0 ) { xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: shared memory error in shmget: %s\n" - "video_out_xxmc: => not using MIT Shared Memory extension.\n"), strerror(errno)); + _("%s: shared memory error in shmget: %s\n"), LOG_MODULE, strerror(errno)); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -675,14 +674,14 @@ static XvImage *create_ximage (xxmc_driver_t *this, XShmSegmentInfo *shminfo, if (shminfo->shmaddr == NULL) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: shared memory error (address error NULL)\n"); + LOG_MODULE ": shared memory error (address error NULL)\n"); this->use_shm = 0; goto finishShmTesting; } if (shminfo->shmaddr == ((char *) -1)) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: shared memory error (address error)\n"); + LOG_MODULE ": shared memory error (address error)\n"); this->use_shm = 0; goto finishShmTesting; } @@ -696,12 +695,13 @@ static XvImage *create_ximage (xxmc_driver_t *this, XShmSegmentInfo *shminfo, shmctl(shminfo->shmid, IPC_RMID, 0); if (gX11Fail) { - xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: x11 error during shared memory XImage creation\n" - "video_out_xxmc: => not using MIT Shared Memory extension.\n")); shmdt (shminfo->shmaddr); shmctl (shminfo->shmid, IPC_RMID, 0); shminfo->shmid = -1; + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: x11 error during shared memory XImage creation\n"), LOG_MODULE); + xprintf(this->xine, XINE_VERBOSITY_LOG, + _("%s: => not using MIT Shared Memory extension.\n"), LOG_MODULE); this->use_shm = 0; goto finishShmTesting; } @@ -766,13 +766,13 @@ static void xxmc_dispose_context(xxmc_driver_t *driver) } xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Freeing up XvMC Surfaces and subpictures.\n"); + LOG_MODULE ": Freeing up XvMC Surfaces and subpictures.\n"); if (driver->xvmc_palette) free(driver->xvmc_palette); _x_dispose_xx44_palette( &driver->palette ); xxmc_xvmc_destroy_subpictures( driver ); xxmc_xvmc_destroy_surfaces( driver ); xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Freeing up XvMC Context.\n"); + LOG_MODULE ": Freeing up XvMC Context.\n"); XLockDisplay (driver->display); if (driver->subImage) dispose_ximage(driver, &driver->subShmInfo, driver->subImage); @@ -812,10 +812,10 @@ static int xxmc_find_context(xxmc_driver_t *driver, xine_xxmc_t *xxmc, curCap = driver->xvmc_cap; for (i =0; i < driver->xvmc_num_cap; ++i) { xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Surface type %d. Capabilities 0x%8x 0x%8x\n",i, + LOG_MODULE ": Surface type %d. Capabilities 0x%8x 0x%8x\n",i, curCap->mpeg_flags,curCap->accel_flags); xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Requests: 0x%8x 0x%8x\n", + LOG_MODULE ": Requests: 0x%8x 0x%8x\n", request_mpeg_flags,request_accel_flags); if (((curCap->mpeg_flags & request_mpeg_flags) == request_mpeg_flags) && ((curCap->accel_flags & request_accel_flags)) && @@ -846,7 +846,7 @@ static int xxmc_create_context(xxmc_driver_t *driver, unsigned width, unsigned h curCap = driver->xvmc_cap + driver->xvmc_cur_cap; xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Creating new XvMC Context %d\n",curCap->type_id); + LOG_MODULE ": Creating new XvMC Context %d\n",curCap->type_id); XVMCLOCKDISPLAY( driver->display ); if (Success == XvMCCreateContext( driver->display, driver->xv_port, curCap->type_id, width, @@ -879,7 +879,7 @@ static void xxmc_setup_subpictures(xxmc_driver_t *driver, unsigned width, unsign if ((driver->xvmc_backend_subpic = (curCap->flags & XVMC_BACKEND_SUBPICTURE))) xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Using Backend subpictures.\n"); + LOG_MODULE ": Using Backend subpictures.\n"); if (!driver->subImage) { /* @@ -895,7 +895,7 @@ static void xxmc_setup_subpictures(xxmc_driver_t *driver, unsigned width, unsign XUnlockDisplay (driver->display); if (NULL == driver->subImage) { xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: Failed allocating XvImage for supbictures.\n"); + LOG_MODULE ": Failed allocating XvImage for supbictures.\n"); return; } } @@ -977,7 +977,7 @@ static void xvmc_check_colorkey_properties(xxmc_driver_t *driver) static int xxmc_xvmc_update_context(xxmc_driver_t *driver, xxmc_frame_t *frame, - uint32_t width, uint32_t height) + uint32_t width, uint32_t height, int frame_format_xxmc) { xine_xxmc_t *xxmc = &frame->xxmc_data; @@ -990,9 +990,13 @@ static int xxmc_xvmc_update_context(xxmc_driver_t *driver, xxmc_frame_t *frame, return 0; xprintf(driver->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: New format. Need to change XvMC Context.\n" - "width: %d height: %d mpeg: %d acceleration: %d\n", width, height, - xxmc->mpeg, xxmc->acceleration); + LOG_MODULE ": New format. Need to change XvMC Context.\n" + LOG_MODULE ": width: %d height: %d", width, height); + if (frame_format_xxmc) { + xprintf(driver->xine, XINE_VERBOSITY_LOG, + " mpeg: %d acceleration: %d", xxmc->mpeg, xxmc->acceleration); + } + xprintf(driver->xine, XINE_VERBOSITY_LOG, "\n"); if (frame->xvmc_surf) xxmc_xvmc_free_surface( driver , frame->xvmc_surf); @@ -1000,24 +1004,24 @@ static int xxmc_xvmc_update_context(xxmc_driver_t *driver, xxmc_frame_t *frame, xxmc_dispose_context( driver ); - if (xxmc_find_context( driver, xxmc, width, height )) { + if (frame_format_xxmc && xxmc_find_context( driver, xxmc, width, height )) { xxmc_create_context( driver, width, height); xvmc_check_colorkey_properties( driver ); xxmc_setup_subpictures(driver, width, height); if ((driver->xvmc_accel & (XINE_XVMC_ACCEL_MOCOMP | XINE_XVMC_ACCEL_IDCT))) { if (!xxmc_mocomp_create_macroblocks(driver, frame, 1)) { - lprintf("video_out_xxmc: ERROR: Macroblock allocation failed\n"); + printf(LOG_MODULE ": ERROR: Macroblock allocation failed\n"); xxmc_dispose_context( driver ); } } } if (!driver->contextActive) { - printf("video_out_xxmc: Using software decoding for this stream.\n"); + printf(LOG_MODULE ": Using software decoding for this stream.\n"); driver->xvmc_accel = 0; } else { - printf("video_out_xxmc: Using hardware decoding for this stream.\n"); + printf(LOG_MODULE ": Using hardware decoding for this stream.\n"); } driver->xvmc_mpeg = xxmc->mpeg; @@ -1053,9 +1057,9 @@ static void xxmc_frame_updates(xxmc_driver_t *driver, if (frame->xvmc_surf == NULL) { if (NULL == (frame->xvmc_surf = xxmc_xvmc_alloc_surface( driver, &driver->context))) { - fprintf(stderr, "video_out_xxmc: ERROR: Accelerated surface allocation failed.\n" - "video_out_xxmc: You are probably out of framebuffer memory.\n" - "video_out_xxmc: Falling back to software decoding.\n"); + fprintf(stderr, LOG_MODULE ": ERROR: Accelerated surface allocation failed.\n" + LOG_MODULE ": You are probably out of framebuffer memory.\n" + LOG_MODULE ": Falling back to software decoding.\n"); driver->xvmc_accel = 0; xxmc_dispose_context( driver ); return; @@ -1231,7 +1235,7 @@ static void xxmc_do_update_frame(vo_driver_t *this_gen, (this->xvmc_width != width) || (this->xvmc_height != height)) { this->last_accel_request = xxmc->acceleration; - xxmc_xvmc_update_context(this, frame, width, height); + xxmc_xvmc_update_context(this, frame, width, height, 1); } else { this->last_accel_request = xxmc->acceleration; } @@ -1254,6 +1258,11 @@ static void xxmc_do_update_frame(vo_driver_t *this_gen, xvmc_context_writer_unlock( &this->xvmc_lock); } else { + /* switch back to an unaccelerated context */ + if (this->last_accel_request != 0xFFFFFFFF) { + this->last_accel_request = 0xFFFFFFFF; + xxmc_xvmc_update_context(this, frame, width, height, 0); + } frame->vo_frame.proc_duplicate_frame_data = NULL; xxmc_do_update_frame_xv(this_gen, frame_gen, width, height, ratio, format, flags); @@ -1579,6 +1588,28 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) xxmc_frame_t *frame = (xxmc_frame_t *) frame_gen; xine_xxmc_t *xxmc = &frame->xxmc_data; int first_field; + int disable_deinterlace = 0; + struct timeval tv_top; + + /* + * take time to calculate the time to sleep for the bottom field + */ + gettimeofday(&tv_top, 0); + + /* + * bob deinterlacing doesn't make much sense for still images or at replay speeds + * other than 100 %, so let's disable deinterlacing at all for this frame + */ + if (this->deinterlace_enabled && this->bob) { + disable_deinterlace = frame->vo_frame.progressive_frame + || !frame->vo_frame.stream + || xine_get_param(frame->vo_frame.stream, XINE_PARAM_FINE_SPEED) != XINE_FINE_SPEED_NORMAL; + if (!disable_deinterlace) { + int vo_bufs_in_fifo = 0; + _x_query_buffer_usage(frame->vo_frame.stream, NULL, NULL, &vo_bufs_in_fifo, NULL); + disable_deinterlace = (vo_bufs_in_fifo <= 0); + } + } /* * queue frames (deinterlacing) @@ -1589,6 +1620,20 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) xxmc_add_recent_frame (this, frame); /* deinterlacing */ + /* + * the current implementation doesn't need recent frames for deinterlacing, + * but as most of the time we only have a little number of frames available + * per device, we only hold references to the most recent frame by filling + * the whole buffer with the same frame + */ + { + int i; + for (i = 1; i < VO_NUM_RECENT_FRAMES; i++) { + frame->vo_frame.lock(&frame->vo_frame); + xxmc_add_recent_frame (this, frame); /* deinterlacing */ + } + } + if ((frame->format == XINE_IMGFMT_XXMC) && (!xxmc->decoded || !xxmc_xvmc_surface_valid(this, frame->xvmc_surf))) { xvmc_context_reader_unlock( &this->xvmc_lock ); @@ -1616,7 +1661,7 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) first_field = (frame->vo_frame.top_field_first) ? XVMC_TOP_FIELD : XVMC_BOTTOM_FIELD; first_field = (this->bob) ? first_field : XVMC_TOP_FIELD; - this->cur_field = (this->deinterlace_enabled) ? first_field : XVMC_FRAME_PICTURE; + this->cur_field = (this->deinterlace_enabled && !disable_deinterlace) ? first_field : XVMC_FRAME_PICTURE; xxmc_redraw_needed (this_gen); if (frame->format == XINE_IMGFMT_XXMC) { @@ -1629,21 +1674,42 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) this->sc.output_width, this->sc.output_height, this->cur_field); XVMCUNLOCKDISPLAY( this->display ); - if (this->deinterlace_enabled && this->bob) { - unsigned - ms_per_field = 500 * frame->vo_frame.duration / 90000 - 2; - - usleep(ms_per_field*1000); - this->cur_field = (frame->vo_frame.top_field_first) ? XVMC_BOTTOM_FIELD : XVMC_TOP_FIELD; + if (this->deinterlace_enabled && !disable_deinterlace && this->bob) { + struct timeval tv_middle; + long us_spent_so_far, us_per_field = frame->vo_frame.duration * 50 / 9; - XVMCLOCKDISPLAY( this->display ); - XvMCPutSurface( this->display, frame->xvmc_surf , this->drawable, - this->sc.displayed_xoffset, this->sc.displayed_yoffset, - this->sc.displayed_width, this->sc.displayed_height, - this->sc.output_xoffset, this->sc.output_yoffset, - this->sc.output_width, this->sc.output_height, - this->cur_field); - XVMCUNLOCKDISPLAY( this->display ); + gettimeofday(&tv_middle, 0); + us_spent_so_far = (tv_middle.tv_sec - tv_top.tv_sec) * 1000000 + (tv_middle.tv_usec - tv_top.tv_usec); + if (us_spent_so_far < 0) + us_spent_so_far = 0; + + /* + * typically, the operations above take just a few milliseconds, but when the + * driver actively waits to sync on the next field, we better skip showing the + * other field as it would lead to further busy waiting + * so display the other field only if we've spent less than 75 % of the per + * field time so far + */ + if (4 * us_spent_so_far < 3 * us_per_field) { + long us_delay = (us_per_field - 2000) - us_spent_so_far; + if (us_delay > 0) { + xvmc_context_reader_unlock( &this->xvmc_lock ); + xine_usec_sleep(us_delay); + LOCK_AND_SURFACE_VALID( this, frame->xvmc_surf ); + } + + this->cur_field = (frame->vo_frame.top_field_first) ? XVMC_BOTTOM_FIELD : XVMC_TOP_FIELD; + + XVMCLOCKDISPLAY( this->display ); + XvMCPutSurface( this->display, frame->xvmc_surf , this->drawable, + this->sc.displayed_xoffset, this->sc.displayed_yoffset, + this->sc.displayed_width, this->sc.displayed_height, + this->sc.output_xoffset, this->sc.output_yoffset, + this->sc.output_width, this->sc.output_height, + this->cur_field); + + XVMCUNLOCKDISPLAY( this->display ); + } } } else { XLockDisplay (this->display); @@ -1681,7 +1747,7 @@ static int xxmc_get_property (vo_driver_t *this_gen, int property) { break; } - lprintf("video_out_xxmc: property #%d = %d\n", property, this->props[property].value); + lprintf("%s: property #%d = %d\n", LOG_MODULE, property, this->props[property].value); return this->props[property].value; } @@ -1744,7 +1810,7 @@ static int xxmc_set_property (vo_driver_t *this_gen, case VO_PROP_INTERLACED: this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: VO_PROP_INTERLACED(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_INTERLACED(%d)\n", this->props[property].value); this->deinterlace_enabled = value; break; @@ -1754,7 +1820,7 @@ static int xxmc_set_property (vo_driver_t *this_gen, this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ASPECT_RATIO(%d)\n", this->props[property].value); this->sc.user_ratio = value; xxmc_compute_ideal_size (this); @@ -1766,7 +1832,7 @@ static int xxmc_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: VO_PROP_ZOOM_X = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_X = %d\n", this->props[property].value); this->sc.zoom_factor_x = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -1780,7 +1846,7 @@ static int xxmc_set_property (vo_driver_t *this_gen, if ((value >= XINE_VO_ZOOM_MIN) && (value <= XINE_VO_ZOOM_MAX)) { this->props[property].value = value; xprintf(this->xine, XINE_VERBOSITY_LOG, - "video_out_xxmc: VO_PROP_ZOOM_Y = %d\n", this->props[property].value); + LOG_MODULE ": VO_PROP_ZOOM_Y = %d\n", this->props[property].value); this->sc.zoom_factor_y = (double)value / (double)XINE_VO_ZOOM_STEP; @@ -1927,14 +1993,14 @@ static void xxmc_dispose (vo_driver_t *this_gen) { XLockDisplay (this->display); if(XvUngrabPort (this->display, this->xv_port, CurrentTime) != Success) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_out_xxmc: xxmc_exit: XvUngrabPort() failed.\n"); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": xxmc_exit: XvUngrabPort() failed.\n"); } XFreeGC(this->display, this->gc); XUnlockDisplay (this->display); for( i=0; i < VO_NUM_RECENT_FRAMES; i++ ) { if( this->recent_frames[i] ) - this->recent_frames[i]->vo_frame.dispose + this->recent_frames[i]->vo_frame.free (&this->recent_frames[i]->vo_frame); this->recent_frames[i] = NULL; } @@ -1991,7 +2057,7 @@ static void xxmc_check_capability (xxmc_driver_t *this, this->props[property].atom, &int_default); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: port attribute %s (%d) value is %d\n", str_prop, property, int_default); + LOG_MODULE ": port attribute %s (%d) value is %d\n", str_prop, property, int_default); /* * We enable autopaint by default. @@ -2053,7 +2119,7 @@ static void xxmc_update_XV_FILTER(void *this_gen, xine_cfg_entry_t *entry) { XUnlockDisplay(this->display); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); + LOG_MODULE ": bilinear scaling mode (XV_FILTER) = %d\n",xv_filter); } static void xxmc_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry) { @@ -2069,7 +2135,7 @@ static void xxmc_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry XUnlockDisplay(this->display); xprintf(this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: double buffering mode = %d\n", xv_double_buffer); + LOG_MODULE ": double buffering mode = %d\n", xv_double_buffer); } static void xxmc_update_xv_pitch_alignment(void *this_gen, xine_cfg_entry_t *entry) { @@ -2129,7 +2195,7 @@ static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) return; } xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: XvMC extension present.\n"); + LOG_MODULE ": XvMC extension present.\n"); surfaceInfo = XvMCListSurfaceTypes(this->display, xv_port, &numSurf); if (0 == surfaceInfo) { @@ -2145,7 +2211,7 @@ static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) curCap = this->xvmc_cap; xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Found %d XvMC surface types\n",numSurf); + LOG_MODULE ": Found %d XvMC surface types\n", numSurf); for (i=0; i< numSurf; ++i) { curCap->mpeg_flags = 0; @@ -2169,10 +2235,10 @@ static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) curCap->sub_max_height = curInfo->subpicture_max_height; curCap->flags = curInfo->flags; xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Surface type %d: Max size: %d %d.\n", + LOG_MODULE ": Surface type %d: Max size: %d %d.\n", i,curCap->max_width,curCap->max_height); xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Surface type %d: Max subpic size: %d %d.\n", + LOG_MODULE ": Surface type %d: Max subpic size: %d %d.\n", i,curCap->sub_max_width,curCap->sub_max_height); curCap->type_id = curInfo->surface_type_id; @@ -2181,21 +2247,18 @@ static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) curCap->subPicType.id = 0; if (formatValues) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Surface type %d: Found %d XvMC subpicture " - "types\n",i,numSub); + LOG_MODULE ": Surface type %d: Found %d XvMC subpicture types\n",i,numSub); for (j = 0; j<numSub; ++j) { if (formatValues[j].id == FOURCC_IA44) { curCap->subPicType = formatValues[j]; xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Surface type %d: Detected and using " - "IA44 subpicture type.\n",i); + LOG_MODULE ": Surface type %d: Detected and using IA44 subpicture type.\n",i); /* Prefer IA44 */ break; } else if (formatValues[j].id == FOURCC_AI44) { curCap->subPicType = formatValues[j]; xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Surface type %d: Detected AI44 " - "subpicture type.\n",i); + LOG_MODULE ": Surface type %d: Detected AI44 subpicture type.\n",i); } } } @@ -2226,9 +2289,8 @@ static void checkXvMCCap( xxmc_driver_t *this, XvPortID xv_port) free(this->xvmc_cap); this->xvmc_cap = 0; xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_out_xxmc: Apparent attempt to use a direct XvMC " - "context\nvideo_out_xxmc: on a remote display. " - "Falling back to XV.\n"); + LOG_MODULE ": Apparent attempt to use a direct XvMC context on a remote display.\n" + LOG_MODULE ": Falling back to Xv.\n"); XVMCUNLOCKDISPLAY( this->display ); xvmc_context_writer_unlock( &this->xvmc_lock ); return; @@ -2284,7 +2346,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi XLockDisplay(this->display); if (Success != XvQueryExtension(this->display, &ver,&rel, &req, &ev,&err)) { - xprintf (class->xine, XINE_VERBOSITY_LOG, _("video_out_xxmc: Xv extension not present.\n")); + xprintf (class->xine, XINE_VERBOSITY_LOG, _("%s: Xv extension not present.\n"), LOG_MODULE); XUnlockDisplay(this->display); return NULL; } @@ -2294,7 +2356,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi */ if (Success != XvQueryAdaptors(this->display,DefaultRootWindow(this->display), &adaptors, &adaptor_info)) { - xprintf(class->xine, XINE_VERBOSITY_DEBUG, "video_out_xxmc: XvQueryAdaptors failed.\n"); + xprintf(class->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": XvQueryAdaptors failed.\n"); XUnlockDisplay(this->display); return NULL; } @@ -2321,8 +2383,9 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi if (!xv_port) { xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: Xv extension is present but I couldn't find a usable yuv12 port.\n" - " Looks like your graphics hardware driver doesn't support Xv?!\n")); + _("%s: Xv extension is present but I couldn't find a usable yuv12 port.\n" + "\tLooks like your graphics hardware driver doesn't support Xv?!\n"), + LOG_MODULE); /* XvFreeAdaptorInfo (adaptor_info); this crashed on me (gb)*/ XUnlockDisplay(this->display); @@ -2330,8 +2393,8 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi } else xprintf(class->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: using Xv port %ld from adaptor %s for hardware " - "colorspace conversion and scaling.\n"), xv_port, + _("%s: using Xv port %ld from adaptor %s for hardware " + "colorspace conversion and scaling.\n"), LOG_MODULE, xv_port, adaptor_info[adaptor_num].name); XUnlockDisplay(this->display); @@ -2407,7 +2470,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi if((attr[k].flags & XvSettable) && (attr[k].flags & XvGettable)) { if(!strcmp(attr[k].name, "XV_HUE")) { if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { - xprintf (this->xine, XINE_VERBOSITY_NONE, "video_out_xxmc: ignoring broken XV_HUE settings on NVidia cards\n"); + xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); } else { xxmc_check_capability (this, VO_PROP_HUE, attr[k], adaptor_info[adaptor_num].base_id, "XV_HUE", @@ -2477,7 +2540,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi XFree(attr); } else - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xxmc: no port attributes defined.\n"); + xprintf(this->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": no port attributes defined.\n"); XvFreeAdaptorInfo(adaptor_info); /* @@ -2506,12 +2569,12 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi this->xv_format_yv12 = fo[i].id; this->capabilities |= VO_CAP_YV12; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: this adaptor supports the yv12 format.\n")); + _("%s: this adaptor supports the yv12 format.\n"), LOG_MODULE); } else if (fo[i].id == XINE_IMGFMT_YUY2) { this->xv_format_yuy2 = fo[i].id; this->capabilities |= VO_CAP_YUY2; xprintf(this->xine, XINE_VERBOSITY_LOG, - _("video_out_xxmc: this adaptor supports the yuy2 format.\n")); + _("%s: this adaptor supports the yuy2 format.\n"), LOG_MODULE); } } @@ -2569,10 +2632,10 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi this->cur_field = XVMC_FRAME_PICTURE; #ifdef HAVE_VLDXVMC - printf("video_out_xxmc: Unichrome CPU saving is %s.\n", + printf("%s: Unichrome CPU saving is %s.\n", LOG_MODULE, (this->cpu_save_enabled) ? "on":"off"); #else - printf("video_out_xxmc: warning - compiled with no vld extensions.\n"); + printf("%s: warning - compiled with no vld extensions.\n", LOG_MODULE); #endif this->props[VO_PROP_MAX_NUM_FRAMES].value = (use_more_frames) ? 15:8; this->cpu_saver = 0.; |
