annotate lib/libavutil/imgutils.h @ 2209:3664342f5d93

DrawCardsRectangles continue
author Ritor1
date Wed, 12 Feb 2014 17:32:47 +0600
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 #ifndef AVUTIL_IMGUTILS_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 #define AVUTIL_IMGUTILS_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23 * @file
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24 * misc image utilities
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26 * @addtogroup lavu_picture
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30 #include "avutil.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 #include "pixdesc.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 * Compute the max pixel step for each plane of an image with a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 * format described by pixdesc.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 * The pixel step is the distance in bytes between the first byte of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 * the group of bytes which describe a pixel component and the first
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 * byte of the successive group in the same plane for the same
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 * component.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 * @param max_pixsteps an array which is filled with the max pixel step
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * for each plane. Since a plane may contain different pixel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 * components, the computed max_pixsteps[plane] is relative to the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * component in the plane with the max pixel step.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 * @param max_pixstep_comps an array which is filled with the component
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 * for each plane which has the max pixel step. May be NULL.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 const AVPixFmtDescriptor *pixdesc);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * Compute the size of an image line with format pix_fmt and width
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 * width for the plane plane.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 * @return the computed size in bytes
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 * Fill plane linesizes for an image with pixel format pix_fmt and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 * width width.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 * @param linesizes array to be filled with the linesize for each plane
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 * @return >= 0 in case of success, a negative error code otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 * Fill plane data pointers for an image with pixel format pix_fmt and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 * height height.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 * @param data pointers array to be filled with the pointer for each image plane
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 * @param ptr the pointer to a buffer which will contain the image
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 * @param linesizes the array containing the linesize for each
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76 * plane, should be filled by av_image_fill_linesizes()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77 * @return the size in bytes required for the image buffer, a negative
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
78 * error code in case of failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
79 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
80 int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
81 uint8_t *ptr, const int linesizes[4]);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
82
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
83 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
84 * Allocate an image with size w and h and pixel format pix_fmt, and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
85 * fill pointers and linesizes accordingly.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
86 * The allocated image buffer has to be freed by using
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
87 * av_freep(&pointers[0]).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
88 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
89 * @param align the value to use for buffer size alignment
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
90 * @return the size in bytes required for the image buffer, a negative
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
91 * error code in case of failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
92 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
93 int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
94 int w, int h, enum AVPixelFormat pix_fmt, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
95
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
96 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
97 * Copy image plane from src to dst.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
98 * That is, copy "height" number of lines of "bytewidth" bytes each.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
99 * The first byte of each successive line is separated by *_linesize
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
100 * bytes.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
101 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
102 * bytewidth must be contained by both absolute values of dst_linesize
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
103 * and src_linesize, otherwise the function behavior is undefined.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
104 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
105 * @param dst_linesize linesize for the image plane in dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
106 * @param src_linesize linesize for the image plane in src
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
107 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
108 void av_image_copy_plane(uint8_t *dst, int dst_linesize,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
109 const uint8_t *src, int src_linesize,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
110 int bytewidth, int height);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
111
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
112 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
113 * Copy image in src_data to dst_data.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
114 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
115 * @param dst_linesizes linesizes for the image in dst_data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
116 * @param src_linesizes linesizes for the image in src_data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
117 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
118 void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
119 const uint8_t *src_data[4], const int src_linesizes[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
120 enum AVPixelFormat pix_fmt, int width, int height);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
121
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
122 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
123 * Setup the data pointers and linesizes based on the specified image
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
124 * parameters and the provided array.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
125 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
126 * The fields of the given image are filled in by using the src
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
127 * address which points to the image data buffer. Depending on the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
128 * specified pixel format, one or multiple image data pointers and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
129 * line sizes will be set. If a planar format is specified, several
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
130 * pointers will be set pointing to the different picture planes and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
131 * the line sizes of the different planes will be stored in the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
132 * lines_sizes array. Call with src == NULL to get the required
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
133 * size for the src buffer.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
134 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
135 * To allocate the buffer and fill in the dst_data and dst_linesize in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
136 * one call, use av_image_alloc().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
137 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
138 * @param dst_data data pointers to be filled in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
139 * @param dst_linesizes linesizes for the image in dst_data to be filled in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
140 * @param src buffer which will contain or contains the actual image data, can be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
141 * @param pix_fmt the pixel format of the image
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
142 * @param width the width of the image in pixels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
143 * @param height the height of the image in pixels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
144 * @param align the value used in src for linesize alignment
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
145 * @return the size in bytes required for src, a negative error code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
146 * in case of failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
147 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
148 int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
149 const uint8_t *src,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
150 enum AVPixelFormat pix_fmt, int width, int height, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
151
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
152 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
153 * Return the size in bytes of the amount of data required to store an
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
154 * image with the given parameters.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
155 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
156 * @param[in] align the assumed linesize alignment
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
157 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
158 int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
159
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
160 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
161 * Copy image data from an image into a buffer.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
162 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
163 * av_image_get_buffer_size() can be used to compute the required size
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
164 * for the buffer to fill.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
165 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
166 * @param dst a buffer into which picture data will be copied
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
167 * @param dst_size the size in bytes of dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
168 * @param src_data pointers containing the source image data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
169 * @param src_linesizes linesizes for the image in src_data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
170 * @param pix_fmt the pixel format of the source image
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
171 * @param width the width of the source image in pixels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
172 * @param height the height of the source image in pixels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
173 * @param align the assumed linesize alignment for dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
174 * @return the number of bytes written to dst, or a negative value
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
175 * (error code) on error
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
176 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
177 int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
178 const uint8_t * const src_data[4], const int src_linesize[4],
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
179 enum AVPixelFormat pix_fmt, int width, int height, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
180
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
181 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
182 * Check if the given dimension of an image is valid, meaning that all
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
183 * bytes of the image can be addressed with a signed int.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
184 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
185 * @param w the width of the picture
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
186 * @param h the height of the picture
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
187 * @param log_offset the offset to sum to the log level for logging with log_ctx
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
188 * @param log_ctx the parent logging context, it may be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
189 * @return >= 0 if valid, a negative error code otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
190 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
191 int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
192
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
193 int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
194
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
195 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
196 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
197 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
198
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
199
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
200 #endif /* AVUTIL_IMGUTILS_H */