]> git.sesse.net Git - vlc/blob - include/video_output.h
Scaling horizontal >=1
[vlc] / include / video_output.h
1 /*******************************************************************************
2  * video_output.h : video output thread
3  * (c)1999 VideoLAN
4  *******************************************************************************
5  * This module describes the programming interface for video output threads.
6  * It includes functions allowing to open a new thread, send pictures to a
7  * thread, and destroy a previously oppenned video output thread.
8  *******************************************************************************/
9
10 /*******************************************************************************
11  * vout_yuv_convert_t: YUV convertion function
12  *******************************************************************************
13  * This is the prototype common to all convertion functions. The type of p_pic
14  * will change depending of the screen depth treated.
15  * Parameters:
16  *      p_vout                          video output thread
17  *      p_pic                           picture address 
18  *      p_y, p_u, p_v                   Y,U,V samples addresses
19  *      i_width, i_height               Y samples extension
20  *      i_pic_width, i_pic_height       picture extension
21  *      i_pic_line_width                picture total line width
22  *      i_matrix_coefficients           matrix coefficients
23  * Picture width and source dimensions must be multiples of 16.
24  *******************************************************************************/
25 typedef void (vout_yuv_convert_t)( p_vout_thread_t p_vout, void *p_pic,
26                                    yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
27                                    int i_width, int i_height,
28                                    int i_pic_width, int i_pic_height, int i_pic_skip,
29                                    int i_matrix_coefficients );
30
31 /*******************************************************************************
32  * vout_yuv_t: pre-calculated YUV convertion tables
33  *******************************************************************************
34  * These tables are used by convertion and scaling functions.
35  *******************************************************************************/
36 typedef struct vout_yuv_s
37 {
38     /* Convertion functions */
39     vout_yuv_convert_t *        p_Convert420;           /* YUV 4:2:0 converter */
40     vout_yuv_convert_t *        p_Convert422;           /* YUV 4:2:2 converter */
41     vout_yuv_convert_t *        p_Convert444;           /* YUV 4:4:4 converter */
42
43     /* Pre-calculated convertion tables */
44     void *              p_base;             /* base for all translation tables */    
45     union 
46     {        
47         struct { u16 *p_red, *p_green, *p_blue; } rgb16;   /* color 15, 16 bpp */
48         struct { u32 *p_red, *p_green, *p_blue; } rgb32;   /* color 24, 32 bpp */
49         struct { u16 *p_gray; }                   gray16;   /* gray 15, 16 bpp */
50         struct { u32 *p_gray; }                   gray32;   /* gray 24, 32 bpp */
51     } yuv;
52     union
53     {
54         u16 *           p_rgb16;
55         u32 *           p_rgb32;        
56     } yuv2;//??    
57
58     /* Temporary convertion buffer - this buffer may be used by convertion
59      * functions and should be 2 screen lines width */
60     void *              p_buffer;                         /* convertion buffer */    
61 } vout_yuv_t;
62
63 /*******************************************************************************
64  * vout_buffer_t: rendering buffer
65  *******************************************************************************
66  * This structure store informations about a buffer. Buffers are not completely
67  * cleared between displays, and modified areas needs to be stored.
68  *******************************************************************************/
69 typedef struct vout_buffer_s
70 {     
71     /* Picture area */
72     int         i_pic_x, i_pic_y;                         /* picture position  */
73     int         i_pic_width, i_pic_height;                /* picture extension */
74     
75     /* Other areas - only vertical extensions of areas are stored */
76     int         i_areas;                                    /* number of areas */    
77     int         pi_area_begin[VOUT_MAX_AREAS];            /* beginning of area */ 
78     int         pi_area_end[VOUT_MAX_AREAS];                    /* end of area */
79     
80     /* Picture data */
81     byte_t *    p_data;                                      /* memory address */
82 } vout_buffer_t;
83
84 /*******************************************************************************
85  * vout_thread_t: video output thread descriptor
86  *******************************************************************************
87  * Any independant video output device, such as an X11 window or a GGI device,
88  * is represented by a video output thread, and described using following 
89  * structure.
90  *******************************************************************************/
91 typedef struct vout_thread_s
92 {
93     /* Thread properties and lock */
94     boolean_t           b_die;                                   /* `die' flag */
95     boolean_t           b_error;                               /* `error' flag */
96     boolean_t           b_active;                             /* `active' flag */
97     vlc_thread_t        thread_id;                 /* id for pthread functions */
98     vlc_mutex_t         picture_lock;                     /* picture heap lock */
99     vlc_mutex_t         subpicture_lock;               /* subpicture heap lock */   
100     vlc_mutex_t         change_lock;                     /* thread change lock */    
101     int *               pi_status;                    /* temporary status flag */
102     p_vout_sys_t        p_sys;                         /* system output method */
103
104     /* Current display properties */    
105     u16                 i_changes;               /* changes made to the thread */    
106     int                 i_width;                /* current output method width */
107     int                 i_height;              /* current output method height */
108     int                 i_bytes_per_line;/* bytes per line (including virtual) */
109     int                 i_screen_depth;                      /* bits per pixel */
110     int                 i_bytes_per_pixel;                /* real screen depth */
111     float               f_gamma;                                      /* gamma */
112
113     /* Pictures and rendering properties */
114     boolean_t           b_grayscale;             /* color or grayscale display */   
115     boolean_t           b_info;              /* print additionnal informations */
116     boolean_t           b_interface;                       /* render interface */    
117     boolean_t           b_scale;                      /* allow picture scaling */    
118
119     /* Idle screens management */
120     mtime_t             last_display_date;       /* last non idle display date */
121     mtime_t             last_idle_date;              /* last idle display date */
122
123 #ifdef STATS    
124     /* Statistics - these numbers are not supposed to be accurate, but are a
125      * good indication of the thread status */
126     mtime_t             render_time;               /* last picture render time */
127     count_t             c_fps_samples;                       /* picture counts */    
128     mtime_t             p_fps_sample[ VOUT_FPS_SAMPLES ]; /* FPS samples dates */
129 #endif
130
131     /* Rendering buffers */
132     int                 i_buffer_index;                        /* buffer index */
133     vout_buffer_t       p_buffer[2];                     /* buffers properties */
134
135     /* Videos heap and translation tables */
136     picture_t           p_picture[VOUT_MAX_PICTURES];              /* pictures */
137     subpicture_t        p_subpicture[VOUT_MAX_PICTURES];        /* subpictures */    
138     vout_yuv_t          yuv;                             /* translation tables */
139
140     /* Bitmap fonts */
141     p_vout_font_t       p_default_font;                        /* default font */    
142     p_vout_font_t       p_large_font;                            /* large font */    
143 } vout_thread_t;
144
145 /* Flags for changes - these flags are set in the i_changes field when another
146  * thread changed a variable */
147 #define VOUT_INFO_CHANGE        0x0001                       /* b_info changed */
148 #define VOUT_GRAYSCALE_CHANGE   0x0002                  /* b_grayscale changed */
149 #define VOUT_INTF_CHANGE        0x0004                  /* b_interface changed */
150 #define VOUT_SCALE_CHANGE       0x0008                      /* b_scale changed */
151 #define VOUT_SIZE_CHANGE        0x0200                         /* size changed */
152 #define VOUT_DEPTH_CHANGE       0x0400                        /* depth changed */
153 #define VOUT_GAMMA_CHANGE       0x0010                        /* gamma changed */
154 #define VOUT_YUV_CHANGE         0x0800                    /* change yuv tables */
155 #define VOUT_NODISPLAY_CHANGE   0xff00      /* changes which forbidden display */
156
157 /*******************************************************************************
158  * Prototypes
159  *******************************************************************************/
160 vout_thread_t * vout_CreateThread       ( char *psz_display, int i_root_window, 
161                                           int i_width, int i_height, int *pi_status );
162 void            vout_DestroyThread      ( vout_thread_t *p_vout, int *pi_status );
163 picture_t *     vout_CreatePicture      ( vout_thread_t *p_vout, int i_type, 
164                                           int i_width, int i_height );
165 void            vout_DestroyPicture     ( vout_thread_t *p_vout, picture_t *p_pic );
166 void            vout_DisplayPicture     ( vout_thread_t *p_vout, picture_t *p_pic );
167 void            vout_DatePicture        ( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date );
168 void            vout_LinkPicture        ( vout_thread_t *p_vout, picture_t *p_pic );
169 void            vout_UnlinkPicture      ( vout_thread_t *p_vout, picture_t *p_pic );
170 subpicture_t *  vout_CreateSubPicture   ( vout_thread_t *p_vout, int i_type, int i_size );
171 void            vout_DestroySubPicture  ( vout_thread_t *p_vout, subpicture_t *p_subpic );
172 void            vout_DisplaySubPicture  ( vout_thread_t *p_vout, subpicture_t *p_subpic );
173
174 void            vout_SetBuffers         ( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 );