Commit d8e44fce authored by Sam Hocevar's avatar Sam Hocevar

  * Fixed aspect ratio handling.
  * Fixed potential compilation issues under eg. BSD/OS.
parent fb39f2e7
...@@ -80,6 +80,9 @@ LIB_GGI = @LIB_GGI@ ...@@ -80,6 +80,9 @@ LIB_GGI = @LIB_GGI@
LIB_GLIDE = @LIB_GLIDE@ LIB_GLIDE = @LIB_GLIDE@
LIB_GNOME = @LIB_GNOME@ LIB_GNOME = @LIB_GNOME@
LIB_GTK = @LIB_GTK@ LIB_GTK = @LIB_GTK@
LIB_IMDCT = @LIB_IMDCT@
LIB_IMDCT3DN = @LIB_IMDCT3DN@
LIB_IMDCTSSE = @LIB_IMDCTSSE@
LIB_KDE = @LIB_KDE@ LIB_KDE = @LIB_KDE@
LIB_LIBDVDCSS = @LIB_LIBDVDCSS@ LIB_LIBDVDCSS = @LIB_LIBDVDCSS@
LIB_MACOSX = @LIB_MACOSX@ LIB_MACOSX = @LIB_MACOSX@
......
This diff is collapsed.
...@@ -145,7 +145,12 @@ AC_FUNC_MMAP ...@@ -145,7 +145,12 @@ AC_FUNC_MMAP
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_LIB(dl,dlopen,LIB="${LIB} -ldl") AC_CHECK_LIB(dl,dlopen,LIB="${LIB} -ldl")
AC_CHECK_LIB(m,cos,LIB_IMDCT="${LIB_IMDCT} -lm") AC_CHECK_LIB(m,cos,LIB_IMDCT="${LIB_IMDCT} -lm")
AC_CHECK_LIB(m,pow,LIB_YUV="${LIB_YUV} -lm") AC_CHECK_LIB(m,pow,
LIB_YUV="${LIB_YUV} -lm"
LIB_IMDCT="${LIB_IMDCT} -lm"
LIB_IMDCT3DN="${LIB_IMDCT3DN} -lm"
LIB_IMDCTSSE="${LIB_IMDCTSSE} -lm"
)
dnl Check for pthreads - borrowed from XMMS dnl Check for pthreads - borrowed from XMMS
THREAD_LIB=error THREAD_LIB=error
...@@ -1260,6 +1265,9 @@ AC_SUBST(LIB_GGI) ...@@ -1260,6 +1265,9 @@ AC_SUBST(LIB_GGI)
AC_SUBST(LIB_GLIDE) AC_SUBST(LIB_GLIDE)
AC_SUBST(LIB_GNOME) AC_SUBST(LIB_GNOME)
AC_SUBST(LIB_GTK) AC_SUBST(LIB_GTK)
AC_SUBST(LIB_IMDCT)
AC_SUBST(LIB_IMDCT3DN)
AC_SUBST(LIB_IMDCTSSE)
AC_SUBST(LIB_KDE) AC_SUBST(LIB_KDE)
AC_SUBST(LIB_LIBDVDCSS) AC_SUBST(LIB_LIBDVDCSS)
AC_SUBST(LIB_MACOSX) AC_SUBST(LIB_MACOSX)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.57 2001/12/12 02:13:50 sam Exp $ * $Id: common.h,v 1.58 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -544,8 +544,7 @@ typedef struct module_symbols_s ...@@ -544,8 +544,7 @@ typedef struct module_symbols_s
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, int, int ); struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, int, int );
struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *, struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
int, int ); int, int );
struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s *, struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s * );
int, int, int, int );
void ( * vout_DestroySubPicture ) ( struct vout_thread_s *, void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * ); struct subpicture_s * );
...@@ -561,6 +560,8 @@ typedef struct module_symbols_s ...@@ -561,6 +560,8 @@ typedef struct module_symbols_s
struct picture_s * ); struct picture_s * );
void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout, void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
struct picture_s *p_pic, mtime_t ); struct picture_s *p_pic, mtime_t );
void ( * vout_PlacePicture ) ( struct vout_thread_s *, int, int,
int *, int *, int *, int * );
u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int ); u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
void ( * UnalignedRemoveBits ) ( struct bit_stream_s * ); void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
(p_symbols)->vout_DatePicture = vout_DatePicture; \ (p_symbols)->vout_DatePicture = vout_DatePicture; \
(p_symbols)->vout_LinkPicture = vout_LinkPicture; \ (p_symbols)->vout_LinkPicture = vout_LinkPicture; \
(p_symbols)->vout_UnlinkPicture = vout_UnlinkPicture; \ (p_symbols)->vout_UnlinkPicture = vout_UnlinkPicture; \
(p_symbols)->vout_PlacePicture = vout_PlacePicture; \
(p_symbols)->UnalignedGetBits = UnalignedGetBits; \ (p_symbols)->UnalignedGetBits = UnalignedGetBits; \
(p_symbols)->UnalignedRemoveBits = UnalignedRemoveBits; \ (p_symbols)->UnalignedRemoveBits = UnalignedRemoveBits; \
(p_symbols)->UnalignedShowBits = UnalignedShowBits; \ (p_symbols)->UnalignedShowBits = UnalignedShowBits; \
...@@ -205,6 +206,7 @@ ...@@ -205,6 +206,7 @@
# define vout_DatePicture p_symbols->vout_DatePicture # define vout_DatePicture p_symbols->vout_DatePicture
# define vout_LinkPicture p_symbols->vout_LinkPicture # define vout_LinkPicture p_symbols->vout_LinkPicture
# define vout_UnlinkPicture p_symbols->vout_UnlinkPicture # define vout_UnlinkPicture p_symbols->vout_UnlinkPicture
# define vout_PlacePicture p_symbols->vout_PlacePicture
# define DecodeLanguage p_symbols->DecodeLanguage # define DecodeLanguage p_symbols->DecodeLanguage
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* includes all common video types and constants. * includes all common video types and constants.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.33 2001/12/09 17:01:35 sam Exp $ * $Id: video.h,v 1.34 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -60,6 +60,7 @@ typedef struct picture_s ...@@ -60,6 +60,7 @@ typedef struct picture_s
/* Type and flags - should NOT be modified except by the vout thread */ /* Type and flags - should NOT be modified except by the vout thread */
int i_status; /* picture flags */ int i_status; /* picture flags */
int i_type; /* is picture a direct buffer ? */
int i_matrix_coefficients; /* in YUV type, encoding type */ int i_matrix_coefficients; /* in YUV type, encoding type */
/* Picture management properties - these properties can be modified using /* Picture management properties - these properties can be modified using
...@@ -67,14 +68,6 @@ typedef struct picture_s ...@@ -67,14 +68,6 @@ typedef struct picture_s
int i_refcount; /* link reference counter */ int i_refcount; /* link reference counter */
mtime_t date; /* display date */ mtime_t date; /* display date */
/* Picture static properties - those properties are fixed at initialization
* and should NOT be modified */
int i_width; /* picture width */
int i_height; /* picture height */
int i_chroma; /* picture chroma */
int i_aspect_ratio; /* aspect ratio */
boolean_t b_directbuffer; /* is it a direct buffer ? */
/* These values can be calculated from i_chroma, i_width and i_height /* These values can be calculated from i_chroma, i_width and i_height
* but we leave them to prevent unnecessary calculation */ * but we leave them to prevent unnecessary calculation */
int i_size; int i_size;
...@@ -104,16 +97,31 @@ typedef struct picture_s ...@@ -104,16 +97,31 @@ typedef struct picture_s
} picture_t; } picture_t;
/* Pictures chromas */ /*****************************************************************************
#define EMPTY_PICTURE 0 /* picture slot is empty and available */ * picture_heap_t: video picture heap
#define YUV_420_PICTURE 100 /* 4:2:0 YUV picture */ *****************************************************************************/
#define YUV_422_PICTURE 101 /* 4:2:2 YUV picture */ typedef struct picture_heap_s
#define YUV_444_PICTURE 102 /* 4:4:4 YUV picture */ {
#define RGB_8BPP_PICTURE 200 /* RGB 8bpp picture */ int i_pictures; /* current heap size */
#define RGB_16BPP_PICTURE 201 /* RGB 16bpp picture */
#define RGB_32BPP_PICTURE 202 /* RGB 32bpp picture */
/* Pictures status */ /* Picture static properties - those properties are fixed at initialization
* and should NOT be modified */
int i_width; /* picture width */
int i_height; /* picture height */
int i_chroma; /* picture chroma */
int i_aspect; /* aspect ratio */
/* Real pictures */
picture_t* pp_picture[VOUT_MAX_PICTURES]; /* pictures */
} picture_heap_t;
/* Picture type */
#define EMPTY_PICTURE 0 /* empty buffer */
#define MEMORY_PICTURE 100 /* heap-allocated buffer */
#define DIRECT_PICTURE 200 /* direct buffer */
/* Picture status */
#define FREE_PICTURE 0 /* free and not allocated */ #define FREE_PICTURE 0 /* free and not allocated */
#define RESERVED_PICTURE 1 /* allocated and reserved */ #define RESERVED_PICTURE 1 /* allocated and reserved */
#define RESERVED_DATED_PICTURE 2 /* waiting for DisplayPicture */ #define RESERVED_DATED_PICTURE 2 /* waiting for DisplayPicture */
...@@ -122,7 +130,16 @@ typedef struct picture_s ...@@ -122,7 +130,16 @@ typedef struct picture_s
#define DISPLAYED_PICTURE 5 /* been displayed but is linked */ #define DISPLAYED_PICTURE 5 /* been displayed but is linked */
#define DESTROYED_PICTURE 6 /* allocated but no more used */ #define DESTROYED_PICTURE 6 /* allocated but no more used */
/* Aspect ratios (ISO/IEC 13818-2 section 6.3.3, table 6-3) */ /* Picture chroma */
#define EMPTY_PICTURE 0 /* picture slot is empty and available */
#define YUV_420_PICTURE 100 /* 4:2:0 YUV picture */
#define YUV_422_PICTURE 101 /* 4:2:2 YUV picture */
#define YUV_444_PICTURE 102 /* 4:4:4 YUV picture */
#define RGB_8BPP_PICTURE 200 /* RGB 8bpp picture */
#define RGB_16BPP_PICTURE 201 /* RGB 16bpp picture */
#define RGB_32BPP_PICTURE 202 /* RGB 32bpp picture */
/* Aspect ratio (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
#define AR_SQUARE_PICTURE 1 /* square pixels */ #define AR_SQUARE_PICTURE 1 /* square pixels */
#define AR_3_4_PICTURE 2 /* 3:4 picture (TV) */ #define AR_3_4_PICTURE 2 /* 3:4 picture (TV) */
#define AR_16_9_PICTURE 3 /* 16:9 picture (wide screen) */ #define AR_16_9_PICTURE 3 /* 16:9 picture (wide screen) */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* thread, and destroy a previously oppenned video output thread. * thread, and destroy a previously oppenned video output thread.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.64 2001/12/09 17:01:35 sam Exp $ * $Id: video_output.h,v 1.65 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -68,27 +68,6 @@ typedef struct vout_chroma_s ...@@ -68,27 +68,6 @@ typedef struct vout_chroma_s
} vout_chroma_t; } vout_chroma_t;
/*****************************************************************************
* vout_buffer_t: rendering buffer
*****************************************************************************
* This structure stores information about a buffer. Buffers are not completely
* cleared between displays, and modified areas need to be stored.
*****************************************************************************/
typedef struct vout_buffer_s
{
/* Picture area */
int i_pic_x, i_pic_y; /* picture position */
int i_pic_width, i_pic_height; /* picture size */
/* Other areas - only vertical extensions of areas are stored */
int i_areas; /* number of areas */
int pi_area_begin[VOUT_MAX_AREAS]; /* beginning of area */
int pi_area_end[VOUT_MAX_AREAS]; /* end of area */
/* Picture data */
byte_t * p_data; /* memory address */
} vout_buffer_t;
/***************************************************************************** /*****************************************************************************
* vout_fifo_t * vout_fifo_t
*****************************************************************************/ *****************************************************************************/
...@@ -128,32 +107,15 @@ typedef struct vout_thread_s ...@@ -128,32 +107,15 @@ typedef struct vout_thread_s
int * pi_status; /* temporary status flag */ int * pi_status; /* temporary status flag */
p_vout_sys_t p_sys; /* system output method */ p_vout_sys_t p_sys; /* system output method */
/* Current input properties */
int i_width; /* current input width */
int i_height; /* current input height */
int i_chroma; /* current input chroma */
int i_aspect_ratio; /* current input aspect ratio */
/* Current display properties */ /* Current display properties */
u16 i_changes; /* changes made to the thread */ u16 i_changes; /* changes made to the thread */
float f_gamma; /* gamma */ float f_gamma; /* gamma */
boolean_t b_grayscale; /* color or grayscale display */
/* Color masks and shifts in RGB mode - masks are set by system boolean_t b_info; /* print additional information */
* initialization, shifts are calculated. A pixel color value can be boolean_t b_interface; /* render interface */
* obtained using the formula ((value >> rshift) << lshift) */ boolean_t b_scale; /* allow picture scaling */
u32 i_red_mask; /* red mask */ boolean_t b_fullscreen; /* toogle fullscreen display */
u32 i_green_mask; /* green mask */ mtime_t render_time; /* last picture render time */
u32 i_blue_mask; /* blue mask */
int i_red_lshift, i_red_rshift; /* red shifts */
int i_green_lshift, i_green_rshift; /* green shifts */
int i_blue_lshift, i_blue_rshift; /* blue shifts */
/* Useful pre-calculated pixel values - these are not supposed to be
* accurate values, but rather values looking nice, given their usage. */
u32 i_white_pixel; /* white */
u32 i_black_pixel; /* black */
u32 i_gray_pixel; /* gray */
u32 i_blue_pixel; /* blue */
/* Plugin used and shortcuts to access its capabilities */ /* Plugin used and shortcuts to access its capabilities */
struct module_s * p_module; struct module_s * p_module;
...@@ -167,26 +129,21 @@ typedef struct vout_thread_s ...@@ -167,26 +129,21 @@ typedef struct vout_thread_s
void ( *pf_setpalette ) ( struct vout_thread_s *, void ( *pf_setpalette ) ( struct vout_thread_s *,
u16 *, u16 *, u16 * ); u16 *, u16 *, u16 * );
/* Pictures and rendering properties */
boolean_t b_grayscale; /* color or grayscale display */
boolean_t b_info; /* print additional information */
boolean_t b_interface; /* render interface */
boolean_t b_scale; /* allow picture scaling */
boolean_t b_fullscreen; /* toogle fullscreen display */
mtime_t render_time; /* last picture render time */
/* Statistics - these numbers are not supposed to be accurate, but are a /* Statistics - these numbers are not supposed to be accurate, but are a
* good indication of the thread status */ * good indication of the thread status */
count_t c_fps_samples; /* picture counts */ count_t c_fps_samples; /* picture counts */
mtime_t p_fps_sample[VOUT_FPS_SAMPLES]; /* FPS samples dates */ mtime_t p_fps_sample[VOUT_FPS_SAMPLES]; /* FPS samples dates */
/* Video heap and translation tables */ /* Video heap and translation tables */
int i_heap_size; /* heap size */
picture_heap_t render; /* rendered pictures */
picture_heap_t output; /* direct buffers */
boolean_t b_direct; /* rendered are like direct ? */
vout_chroma_t chroma; /* translation tables */
/* Picture and subpicture heaps */
picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */ picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /* subpictures */ subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /* subpictures */
int i_directbuffers; /* number of pictures in VRAM */
int i_pictures; /* current heap size */
vout_chroma_t chroma; /* translation tables */
/* Bitmap fonts */ /* Bitmap fonts */
p_vout_font_t p_default_font; /* default font */ p_vout_font_t p_default_font; /* default font */
...@@ -200,6 +157,11 @@ typedef struct vout_thread_s ...@@ -200,6 +157,11 @@ typedef struct vout_thread_s
* calculation of the jitter */ * calculation of the jitter */
} vout_thread_t; } vout_thread_t;
#define I_OUTPUTPICTURES p_vout->output.i_pictures
#define PP_OUTPUTPICTURE p_vout->output.pp_picture
#define I_RENDERPICTURES p_vout->render.i_pictures
#define PP_RENDERPICTURE p_vout->render.pp_picture
/* Flags for changes - these flags are set in the i_changes field when another /* Flags for changes - these flags are set in the i_changes field when another
* thread changed a variable */ * thread changed a variable */
#define VOUT_INFO_CHANGE 0x0001 /* b_info changed */ #define VOUT_INFO_CHANGE 0x0001 /* b_info changed */
...@@ -218,17 +180,6 @@ typedef struct vout_thread_s ...@@ -218,17 +180,6 @@ typedef struct vout_thread_s
#define MAX_JITTER_SAMPLES 20 #define MAX_JITTER_SAMPLES 20
/*****************************************************************************
* Macros
*****************************************************************************/
/* RGB2PIXEL: assemble RGB components to a pixel value, returns a u32 */
#define RGB2PIXEL( p_vout, i_red, i_green, i_blue ) \
(((((u32)i_red) >> p_vout->i_red_rshift) << p_vout->i_red_lshift) | \
((((u32)i_green) >> p_vout->i_green_rshift) << p_vout->i_green_lshift) | \
((((u32)i_blue) >> p_vout->i_blue_rshift) << p_vout->i_blue_lshift))
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -242,7 +193,7 @@ vout_fifo_t * vout_CreateFifo ( void ); ...@@ -242,7 +193,7 @@ vout_fifo_t * vout_CreateFifo ( void );
void vout_DestroyFifo ( vout_fifo_t * ); void vout_DestroyFifo ( vout_fifo_t * );
void vout_FreeFifo ( vout_fifo_t * ); void vout_FreeFifo ( vout_fifo_t * );
picture_t * vout_CreatePicture ( vout_thread_t *, int, int, int, int ); picture_t * vout_CreatePicture ( vout_thread_t * );
void vout_DestroyPicture ( vout_thread_t *, picture_t * ); void vout_DestroyPicture ( vout_thread_t *, picture_t * );
void vout_DisplayPicture ( vout_thread_t *, picture_t * ); void vout_DisplayPicture ( vout_thread_t *, picture_t * );
void vout_DatePicture ( vout_thread_t *, picture_t *, mtime_t ); void vout_DatePicture ( vout_thread_t *, picture_t *, mtime_t );
...@@ -250,10 +201,13 @@ void vout_LinkPicture ( vout_thread_t *, picture_t * ); ...@@ -250,10 +201,13 @@ void vout_LinkPicture ( vout_thread_t *, picture_t * );
void vout_UnlinkPicture ( vout_thread_t *, picture_t * ); void vout_UnlinkPicture ( vout_thread_t *, picture_t * );
picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *, picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *,
subpicture_t * ); subpicture_t * );
void vout_PlacePicture ( vout_thread_t *, int, int,
int *, int *, int *, int * );
subpicture_t * vout_CreateSubPicture ( vout_thread_t *, int, int ); subpicture_t * vout_CreateSubPicture ( vout_thread_t *, int, int );
void vout_DestroySubPicture ( vout_thread_t *, subpicture_t * ); void vout_DestroySubPicture ( vout_thread_t *, subpicture_t * );
void vout_DisplaySubPicture ( vout_thread_t *, subpicture_t * ); void vout_DisplaySubPicture ( vout_thread_t *, subpicture_t * );
subpicture_t * vout_SortSubPictures ( vout_thread_t *, mtime_t ); subpicture_t * vout_SortSubPictures ( vout_thread_t *, mtime_t );
void vout_RenderSubPictures ( picture_t *, subpicture_t * ); void vout_RenderSubPictures ( vout_thread_t *, picture_t *,
subpicture_t * );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_directx.c: Windows DirectX video output display method * vout_directx.c: Windows DirectX video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: vout_directx.c,v 1.15 2001/12/07 18:33:07 sam Exp $ * $Id: vout_directx.c,v 1.16 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -1355,7 +1355,7 @@ static void DirectXKeepAspectRatio( vout_thread_t *p_vout, RECT *rect_window ) ...@@ -1355,7 +1355,7 @@ static void DirectXKeepAspectRatio( vout_thread_t *p_vout, RECT *rect_window )
if( !p_vout->p_rendered_pic ) return; if( !p_vout->p_rendered_pic ) return;
switch( p_vout->p_rendered_pic->i_aspect_ratio ) switch( p_vout->p_rendered_pic->i_aspect )
{ {
case AR_16_9_PICTURE: case AR_16_9_PICTURE:
if( ((rect_window->right-rect_window->left)*9) if( ((rect_window->right-rect_window->left)*9)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_dummy.c: Dummy video output display method for testing purposes * vout_dummy.c: Dummy video output display method for testing purposes
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: vout_dummy.c,v 1.10 2001/12/09 17:01:36 sam Exp $ * $Id: vout_dummy.c,v 1.11 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -72,6 +72,8 @@ static void vout_Destroy ( struct vout_thread_s * ); ...@@ -72,6 +72,8 @@ static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * ); static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( struct vout_thread_s *, struct picture_s * ); static void vout_Display ( struct vout_thread_s *, struct picture_s * );
static int DummyNewPicture( struct vout_thread_s *, struct picture_s * );
/***************************************************************************** /*****************************************************************************
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much. * we don't pollute the namespace too much.
...@@ -124,91 +126,62 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -124,91 +126,62 @@ static int vout_Create( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int vout_Init( vout_thread_t *p_vout ) static int vout_Init( vout_thread_t *p_vout )
{ {
int i_index;
picture_t *p_pic; picture_t *p_pic;
int i_index = 0;
int i_luma_bytes, i_chroma_bytes;
/* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */ I_OUTPUTPICTURES = 0;
while( i_index < DUMMY_MAX_DIRECTBUFFERS )
{
p_pic = &p_vout->p_picture[ i_index ];
switch( p_vout->i_chroma ) /* Initialize the output structure */
switch( p_vout->render.i_chroma )
{ {
/* We know this chroma, allocate a buffer which will be used
* directly by the decoder */
case YUV_420_PICTURE: case YUV_420_PICTURE:
p_vout->output.i_chroma = p_vout->render.i_chroma;
p_pic->i_chroma = YUV_420_PICTURE; p_vout->output.i_width = p_vout->render.i_width;
p_pic->i_width = p_vout->i_width; p_vout->output.i_height = p_vout->render.i_height;
p_pic->i_height = p_vout->i_height; p_vout->output.i_aspect = p_vout->render.i_aspect;
/* Precalculate some values */
p_pic->i_size = p_vout->i_width * p_vout->i_height;
p_pic->i_chroma_width = p_vout->i_width / 2;
p_pic->i_chroma_size = p_vout->i_width * p_vout->i_height / 2;
/* Allocate the memory buffer */
i_luma_bytes = p_pic->i_size * sizeof(pixel_data_t);
i_chroma_bytes = p_pic->i_chroma_size * sizeof(pixel_data_t);
/* Y buffer */
p_pic->planes[ Y_PLANE ].p_data = malloc( i_luma_bytes + 2 * i_chroma_bytes );
p_pic->planes[ Y_PLANE ].i_bytes = i_luma_bytes;
/* U buffer */
p_pic->planes[ U_PLANE ].p_data = p_pic->planes[ Y_PLANE ].p_data + p_pic->i_height * p_pic->i_width;
p_pic->planes[ U_PLANE ].i_bytes = i_chroma_bytes;
/* V buffer */
p_pic->planes[ V_PLANE ].p_data = p_pic->planes[ U_PLANE ].p_data + p_pic->i_height * p_pic->i_chroma_width;
p_pic->planes[ V_PLANE ].i_bytes = i_chroma_bytes;
/* We allocated 3 planes */
p_pic->i_planes = 3;
break; break;
/* Unknown chroma, allocate an RGB buffer, the video output's job
* will be to do the chroma->RGB conversion */
default: default:
p_vout->output.i_chroma = RGB_16BPP_PICTURE;
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;
}
p_pic->i_chroma = RGB_16BPP_PICTURE; /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
p_pic->i_width = DUMMY_WIDTH; while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
p_pic->i_height = DUMMY_HEIGHT; {
p_pic = NULL;
/* Precalculate some values */
i_luma_bytes = sizeof(u16) * DUMMY_WIDTH * DUMMY_HEIGHT;
/* Allocate the memory buffer */
p_pic->planes[ RGB_PLANE ].p_data = malloc( i_luma_bytes );
p_pic->planes[ RGB_PLANE ].i_bytes = i_luma_bytes;
/* We allocated 1 plane */
p_pic->i_planes = 1;
/* Find an empty picture slot */
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
{
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{
p_pic = p_vout->p_picture + i_index;
break; break;
} }
}
if( p_pic->i_planes == 0 ) /* Allocate the picture */
if( DummyNewPicture( p_vout, p_pic ) )
{ {
break; break;
} }
p_pic->i_status = DESTROYED_PICTURE; p_pic->i_status = DESTROYED_PICTURE;
p_pic->i_type = DIRECT_PICTURE;
p_pic->b_directbuffer = 1;
p_pic->i_left_margin = p_pic->i_left_margin =
p_pic->i_right_margin = p_pic->i_right_margin =
p_pic->i_top_margin = p_pic->i_top_margin =
p_pic->i_bottom_margin = 0; p_pic->i_bottom_margin = 0;
i_index++; PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
}
/* How many directbuffers did we create ? */ I_OUTPUTPICTURES++;
p_vout->i_directbuffers = i_index; }
return( 0 ); return( 0 );
} }
...@@ -220,11 +193,11 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -220,11 +193,11 @@ static void vout_End( vout_thread_t *p_vout )
{ {
int i_index; int i_index;
/* Free the fake direct buffers we allocated */ /* Free the fake output buffers we allocated */
for( i_index = p_vout->i_directbuffers ; i_index ; ) for( i_index = I_OUTPUTPICTURES ; i_index ; )
{ {
i_index--; i_index--;
free( p_vout->p_picture[ i_index ].planes[ 0 ].p_data ); free( PP_OUTPUTPICTURE[ i_index ]->planes[ 0 ].p_data );
} }
} }
...@@ -260,3 +233,68 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -260,3 +233,68 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
/* No need to do anything, the fake direct buffers stay as they are */ /* No need to do anything, the fake direct buffers stay as they are */
} }
/*****************************************************************************
* DummyNewPicture: allocate a picture
*****************************************************************************
* Returns 0 on success, -1 otherwise
*****************************************************************************/
static int DummyNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
int i_luma_bytes, i_chroma_bytes;
int i_width = p_vout->output.i_width;
int i_height = p_vout->output.i_height;
switch( p_vout->output.i_chroma )
{
/* We know this chroma, allocate a buffer which will be used
* directly by the decoder */
case YUV_420_PICTURE:
/* Precalculate some values */
p_pic->i_size = i_width * i_height;
p_pic->i_chroma_width = i_width / 2;
p_pic->i_chroma_size = i_width * i_height / 2;
/* Allocate the memory buffer */
i_luma_bytes = p_pic->i_size * sizeof(pixel_data_t);
i_chroma_bytes = p_pic->i_chroma_size * sizeof(pixel_data_t);
/* Y buffer */
p_pic->planes[ Y_PLANE ].p_data = malloc( i_luma_bytes + 2 * i_chroma_bytes );
p_pic->planes[ Y_PLANE ].i_bytes = i_luma_bytes;
/* U buffer */
p_pic->planes[ U_PLANE ].p_data = p_pic->planes[ Y_PLANE ].p_data + i_height * i_width;
p_pic->planes[ U_PLANE ].i_bytes = i_chroma_bytes;
/* V buffer */
p_pic->planes[ V_PLANE ].p_data = p_pic->planes[ U_PLANE ].p_data + i_height * p_pic->i_chroma_width;
p_pic->planes[ V_PLANE ].i_bytes = i_chroma_bytes;
/* We allocated 3 planes */
p_pic->i_planes = 3;
return( 0 );
break;
/* Unknown chroma, allocate an RGB buffer, the video output's job
* will be to do the chroma->RGB conversion */
default:
/* Precalculate some values */
i_luma_bytes = sizeof(u16) * i_width * i_height;
/* Allocate the memory buffer */
p_pic->planes[ RGB_PLANE ].p_data = malloc( i_luma_bytes );
p_pic->planes[ RGB_PLANE ].i_bytes = i_luma_bytes;
/* We allocated 1 plane */
p_pic->i_planes = 1;
return( 0 );
break;
}
}
...@@ -44,21 +44,21 @@ $(BUILTIN_IMDCT3DN): BUILTIN_IMDCT3DN_%.o: %.c ...@@ -44,21 +44,21 @@ $(BUILTIN_IMDCT3DN): BUILTIN_IMDCT3DN_%.o: %.c
# Real targets # Real targets
# #
../imdct.so: $(PLUGIN_IMDCT) $(PLUGIN_IMDCTCOMMON) ../imdct.so: $(PLUGIN_IMDCT) $(PLUGIN_IMDCTCOMMON) $(LIB_IMDCT)
$(CC) -o $@ $^ $(PLCFLAGS) $(CC) -o $@ $^ $(PLCFLAGS)
../imdct.a: $(BUILTIN_IMDCT) ../imdct.a: $(BUILTIN_IMDCT)
ar r $@ $^ ar r $@ $^
$(RANLIB) $@ $(RANLIB) $@
../imdctsse.so: $(PLUGIN_IMDCTSSE) $(PLUGIN_IMDCTCOMMON) ../imdctsse.so: $(PLUGIN_IMDCTSSE) $(PLUGIN_IMDCTCOMMON) $(LIB_IMDCTSSE)
$(CC) -o $@ $^ $(PLCFLAGS) $(CC) -o $@ $^ $(PLCFLAGS)
../imdctsse.a: $(BUILTIN_IMDCTSSE) ../imdctsse.a: $(BUILTIN_IMDCTSSE)
ar r $@ $^ ar r $@ $^
$(RANLIB) $@ $(RANLIB) $@
../imdct3dn.so: $(PLUGIN_IMDCT3DN) $(PLUGIN_IMDCTCOMMON) ../imdct3dn.so: $(PLUGIN_IMDCT3DN) $(PLUGIN_IMDCTCOMMON) $(LIB_IMDCT3DN)
$(CC) -o $@ $^ $(PLCFLAGS) $(CC) -o $@ $^ $(PLCFLAGS)
../imdct3dn.a: $(BUILTIN_IMDCT3DN) ../imdct3dn.a: $(BUILTIN_IMDCT3DN)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.h : video parser thread * video_parser.h : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_parser.h,v 1.1 2001/11/13 12:09:18 henri Exp $ * $Id: video_parser.h,v 1.2 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Jean-Marc Dressler <polux@via.ecp.fr> * Jean-Marc Dressler <polux@via.ecp.fr>
...@@ -113,7 +113,7 @@ typedef struct sequence_s ...@@ -113,7 +113,7 @@ typedef struct sequence_s
u32 i_size; /* total number of pel of the lum comp */ u32 i_size; /* total number of pel of the lum comp */
u32 i_mb_height, i_mb_width, i_mb_size; u32 i_mb_height, i_mb_width, i_mb_size;
/* the same, in macroblock units */ /* the same, in macroblock units */
unsigned int i_aspect_ratio; /* height/width display ratio */ unsigned int i_aspect; /* height/width display ratio */
unsigned int i_matrix_coefficients;/* coeffs of the YUV transform */ unsigned int i_matrix_coefficients;/* coeffs of the YUV transform */
int i_chroma_format, i_scalable_mode; int i_chroma_format, i_scalable_mode;
int i_chroma_nb_blocks; int i_chroma_nb_blocks;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_headers.c : headers parsing * vpar_headers.c : headers parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: vpar_headers.c,v 1.5 2001/12/10 10:58:54 massiot Exp $ * $Id: vpar_headers.c,v 1.6 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -310,7 +310,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -310,7 +310,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
p_vpar->sequence.i_width = GetBits( &p_vpar->bit_stream, 12 ); p_vpar->sequence.i_width = GetBits( &p_vpar->bit_stream, 12 );
p_vpar->sequence.i_height = GetBits( &p_vpar->bit_stream, 12 ); p_vpar->sequence.i_height = GetBits( &p_vpar->bit_stream, 12 );
p_vpar->sequence.i_aspect_ratio = GetBits( &p_vpar->bit_stream, 4 ); p_vpar->sequence.i_aspect = GetBits( &p_vpar->bit_stream, 4 );
p_vpar->sequence.i_frame_rate = p_vpar->sequence.i_frame_rate =
i_frame_rate_table[ GetBits( &p_vpar->bit_stream, 4 ) ]; i_frame_rate_table[ GetBits( &p_vpar->bit_stream, 4 ) ];
...@@ -400,22 +400,22 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -400,22 +400,22 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
12015 12015
}; };
if( p_vpar->sequence.i_aspect_ratio > 1 ) if( p_vpar->sequence.i_aspect > 1 )
{ {
i_xyratio = p_vpar->sequence.i_height * i_xyratio = p_vpar->sequence.i_height *
pi_mpeg1ratio[p_vpar->sequence.i_aspect_ratio] / pi_mpeg1ratio[p_vpar->sequence.i_aspect] /
p_vpar->sequence.i_width; p_vpar->sequence.i_width;
if( 7450 < i_xyratio && i_xyratio < 7550 ) if( 7450 < i_xyratio && i_xyratio < 7550 )
{ {
p_vpar->sequence.i_aspect_ratio = 2; p_vpar->sequence.i_aspect = 2;
} }
else if( 5575 < i_xyratio && i_xyratio < 5675 ) else if( 5575 < i_xyratio && i_xyratio < 5675 )
{ {
p_vpar->sequence.i_aspect_ratio = 3; p_vpar->sequence.i_aspect = 3;
} }
else if( 4475 < i_xyratio && i_xyratio < 4575 ) else if( 4475 < i_xyratio && i_xyratio < 4575 )
{ {
p_vpar->sequence.i_aspect_ratio = 4; p_vpar->sequence.i_aspect = 4;
} }
} }
...@@ -478,7 +478,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -478,7 +478,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
vout_CreateThread( NULL, p_vpar->sequence.i_width, vout_CreateThread( NULL, p_vpar->sequence.i_width,
p_vpar->sequence.i_height, p_vpar->sequence.i_height,
99 + p_vpar->sequence.i_chroma_format, 99 + p_vpar->sequence.i_chroma_format,
p_vpar->sequence.i_aspect_ratio ); p_vpar->sequence.i_aspect );
/* Everything failed */ /* Everything failed */
if( p_vpar->p_vout == NULL ) if( p_vpar->p_vout == NULL )
...@@ -774,12 +774,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -774,12 +774,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
if( !p_vpar->picture.i_current_structure ) if( !p_vpar->picture.i_current_structure )
{ {
/* This is a new frame. Get a structure from the video_output. */ /* This is a new frame. Get a structure from the video_output. */
while( ( P_picture = vout_CreatePicture( p_vpar->p_vout, while( ( P_picture = vout_CreatePicture( p_vpar->p_vout ) ) == NULL )
p_vpar->sequence.i_width,
p_vpar->sequence.i_height,
/* XXX */ 99 + p_vpar->sequence.i_chroma_format,
p_vpar->sequence.i_aspect_ratio ) )
== NULL )
{ {
intf_DbgMsg("vpar debug: vout_CreatePicture failed, delaying"); intf_DbgMsg("vpar debug: vout_CreatePicture failed, delaying");
if( p_vpar->p_fifo->b_die || p_vpar->p_fifo->b_error ) if( p_vpar->p_fifo->b_die || p_vpar->p_fifo->b_error )
...@@ -791,7 +786,6 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -791,7 +786,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
/* Initialize values. */ /* Initialize values. */
vpar_SynchroDecode( p_vpar, p_vpar->picture.i_coding_type, i_structure ); vpar_SynchroDecode( p_vpar, p_vpar->picture.i_coding_type, i_structure );
P_picture->i_aspect_ratio = p_vpar->sequence.i_aspect_ratio;
P_picture->i_matrix_coefficients = p_vpar->sequence.i_matrix_coefficients; P_picture->i_matrix_coefficients = p_vpar->sequence.i_matrix_coefficients;
p_vpar->picture.i_field_width = ( p_vpar->sequence.i_width p_vpar->picture.i_field_width = ( p_vpar->sequence.i_width
<< ( 1 - p_vpar->picture.b_frame_structure ) ); << ( 1 - p_vpar->picture.b_frame_structure ) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_sdl.c: SDL video output display method * vout_sdl.c: SDL video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: vout_sdl.c,v 1.68 2001/12/09 17:01:37 sam Exp $ * $Id: vout_sdl.c,v 1.69 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Pierre Baillet <oct@zoy.org> * Pierre Baillet <oct@zoy.org>
...@@ -176,8 +176,8 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -176,8 +176,8 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->b_cursor_autohidden = 0; p_vout->p_sys->b_cursor_autohidden = 0;
p_vout->p_sys->i_lastmoved = mdate(); p_vout->p_sys->i_lastmoved = mdate();
p_vout->p_sys->i_width = p_vout->i_width; p_vout->p_sys->i_width = p_vout->render.i_width;
p_vout->p_sys->i_height = p_vout->i_height; p_vout->p_sys->i_height = p_vout->render.i_height;
if( SDLOpenDisplay( p_vout ) ) if( SDLOpenDisplay( p_vout ) )
{ {
...@@ -196,33 +196,58 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -196,33 +196,58 @@ static int vout_Create( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int vout_Init( vout_thread_t *p_vout ) static int vout_Init( vout_thread_t *p_vout )
{ {
int i_index;
picture_t *p_pic; picture_t *p_pic;
int i_index = 0;
I_OUTPUTPICTURES = 0;
/* Initialize the output structure */
switch( p_vout->render.i_chroma )
{
case YUV_420_PICTURE:
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;
default:
return( 0 );
}
/* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */ /* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
while( i_index < SDL_MAX_DIRECTBUFFERS ) while( I_OUTPUTPICTURES < SDL_MAX_DIRECTBUFFERS )
{
p_pic = NULL;
/* Find an empty picture slot */
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
{
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{ {
p_pic = &p_vout->p_picture[ i_index ]; p_pic = p_vout->p_picture + i_index;
break;
}
}
/* Allocate the picture */
if( SDLNewPicture( p_vout, p_pic ) ) if( SDLNewPicture( p_vout, p_pic ) )
{ {
break; break;
} }
p_pic->i_status = DESTROYED_PICTURE; p_pic->i_status = DESTROYED_PICTURE;
p_pic->i_type = DIRECT_PICTURE;
p_pic->b_directbuffer = 1;
p_pic->i_left_margin = p_pic->i_left_margin =
p_pic->i_right_margin = p_pic->i_right_margin =
p_pic->i_top_margin = p_pic->i_top_margin =
p_pic->i_bottom_margin = 0; p_pic->i_bottom_margin = 0;
i_index++; PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
}
/* How many directbuffers did we create ? */ I_OUTPUTPICTURES++;
p_vout->i_directbuffers = i_index; }
return( 0 ); return( 0 );
} }
...@@ -236,13 +261,13 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -236,13 +261,13 @@ static void vout_End( vout_thread_t *p_vout )
{ {
int i_index; int i_index;
/* Free the direct buffers we allocated */ /* Free the output buffers we allocated */
for( i_index = p_vout->i_directbuffers ; i_index ; ) for( i_index = I_OUTPUTPICTURES ; i_index ; )
{ {
i_index--; i_index--;
SDL_UnlockYUVOverlay( p_vout->p_picture[ i_index ].p_sys->p_overlay ); SDL_UnlockYUVOverlay( PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
SDL_FreeYUVOverlay( p_vout->p_picture[ i_index ].p_sys->p_overlay ); SDL_FreeYUVOverlay( PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
free( p_vout->p_picture[ i_index ].p_sys ); free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
} }
} }
...@@ -410,26 +435,21 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -410,26 +435,21 @@ static int vout_Manage( vout_thread_t *p_vout )
***************************************************************************** *****************************************************************************
* This function sends the currently rendered image to the display. * This function sends the currently rendered image to the display.
*****************************************************************************/ *****************************************************************************/
static void vout_Display( vout_thread_t *p_vout, picture_t *p_picture ) static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
{ {
int x, y, w, h;
SDL_Rect disp; SDL_Rect disp;
/* We'll need to deal with aspect ratio later */ vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
disp.w = p_vout->p_sys->i_width; &x, &y, &w, &h );
disp.h = p_vout->p_sys->i_height; disp.x = x;
disp.x = 0; disp.y = y;
disp.y = 0; disp.w = w;
disp.h = h;
if( p_picture->b_directbuffer ) SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
{ SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
SDL_UnlockYUVOverlay( p_picture->p_sys->p_overlay); SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
SDL_DisplayYUVOverlay( p_picture->p_sys->p_overlay , &disp );
SDL_LockYUVOverlay( p_picture->p_sys->p_overlay);
}
else
{
intf_ErrMsg( "vout error: main thread passed a virtual buffer" );
}
} }
/* following functions are local */ /* following functions are local */
...@@ -495,7 +515,10 @@ static void SDLCloseDisplay( vout_thread_t *p_vout ) ...@@ -495,7 +515,10 @@ static void SDLCloseDisplay( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
switch( p_vout->i_chroma ) int i_width = p_vout->output.i_width;
int i_height = p_vout->output.i_height;
switch( p_vout->output.i_chroma )
{ {
case YUV_420_PICTURE: case YUV_420_PICTURE:
/* We know this chroma, allocate a buffer which will be used /* We know this chroma, allocate a buffer which will be used
...@@ -508,7 +531,7 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -508,7 +531,7 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
} }
p_pic->p_sys->p_overlay = p_pic->p_sys->p_overlay =
SDL_CreateYUVOverlay( p_vout->i_width, p_vout->i_height, SDL_CreateYUVOverlay( i_width, i_height,
SDL_YV12_OVERLAY, SDL_YV12_OVERLAY,
p_vout->p_sys->p_display ); p_vout->p_sys->p_display );
...@@ -520,14 +543,10 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -520,14 +543,10 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
SDL_LockYUVOverlay( p_pic->p_sys->p_overlay ); SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
p_pic->i_chroma = p_vout->i_chroma; /* YUV_420_PICTURE */
p_pic->i_width = p_vout->i_width;
p_pic->i_height = p_vout->i_height;
/* Precalculate some values */ /* Precalculate some values */
p_pic->i_size = p_vout->i_width * p_vout->i_height; p_pic->i_size = i_width * i_height;
p_pic->i_chroma_width = p_vout->i_width / 2; p_pic->i_chroma_width = i_width / 2;
p_pic->i_chroma_size = p_vout->i_height * p_pic->i_chroma_width; p_pic->i_chroma_size = i_height * ( i_width / 2 );
/* FIXME: try to get the right i_bytes value from p_overlay */ /* FIXME: try to get the right i_bytes value from p_overlay */
p_pic->planes[ Y_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[0]; p_pic->planes[ Y_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[0];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_common.c: Functions common to the X11 and XVideo plugins * vout_common.c: Functions common to the X11 and XVideo plugins
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: vout_common.c,v 1.2 2001/12/10 10:58:54 massiot Exp $ * $Id: vout_common.c,v 1.3 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -129,13 +129,13 @@ int _M( vout_Manage ) ( vout_thread_t *p_vout ) ...@@ -129,13 +129,13 @@ int _M( vout_Manage ) ( vout_thread_t *p_vout )
{ {
/* ConfigureNotify event: prepare */ /* ConfigureNotify event: prepare */
if( (xevent.type == ConfigureNotify) if( (xevent.type == ConfigureNotify)
&& ((xevent.xconfigure.width != p_vout->p_sys->i_window_width) && ((xevent.xconfigure.width != p_vout->p_sys->i_width)
|| (xevent.xconfigure.height != p_vout->p_sys->i_window_height)) ) || (xevent.xconfigure.height != p_vout->p_sys->i_height)) )
{ {
/* Update dimensions */ /* Update dimensions */
b_resized = 1; b_resized = 1;
p_vout->p_sys->i_window_width = xevent.xconfigure.width; p_vout->p_sys->i_width = xevent.xconfigure.width;
p_vout->p_sys->i_window_height = xevent.xconfigure.height; p_vout->p_sys->i_height = xevent.xconfigure.height;
} }
/* MapNotify event: change window status and disable screen saver */ /* MapNotify event: change window status and disable screen saver */
else if( xevent.type == MapNotify) else if( xevent.type == MapNotify)
...@@ -410,11 +410,9 @@ int _M( vout_Manage ) ( vout_thread_t *p_vout ) ...@@ -410,11 +410,9 @@ int _M( vout_Manage ) ( vout_thread_t *p_vout )
{ {
p_vout->i_changes &= ~VOUT_SIZE_CHANGE; p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
p_vout->i_width = p_vout->p_sys->i_window_width;
p_vout->i_height = p_vout->p_sys->i_window_height;
intf_WarnMsg( 3, "vout: video display resized (%dx%d)", intf_WarnMsg( 3, "vout: video display resized (%dx%d)",
p_vout->i_width, p_vout->i_height ); p_vout->p_sys->i_width,
p_vout->p_sys->i_height );
} }
#endif #endif
...@@ -450,21 +448,21 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout ) ...@@ -450,21 +448,21 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout )
/* If we're full screen, we're full screen! */ /* If we're full screen, we're full screen! */
if( p_vout->b_fullscreen ) if( p_vout->b_fullscreen )
{ {
p_vout->p_sys->i_window_width = p_vout->p_sys->i_width =
DisplayWidth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen ); DisplayWidth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
p_vout->p_sys->i_window_height = p_vout->p_sys->i_height =
DisplayHeight( p_vout->p_sys->p_display, p_vout->p_sys->i_screen ); DisplayHeight( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
} }
else else
{ {
/* Set main window's size */ /* Set main window's size */
p_vout->p_sys->i_window_width = p_vout->i_width; p_vout->p_sys->i_width = p_vout->render.i_width;
p_vout->p_sys->i_window_height = p_vout->i_height; p_vout->p_sys->i_height = p_vout->render.i_height;
} }
/* Prepare window manager hints and properties */ /* Prepare window manager hints and properties */
xsize_hints.base_width = p_vout->p_sys->i_window_width; xsize_hints.base_width = p_vout->p_sys->i_width;
xsize_hints.base_height = p_vout->p_sys->i_window_height; xsize_hints.base_height = p_vout->p_sys->i_height;
xsize_hints.flags = PSize; xsize_hints.flags = PSize;
p_vout->p_sys->wm_protocols = XInternAtom( p_vout->p_sys->p_display, p_vout->p_sys->wm_protocols = XInternAtom( p_vout->p_sys->p_display,
"WM_PROTOCOLS", True ); "WM_PROTOCOLS", True );
...@@ -485,8 +483,8 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout ) ...@@ -485,8 +483,8 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout )
XCreateWindow( p_vout->p_sys->p_display, XCreateWindow( p_vout->p_sys->p_display,
DefaultRootWindow( p_vout->p_sys->p_display ), DefaultRootWindow( p_vout->p_sys->p_display ),
0, 0, 0, 0,
p_vout->p_sys->i_window_width, p_vout->p_sys->i_width,
p_vout->p_sys->i_window_height, p_vout->p_sys->i_height,
#ifdef MODULE_NAME_IS_x11 #ifdef MODULE_NAME_IS_x11
/* XXX - what's this ? */ /* XXX - what's this ? */
0, 0,
...@@ -567,8 +565,8 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout ) ...@@ -567,8 +565,8 @@ int _M( XCommonCreateWindow ) ( vout_thread_t *p_vout )
&& (xevent.xconfigure.window == p_vout->p_sys->window) ) && (xevent.xconfigure.window == p_vout->p_sys->window) )
{ {
b_configure_notify = 1; b_configure_notify = 1;
p_vout->p_sys->i_window_width = xevent.xconfigure.width; p_vout->p_sys->i_width = xevent.xconfigure.width;
p_vout->p_sys->i_window_height = xevent.xconfigure.height; p_vout->p_sys->i_height = xevent.xconfigure.height;
} }
} while( !( b_expose && b_configure_notify && b_map_notify ) ); } while( !( b_expose && b_configure_notify && b_map_notify ) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_xvideo.c: Xvideo video output display method * vout_xvideo.c: Xvideo video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: vout_common.h,v 1.1 2001/12/09 17:01:37 sam Exp $ * $Id: vout_common.h,v 1.2 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Shane Harper <shanegh@optusnet.com.au> * Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -63,8 +63,8 @@ typedef struct vout_sys_s ...@@ -63,8 +63,8 @@ typedef struct vout_sys_s
Atom wm_protocols; Atom wm_protocols;
Atom wm_delete_window; Atom wm_delete_window;
int i_window_width; /* width of main window */ int i_width; /* width of main window */
int i_window_height; /* height of main window */ int i_height; /* height of main window */
/* Screen saver properties */ /* Screen saver properties */
int i_ss_timeout; /* timeout */ int i_ss_timeout; /* timeout */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_xvideo.c: Xvideo video output display method * vout_xvideo.c: Xvideo video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: vout_xvideo.c,v 1.37 2001/12/09 17:01:37 sam Exp $ * $Id: vout_xvideo.c,v 1.38 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Shane Harper <shanegh@optusnet.com.au> * Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -95,9 +95,6 @@ static void DestroyShmImage( Display *, XvImage *, XShmSegmentInfo * ); ...@@ -95,9 +95,6 @@ static void DestroyShmImage( Display *, XvImage *, XShmSegmentInfo * );
static int CheckForXVideo ( Display * ); static int CheckForXVideo ( Display * );
static int GetXVideoPort ( Display * ); static int GetXVideoPort ( Display * );
static void XVideoOutputCoords ( const picture_t *, const boolean_t,
const int, const int,
int *, int *, int *, int * );
/*static void XVideoSetAttribute ( vout_thread_t *, char *, float );*/ /*static void XVideoSetAttribute ( vout_thread_t *, char *, float );*/
...@@ -266,33 +263,58 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -266,33 +263,58 @@ static int vout_Create( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int vout_Init( vout_thread_t *p_vout ) static int vout_Init( vout_thread_t *p_vout )
{ {
int i_index;
picture_t *p_pic; picture_t *p_pic;
int i_index = 0;
I_OUTPUTPICTURES = 0;
/* Initialize the output structure */
switch( p_vout->render.i_chroma )
{
case YUV_420_PICTURE:
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;
default:
return( 0 );
}
/* Try to initialize up to XVIDEO_MAX_DIRECTBUFFERS direct buffers */ /* Try to initialize up to XVIDEO_MAX_DIRECTBUFFERS direct buffers */
while( i_index < XVIDEO_MAX_DIRECTBUFFERS ) while( I_OUTPUTPICTURES < XVIDEO_MAX_DIRECTBUFFERS )
{
p_pic = NULL;
/* Find an empty picture slot */
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
{
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{ {
p_pic = &p_vout->p_picture[ i_index ]; p_pic = p_vout->p_picture + i_index;
break;
}
}
/* Allocate the picture */
if( XVideoNewPicture( p_vout, p_pic ) ) if( XVideoNewPicture( p_vout, p_pic ) )
{ {
break; break;
} }
p_pic->i_status = DESTROYED_PICTURE; p_pic->i_status = DESTROYED_PICTURE;
p_pic->i_type = DIRECT_PICTURE;
p_pic->b_directbuffer = 1;
p_pic->i_left_margin = p_pic->i_left_margin =
p_pic->i_right_margin = p_pic->i_right_margin =
p_pic->i_top_margin = p_pic->i_top_margin =
p_pic->i_bottom_margin = 0; p_pic->i_bottom_margin = 0;
i_index++; PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
}
/* How many directbuffers did we create ? */ I_OUTPUTPICTURES++;
p_vout->i_directbuffers = i_index; }
return( 0 ); return( 0 );
} }
...@@ -308,13 +330,13 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -308,13 +330,13 @@ static void vout_End( vout_thread_t *p_vout )
int i_index; int i_index;
/* Free the direct buffers we allocated */ /* Free the direct buffers we allocated */
for( i_index = p_vout->i_directbuffers ; i_index ; ) for( i_index = I_OUTPUTPICTURES ; i_index ; )
{ {
i_index--; i_index--;
DestroyShmImage( p_vout->p_sys->p_display, DestroyShmImage( p_vout->p_sys->p_display,
p_vout->p_picture[ i_index ].p_sys->p_xvimage, PP_OUTPUTPICTURE[ i_index ]->p_sys->p_xvimage,
&p_vout->p_picture[ i_index ].p_sys->shminfo ); &PP_OUTPUTPICTURE[ i_index ]->p_sys->shminfo );
free( p_vout->p_picture[ i_index ].p_sys ); free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
} }
} }
...@@ -350,30 +372,23 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -350,30 +372,23 @@ static void vout_Destroy( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
{ {
int i_dest_width, i_dest_height, i_dest_x, i_dest_y; int i_width, i_height, i_x, i_y;
//printf("pic: %i %i, disp: %i %i\n", p_pic->i_width, p_pic->i_height, p_vout->p_sys->i_window_width, p_vout->p_sys->i_window_height); vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
//printf("pic aspect ratio: %i\n", p_pic->i_aspect_ratio); &i_x, &i_y, &i_width, &i_height );
XVideoOutputCoords( p_pic, p_vout->b_scale,
p_vout->p_sys->i_window_width,
p_vout->p_sys->i_window_height,
&i_dest_x, &i_dest_y,
&i_dest_width, &i_dest_height);
//printf("resized to %i %i, moved at %i %i\n", i_dest_width, i_dest_height, i_dest_x, i_dest_y);
XvShmPutImage( p_vout->p_sys->p_display, p_vout->p_sys->i_xvport, XvShmPutImage( p_vout->p_sys->p_display, p_vout->p_sys->i_xvport,
p_vout->p_sys->yuv_window, p_vout->p_sys->gc, p_vout->p_sys->yuv_window, p_vout->p_sys->gc,
p_pic->p_sys->p_xvimage, p_pic->p_sys->p_xvimage, 0 /*src_x*/, 0 /*src_y*/,
0 /*src_x*/, 0 /*src_y*/, p_pic->i_width, p_pic->i_height, p_vout->output.i_width, p_vout->output.i_height,
0 /*dest_x*/, 0 /*dest_y*/, i_dest_width, i_dest_height, 0 /*dest_x*/, 0 /*dest_y*/, i_width, i_height,
True ); True );
XResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window, XResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window,
i_dest_width, i_dest_height ); i_width, i_height );
#if 0
XMoveWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window, XMoveWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window,
i_dest_x, i_dest_y ); i_x, i_y );
#endif
} }
/* following functions are local */ /* following functions are local */
...@@ -411,7 +426,10 @@ static int CheckForXVideo( Display *p_display ) ...@@ -411,7 +426,10 @@ static int CheckForXVideo( Display *p_display )
*****************************************************************************/ *****************************************************************************/
static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
switch( p_vout->i_chroma ) int i_width = p_vout->output.i_width;
int i_height = p_vout->output.i_height;
switch( p_vout->output.i_chroma )
{ {
case YUV_420_PICTURE: case YUV_420_PICTURE:
/* We know this chroma, allocate a buffer which will be used /* We know this chroma, allocate a buffer which will be used
...@@ -428,31 +446,29 @@ static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -428,31 +446,29 @@ static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
CreateShmImage( p_vout->p_sys->p_display, CreateShmImage( p_vout->p_sys->p_display,
p_vout->p_sys->i_xvport, p_vout->p_sys->i_xvport,
&p_pic->p_sys->shminfo, &p_pic->p_sys->shminfo,
p_vout->i_width, p_vout->i_height ); p_vout->output.i_width,
p_vout->output.i_height );
if( p_pic->p_sys->p_xvimage == NULL ) if( p_pic->p_sys->p_xvimage == NULL )
{ {
free( p_pic->p_sys ); free( p_pic->p_sys );
return -1; return -1;
} }
p_pic->i_chroma = p_vout->i_chroma; /* YUV_420_PICTURE */
p_pic->i_width = p_vout->i_width;
p_pic->i_height = p_vout->i_height;
/* Precalculate some values */ /* Precalculate some values */
p_pic->i_size = p_vout->i_width * p_vout->i_height; p_pic->i_size = i_width * i_height;
p_pic->i_chroma_width = p_vout->i_width / 2; p_pic->i_chroma_width = i_width / 2;
p_pic->i_chroma_size = p_vout->i_height * p_pic->i_chroma_width; p_pic->i_chroma_size = i_height * ( i_width / 2 );
/* FIXME: try to get the right i_bytes value from p_overlay */ /* FIXME: try to get the right i_bytes value from p_xvimage */
p_pic->planes[ Y_PLANE ].p_data = p_pic->p_sys->p_xvimage->data; p_pic->planes[Y_PLANE].p_data = p_pic->p_sys->p_xvimage->data;
p_pic->planes[ Y_PLANE ].i_bytes = p_pic->i_size * sizeof(u8); p_pic->planes[Y_PLANE].i_bytes = p_pic->i_size * sizeof(u8);
p_pic->planes[ U_PLANE ].p_data = (u8*)p_pic->p_sys->p_xvimage->data p_pic->planes[U_PLANE].p_data = (u8*)p_pic->p_sys->p_xvimage->data
+ p_pic->i_size * 5 / 4; + p_pic->i_size * 5 / 4;
p_pic->planes[ U_PLANE ].i_bytes = p_pic->i_size * sizeof(u8) / 4; p_pic->planes[U_PLANE].i_bytes = p_pic->i_size * sizeof(u8) / 4;
p_pic->planes[ V_PLANE ].p_data = (u8*)p_pic->p_sys->p_xvimage->data p_pic->planes[V_PLANE].p_data = (u8*)p_pic->p_sys->p_xvimage->data
+ p_pic->i_size; + p_pic->i_size;
p_pic->planes[ V_PLANE ].i_bytes = p_pic->i_size * sizeof(u8) / 4; p_pic->planes[V_PLANE].i_bytes = p_pic->i_size * sizeof(u8) / 4;
p_pic->i_planes = 3; p_pic->i_planes = 3;
return 0; return 0;
...@@ -461,7 +477,7 @@ static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -461,7 +477,7 @@ static int XVideoNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
/* Unknown chroma, tell the guy to get lost */ /* Unknown chroma, tell the guy to get lost */
p_pic->i_planes = 0; p_pic->i_planes = 0;
return 0; return -1;
} }
} }
...@@ -549,46 +565,6 @@ static void DestroyShmImage( Display *p_display, XvImage *p_xvimage, ...@@ -549,46 +565,6 @@ static void DestroyShmImage( Display *p_display, XvImage *p_xvimage,
} }
} }
/* This based on some code in SetBufferPicture... At the moment it's only
* used by the xvideo plugin, but others may want to use it. */
static void XVideoOutputCoords( const picture_t *p_pic, const boolean_t scale,
const int win_w, const int win_h,
int *dx, int *dy, int *w, int *h )
{
if( !scale )
{
*w = p_pic->i_width;
*h = p_pic->i_height;
}
else
{
*h = win_h;
switch( p_pic->i_aspect_ratio )
{
case AR_3_4_PICTURE:
*w = win_h * 4 / 3;
break;
case AR_16_9_PICTURE:
*w = win_h * 16 / 9;
break;
case AR_221_1_PICTURE:
*w = win_h * 221 / 100;
break;
case AR_SQUARE_PICTURE:
default:
*w = win_h * p_pic->i_width / p_pic->i_height;
break;
}
}
/* Set picture position */
*dx = (win_w - *w) / 2;
*dy = (win_h - *h) / 2;
}
/***************************************************************************** /*****************************************************************************
* GetXVideoPort: get YUV12 port * GetXVideoPort: get YUV12 port
***************************************************************************** *****************************************************************************
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread. * thread, and destroy a previously oppened video output thread.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: video_output.c,v 1.146 2001/12/09 17:01:37 sam Exp $ * $Id: video_output.c,v 1.147 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -94,7 +94,7 @@ void vout_EndBank ( void ) ...@@ -94,7 +94,7 @@ void vout_EndBank ( void )
*****************************************************************************/ *****************************************************************************/
vout_thread_t * vout_CreateThread ( int *pi_status, vout_thread_t * vout_CreateThread ( int *pi_status,
int i_width, int i_height, int i_width, int i_height,
int i_chroma, int i_aspect_ratio ) int i_chroma, int i_aspect )
{ {
vout_thread_t * p_vout; /* thread descriptor */ vout_thread_t * p_vout; /* thread descriptor */
int i_status; /* thread status */ int i_status; /* thread status */
...@@ -142,9 +142,7 @@ vout_thread_t * vout_CreateThread ( int *pi_status, ...@@ -142,9 +142,7 @@ vout_thread_t * vout_CreateThread ( int *pi_status,
for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++) for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
{ {
p_vout->p_picture[i_index].i_status = FREE_PICTURE; p_vout->p_picture[i_index].i_status = FREE_PICTURE;
p_vout->p_picture[i_index].i_chroma = EMPTY_PICTURE; p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
p_vout->p_picture[i_index].i_aspect_ratio = i_aspect_ratio;
p_vout->p_picture[i_index].b_directbuffer = 0;
} }
for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++) for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
...@@ -153,12 +151,14 @@ vout_thread_t * vout_CreateThread ( int *pi_status, ...@@ -153,12 +151,14 @@ vout_thread_t * vout_CreateThread ( int *pi_status,
p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE; p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
} }
p_vout->i_width = i_width; /* Initialize the rendering heap */
p_vout->i_height = i_height; p_vout->i_heap_size = 0;
p_vout->i_chroma = i_chroma;
p_vout->i_aspect_ratio = i_aspect_ratio; I_RENDERPICTURES = 0;
p_vout->i_pictures = 0; p_vout->render.i_width = i_width;
p_vout->i_directbuffers = 0; p_vout->render.i_height = i_height;
p_vout->render.i_chroma = i_chroma;
p_vout->render.i_aspect = i_aspect;
/* Initialize misc stuff */ /* Initialize misc stuff */
p_vout->i_changes = 0; p_vout->i_changes = 0;
...@@ -242,6 +242,8 @@ void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status ) ...@@ -242,6 +242,8 @@ void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
*****************************************************************************/ *****************************************************************************/
static int InitThread( vout_thread_t *p_vout ) static int InitThread( vout_thread_t *p_vout )
{ {
int i_index;
/* Update status */ /* Update status */
*p_vout->pi_status = THREAD_START; *p_vout->pi_status = THREAD_START;
...@@ -258,7 +260,7 @@ static int InitThread( vout_thread_t *p_vout ) ...@@ -258,7 +260,7 @@ static int InitThread( vout_thread_t *p_vout )
return( 1 ); return( 1 );
} }
if( !p_vout->i_directbuffers ) if( !I_OUTPUTPICTURES )
{ {
intf_ErrMsg( "vout error: plugin was unable to allocate at least " intf_ErrMsg( "vout error: plugin was unable to allocate at least "
"one direct buffer" ); "one direct buffer" );
...@@ -266,8 +268,35 @@ static int InitThread( vout_thread_t *p_vout ) ...@@ -266,8 +268,35 @@ static int InitThread( vout_thread_t *p_vout )
return( 1 ); return( 1 );
} }
intf_WarnMsg( 1, "vout info: got %i direct buffer(s)", /* Check whether we managed to create direct buffers similar to
p_vout->i_directbuffers ); * the render buffers, ie same size, chroma and aspect ratio */
if( ( p_vout->output.i_width == p_vout->render.i_width )
&& ( p_vout->output.i_height == p_vout->render.i_height )
&& ( p_vout->output.i_chroma == p_vout->render.i_chroma )
&& ( p_vout->output.i_aspect == p_vout->render.i_aspect ) )
{
p_vout->b_direct = 1;
/* Map the first render buffers to the first direct buffers, but
* leave the first direct buffer for memcpy operations */
i_index = 1;
}
else
{
p_vout->b_direct = 0;
/* Append render buffers after the direct buffers */
i_index = I_RENDERPICTURES;
}
for( ; i_index < VOUT_MAX_PICTURES; i_index++ )
{
PP_RENDERPICTURE[ I_RENDERPICTURES ]
= &p_vout->p_picture[ i_index ];
I_RENDERPICTURES++;
}
intf_WarnMsg( 1, "vout info: got %i direct buffer(s)", I_OUTPUTPICTURES );
/* Mark thread as running and return */ /* Mark thread as running and return */
p_vout->b_active = 1; p_vout->b_active = 1;
...@@ -323,8 +352,6 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -323,8 +352,6 @@ static void RunThread( vout_thread_t *p_vout)
while( (!p_vout->b_die) && (!p_vout->b_error) ) while( (!p_vout->b_die) && (!p_vout->b_error) )
{ {
/* Initialize loop variables */ /* Initialize loop variables */
p_picture = NULL;
p_directbuffer = NULL;
display_date = 0; display_date = 0;
current_date = mdate(); current_date = mdate();
...@@ -333,7 +360,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -333,7 +360,7 @@ static void RunThread( vout_thread_t *p_vout)
if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) ) if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
{ {
intf_Msg( "vout stats: picture heap: %d/%d", intf_Msg( "vout stats: picture heap: %d/%d",
p_vout->i_pictures, VOUT_MAX_PICTURES ); I_RENDERPICTURES, p_vout->i_heap_size );
} }
#endif #endif
...@@ -341,13 +368,17 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -341,13 +368,17 @@ static void RunThread( vout_thread_t *p_vout)
* Find the picture to display - this operation does not need lock, * Find the picture to display - this operation does not need lock,
* since only READY_PICTUREs are handled * since only READY_PICTUREs are handled
*/ */
for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ ) p_picture = NULL;
for( i_index = 0;
i_index < I_RENDERPICTURES;
i_index++ )
{ {
if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) && if( (PP_RENDERPICTURE[i_index]->i_status == READY_PICTURE)
( (p_picture == NULL) || && ( (p_picture == NULL) ||
(p_vout->p_picture[i_index].date < display_date) ) ) (PP_RENDERPICTURE[i_index]->date < display_date) ) )
{ {
p_picture = &p_vout->p_picture[i_index]; p_picture = PP_RENDERPICTURE[i_index];
display_date = p_picture->date; display_date = p_picture->date;
} }
} }
...@@ -373,7 +404,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -373,7 +404,7 @@ static void RunThread( vout_thread_t *p_vout)
{ {
/* Destroy the picture without displaying it */ /* Destroy the picture without displaying it */
p_picture->i_status = DESTROYED_PICTURE; p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_pictures--; p_vout->i_heap_size--;
} }
intf_WarnMsg( 1, "vout warning: late picture skipped (%p)", intf_WarnMsg( 1, "vout warning: late picture skipped (%p)",
p_picture ); p_picture );
...@@ -450,7 +481,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -450,7 +481,7 @@ static void RunThread( vout_thread_t *p_vout)
else else
{ {
p_picture->i_status = DESTROYED_PICTURE; p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_pictures--; p_vout->i_heap_size--;
} }
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
} }
...@@ -527,11 +558,9 @@ static void EndThread( vout_thread_t *p_vout ) ...@@ -527,11 +558,9 @@ static void EndThread( vout_thread_t *p_vout )
#endif #endif
/* Destroy all remaining pictures */ /* Destroy all remaining pictures */
for( i_index = p_vout->i_directbuffers; for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
i_index < VOUT_MAX_PICTURES;
i_index++ )
{ {
if( p_vout->p_picture[i_index].i_status != FREE_PICTURE ) if ( p_vout->p_picture[i_index].i_type == MEMORY_PICTURE )
{ {
free( p_vout->p_picture[i_index].planes[0].p_data ); free( p_vout->p_picture[i_index].planes[0].p_data );
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_subpictures.c : subpicture management functions * vout_subpictures.c : subpicture management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000 VideoLAN
* $Id: vout_subpictures.c,v 1.1 2001/12/09 17:01:37 sam Exp $ * $Id: vout_subpictures.c,v 1.2 2001/12/13 12:47:17 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -43,8 +43,10 @@ ...@@ -43,8 +43,10 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static void vout_RenderRGBSPU( picture_t *p_pic, const subpicture_t *p_spu ); static void vout_RenderRGBSPU( const vout_thread_t *p_vout, picture_t *p_pic,
static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu ); const subpicture_t *p_spu );
static void vout_RenderYUVSPU( const vout_thread_t *p_vout, picture_t *p_pic,
const subpicture_t *p_spu );
/* FIXME: fake palette - the real one has to be sought in the .IFO */ /* FIXME: fake palette - the real one has to be sought in the .IFO */
static int p_palette[4] = { 0x0000, 0x0000, 0xffff, 0x8888 }; static int p_palette[4] = { 0x0000, 0x0000, 0xffff, 0x8888 };
...@@ -67,7 +69,7 @@ void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic ) ...@@ -67,7 +69,7 @@ void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
/* Check if status is valid */ /* Check if status is valid */
if( p_subpic->i_status != RESERVED_SUBPICTURE ) if( p_subpic->i_status != RESERVED_SUBPICTURE )
{ {
intf_ErrMsg("error: subpicture %p has invalid status %d", p_subpic, intf_ErrMsg("error: subpicture %p has invalid status #%d", p_subpic,
p_subpic->i_status ); p_subpic->i_status );
} }
#endif #endif
...@@ -219,7 +221,8 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic ) ...@@ -219,7 +221,8 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
{ {
#ifdef DEBUG #ifdef DEBUG
/* Check if status is valid */ /* Check if status is valid */
if( p_subpic->i_status != RESERVED_SUBPICTURE ) if( ( p_subpic->i_status != RESERVED_SUBPICTURE )
&& ( p_subpic->i_status != READY_SUBPICTURE ) )
{ {
intf_ErrMsg("error: subpicture %p has invalid status %d", intf_ErrMsg("error: subpicture %p has invalid status %d",
p_subpic, p_subpic->i_status ); p_subpic, p_subpic->i_status );
...@@ -238,7 +241,8 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic ) ...@@ -238,7 +241,8 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
***************************************************************************** *****************************************************************************
* This function renders a sub picture unit. * This function renders a sub picture unit.
*****************************************************************************/ *****************************************************************************/
void vout_RenderSubPictures( picture_t *p_pic, subpicture_t *p_subpic ) void vout_RenderSubPictures( vout_thread_t *p_vout, picture_t *p_pic,
subpicture_t *p_subpic )
{ {
#if 0 #if 0
p_vout_font_t p_font; /* text font */ p_vout_font_t p_font; /* text font */
...@@ -250,8 +254,8 @@ void vout_RenderSubPictures( picture_t *p_pic, subpicture_t *p_subpic ) ...@@ -250,8 +254,8 @@ void vout_RenderSubPictures( picture_t *p_pic, subpicture_t *p_subpic )
switch( p_subpic->i_type ) switch( p_subpic->i_type )
{ {
case DVD_SUBPICTURE: /* DVD subpicture unit */ case DVD_SUBPICTURE: /* DVD subpicture unit */
vout_RenderRGBSPU( p_pic, p_subpic ); vout_RenderRGBSPU( p_vout, p_pic, p_subpic );
vout_RenderYUVSPU( p_pic, p_subpic ); vout_RenderYUVSPU( p_vout, p_pic, p_subpic );
break; break;
#if 0 #if 0
...@@ -415,7 +419,8 @@ subpicture_t *vout_SortSubPictures( vout_thread_t *p_vout, ...@@ -415,7 +419,8 @@ subpicture_t *vout_SortSubPictures( vout_thread_t *p_vout,
* RLE buffer again and again. Most sanity checks are done in spu_decoder.c * RLE buffer again and again. Most sanity checks are done in spu_decoder.c
* so that this routine can be as fast as possible. * so that this routine can be as fast as possible.
*****************************************************************************/ *****************************************************************************/
static void vout_RenderRGBSPU( picture_t *p_pic, const subpicture_t *p_spu ) static void vout_RenderRGBSPU( const vout_thread_t *p_vout, picture_t *p_pic,
const subpicture_t *p_spu )
{ {
#if 0 #if 0
int i_len, i_color; int i_len, i_color;
...@@ -522,7 +527,8 @@ static void vout_RenderRGBSPU( picture_t *p_pic, const subpicture_t *p_spu ) ...@@ -522,7 +527,8 @@ static void vout_RenderRGBSPU( picture_t *p_pic, const subpicture_t *p_spu )
* RLE buffer again and again. Most sanity checks are done in spu_decoder.c * RLE buffer again and again. Most sanity checks are done in spu_decoder.c
* so that this routine can be as fast as possible. * so that this routine can be as fast as possible.
*****************************************************************************/ *****************************************************************************/
static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu ) static void vout_RenderYUVSPU( const vout_thread_t *p_vout, picture_t *p_pic,
const subpicture_t *p_spu )
{ {
int i_len, i_color; int i_len, i_color;
u16 *p_source = (u16 *)p_spu->p_data; u16 *p_source = (u16 *)p_spu->p_data;
...@@ -530,10 +536,10 @@ static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu ) ...@@ -530,10 +536,10 @@ static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu )
int i_x, i_y; int i_x, i_y;
u8 *p_dest = p_pic->planes[ Y_PLANE ].p_data + p_spu->i_x + p_spu->i_width u8 *p_dest = p_pic->planes[ Y_PLANE ].p_data + p_spu->i_x + p_spu->i_width
+ p_pic->i_width * ( p_spu->i_y + p_spu->i_height ); + p_vout->output.i_width * ( p_spu->i_y + p_spu->i_height );
/* Draw until we reach the bottom of the subtitle */ /* Draw until we reach the bottom of the subtitle */
i_y = p_spu->i_height * p_pic->i_width; i_y = p_spu->i_height * p_vout->output.i_width;
while( i_y ) while( i_y )
{ {
...@@ -556,7 +562,7 @@ static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu ) ...@@ -556,7 +562,7 @@ static void vout_RenderYUVSPU( picture_t *p_pic, const subpicture_t *p_spu )
i_x -= *p_source++ >> 2; i_x -= *p_source++ >> 2;
} }
i_y -= p_pic->i_width; i_y -= p_vout->output.i_width;
} }
} }
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