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 #include "pixfmt.h"
27 
28 typedef struct AVComponentDescriptor{
29  uint16_t plane :2;
30 
35  uint16_t step_minus1 :3;
36 
41  uint16_t offset_plus1 :3;
42  uint16_t shift :3;
43  uint16_t depth_minus1 :4;
45 
55 typedef struct AVPixFmtDescriptor{
56  const char *name;
57  uint8_t nb_components;
58 
66  uint8_t log2_chroma_w;
67 
75  uint8_t log2_chroma_h;
76  uint8_t flags;
77 
85 
86 #define PIX_FMT_BE 1
87 #define PIX_FMT_PAL 2
88 #define PIX_FMT_BITSTREAM 4
89 #define PIX_FMT_HWACCEL 8
90 #define PIX_FMT_PLANAR 16
91 #define PIX_FMT_RGB 32
92 
93 
97 
114 void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
115  const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component);
116 
131 void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
132  const AVPixFmtDescriptor *desc, int x, int y, int c, int w);
133 
145 enum PixelFormat av_get_pix_fmt(const char *name);
146 
153 const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt);
154 
165 char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
166 
175 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
176 
177 #endif /* AVUTIL_PIXDESC_H */
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:29
enum PixelFormat pix_fmt
Definition: v4l.c:65
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:66
uint16_t shift
number of least significant bits that must be shifted away to get the value
Definition: pixdesc.h:42
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:1135
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:74
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:83
const char data[16]
Definition: mxf.c:60
char * av_get_pix_fmt_string(char *buf, int buf_size, enum PixelFormat 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:1148
const char * name
Definition: pixdesc.h:56
uint16_t depth_minus1
number of bits in the component minus 1
Definition: pixdesc.h:43
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:75
const char * av_get_pix_fmt_name(enum PixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:1104
struct AVComponentDescriptor AVComponentDescriptor
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:57
uint8_t flags
Definition: pixdesc.h:76
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:55
enum PixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:1116
struct AVPixFmtDescriptor AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const AVPixFmtDescriptor av_pix_fmt_descriptors[]
The array of all the pixel format descriptors.
Definition: pixdesc.c:119
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1.
Definition: pixdesc.h:35
const char * name
Definition: audioconvert.c:61
uint16_t plane
which of the 4 planes contains the component
Definition: pixdesc.h:29
PixelFormat
Pixel format.
Definition: pixfmt.h:62
pixel format definitions
uint16_t offset_plus1
Number of elements before the component of the first pixel plus 1.
Definition: pixdesc.h:41