FFmpeg
pixdesc.h
1 /*
2  * pixel format descriptor
3  * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVUTIL_PIXDESC_H
23 #define AVUTIL_PIXDESC_H
24 
25 #include <inttypes.h>
26 
27 #include "attributes.h"
28 #include "pixfmt.h"
29 #include "version.h"
30 
31 typedef struct AVComponentDescriptor {
35  int plane;
36 
41  int step;
42 
47  int offset;
48 
53  int shift;
54 
58  int depth;
59 
60 #if FF_API_PLUS1_MINUS1
61 
62  attribute_deprecated int step_minus1;
63 
65  attribute_deprecated int depth_minus1;
66 
68  attribute_deprecated int offset_plus1;
69 #endif
71 
81 typedef struct AVPixFmtDescriptor {
82  const char *name;
83  uint8_t nb_components;
84 
92  uint8_t log2_chroma_w;
93 
101  uint8_t log2_chroma_h;
102 
106  uint64_t flags;
107 
118 
122  const char *alias;
124 
128 #define AV_PIX_FMT_FLAG_BE (1 << 0)
129 
132 #define AV_PIX_FMT_FLAG_PAL (1 << 1)
133 
136 #define AV_PIX_FMT_FLAG_BITSTREAM (1 << 2)
137 
140 #define AV_PIX_FMT_FLAG_HWACCEL (1 << 3)
141 
144 #define AV_PIX_FMT_FLAG_PLANAR (1 << 4)
145 
148 #define AV_PIX_FMT_FLAG_RGB (1 << 5)
149 
166 #define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6)
167 
181 #define AV_PIX_FMT_FLAG_ALPHA (1 << 7)
182 
186 #define AV_PIX_FMT_FLAG_BAYER (1 << 8)
187 
192 #define AV_PIX_FMT_FLAG_FLOAT (1 << 9)
193 
203 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
204 
209 int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
210 
215 const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
216 
224 const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
225 
230 enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
231 
242 int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
243  int *h_shift, int *v_shift);
244 
249 int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
250 
254 const char *av_color_range_name(enum AVColorRange range);
255 
259 int av_color_range_from_name(const char *name);
260 
264 const char *av_color_primaries_name(enum AVColorPrimaries primaries);
265 
269 int av_color_primaries_from_name(const char *name);
270 
274 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
275 
279 int av_color_transfer_from_name(const char *name);
280 
284 const char *av_color_space_name(enum AVColorSpace space);
285 
289 int av_color_space_from_name(const char *name);
290 
294 const char *av_chroma_location_name(enum AVChromaLocation location);
295 
299 int av_chroma_location_from_name(const char *name);
300 
312 enum AVPixelFormat av_get_pix_fmt(const char *name);
313 
320 const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
321 
332 char *av_get_pix_fmt_string(char *buf, int buf_size,
333  enum AVPixelFormat pix_fmt);
334 
351 void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
352  const int linesize[4], const AVPixFmtDescriptor *desc,
353  int x, int y, int c, int w, int read_pal_component);
354 
369 void av_write_image_line(const uint16_t *src, uint8_t *data[4],
370  const int linesize[4], const AVPixFmtDescriptor *desc,
371  int x, int y, int c, int w);
372 
381 enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
382 
383 #define FF_LOSS_RESOLUTION 0x0001
384 #define FF_LOSS_DEPTH 0x0002
385 #define FF_LOSS_COLORSPACE 0x0004
386 #define FF_LOSS_ALPHA 0x0008
387 #define FF_LOSS_COLORQUANT 0x0010
388 #define FF_LOSS_CHROMA 0x0020
408 int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
409  enum AVPixelFormat src_pix_fmt,
410  int has_alpha);
411 
430 enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
431  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
432 
433 #endif /* AVUTIL_PIXDESC_H */
attribute_deprecated int offset_plus1
deprecated, use offset instead
Definition: pixdesc.h:68
int plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:35
const char * alias
Alternative comma-separated names.
Definition: pixdesc.h:122
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:444
Macro definitions for various function/variable attributes.
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:473
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:496
Definition: pixdesc.h:31
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:420
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
Libavutil version macros.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
attribute_deprecated int step_minus1
deprecated, use step instead
Definition: pixdesc.h:62
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int shift
Number of least significant bits that must be shifted away to get the value.
Definition: pixdesc.h:53
int offset
Number of elements before the component of the first pixel.
Definition: pixdesc.h:47
attribute_deprecated int depth_minus1
deprecated, use depth instead
Definition: pixdesc.h:65
pixel format definitions
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:518
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:41