OpenFFmpeg
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 
177 #define AV_PIX_FMT_FLAG_ALPHA (1 << 7)
178 
182 #define AV_PIX_FMT_FLAG_BAYER (1 << 8)
183 
188 #define AV_PIX_FMT_FLAG_FLOAT (1 << 9)
189 
199 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
200 
205 int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
206 
211 const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
212 
220 const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
221 
226 enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
227 
238 int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
239  int *h_shift, int *v_shift);
240 
245 int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
246 
250 const char *av_color_range_name(enum AVColorRange range);
251 
255 int av_color_range_from_name(const char *name);
256 
260 const char *av_color_primaries_name(enum AVColorPrimaries primaries);
261 
265 int av_color_primaries_from_name(const char *name);
266 
270 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
271 
275 int av_color_transfer_from_name(const char *name);
276 
280 const char *av_color_space_name(enum AVColorSpace space);
281 
285 int av_color_space_from_name(const char *name);
286 
290 const char *av_chroma_location_name(enum AVChromaLocation location);
291 
295 int av_chroma_location_from_name(const char *name);
296 
308 enum AVPixelFormat av_get_pix_fmt(const char *name);
309 
316 const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
317 
328 char *av_get_pix_fmt_string(char *buf, int buf_size,
329  enum AVPixelFormat pix_fmt);
330 
348 void av_read_image_line2(void *dst, const uint8_t *data[4],
349  const int linesize[4], const AVPixFmtDescriptor *desc,
350  int x, int y, int c, int w, int read_pal_component,
351  int dst_element_size);
352 
353 void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
354  const int linesize[4], const AVPixFmtDescriptor *desc,
355  int x, int y, int c, int w, int read_pal_component);
356 
372 void av_write_image_line2(const void *src, uint8_t *data[4],
373  const int linesize[4], const AVPixFmtDescriptor *desc,
374  int x, int y, int c, int w, int src_element_size);
375 
376 void av_write_image_line(const uint16_t *src, uint8_t *data[4],
377  const int linesize[4], const AVPixFmtDescriptor *desc,
378  int x, int y, int c, int w);
379 
388 enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
389 
390 #define FF_LOSS_RESOLUTION 0x0001
391 #define FF_LOSS_DEPTH 0x0002
392 #define FF_LOSS_COLORSPACE 0x0004
393 #define FF_LOSS_ALPHA 0x0008
394 #define FF_LOSS_COLORQUANT 0x0010
395 #define FF_LOSS_CHROMA 0x0020
415 int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
416  enum AVPixelFormat src_pix_fmt,
417  int has_alpha);
418 
437 enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
438  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
439 
440 #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:464
Macro definitions for various function/variable attributes.
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:493
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:516
Definition: pixdesc.h:31
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:440
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:538
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:41