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