Libav
pixdesc.h
Go to the documentation of this file.
1 /*
2  * pixel format descriptor
3  * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
30 typedef struct AVComponentDescriptor {
34  uint16_t plane : 2;
35 
40  uint16_t step_minus1 : 3;
41 
46  uint16_t offset_plus1 : 3;
47 
52  uint16_t shift : 3;
53 
57  uint16_t depth_minus1 : 4;
59 
69 typedef struct AVPixFmtDescriptor {
70  const char *name;
72 
81 
91 
98 
102  const char *alias;
104 
108 #define AV_PIX_FMT_FLAG_BE (1 << 0)
109 
112 #define AV_PIX_FMT_FLAG_PAL (1 << 1)
113 
116 #define AV_PIX_FMT_FLAG_BITSTREAM (1 << 2)
117 
120 #define AV_PIX_FMT_FLAG_HWACCEL (1 << 3)
121 
124 #define AV_PIX_FMT_FLAG_PLANAR (1 << 4)
125 
128 #define AV_PIX_FMT_FLAG_RGB (1 << 5)
129 
134 #define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6)
135 
138 #define AV_PIX_FMT_FLAG_ALPHA (1 << 7)
139 
140 #if FF_API_PIX_FMT
141 
144 #define PIX_FMT_BE AV_PIX_FMT_FLAG_BE
145 #define PIX_FMT_PAL AV_PIX_FMT_FLAG_PAL
146 #define PIX_FMT_BITSTREAM AV_PIX_FMT_FLAG_BITSTREAM
147 #define PIX_FMT_HWACCEL AV_PIX_FMT_FLAG_HWACCEL
148 #define PIX_FMT_PLANAR AV_PIX_FMT_FLAG_PLANAR
149 #define PIX_FMT_RGB AV_PIX_FMT_FLAG_RGB
150 #define PIX_FMT_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL
151 #define PIX_FMT_ALPHA AV_PIX_FMT_FLAG_ALPHA
152 #endif
153 
154 #if FF_API_PIX_FMT_DESC
155 
159 #endif
160 
177 void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
178  const int linesize[4], const AVPixFmtDescriptor *desc,
179  int x, int y, int c, int w, int read_pal_component);
180 
195 void av_write_image_line(const uint16_t *src, uint8_t *data[4],
196  const int linesize[4], const AVPixFmtDescriptor *desc,
197  int x, int y, int c, int w);
198 
210 enum AVPixelFormat av_get_pix_fmt(const char *name);
211 
218 const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
219 
230 char *av_get_pix_fmt_string(char *buf, int buf_size,
231  enum AVPixelFormat pix_fmt);
232 
242 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
243 
249 
258 
264 
276  int *h_shift, int *v_shift);
277 
283 
293 
294 #endif /* AVUTIL_PIXDESC_H */
const char * alias
Alternative comma-separated names.
Definition: pixdesc.h:102
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
Read a line from an image, and write the values of the pixel format component c to dst...
Definition: pixdesc.c:33
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
uint16_t shift
Number of least significant bits that must be shifted away to get the value.
Definition: pixdesc.h:52
Macro definitions for various function/variable attributes.
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
Definition: pixdesc.c:1653
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:1571
void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
Write the values from src to the pixel format component c of an image line.
Definition: pixdesc.c:81
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:97
uint8_t
const char * name
const char data[16]
Definition: mxf.c:70
const char * name
Definition: pixdesc.h:70
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
Definition: pixdesc.c:1625
uint16_t depth_minus1
Number of bits in the component minus 1.
Definition: pixdesc.h:57
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:1606
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1599
enum AVPixelFormat pix_fmt
Definition: movenc.c:843
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1637
char * av_get_pix_fmt_string(char *buf, int buf_size, enum AVPixelFormat pix_fmt)
Print in buf the string corresponding to the pixel format with number pix_fmt, or an header if pix_fm...
Definition: pixdesc.c:1584
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:1615
uint8_t flags
Definition: pixdesc.h:90
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1.
Definition: pixdesc.h:40
#define attribute_deprecated
Definition: attributes.h:80
uint16_t plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:34
attribute_deprecated const AVPixFmtDescriptor av_pix_fmt_descriptors[]
The array of all the pixel format descriptors.
Definition: pixdesc.c:132
pixel format definitions
uint16_t offset_plus1
Number of elements before the component of the first pixel plus 1.
Definition: pixdesc.h:46
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:1540
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:1552