Commit aea6698d authored by Sam Hocevar's avatar Sam Hocevar

  * ./include/common.h: hton64 is now an inline function.
  * ./src/video_output/vout_pictures.c et al.: vout4 now automatically
    detects when two chroma formats are the same, such as UYVY/Y422, or
    roughly equivalent, such as I420/YV12. Plugins need not worry about
    conversion anymore.
parent 53b978f8
List of known vlc bugs
$Id: BUGS,v 1.1 2002/01/04 14:01:33 sam Exp $
$Id: BUGS,v 1.2 2002/01/05 02:22:02 sam Exp $
Please try to keep this file up to date. Also, grep for FIXME in the
source files for more and more bugs to fix.
......@@ -23,10 +23,18 @@ Input:
* vlc:foo targets don't work anymore.
Audio output:
* Audio output stutters on some audio cards. For instance kwyxz's SB
128 with an es1371 chip.
Video output:
* We don't render subtitles on RGB surfaces.
* Subtitle colors are just plain wrong.
* The DirectX video output plugin is broken because of vout4.
* The GGI video output plugin is broken because of vout4.
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.64 2002/01/04 14:01:34 sam Exp $
* $Id: common.h,v 1.65 2002/01/05 02:22:02 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -286,8 +286,6 @@ struct probedata_s;
* byte orders other than little and big endians are not supported, but only
* the VAX seems to have such exotic properties - note that these 'functions'
* needs <netinet/in.h> or the local equivalent. */
/* FIXME: hton64 should be declared as an extern inline function to avoid
* border effects (see byteorder.h) */
#if WORDS_BIGENDIAN
# define hton16 htons
# define hton32 htonl
......@@ -298,7 +296,12 @@ struct probedata_s;
#else
# define hton16 htons
# define hton32 htonl
# define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
static __inline__ u64 __hton64( u64 i )
{
return ((u64)(htonl((i) & 0xffffffff)) << 32)
| htonl(((i) >> 32) & 0xffffffff );
}
# define hton64(i) __hton64( i )
# define ntoh16 ntohs
# define ntoh32 ntohl
# define ntoh64 hton64
......
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.39 2002/01/04 14:01:34 sam Exp $
* $Id: video.h,v 1.40 2002/01/05 02:22:03 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -174,6 +174,62 @@ typedef struct picture_heap_s
#define U_PIXELS p[U_PLANE].p_pixels
#define V_PIXELS p[V_PLANE].p_pixels
static __inline__ int vout_ChromaCmp( u32 i_chroma, u32 i_amorhc )
{
/* If they are the same, they are the same ! */
if( i_chroma == i_amorhc )
{
return 1;
}
/* Check for equivalence classes */
switch( i_chroma )
{
case FOURCC_I420:
case FOURCC_IYUV:
case FOURCC_YV12:
switch( i_amorhc )
{
case FOURCC_I420:
case FOURCC_IYUV:
case FOURCC_YV12:
return 1;
default:
return 0;
}
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
switch( i_amorhc )
{
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
return 1;
default:
return 0;
}
case FOURCC_YUY2:
case FOURCC_YUNV:
switch( i_amorhc )
{
case FOURCC_YUY2:
case FOURCC_YUNV:
return 1;
default:
return 0;
}
default:
return 0;
}
}
/*****************************************************************************
* vout_CopyPicture: copy a picture to another one
*****************************************************************************
......
......@@ -2,7 +2,7 @@
* vout_sdl.c: SDL video output display method
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: vout_sdl.c,v 1.76 2002/01/04 14:01:34 sam Exp $
* $Id: vout_sdl.c,v 1.77 2002/01/05 02:22:03 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Pierre Baillet <oct@zoy.org>
......@@ -61,13 +61,12 @@
typedef struct vout_sys_s
{
SDL_Surface * p_display; /* display device */
SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
int i_width;
int i_height;
/* For YUV output */
u32 i_chroma; /* The internally selected chroma */
SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
/* For RGB output */
int i_surfaces;
......@@ -111,47 +110,6 @@ static __inline__ void vout_Seek( off_t i_seek )
#undef area
}
/*****************************************************************************
* Return the best suited FourCC value for a given chroma. We use this
* because a decoder may output FOURCC_IYUV, which is exactly the same as
* FOURCC_I420, but X servers usually know FOURCC_I420 and not FOURCC_IYUV.
*****************************************************************************/
static __inline__ u32 BestChroma( u32 i_chroma )
{
/* XXX: don't forget to update vout_Init if you change this */
switch( i_chroma )
{
/* These ones are almost the same */
case FOURCC_I420:
case FOURCC_IYUV:
case FOURCC_YV12:
return SDL_YV12_OVERLAY;
/* These ones are all the same */
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
return SDL_UYVY_OVERLAY;
/* These ones are all the same */
case FOURCC_YUY2:
case FOURCC_YUNV:
return SDL_YUY2_OVERLAY;
/* We know this one */
case FOURCC_YVYU:
return SDL_YVYU_OVERLAY;
/* This is seldom supported, but we know how to convert it */
case FOURCC_I422:
return SDL_YUY2_OVERLAY;
/* We don't know this chroma, but maybe SDL does */
default:
return i_chroma;
}
}
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -301,7 +259,6 @@ static int vout_Init( vout_thread_t *p_vout )
if( p_vout->p_sys->p_overlay == NULL )
{
/* All we have is an RGB image with square pixels */
p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
p_vout->output.i_width = p_vout->p_sys->i_width;
p_vout->output.i_height = p_vout->p_sys->i_height;
p_vout->output.i_aspect = p_vout->p_sys->i_width
......@@ -310,46 +267,11 @@ static int vout_Init( vout_thread_t *p_vout )
}
else
{
switch( p_vout->render.i_chroma )
{
case FOURCC_I420:
case FOURCC_IYUV:
case FOURCC_YV12:
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
case FOURCC_YUY2:
case FOURCC_YUNV:
case FOURCC_YVYU:
/* We can directly handle all these chromas */
p_vout->output.i_chroma = p_vout->render.i_chroma;
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
break;
case FOURCC_I422:
/* We need to convert this one, but at least we keep the
* aspect ratio */
p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
break;
default:
/* All we have is an RGB image with square pixels */
p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
p_vout->output.i_width = p_vout->p_sys->i_width;
p_vout->output.i_height = p_vout->p_sys->i_height;
p_vout->output.i_aspect = p_vout->p_sys->i_width
* VOUT_ASPECT_FACTOR
/ p_vout->p_sys->i_height;
break;
}
/* We may need to convert the chroma, but at least we keep the
* aspect ratio */
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
}
/* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
......@@ -674,35 +596,80 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
SDL_LockSurface( p_vout->p_sys->p_display );
/* Ask BestChroma what we should use as a chroma */
p_vout->p_sys->i_chroma = BestChroma( p_vout->render.i_chroma );
switch( p_vout->render.i_chroma )
{
case FOURCC_I420:
case FOURCC_IYUV:
p_vout->output.i_chroma = SDL_IYUV_OVERLAY;
break;
case FOURCC_YUY2:
case FOURCC_YUNV:
p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
break;
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
p_vout->output.i_chroma = SDL_UYVY_OVERLAY;
break;
case FOURCC_YVYU:
p_vout->output.i_chroma = SDL_YVYU_OVERLAY;
break;
case FOURCC_YV12:
default:
p_vout->output.i_chroma = SDL_YV12_OVERLAY;
break;
}
p_vout->p_sys->p_overlay =
SDL_CreateYUVOverlay( 32, 32, p_vout->p_sys->i_chroma,
SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
p_vout->p_sys->p_display );
/* See if BestChroma's guess was valid */
if( p_vout->p_sys->p_overlay == NULL )
{
intf_WarnMsg( 3, "vout warning: cannot set SDL overlay 0x%.8llx",
p_vout->p_sys->i_chroma );
p_vout->output.i_chroma = SDL_IYUV_OVERLAY;
p_vout->p_sys->p_overlay =
SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
p_vout->p_sys->p_display );
}
if( p_vout->p_sys->p_overlay == NULL )
{
p_vout->output.i_chroma = SDL_YV12_OVERLAY;
p_vout->p_sys->p_overlay =
SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
p_vout->p_sys->p_display );
}
if( p_vout->p_sys->p_overlay == NULL )
{
p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
p_vout->p_sys->p_overlay =
SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
p_vout->p_sys->p_display );
}
if( p_vout->p_sys->p_overlay == NULL )
{
intf_WarnMsg( 3, "vout warning: no SDL overlay for 0x%.8x (%4.4s)",
p_vout->render.i_chroma,
(char*)&p_vout->render.i_chroma );
switch( p_vout->p_sys->p_display->format->BitsPerPixel )
{
case 8:
p_vout->p_sys->i_chroma = FOURCC_BI_RGB;
p_vout->output.i_chroma = FOURCC_BI_RGB;
break;
case 15:
p_vout->p_sys->i_chroma = FOURCC_RV15;
p_vout->output.i_chroma = FOURCC_RV15;
break;
case 16:
p_vout->p_sys->i_chroma = FOURCC_RV16;
p_vout->output.i_chroma = FOURCC_RV16;
break;
case 24:
p_vout->p_sys->i_chroma = FOURCC_BI_BITFIELDS;
p_vout->output.i_chroma = FOURCC_BI_BITFIELDS;
break;
case 32:
p_vout->p_sys->i_chroma = FOURCC_BI_BITFIELDS;
p_vout->output.i_chroma = FOURCC_BI_BITFIELDS;
break;
default:
intf_ErrMsg( "vout error: unknown screen depth" );
......@@ -760,123 +727,121 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
int i_width = p_vout->output.i_width;
int i_height = p_vout->output.i_height;
switch( p_vout->p_sys->i_chroma )
if( p_vout->p_sys->p_overlay == NULL )
{
case SDL_YV12_OVERLAY:
case SDL_IYUV_OVERLAY:
case SDL_YUY2_OVERLAY:
case SDL_UYVY_OVERLAY:
case SDL_YVYU_OVERLAY:
p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
if( p_pic->p_sys == NULL )
{
return -1;
}
p_pic->p_sys->p_overlay =
SDL_CreateYUVOverlay( i_width, i_height,
p_vout->p_sys->i_chroma,
p_vout->p_sys->p_display );
if( p_pic->p_sys->p_overlay == NULL )
{
free( p_pic->p_sys );
return -1;
}
SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
p_pic->Y_PIXELS = p_pic->p_sys->p_overlay->pixels[0];
p_pic->p[Y_PLANE].i_lines = p_pic->p_sys->p_overlay->h;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[0];
/* RGB picture */
if( p_vout->p_sys->i_surfaces )
{
/* We already allocated this surface, return */
return -1;
}
switch( p_vout->p_sys->i_chroma )
{
case SDL_YV12_OVERLAY:
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0;
p_pic->i_planes = 3;
break;
p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
case SDL_IYUV_OVERLAY:
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0;
if( p_pic->p_sys == NULL )
{
return -1;
}
p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->p->p_pixels = p_vout->p_sys->p_display->pixels;
p_pic->p->i_lines = p_vout->p_sys->p_display->h;
p_pic->p->i_pitch = p_vout->p_sys->p_display->pitch;
p_pic->p->i_pixel_bytes = 2;
p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0;
if( p_pic->p->i_pitch == 2 * p_vout->p_sys->p_display->w )
{
p_pic->p->b_margin = 0;
}
else
{
p_pic->p->b_margin = 1;
p_pic->p->b_hidden = 1;
p_pic->p->i_visible_bytes = 2 * p_vout->p_sys->p_display->w;
}
p_pic->i_planes = 3;
break;
p_pic->p->i_red_mask = p_vout->p_sys->p_display->format->Rmask;
p_pic->p->i_green_mask = p_vout->p_sys->p_display->format->Gmask;
p_pic->p->i_blue_mask = p_vout->p_sys->p_display->format->Bmask;
default:
p_pic->p[Y_PLANE].i_pixel_bytes = 2;
p_pic->p[Y_PLANE].b_margin = 0;
p_vout->p_sys->i_surfaces++;
p_pic->i_planes = 1;
break;
}
p_pic->i_planes = 1;
}
else
{
p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
return 0;
if( p_pic->p_sys == NULL )
{
return -1;
}
default:
/* RGB picture */
if( p_vout->p_sys->i_surfaces )
{
/* We already allocated this surface, return */
return -1;
}
p_pic->p_sys->p_overlay =
SDL_CreateYUVOverlay( i_width, i_height,
p_vout->output.i_chroma,
p_vout->p_sys->p_display );
p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
if( p_pic->p_sys->p_overlay == NULL )
{
free( p_pic->p_sys );
return -1;
}
if( p_pic->p_sys == NULL )
{
return -1;
}
SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
p_pic->p->p_pixels = p_vout->p_sys->p_display->pixels;
p_pic->p->i_lines = p_vout->p_sys->p_display->h;
p_pic->p->i_pitch = p_vout->p_sys->p_display->pitch;
p_pic->Y_PIXELS = p_pic->p_sys->p_overlay->pixels[0];
p_pic->p[Y_PLANE].i_lines = p_pic->p_sys->p_overlay->h;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[0];
p_pic->p->i_pixel_bytes = 2;
if( p_pic->p->i_pitch != 2 * p_vout->p_sys->p_display->w )
{
intf_ErrMsg("OOO XXX OOO --- Wooooooohoooo !! --- OOO XXX OOO");
intf_ErrMsg("%i != 2 * %i", p_pic->p->i_pitch, p_vout->p_sys->p_display->w );
}
p_pic->p->b_margin = 0;
switch( p_vout->output.i_chroma )
{
case SDL_YV12_OVERLAY:
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0;
p_pic->i_planes = 3;
break;
p_pic->p->i_red_mask = p_vout->p_sys->p_display->format->Rmask;
p_pic->p->i_green_mask = p_vout->p_sys->p_display->format->Gmask;
p_pic->p->i_blue_mask = p_vout->p_sys->p_display->format->Bmask;
case SDL_IYUV_OVERLAY:
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0;
p_pic->i_planes = 3;
break;
p_vout->p_sys->i_surfaces++;
default:
p_pic->p[Y_PLANE].i_pixel_bytes = 2;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->i_planes = 1;
return 0;
break;
}
}
return 0;
}
......@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.5 2002/01/04 14:01:34 sam Exp $
* $Id: xcommon.c,v 1.6 2002/01/05 02:22:03 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -112,7 +112,7 @@ static void DestroyCursor ( vout_thread_t * );
static void ToggleCursor ( vout_thread_t * );
#ifdef MODULE_NAME_IS_xvideo
static int XVideoGetPort ( Display *, int );
static int XVideoGetPort ( Display *, u32, u32 * );
static void XVideoReleasePort ( Display *, int );
#endif
......@@ -138,7 +138,6 @@ typedef struct vout_sys_s
Window yuv_window; /* sub-window for displaying yuv video
data */
int i_xvport;
u32 i_chroma; /* the chroma we will select */
#else
Colormap colormap; /* colormap used (8bpp only) */
......@@ -236,41 +235,6 @@ static __inline__ void vout_Seek( off_t i_seek )
#undef area
}
/*****************************************************************************
* Return the best suited FourCC value for a given chroma. We use this
* because a decoder may output FOURCC_IYUV, which is exactly the same as
* FOURCC_I420, but X servers usually know FOURCC_I420 and not FOURCC_IYUV.
*****************************************************************************/
static __inline__ u32 BestChroma( u32 i_chroma )
{
/* XXX: don't forget to update vout_Init if you change this */
switch( i_chroma )
{
/* These ones are all the same */
case FOURCC_I420:
case FOURCC_IYUV:
case FOURCC_YV12:
return FOURCC_I420;
/* These ones are all the same */
case FOURCC_YUY2:
case FOURCC_YUNV:
return FOURCC_YUY2;