Commit 90a72314 authored by Eric Petit's avatar Eric Petit

macosx/prefs.m: compile fix

 macosx/vout*: fixed quality problems introduced in my last commit
   (noticeably slower now, but fixed), cleaning
parent 0a306cee
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* prefs.m: MacOS X module for vlc * prefs.m: MacOS X module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2003 VideoLAN * Copyright (C) 2002-2003 VideoLAN
* $Id: prefs.m,v 1.38 2004/01/30 12:44:21 hartman Exp $ * $Id: prefs.m,v 1.39 2004/02/02 08:50:41 titer Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <hartman at videolan.org> * Derk-Jan Hartman <hartman at videolan.org>
...@@ -38,6 +38,43 @@ ...@@ -38,6 +38,43 @@
#define MODULE_ID 1243 #define MODULE_ID 1243
#define CAPABILITY_ID 1244 #define CAPABILITY_ID 1244
/*****************************************************************************
* GetCapabilityHelp: Display the help for one capability.
*****************************************************************************/
static char * GetCapabilityHelp( char *psz_capability, int i_type)
{
if( psz_capability == NULL) return "";
if( !strcasecmp(psz_capability,"access") )
return i_type == 1 ? ACCESS_TITLE : ACCESS_HELP;
if( !strcasecmp(psz_capability,"audio filter") )
return i_type == 1 ? AUDIO_FILTER_TITLE : AUDIO_FILTER_HELP;
if( !strcasecmp(psz_capability,"audio output") )
return i_type == 1 ? AOUT_TITLE : AOUT_HELP;
if( !strcasecmp(psz_capability,"audio encoder") )
return i_type == 1 ? AOUT_ENC_TITLE : AOUT_ENC_HELP;
if( !strcasecmp(psz_capability,"chroma") )
return i_type == 1 ? CHROMA_TITLE : CHROMA_HELP;
if( !strcasecmp(psz_capability,"decoder") )
return i_type == 1 ? DECODER_TITLE : DECODER_HELP;
if( !strcasecmp(psz_capability,"demux") )
return i_type == 1 ? DEMUX_TITLE : DEMUX_HELP;
if( !strcasecmp(psz_capability,"interface") )
return i_type == 1 ? INTERFACE_TITLE : INTERFACE_HELP;
if( !strcasecmp(psz_capability,"sout access") )
return i_type == 1 ? SOUT_TITLE : SOUT_HELP;
if( !strcasecmp(psz_capability,"subtitle demux") )
return i_type == 1 ? SUBTITLE_DEMUX_TITLE : SUBTITLE_DEMUX_HELP;
if( !strcasecmp(psz_capability,"text renderer") )
return i_type == 1 ? TEXT_TITLE : TEXT_HELP;
if( !strcasecmp(psz_capability,"video output") )
return i_type == 1 ? VOUT__TITLE : VOUT_HELP;
if( !strcasecmp(psz_capability,"video filter") )
return i_type == 1 ? VIDEO_FILTER_TITLE : VIDEO_FILTER_HELP;
return " ";
}
/***************************************************************************** /*****************************************************************************
* VLCPrefs implementation * VLCPrefs implementation
*****************************************************************************/ *****************************************************************************/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.h: MacOS X interface module * vout.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * Copyright (C) 2001-2003 VideoLAN
* $Id: vout.h,v 1.20 2004/01/29 02:01:49 titer Exp $ * $Id: vout.h,v 1.21 2004/02/02 08:50:41 titer Exp $
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org> * Florian G. Pflug <fgp@phlo.org>
...@@ -58,12 +58,16 @@ ...@@ -58,12 +58,16 @@
*****************************************************************************/ *****************************************************************************/
@interface VLCGLView : NSOpenGLView @interface VLCGLView : NSOpenGLView
{ {
int i_init_done; vout_thread_t * p_vout;
unsigned long i_texture; int b_init_done;
unsigned long i_cur_texture;
float f_x;
float f_y;
} }
- (void) initTexture; - (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) p_vout;
- (void) reloadTexture: (uint8_t *) buffer; - (void) initTextures;
- (void) reloadTexture: (picture_t *) p_pic;
@end @end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.m: MacOS X video output module * vout.m: MacOS X video output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * Copyright (C) 2001-2003 VideoLAN
* $Id: vout.m,v 1.75 2004/01/29 02:01:49 titer Exp $ * $Id: vout.m,v 1.76 2004/02/02 08:50:41 titer Exp $
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org> * Florian G. Pflug <fgp@phlo.org>
...@@ -337,9 +337,9 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -337,9 +337,9 @@ static int vout_Init( vout_thread_t *p_vout )
if( p_vout->p_sys->i_opengl ) if( p_vout->p_sys->i_opengl )
{ {
/* Do this now instead of initWithFrame because we need a [p_vout->p_sys->o_glview lockFocus];
first buffer for the glTexImage2D call */ [p_vout->p_sys->o_glview initTextures];
[p_vout->p_sys->o_glview initTexture]; [p_vout->p_sys->o_glview unlockFocus];
} }
return( 0 ); return( 0 );
...@@ -476,8 +476,13 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -476,8 +476,13 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
} }
else else
{ {
/* Update the texture with our new picture */ if( [p_vout->p_sys->o_glview lockFocusIfCanDraw] )
[p_vout->p_sys->o_glview reloadTexture: p_pic->p->p_pixels]; {
[p_vout->p_sys->o_glview reloadTexture: p_pic];
[p_vout->p_sys->o_glview drawRect:
[p_vout->p_sys->o_glview bounds]];
[p_vout->p_sys->o_glview unlockFocus];
}
} }
} }
...@@ -1264,13 +1269,16 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1264,13 +1269,16 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
@implementation VLCGLView @implementation VLCGLView
- (id) initWithFrame: (NSRect) frame - (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) _p_vout
{ {
p_vout = _p_vout;
NSOpenGLPixelFormatAttribute attribs[] = NSOpenGLPixelFormatAttribute attribs[] =
{ {
NSOpenGLPFAAccelerated, NSOpenGLPFAAccelerated,
NSOpenGLPFANoRecovery, NSOpenGLPFANoRecovery,
NSOpenGLPFADoubleBuffer, NSOpenGLPFADoubleBuffer,
NSOpenGLPFAWindow,
0 0
}; };
...@@ -1288,146 +1296,149 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1288,146 +1296,149 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
[[self openGLContext] makeCurrentContext]; [[self openGLContext] makeCurrentContext];
[[self openGLContext] update]; [[self openGLContext] update];
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glClearColor( 0.0, 0.0, 0.0, 0.0 ); glClearColor( 0.0, 0.0, 0.0, 0.0 );
i_init_done = 0; b_init_done = 0;
return self; return self;
} }
- (void) reshape - (void) reshape
{ {
[[self openGLContext] update]; [[self openGLContext] makeCurrentContext];
NSRect bounds = [self bounds]; NSRect bounds = [self bounds];
glViewport( 0, 0, (GLint) bounds.size.width, glViewport( 0, 0, (GLint) bounds.size.width,
(GLint) bounds.size.height ); (GLint) bounds.size.height );
/* Quad size is set in order to preserve the aspect ratio */
if( bounds.size.height * p_vout->output.i_aspect <
bounds.size.width * VOUT_ASPECT_FACTOR )
{
f_x = bounds.size.height * p_vout->render.i_aspect /
VOUT_ASPECT_FACTOR / bounds.size.width;
f_y = 1.0;
}
else
{
f_x = 1.0;
f_y = bounds.size.width * VOUT_ASPECT_FACTOR /
p_vout->render.i_aspect / bounds.size.height;
}
} }
- (void) initTexture - (void) initTextures
{ {
vout_thread_t * p_vout; int i;
id o_window = [self window]; GLuint pi_textures[QT_MAX_DIRECTBUFFERS];
p_vout = (vout_thread_t *)[o_window getVout];
[self lockFocus];
[[self openGLContext] makeCurrentContext]; [[self openGLContext] makeCurrentContext];
/* Swap buffers only during the vertical retrace of the monitor. /* Create textures */
http://developer.apple.com/documentation/GraphicsImaging/ glGenTextures( QT_MAX_DIRECTBUFFERS, pi_textures );
Conceptual/OpenGL/chap5/chapter_5_section_44.html */
long params[] = { 1 };
CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval,
params );
/* Create the texture */ for( i = 0; i < I_OUTPUTPICTURES; i++ )
glGenTextures( 1, &i_texture ); {
glEnable( GL_TEXTURE_RECTANGLE_EXT ); glEnable( GL_TEXTURE_RECTANGLE_EXT );
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture ); glEnable( GL_UNPACK_CLIENT_STORAGE_APPLE );
glEnable( GL_APPLE_texture_range );
/* Turn on AGP transferts */
glTexParameterf( GL_TEXTURE_RECTANGLE_EXT, glBindTexture( GL_TEXTURE_RECTANGLE_EXT, pi_textures[i] );
GL_TEXTURE_PRIORITY, 0.0 );
#if 0
/* Use AGP texturing */ FIXME: the lines below are supposed to avoid a memcpy and get
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, a noticeable performance boost, but they are annoying side
GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE ); effects at the moment -- titer
/* Tell the driver not to make a copy of the texture but to use /* Use AGP texturing */
our buffer */ glTextureRangeAPPLE( GL_TEXTURE_RECTANGLE_EXT, 0, NULL );
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE );
/* Linear interpolation */ #endif
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
GL_TEXTURE_MIN_FILTER, GL_LINEAR ); /* Tell the driver not to make a copy of the texture but to use
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, our buffer */
GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
/* I have no idea what this exactly does, but it seems to be /* Linear interpolation */
necessary for scaling */ glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); /* I have no idea what this exactly does, but it seems to be
necessary for scaling */
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
p_vout->output.i_width, p_vout->output.i_height, 0, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE );
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, glTexParameteri( GL_TEXTURE_RECTANGLE_EXT,
PP_OUTPUTPICTURE[0]->p_data ); GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA,
p_vout->output.i_width, p_vout->output.i_height, 0,
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
PP_OUTPUTPICTURE[i]->p_data );
PP_OUTPUTPICTURE[i]->p_sys = malloc( sizeof( GLuint ) );
*((GLuint*) PP_OUTPUTPICTURE[i]->p_sys) = pi_textures[i];
}
i_init_done = 1; b_init_done = 1;
[self unlockFocus];
} }
- (void) reloadTexture: (uint8_t *) buffer - (void) reloadTexture: (picture_t *) p_pic
{ {
vout_thread_t * p_vout; i_cur_texture = *((GLuint*) p_pic->p_sys);
id o_window = [self window];
p_vout = (vout_thread_t *)[o_window getVout];
[self lockFocus];
[[self openGLContext] makeCurrentContext]; [[self openGLContext] makeCurrentContext];
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture );
/* glTexSubImage2D is usually faster than glTexImage2D */ glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_cur_texture );
/* 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, glTexSubImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0,
p_vout->output.i_width, p_vout->output.i_height, p_vout->output.i_width, p_vout->output.i_height,
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
buffer ); p_pic->p_data );
[self drawRect: [self bounds]];
[self unlockFocus];
} }
- (void) drawRect: (NSRect) rect - (void) drawRect: (NSRect) rect
{ {
vout_thread_t * p_vout; [[self openGLContext] makeCurrentContext];
id o_window = [self window];
p_vout = (vout_thread_t *)[o_window getVout];
/* 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 );
/* Black background */ /* Black background */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
if( !i_init_done ) if( !b_init_done )
return;
/* Draw a quad with our texture on it. Quad size is set in order
to preserve the aspect ratio */
NSRect bounds = [self bounds];
float f_x, f_y;
if( bounds.size.height * p_vout->output.i_aspect <
bounds.size.width * VOUT_ASPECT_FACTOR )
{ {
f_x = bounds.size.height * p_vout->output.i_aspect / [[self openGLContext] flushBuffer];
VOUT_ASPECT_FACTOR / bounds.size.width; return;
f_y = 1.0;
}
else
{
f_x = 1.0;
f_y = bounds.size.width * VOUT_ASPECT_FACTOR /
p_vout->output.i_aspect / bounds.size.height;
} }
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture ); /* Draw a quad with our texture on it */
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_cur_texture );
glBegin( GL_QUADS ); glBegin( GL_QUADS );
/* Top left */ /* Top left */
glTexCoord2f( 0.0f, 0.0f ); glTexCoord2f( 0.0, 0.0 );
glVertex2f( - f_x, f_y ); glVertex2f( - f_x, f_y );
/* Bottom left */ /* Bottom left */
glTexCoord2f( 0.0f, (float) p_vout->output.i_height ); glTexCoord2f( 0.0, (float) p_vout->output.i_height );
glVertex2f( - f_x, - f_y ); glVertex2f( - f_x, - f_y );
/* Bottom right */ /* Bottom right */
glTexCoord2f( (float) p_vout->output.i_width, glTexCoord2f( (float) p_vout->output.i_width,
(float) p_vout->output.i_height ); (float) p_vout->output.i_height );
glVertex2f( f_x, - f_y ); glVertex2f( f_x, - f_y );
/* Top right */ /* Top right */
glTexCoord2f( (float) p_vout->output.i_width, 0.0f ); glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
glVertex2f( f_x, f_y ); glVertex2f( f_x, f_y );
glEnd(); glEnd();
...@@ -1552,7 +1563,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1552,7 +1563,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
else else
{ {
#define o_glview p_vout->p_sys->o_glview #define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect]; o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];
[p_vout->p_sys->o_window setContentView: o_glview]; [p_vout->p_sys->o_window setContentView: o_glview];
[o_glview autorelease]; [o_glview autorelease];
#undef o_glview #undef o_glview
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment