configure.ac: replace == with =
[vlc.git] / include / vlc_picture.h
blobc99f54d7212b39689a8027c64cc92b40442cf080
1 /*****************************************************************************
2 * vlc_picture.h: picture definitions
3 *****************************************************************************
4 * Copyright (C) 1999 - 2009 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Vincent Seguin <seguin@via.ecp.fr>
8 * Samuel Hocevar <sam@via.ecp.fr>
9 * Olivier Aubert <oaubert 47 videolan d07 org>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifndef VLC_PICTURE_H
27 #define VLC_PICTURE_H 1
29 /**
30 * \file
31 * This file defines picture structures and functions in vlc
34 #include <vlc_es.h>
35 #include <vlc_atomic.h>
37 /** Description of a planar graphic field */
38 typedef struct plane_t
40 uint8_t *p_pixels; /**< Start of the plane's data */
42 /* Variables used for fast memcpy operations */
43 int i_lines; /**< Number of lines, including margins */
44 int i_pitch; /**< Number of bytes in a line, including margins */
46 /** Size of a macropixel, defaults to 1 */
47 int i_pixel_pitch;
49 /* Variables used for pictures with margins */
50 int i_visible_lines; /**< How many visible lines are there ? */
51 int i_visible_pitch; /**< How many visible pixels are there ? */
53 } plane_t;
55 /**
56 * Maximum number of plane for a picture
58 #define PICTURE_PLANE_MAX (VOUT_MAX_PLANES)
61 /**
62 * A private definition to help overloading picture release
64 typedef struct picture_gc_sys_t picture_gc_sys_t;
66 /**
67 * Video picture
69 struct picture_t
71 /**
72 * The properties of the picture
74 video_frame_format_t format;
76 plane_t p[PICTURE_PLANE_MAX]; /**< description of the planes */
77 int i_planes; /**< number of allocated planes */
79 /** \name Picture management properties
80 * These properties can be modified using the video output thread API,
81 * but should never be written directly */
82 /**@{*/
83 mtime_t date; /**< display date */
84 bool b_force;
85 /**@}*/
87 /** \name Picture dynamic properties
88 * Those properties can be changed by the decoder
89 * @{
91 bool b_progressive; /**< is it a progressive frame ? */
92 bool b_top_field_first; /**< which field is first */
93 unsigned int i_nb_fields; /**< # of displayed fields */
94 /**@}*/
96 /** Private data - the video output plugin might want to put stuff here to
97 * keep track of the picture */
98 picture_sys_t * p_sys;
100 /** This way the picture_Release can be overloaded */
101 struct
103 vlc_atomic_t refcount;
104 void (*pf_destroy)( picture_t * );
105 picture_gc_sys_t *p_sys;
106 } gc;
108 /** Next picture in a FIFO a pictures */
109 struct picture_t *p_next;
113 * This function will create a new picture.
114 * The picture created will implement a default release management compatible
115 * with picture_Hold and picture_Release. This default management will release
116 * p_sys, gc.p_sys fields if non NULL.
118 VLC_API picture_t * picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) VLC_USED;
121 * This function will create a new picture using the given format.
123 * When possible, it is preferred to use this function over picture_New
124 * as more information about the format is kept.
126 VLC_API picture_t * picture_NewFromFormat( const video_format_t *p_fmt ) VLC_USED;
129 * Resource for a picture.
131 typedef struct
133 picture_sys_t *p_sys;
135 /* Plane resources
136 * XXX all fields MUST be set to the right value.
138 struct
140 uint8_t *p_pixels; /**< Start of the plane's data */
141 int i_lines; /**< Number of lines, including margins */
142 int i_pitch; /**< Number of bytes in a line, including margins */
143 } p[PICTURE_PLANE_MAX];
145 } picture_resource_t;
148 * This function will create a new picture using the provided resource.
150 * If the resource is NULL then a plain picture_NewFromFormat is returned.
152 VLC_API picture_t * picture_NewFromResource( const video_format_t *, const picture_resource_t * ) VLC_USED;
155 * This function will increase the picture reference count.
156 * It will not have any effect on picture obtained from vout
158 * It returns the given picture for convenience.
160 VLC_API picture_t *picture_Hold( picture_t *p_picture );
163 * This function will release a picture.
164 * It will not have any effect on picture obtained from vout
166 VLC_API void picture_Release( picture_t *p_picture );
169 * This function will return true if you are not the only owner of the
170 * picture.
172 * It is only valid if it is created using picture_New.
174 VLC_API bool picture_IsReferenced( picture_t *p_picture );
177 * This function will copy all picture dynamic properties.
179 VLC_API void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src );
182 * This function will reset a picture information (properties and quantizers).
183 * It is sometimes useful for reusing pictures (like from a pool).
185 VLC_API void picture_Reset( picture_t * );
188 * This function will copy the picture pixels.
189 * You can safely copy between pictures that do not have the same size,
190 * only the compatible(smaller) part will be copied.
192 VLC_API void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src );
193 VLC_API void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src );
196 * This function will copy both picture dynamic properties and pixels.
197 * You have to notice that sometime a simple picture_Hold may do what
198 * you want without the copy overhead.
199 * Provided for convenience.
201 * \param p_dst pointer to the destination picture.
202 * \param p_src pointer to the source picture.
204 VLC_API void picture_Copy( picture_t *p_dst, const picture_t *p_src );
207 * This function will export a picture to an encoded bitstream.
209 * pp_image will contain the encoded bitstream in psz_format format.
211 * p_fmt can be NULL otherwise it will be set with the format used for the
212 * picture before encoding.
214 * i_override_width/height allow to override the width and/or the height of the
215 * picture to be encoded:
216 * - if strictly lower than 0, the original dimension will be used.
217 * - if equal to 0, it will be deduced from the other dimension which must be
218 * different to 0.
219 * - if strictly higher than 0, it will override the dimension.
220 * If at most one of them is > 0 then the picture aspect ratio will be kept.
222 VLC_API int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_format_t *p_fmt, picture_t *p_picture, vlc_fourcc_t i_format, int i_override_width, int i_override_height );
225 * This function will setup all fields of a picture_t without allocating any
226 * memory.
227 * XXX The memory must already be initialized.
228 * It does not need to be released.
230 * It will return VLC_EGENERIC if the core does not understand the requested
231 * format.
233 * It can be useful to get the properties of planes.
235 VLC_API int picture_Setup( picture_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den );
239 * This function will blend a given subpicture onto a picture.
241 * The subpicture and all its region must:
242 * - be absolute.
243 * - not be ephemere.
244 * - not have the fade flag.
245 * - contains only picture (no text rendering).
247 VLC_API void picture_BlendSubpicture( picture_t *, filter_t *p_blend, subpicture_t * );
250 /*****************************************************************************
251 * Shortcuts to access image components
252 *****************************************************************************/
254 /* Plane indices */
255 enum
257 Y_PLANE = 0,
258 U_PLANE = 1,
259 V_PLANE = 2,
260 A_PLANE = 3,
263 /* Shortcuts */
264 #define Y_PIXELS p[Y_PLANE].p_pixels
265 #define Y_PITCH p[Y_PLANE].i_pitch
266 #define U_PIXELS p[U_PLANE].p_pixels
267 #define U_PITCH p[U_PLANE].i_pitch
268 #define V_PIXELS p[V_PLANE].p_pixels
269 #define V_PITCH p[V_PLANE].i_pitch
270 #define A_PIXELS p[A_PLANE].p_pixels
271 #define A_PITCH p[A_PLANE].i_pitch
273 /**@}*/
275 #endif /* VLC_PICTURE_H */