vlc_vout.h 25.8 KB
Newer Older
1
/*****************************************************************************
2
 * vlc_video.h: common video definitions
3
 *****************************************************************************
4
 * Copyright (C) 1999 - 2005 the VideoLAN team
5
 * $Id$
6
 *
7
 * Authors: Vincent Seguin <seguin@via.ecp.fr>
Clément Stenac's avatar
Clément Stenac committed
8 9
 *          Samuel Hocevar <sam@via.ecp.fr>
 *          Olivier Aubert <oaubert 47 videolan d07 org>
10 11 12 13 14
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
Clément Stenac's avatar
Clément Stenac committed
15
 *
16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
20
 *
21 22
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
23
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24
 *****************************************************************************/
Clément Stenac's avatar
Clément Stenac committed
25 26 27 28 29

#if !defined( __LIBVLC__ )
  #error You are not libvlc or one of its plugins. You cannot include this file
#endif

Clément Stenac's avatar
Clément Stenac committed
30 31
#ifndef _VLC_VOUT_H_
#define _VLC_VOUT_H_ 1
Gildas Bazin's avatar
 
Gildas Bazin committed
32

Clément Stenac's avatar
Clément Stenac committed
33
#include <vlc_es.h>
34

Clément Stenac's avatar
Clément Stenac committed
35
/** Description of a planar graphic field */
36
typedef struct plane_t
Sam Hocevar's avatar
 
Sam Hocevar committed
37
{
38
    uint8_t *p_pixels;                        /**< Start of the plane's data */
Sam Hocevar's avatar
 
Sam Hocevar committed
39 40

    /* Variables used for fast memcpy operations */
41
    int i_lines;           /**< Number of lines, including margins */
42
    int i_pitch;           /**< Number of bytes in a line, including margins */
Sam Hocevar's avatar
 
Sam Hocevar committed
43

44
    /** Size of a macropixel, defaults to 1 */
45
    int i_pixel_pitch;
Sam Hocevar's avatar
 
Sam Hocevar committed
46 47

    /* Variables used for pictures with margins */
48
    int i_visible_lines;            /**< How many visible lines are there ? */
49
    int i_visible_pitch;            /**< How many visible pixels are there ? */
Sam Hocevar's avatar
 
Sam Hocevar committed
50

Sam Hocevar's avatar
 
Sam Hocevar committed
51 52
} plane_t;

53 54 55
/**
 * Video picture
 *
56
 * Any picture destined to be displayed by a video output thread should be
Michel Kaempf's avatar
Michel Kaempf committed
57
 * stored in this structure from it's creation to it's effective display.
Vincent Seguin's avatar
Vincent Seguin committed
58 59
 * Picture type and flags should only be modified by the output thread. Note
 * that an empty picture MUST have its flags set to 0.
60
 */
61
struct picture_t
Michel Kaempf's avatar
Michel Kaempf committed
62
{
63
    /**
64 65
     * The properties of the picture
     */
Gildas Bazin's avatar
 
Gildas Bazin committed
66 67
    video_frame_format_t format;

68
    /** Picture data - data can always be freely modified, but p_data may
Sam Hocevar's avatar
 
Sam Hocevar committed
69 70
     * NEVER be modified. A direct buffer can be handled as the plugin
     * wishes, it can even swap p_pixels buffers. */
71
    uint8_t        *p_data;
72 73 74
    void           *p_data_orig;                /**< pointer before memalign */
    plane_t         p[ VOUT_MAX_PLANES ];     /**< description of the planes */
    int             i_planes;                /**< number of allocated planes */
75

76 77 78 79 80
    /** \name Type and flags
     * Should NOT be modified except by the vout thread
     * @{*/
    int             i_status;                             /**< picture flags */
    int             i_type;                /**< is picture a direct buffer ? */
81
    bool      b_slow;                 /**< is picture in slow memory ? */
82 83
    int             i_matrix_coefficients;   /**< in YUV type, encoding type */
    /**@}*/
Sam Hocevar's avatar
 
Sam Hocevar committed
84

85 86 87 88
    /** \name Picture management properties
     * These properties can be modified using the video output thread API,
     * but should never be written directly */
    /**@{*/
89
    unsigned        i_refcount;                  /**< link reference counter */
90
    mtime_t         date;                                  /**< display date */
91
    bool      b_force;
92 93 94 95 96 97
    /**@}*/

    /** \name Picture dynamic properties
     * Those properties can be changed by the decoder
     * @{
     */
98
    bool      b_progressive;          /**< is it a progressive frame ? */
99
    unsigned int    i_nb_fields;                  /**< # of displayed fields */
100
    bool      b_top_field_first;             /**< which field is first */
101
    /**@}*/
Clément Stenac's avatar
Clément Stenac committed
102

103
    /** The picture heap we are attached to */
104
    picture_heap_t* p_heap;
Sam Hocevar's avatar
 
Sam Hocevar committed
105

Gildas Bazin's avatar
 
Gildas Bazin committed
106 107 108 109
    /* Some vouts require the picture to be locked before it can be modified */
    int (* pf_lock) ( vout_thread_t *, picture_t * );
    int (* pf_unlock) ( vout_thread_t *, picture_t * );

110
    /** Private data - the video output plugin might want to put stuff here to
Sam Hocevar's avatar
 
Sam Hocevar committed
111
     * keep track of the picture */
112
    picture_sys_t * p_sys;
113 114 115

    /** This way the picture_Release can be overloaded */
    void (*pf_release)( picture_t * );
116 117 118

    /** Next picture in a FIFO a pictures */
    struct picture_t *p_next;
119
};
Michel Kaempf's avatar
Michel Kaempf committed
120

121 122
/**
 * Video picture heap, either render (to store pictures used
Sam Hocevar's avatar
 
Sam Hocevar committed
123
 * by the decoder) or output (to store pictures displayed by the vout plugin)
124
 */
125
struct picture_heap_t
Sam Hocevar's avatar
 
Sam Hocevar committed
126
{
127 128 129 130 131 132 133 134 135 136 137
    int i_pictures;                                   /**< current heap size */

    /* \name Picture static properties
     * Those properties are fixed at initialization and should NOT be modified
     * @{
     */
    unsigned int i_width;                                 /**< picture width */
    unsigned int i_height;                               /**< picture height */
    vlc_fourcc_t i_chroma;                               /**< picture chroma */
    unsigned int i_aspect;                                 /**< aspect ratio */
    /**@}*/
Sam Hocevar's avatar
 
Sam Hocevar committed
138

Sam Hocevar's avatar
 
Sam Hocevar committed
139
    /* Real pictures */
140 141
    picture_t*      pp_picture[VOUT_MAX_PICTURES];             /**< pictures */
    int             i_last_used_pic;              /**< last used pic in heap */
142
    bool      b_allow_modify_pics;
Sam Hocevar's avatar
 
Sam Hocevar committed
143 144

    /* Stuff used for truecolor RGB planes */
145 146 147
    uint32_t i_rmask; int i_rrshift, i_lrshift;
    uint32_t i_gmask; int i_rgshift, i_lgshift;
    uint32_t i_bmask; int i_rbshift, i_lbshift;
Sam Hocevar's avatar
 
Sam Hocevar committed
148

149
    /** Stuff used for palettized RGB planes */
150
    void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
151
};
Sam Hocevar's avatar
 
Sam Hocevar committed
152

Sam Hocevar's avatar
 
Sam Hocevar committed
153 154 155 156
/*****************************************************************************
 * Flags used to describe the status of a picture
 *****************************************************************************/

Sam Hocevar's avatar
 
Sam Hocevar committed
157 158 159 160 161 162
/* Picture type */
#define EMPTY_PICTURE           0                            /* empty buffer */
#define MEMORY_PICTURE          100                 /* heap-allocated buffer */
#define DIRECT_PICTURE          200                         /* direct buffer */

/* Picture status */
Sam Hocevar's avatar
Sam Hocevar committed
163 164 165 166 167 168 169
#define FREE_PICTURE            0                  /* free and not allocated */
#define RESERVED_PICTURE        1                  /* allocated and reserved */
#define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
#define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
#define READY_PICTURE           4                       /* ready for display */
#define DISPLAYED_PICTURE       5            /* been displayed but is linked */
#define DESTROYED_PICTURE       6              /* allocated but no more used */
Michel Kaempf's avatar
Michel Kaempf committed
170

171 172 173
/*****************************************************************************
 * Shortcuts to access image components
 *****************************************************************************/
174

Sam Hocevar's avatar
 
Sam Hocevar committed
175
/* Plane indices */
Sam Hocevar's avatar
 
Sam Hocevar committed
176 177 178
#define Y_PLANE      0
#define U_PLANE      1
#define V_PLANE      2
179
#define A_PLANE      3
Sam Hocevar's avatar
 
Sam Hocevar committed
180 181

/* Shortcuts */
Sam Hocevar's avatar
 
Sam Hocevar committed
182
#define Y_PIXELS     p[Y_PLANE].p_pixels
183
#define Y_PITCH      p[Y_PLANE].i_pitch
Sam Hocevar's avatar
 
Sam Hocevar committed
184
#define U_PIXELS     p[U_PLANE].p_pixels
185
#define U_PITCH      p[U_PLANE].i_pitch
Sam Hocevar's avatar
 
Sam Hocevar committed
186
#define V_PIXELS     p[V_PLANE].p_pixels
187
#define V_PITCH      p[V_PLANE].i_pitch
188 189
#define A_PIXELS     p[A_PLANE].p_pixels
#define A_PITCH      p[A_PLANE].i_pitch
Sam Hocevar's avatar
 
Sam Hocevar committed
190

191 192 193 194 195 196 197 198
/**
 * \defgroup subpicture Video Subpictures
 * Subpictures are pictures that should be displayed on top of the video, like
 * subtitles and OSD
 * \ingroup video_output
 * @{
 */

199 200 201 202 203 204 205 206 207 208 209 210 211 212
/**
 * Video subtitle region
 *
 * A subtitle region is defined by a picture (graphic) and its rendering
 * coordinates.
 * Subtitles contain a list of regions.
 */
struct subpicture_region_t
{
    video_format_t  fmt;                          /**< format of the picture */
    picture_t       picture;             /**< picture comprising this region */

    int             i_x;                             /**< position of region */
    int             i_y;                             /**< position of region */
213
    int             i_align;                  /**< alignment within a region */
214
    int             i_alpha;                               /**< transparency */
215 216

    char            *psz_text;       /**< text string comprising this region */
217
    char            *psz_html;       /**< HTML version of subtitle (NULL = use psz_text) */
Jean-Paul Saman's avatar
Jean-Paul Saman committed
218
    text_style_t    *p_style;        /**< a description of the text style formatting */
219

220
    subpicture_region_t *p_next;                /**< next region in the list */
221
    subpicture_region_t *p_cache;       /**< modified version of this region */
222 223
};

224 225 226
/**
 * Video subtitle
 *
Sam Hocevar's avatar
Sam Hocevar committed
227
 * Any subtitle destined to be displayed by a video output thread should
228
 * be stored in this structure from it's creation to it's effective display.
Vincent Seguin's avatar
Vincent Seguin committed
229 230
 * Subtitle type and flags should only be modified by the output thread. Note
 * that an empty subtitle MUST have its flags set to 0.
231
 */
232
struct subpicture_t
Vincent Seguin's avatar
Vincent Seguin committed
233
{
234
    /** \name Channel ID */
235
    /**@{*/
236
    int             i_channel;                    /**< subpicture channel ID */
237 238
    /**@}*/

239 240 241 242 243 244 245 246 247 248 249 250
    /** \name Type and flags
       Should NOT be modified except by the vout thread */
    /**@{*/
    int             i_type;                                        /**< type */
    int             i_status;                                     /**< flags */
    subpicture_t *  p_next;               /**< next subtitle to be displayed */
    /**@}*/

    /** \name Date properties */
    /**@{*/
    mtime_t         i_start;                  /**< beginning of display date */
    mtime_t         i_stop;                         /**< end of display date */
251
    bool      b_ephemer;    /**< If this flag is set to true the subtitle
252
                                will be displayed untill the next one appear */
253 254
    bool      b_fade;                               /**< enable fading */
    bool      b_pausable;               /**< subpicture will be paused if
255
                                                            stream is paused */
256 257
    /**@}*/

258 259
    subpicture_region_t *p_region;  /**< region list composing this subtitle */

260 261
    /** \name Display properties
     * These properties are only indicative and may be
262
     * changed by the video output thread, or simply ignored depending of the
Sam Hocevar's avatar
Sam Hocevar committed
263
     * subtitle type. */
264
    /**@{*/
265 266 267 268
    int          i_x;                    /**< offset from alignment position */
    int          i_y;                    /**< offset from alignment position */
    int          i_width;                                 /**< picture width */
    int          i_height;                               /**< picture height */
269
    int          i_alpha;                                  /**< transparency */
270 271
    int          i_original_picture_width;  /**< original width of the movie */
    int          i_original_picture_height;/**< original height of the movie */
272
    bool   b_absolute;                       /**< position is absolute */
273
    int          i_flags;                                /**< position flags */
274
     /**@}*/
Sam Hocevar's avatar
 
Sam Hocevar committed
275

276
    /** Pointer to function that renders this subtitle in a picture */
277
    void ( *pf_render )  ( vout_thread_t *, picture_t *, const subpicture_t * );
278
    /** Pointer to function that cleans up the private data of this subtitle */
279
    void ( *pf_destroy ) ( subpicture_t * );
Sam Hocevar's avatar
 
Sam Hocevar committed
280

281 282 283
    /** Pointer to functions for region management */
    subpicture_region_t * ( *pf_create_region ) ( vlc_object_t *,
                                                  video_format_t * );
284 285
    subpicture_region_t * ( *pf_make_region ) ( vlc_object_t *,
                                                video_format_t *, picture_t * );
286 287
    void ( *pf_destroy_region ) ( vlc_object_t *, subpicture_region_t * );

288 289 290 291
    void ( *pf_pre_render ) ( video_format_t *, spu_t *, subpicture_t *, mtime_t );
    subpicture_region_t * ( *pf_update_regions ) ( video_format_t *, spu_t *,
                                                   subpicture_t *, mtime_t );

292
    /** Private data - the subtitle plugin might want to put stuff here to
Sam Hocevar's avatar
 
Sam Hocevar committed
293
     * keep track of the subpicture */
294 295
    subpicture_sys_t *p_sys;                              /* subpicture data */
};
Vincent Seguin's avatar
Vincent Seguin committed
296

297
/* Subpicture type */
Sam Hocevar's avatar
Sam Hocevar committed
298
#define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
Sam Hocevar's avatar
 
Sam Hocevar committed
299
#define MEMORY_SUBPICTURE      100            /* subpicture stored in memory */
Vincent Seguin's avatar
Vincent Seguin committed
300

301 302 303
/* Default subpicture channel ID */
#define DEFAULT_CHAN           1

304
/* Subpicture status */
Sam Hocevar's avatar
Sam Hocevar committed
305 306 307
#define FREE_SUBPICTURE        0                   /* free and not allocated */
#define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
#define READY_SUBPICTURE       2                        /* ready for display */
308

309 310 311 312 313
/* Subpicture position flags */
#define SUBPICTURE_ALIGN_LEFT 0x1
#define SUBPICTURE_ALIGN_RIGHT 0x2
#define SUBPICTURE_ALIGN_TOP 0x4
#define SUBPICTURE_ALIGN_BOTTOM 0x8
Laurent Aimar's avatar
Laurent Aimar committed
314 315
#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
                                SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
316

317 318 319
/* Subpicture rendered flag - should only be used by vout_subpictures */
#define SUBPICTURE_RENDERED  0x10

320 321 322
/*****************************************************************************
 * Prototypes
 *****************************************************************************/
Clément Stenac's avatar
Clément Stenac committed
323

324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
/**
 * Copy the source picture onto the destination picture.
 * \param p_this a vlc object
 * \param p_dst pointer to the destination picture.
 * \param p_src pointer to the source picture.
 */
#define vout_CopyPicture(a,b,c) __vout_CopyPicture(VLC_OBJECT(a),b,c)
VLC_EXPORT( void, __vout_CopyPicture, ( vlc_object_t *p_this, picture_t *p_dst, picture_t *p_src ) );

/**
 * Initialise different fields of a picture_t (but does not allocate memory).
 * \param p_this a vlc object
 * \param p_pic pointer to the picture structure.
 * \param i_chroma the wanted chroma for the picture.
 * \param i_width the wanted width for the picture.
 * \param i_height the wanted height for the picture.
 * \param i_aspect the wanted aspect ratio for the picture.
 */
#define vout_InitPicture(a,b,c,d,e,f) \
        __vout_InitPicture(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT( int, __vout_InitPicture, ( vlc_object_t *p_this, picture_t *p_pic, uint32_t i_chroma, int i_width, int i_height, int i_aspect ) );

/**
 * Initialise different fields of a picture_t and allocates the picture buffer.
 * \param p_this a vlc object
 * \param p_pic pointer to the picture structure.
 * \param i_chroma the wanted chroma for the picture.
 * \param i_width the wanted width for the picture.
 * \param i_height the wanted height for the picture.
 * \param i_aspect the wanted aspect ratio for the picture.
 */
#define vout_AllocatePicture(a,b,c,d,e,f) \
        __vout_AllocatePicture(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT( int, __vout_AllocatePicture,( vlc_object_t *p_this, picture_t *p_pic, uint32_t i_chroma, int i_width, int i_height, int i_aspect ) );
358

Clément Stenac's avatar
Clément Stenac committed
359

360
/**
Clément Stenac's avatar
Clément Stenac committed
361 362 363 364 365
 * \defgroup video_output Video Output
 * 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 opened video output thread.
 * @{
366 367 368
 */

/**
Clément Stenac's avatar
Clément Stenac committed
369
 * Chroma conversion function
370
 *
Clément Stenac's avatar
Clément Stenac committed
371 372 373 374 375
 * This is the prototype common to all conversion functions.
 * \param p_vout video output thread
 * \param p_source source picture
 * \param p_dest destination picture
 * Picture width and source dimensions must be multiples of 16.
376
 */
Clément Stenac's avatar
Clément Stenac committed
377 378
typedef void (vout_chroma_convert_t)( vout_thread_t *,
                                      picture_t *, picture_t * );
379

Clément Stenac's avatar
Clément Stenac committed
380 381 382 383
typedef struct vout_chroma_t
{
    /** conversion functions */
    vout_chroma_convert_t *pf_convert;
384

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
385
    /** Private module-dependent data */
Clément Stenac's avatar
Clément Stenac committed
386 387 388 389 390 391 392 393 394
    chroma_sys_t *      p_sys;                               /* private data */

    /** Plugin used and shortcuts to access its capabilities */
    module_t * p_module;

} vout_chroma_t;

/** Maximum numbers of video filters2 that can be attached to a vout */
#define MAX_VFILTERS 10
395 396

/**
Clément Stenac's avatar
Clément Stenac committed
397
 * Video output thread descriptor
398
 *
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
399
 * Any independent video output device, such as an X11 window or a GGI device,
Clément Stenac's avatar
Clément Stenac committed
400 401
 * is represented by a video output thread, and described using the following
 * structure.
402
 */
Clément Stenac's avatar
Clément Stenac committed
403 404 405
struct vout_thread_t
{
    VLC_COMMON_MEMBERS
406

Clément Stenac's avatar
Clément Stenac committed
407 408 409 410 411
    /** \name Thread properties and locks */
    /**@{*/
    vlc_mutex_t         picture_lock;                 /**< picture heap lock */
    vlc_mutex_t         subpicture_lock;           /**< subpicture heap lock */
    vlc_mutex_t         change_lock;                 /**< thread change lock */
412
    vlc_mutex_t         vfilter_lock;         /**< video filter2 change lock */
Clément Stenac's avatar
Clément Stenac committed
413 414 415 416 417 418 419 420
    vout_sys_t *        p_sys;                     /**< system output method */
    /**@}*/

    /** \name Current display properties */
    /**@{*/
    uint16_t            i_changes;          /**< changes made to the thread.
                                                      \see \ref vout_changes */
    float               f_gamma;                                  /**< gamma */
421 422 423 424 425
    bool          b_grayscale;         /**< color or grayscale display */
    bool          b_info;            /**< print additional information */
    bool          b_interface;                   /**< render interface */
    bool          b_scale;                  /**< allow picture scaling */
    bool          b_fullscreen;         /**< toogle fullscreen display */
Clément Stenac's avatar
Clément Stenac committed
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
    uint32_t            render_time;           /**< last picture render time */
    unsigned int        i_window_width;              /**< video window width */
    unsigned int        i_window_height;            /**< video window height */
    unsigned int        i_alignment;          /**< video alignment in window */
    unsigned int        i_par_num;           /**< monitor pixel aspect-ratio */
    unsigned int        i_par_den;           /**< monitor pixel aspect-ratio */

    intf_thread_t       *p_parent_intf;   /**< parent interface for embedded
                                                               vout (if any) */
    /**@}*/

    /** \name Plugin used and shortcuts to access its capabilities */
    /**@{*/
    module_t *   p_module;
    int       ( *pf_init )       ( vout_thread_t * );
    void      ( *pf_end )        ( vout_thread_t * );
    int       ( *pf_manage )     ( vout_thread_t * );
    void      ( *pf_render )     ( vout_thread_t *, picture_t * );
    void      ( *pf_display )    ( vout_thread_t *, picture_t * );
    void      ( *pf_swap )       ( vout_thread_t * );         /* OpenGL only */
    int       ( *pf_lock )       ( vout_thread_t * );         /* OpenGL only */
    void      ( *pf_unlock )     ( vout_thread_t * );         /* OpenGL only */
    int       ( *pf_control )    ( vout_thread_t *, int, va_list );
    /**@}*/

    /** \name Statistics
     * These numbers are not supposed to be accurate, but are a
     * good indication of the thread status */
    /**@{*/
    count_t       c_fps_samples;                         /**< picture counts */
    mtime_t       p_fps_sample[VOUT_FPS_SAMPLES];     /**< FPS samples dates */
    /**@}*/

    /** \name Video heap and translation tables */
    /**@{*/
    int                 i_heap_size;                          /**< heap size */
    picture_heap_t      render;                       /**< rendered pictures */
    picture_heap_t      output;                          /**< direct buffers */
464
    bool          b_direct;            /**< rendered are like direct ? */
Clément Stenac's avatar
Clément Stenac committed
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
    vout_chroma_t       chroma;                      /**< translation tables */

    video_format_t      fmt_render;      /* render format (from the decoder) */
    video_format_t      fmt_in;            /* input (modified render) format */
    video_format_t      fmt_out;     /* output format (for the video output) */
    /**@}*/

    /* Picture heap */
    picture_t           p_picture[2*VOUT_MAX_PICTURES+1];      /**< pictures */

    /* Subpicture unit */
    spu_t            *p_spu;

    /* Statistics */
    count_t          c_loops;
    count_t          c_pictures, c_late_pictures;
    mtime_t          display_jitter;    /**< average deviation from the PTS */
    count_t          c_jitter_samples;  /**< number of samples used
                                           for the calculation of the
                                           jitter  */
    /** delay created by internal caching */
    int                 i_pts_delay;

    /* Filter chain */
    char *psz_filter_chain;
490
    bool b_filter_change;
Clément Stenac's avatar
Clément Stenac committed
491 492 493 494 495 496 497 498 499 500 501

    /* Video filter2 chain
     * these are handled like in transcode.c
     * XXX: we might need to merge the two chains (v1 and v2 filters) */
    char       *psz_vfilters[MAX_VFILTERS];
    config_chain_t *p_vfilters_cfg[MAX_VFILTERS];
    int         i_vfilters_cfg;

    filter_t   *pp_vfilters[MAX_VFILTERS];
    int         i_vfilters;

502
    bool b_vfilter_change;
Clément Stenac's avatar
Clément Stenac committed
503 504

    /* Misc */
505
    bool       b_snapshot;     /**< take one snapshot on the next loop */
506 507 508

    /* Video output configuration */
    config_chain_t *p_cfg;
509 510

    /* Show media title on videoutput */
511
    bool      b_title_show;
512 513
    mtime_t         i_title_timeout;
    int             i_title_position;
Clément Stenac's avatar
Clément Stenac committed
514 515 516 517 518 519 520 521 522 523 524
};

#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

/** \defgroup vout_changes Flags for changes
 * These flags are set in the vout_thread_t::i_changes field when another
 * thread changed a variable
 * @{
525
 */
Clément Stenac's avatar
Clément Stenac committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
/** b_info changed */
#define VOUT_INFO_CHANGE        0x0001
/** b_grayscale changed */
#define VOUT_GRAYSCALE_CHANGE   0x0002
/** b_interface changed */
#define VOUT_INTF_CHANGE        0x0004
/** b_scale changed */
#define VOUT_SCALE_CHANGE       0x0008
/** gamma changed */
#define VOUT_GAMMA_CHANGE       0x0010
/** b_cursor changed */
#define VOUT_CURSOR_CHANGE      0x0020
/** b_fullscreen changed */
#define VOUT_FULLSCREEN_CHANGE  0x0040
/** size changed */
#define VOUT_SIZE_CHANGE        0x0200
/** depth changed */
#define VOUT_DEPTH_CHANGE       0x0400
/** change chroma tables */
#define VOUT_CHROMA_CHANGE      0x0800
/** cropping parameters changed */
#define VOUT_CROP_CHANGE        0x1000
/** aspect ratio changed */
#define VOUT_ASPECT_CHANGE      0x2000
/** change/recreate picture buffers */
#define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
/**@}*/

/* Alignment flags */
#define VOUT_ALIGN_LEFT         0x0001
#define VOUT_ALIGN_RIGHT        0x0002
#define VOUT_ALIGN_HMASK        0x0003
#define VOUT_ALIGN_TOP          0x0004
#define VOUT_ALIGN_BOTTOM       0x0008
#define VOUT_ALIGN_VMASK        0x000C

#define MAX_JITTER_SAMPLES      20

/*****************************************************************************
 * Prototypes
 *****************************************************************************/
#define vout_Request(a,b,c) __vout_Request(VLC_OBJECT(a),b,c)
VLC_EXPORT( vout_thread_t *, __vout_Request,    ( vlc_object_t *, vout_thread_t *, video_format_t * ) );
#define vout_Create(a,b) __vout_Create(VLC_OBJECT(a),b)
VLC_EXPORT( vout_thread_t *, __vout_Create,       ( vlc_object_t *, video_format_t * ) );
VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );

VLC_EXPORT( int,             vout_ChromaCmp,      ( uint32_t, uint32_t ) );

575
VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, bool, bool, unsigned int ) );
Clément Stenac's avatar
Clément Stenac committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
VLC_EXPORT( void,            vout_InitFormat,     ( video_frame_format_t *, uint32_t, int, int, int ) );
VLC_EXPORT( void,            vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void,            vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void,            vout_DatePicture,    ( vout_thread_t *, picture_t *, mtime_t ) );
VLC_EXPORT( void,            vout_LinkPicture,    ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void,            vout_UnlinkPicture,  ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void,            vout_PlacePicture,   ( vout_thread_t *, unsigned int, unsigned int, unsigned int *, unsigned int *, unsigned int *, unsigned int * ) );
picture_t *     vout_RenderPicture  ( vout_thread_t *, picture_t *,
                                                       subpicture_t * );

VLC_EXPORT( int, vout_vaControlDefault, ( vout_thread_t *, int, va_list ) );
VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) );
VLC_EXPORT( void,   vout_ReleaseWindow, ( vout_thread_t *, void * ) );
VLC_EXPORT( int, vout_ControlWindow, ( vout_thread_t *, void *, int, va_list ) );
void vout_IntfInit( vout_thread_t * );
VLC_EXPORT( int, vout_Snapshot, ( vout_thread_t *p_vout, picture_t *p_pic ) );
592
VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, char *,bool , bool  ) );
Clément Stenac's avatar
Clément Stenac committed
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618


static inline int vout_vaControl( vout_thread_t *p_vout, int i_query,
                                  va_list args )
{
    if( p_vout->pf_control )
        return p_vout->pf_control( p_vout, i_query, args );
    else
        return VLC_EGENERIC;
}

static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... )
{
    va_list args;
    int i_result;

    va_start( args, i_query );
    i_result = vout_vaControl( p_vout, i_query, args );
    va_end( args );
    return i_result;
}

enum output_query_e
{
    VOUT_GET_SIZE,         /* arg1= unsigned int*, arg2= unsigned int*, res= */
    VOUT_SET_SIZE,         /* arg1= unsigned int, arg2= unsigned int, res= */
619
    VOUT_SET_STAY_ON_TOP,  /* arg1= bool       res=    */
Clément Stenac's avatar
Clément Stenac committed
620 621 622
    VOUT_REPARENT,
    VOUT_SNAPSHOT,
    VOUT_CLOSE,
623
    VOUT_SET_FOCUS,         /* arg1= bool       res=    */
624 625
    VOUT_SET_VIEWPORT,      /* arg1= view rect, arg2=clip rect, res= */
    VOUT_REDRAW_RECT,       /* arg1= area rect, res= */
Clément Stenac's avatar
Clément Stenac committed
626 627 628 629 630 631 632 633 634 635
};

typedef struct snapshot_t {
  char *p_data;  /* Data area */

  int i_width;       /* In pixels */
  int i_height;      /* In pixels */
  int i_datasize;    /* In bytes */
  mtime_t date;      /* Presentation time */
} snapshot_t;
636

637
/**@}*/
Gildas Bazin's avatar
 
Gildas Bazin committed
638 639

#endif /* _VLC_VIDEO_H */