video_output.h 8.77 KB
Newer Older
Michel Kaempf's avatar
Michel Kaempf committed
1
2
3
4
5
6
7
8
9
/*******************************************************************************
 * video_output.h : video output thread
 * (c)1999 VideoLAN
 *******************************************************************************
 * This module describes the programming interface for video output threads.
 * It includes functions allowing to open a new thread, send pictures to a
 * thread, and destroy a previously oppenned video output thread.
 *******************************************************************************/

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*******************************************************************************
 * vout_tables_t: pre-calculated convertion tables
 *******************************************************************************
 * These tables are used by convertion and scaling functions.
 *******************************************************************************/
typedef struct vout_tables_s
{
    void *              p_base;             /* base for all translation tables */    
    union 
    {        
        struct { u16 *p_red, *p_green, *p_blue; } rgb16;   /* color 15, 16 bpp */
        struct { u32 *p_red, *p_green, *p_blue; } rgb32;   /* color 24, 32 bpp */
        struct { u16 *p_gray; }                   gray16;   /* gray 15, 16 bpp */
        struct { u32 *p_gray; }                   gray32;   /* gray 24, 32 bpp */
    } yuv;    
} vout_tables_t;

/*******************************************************************************
 * vout_convert_t: convertion function
 *******************************************************************************
 * This is the prototype common to all convertion functions. The type of p_pic
 * will change depending of the screen depth treated.
 * Parameters:
 *      p_vout                  video output thread
 *      p_pic                   picture address (start address in picture)
 *      p_y, p_u, p_v           Y,U,V samples addresses
 *      i_width                 Y samples width
 *      i_height                Y samples height
 *      i_eol                   number of Y samples to reach the next line 
 *      i_pic_eol               number or pixels to reach the next line
 *      i_scale                 if non 0, vertical scaling is 1 - 1/i_scale
Vincent Seguin's avatar
Vincent Seguin committed
41
 *      i_matrix_coefficients   matrix coefficients
42
43
44
45
46
47
48
49
 * Conditions:
 *      start x + i_width                        <  picture width
 *      start y + i_height * (scaling factor)    <  picture height
 *      i_width % 16                             == 0
 *******************************************************************************/
typedef void (vout_convert_t)( p_vout_thread_t p_vout, void *p_pic,
                               yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
                               int i_width, int i_height, int i_eol, int i_pic_eol,
Vincent Seguin's avatar
Vincent Seguin committed
50
                               int i_scale, int i_matrix_coefficients );
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

/*******************************************************************************
 * vout_scale_t: scaling function
 *******************************************************************************
 * When a picture can't be scaled unsing the fast i_y_scale parameter of a
 * transformation, it is rendered in a temporary buffer then scaled using a
 * totally accurate (but also very slow) method.
 * This is the prototype common to all scaling functions. The types of p_buffer
 * and p_pic will change depending of the screen depth treated.
 * Parameters:
 *      p_vout                  video output thread
 *      p_pic                   picture address (start address in picture)
 *      p_buffer                source picture
 *      i_width                 buffer width
 *      i_height                buffer height
 *      i_eol                   number of pixels to reach next buffer line
 *      i_pic_eol               number of pixels to reach next picture line
 *      f_alpha, f_beta         horizontal and vertical scaling factors
 *******************************************************************************/
typedef void (vout_scale_t)( p_vout_thread_t p_vout, void *p_pic, void *p_buffer, 
                             int i_width, int i_height, int i_eol, int i_pic_eol,
                             float f_alpha, float f_beta );

Michel Kaempf's avatar
Michel Kaempf committed
74
75
76
/*******************************************************************************
 * vout_thread_t: video output thread descriptor
 *******************************************************************************
77
78
79
 * Any independant video output device, such as an X11 window or a GGI device,
 * is represented by a video output thread, and described using following 
 * structure.
Michel Kaempf's avatar
Michel Kaempf committed
80
81
82
 *******************************************************************************/
typedef struct vout_thread_s
{
83
    /* Thread properties and lock */
Michel Kaempf's avatar
Michel Kaempf committed
84
85
86
    boolean_t           b_die;                                   /* `die' flag */
    boolean_t           b_error;                               /* `error' flag */
    boolean_t           b_active;                             /* `active' flag */
Vincent Seguin's avatar
Vincent Seguin committed
87
88
    pthread_t           thread_id;                 /* id for pthread functions */
    pthread_mutex_t     lock;                                   /* thread lock */
Michel Kaempf's avatar
Michel Kaempf committed
89
    int *               pi_status;                    /* temporary status flag */
90
    p_vout_sys_t        p_sys;                         /* system output method */
Michel Kaempf's avatar
Michel Kaempf committed
91

92
    /* Current display properties */
93
94
    boolean_t           b_info;              /* print additionnal informations */    
    boolean_t           b_grayscale;             /* color or grayscale display */    
Michel Kaempf's avatar
Michel Kaempf committed
95
96
    int                 i_width;                /* current output method width */
    int                 i_height;              /* current output method height */
97
    int                 i_bytes_per_line;/* bytes per line (including virtual) */    
98
99
    int                 i_screen_depth;              /* bits per pixel - FIXED */
    int                 i_bytes_per_pixel;        /* real screen depth - FIXED */
Vincent Seguin's avatar
Vincent Seguin committed
100
101
    float               f_x_ratio;                 /* horizontal display ratio */
    float               f_y_ratio;                   /* vertical display ratio */
102
    float               f_gamma;                                      /* gamma */    
Michel Kaempf's avatar
Michel Kaempf committed
103

104
105
    /* Changed properties values - some of them are treated directly by the
     * thread, the over may be ignored or handled by vout_SysManage */
106
    //?? info, grayscale, width, height, bytes per line, x ratio, y ratio, gamma
107
    boolean_t           b_gamma_change;              /* gamma change indicator */    
108
109
110
    int                 i_new_width;                              /* new width */    
    int                 i_new_height;                            /* new height */    

Michel Kaempf's avatar
Michel Kaempf committed
111
#ifdef STATS    
112
113
    /* Statistics - these numbers are not supposed to be accurate, but are a
     * good indication of the thread status */
114
115
    count_t             c_loops;                            /* number of loops */
    count_t             c_idle_loops;                  /* number of idle loops */
116
117
    count_t             c_fps_samples;                       /* picture counts */    
    mtime_t             fps_sample[ VOUT_FPS_SAMPLES ];   /* FPS samples dates */
118
119
120
#endif

#ifdef DEBUG_VIDEO
121
    /* Additionnal video debugging informations */
122
    mtime_t             picture_render_time;    /* last picture rendering time */
Michel Kaempf's avatar
Michel Kaempf committed
123
#endif
124
125
 
    /* Video heap and translation tables */
126
    picture_t           p_picture[VOUT_MAX_PICTURES];              /* pictures */
127
128
129
130
131
    vout_tables_t       tables;                          /* translation tables */
    vout_convert_t *    p_ConvertYUV420;                /* YUV 4:2:0 converter */
    vout_convert_t *    p_ConvertYUV422;                /* YUV 4:2:2 converter */
    vout_convert_t *    p_ConvertYUV444;                /* YUV 4:4:4 converter */
    vout_scale_t *      p_Scale;                                     /* scaler */
Michel Kaempf's avatar
Michel Kaempf committed
132
133
134
135
136
} vout_thread_t;

/*******************************************************************************
 * Prototypes
 *******************************************************************************/
Vincent Seguin's avatar
Vincent Seguin committed
137
vout_thread_t * vout_CreateThread               ( 
138
#ifdef VIDEO_X11
139
                                                  char *psz_display, Window root_window, 
Vincent Seguin's avatar
Vincent Seguin committed
140
141
142
#endif
                                                  int i_width, int i_height, int *pi_status
                                                );
Michel Kaempf's avatar
Michel Kaempf committed
143

Vincent Seguin's avatar
Vincent Seguin committed
144
void            vout_DestroyThread              ( vout_thread_t *p_vout, int *pi_status );
Michel Kaempf's avatar
Michel Kaempf committed
145

Vincent Seguin's avatar
Vincent Seguin committed
146
picture_t *     vout_CreatePicture              ( vout_thread_t *p_vout, int i_type, 
147
						  int i_width, int i_height );
Vincent Seguin's avatar
Vincent Seguin committed
148
149
void            vout_DestroyPicture             ( vout_thread_t *p_vout, picture_t *p_pic );
void            vout_DisplayPicture             ( vout_thread_t *p_vout, picture_t *p_pic );
Michel Kaempf's avatar
Michel Kaempf committed
150
151
152
153
154
155
156
157
158
159
void            vout_LinkPicture                ( vout_thread_t *p_vout, picture_t *p_pic );
void            vout_UnlinkPicture              ( vout_thread_t *p_vout, picture_t *p_pic );








Vincent Seguin's avatar
Vincent Seguin committed
160
161
162
163
164
165
166
167
168