FFmpeg
imgutils.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_IMGUTILS_H
20 #define AVUTIL_IMGUTILS_H
21 
30 #include "avutil.h"
31 #include "pixdesc.h"
32 #include "rational.h"
33 
50 void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
51  const AVPixFmtDescriptor *pixdesc);
52 
59 int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
60 
68 int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
69 
81 int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
82  uint8_t *ptr, const int linesizes[4]);
83 
94 int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
95  int w, int h, enum AVPixelFormat pix_fmt, int align);
96 
109 void av_image_copy_plane(uint8_t *dst, int dst_linesize,
110  const uint8_t *src, int src_linesize,
111  int bytewidth, int height);
112 
119 void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
120  const uint8_t *src_data[4], const int src_linesizes[4],
121  enum AVPixelFormat pix_fmt, int width, int height);
122 
137 void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
138  const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
139  enum AVPixelFormat pix_fmt, int width, int height);
140 
167 int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
168  const uint8_t *src,
169  enum AVPixelFormat pix_fmt, int width, int height, int align);
170 
181 int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
182 
200 int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
201  const uint8_t * const src_data[4], const int src_linesize[4],
202  enum AVPixelFormat pix_fmt, int width, int height, int align);
203 
214 int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
215 
229 int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx);
230 
243 int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar);
244 
268 int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
269  enum AVPixelFormat pix_fmt, enum AVColorRange range,
270  int width, int height);
271 
277 #endif /* AVUTIL_IMGUTILS_H */
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
Definition: imgutils.c:76
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, const uint8_t *const src_data[4], const int src_linesize[4], enum AVPixelFormat pix_fmt, int width, int height, int align)
Copy image data from an image into a buffer.
Definition: imgutils.c:453
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
Definition: imgutils.c:192
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array...
Definition: imgutils.c:411
Convenience header that includes libavutil's core.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition: imgutils.c:35
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition: imgutils.c:287
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:496
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
Definition: imgutils.c:431
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
Definition: imgutils.c:387
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:282
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
Definition: imgutils.c:111
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Utilties for rational number calculation.
void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image data located in uncacheable (e.g.
Definition: imgutils.c:403
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:253
int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4], enum AVPixelFormat pix_fmt, enum AVColorRange range, int width, int height)
Overwrite the image data with black.
Definition: imgutils.c:552
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:338
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60