Definitions for several variations of video data. More...
Data Structures | |
struct | gavl_video_format_s |
Video format. More... | |
Defines | |
#define | GAVL_PIXFMT_PLANAR (1<<8) |
#define | GAVL_PIXFMT_RGB (1<<9) |
#define | GAVL_PIXFMT_YUV (1<<10) |
#define | GAVL_PIXFMT_YUVJ (1<<11) |
#define | GAVL_PIXFMT_ALPHA (1<<12) |
#define | GAVL_PIXFMT_GRAY (1<<13) |
#define | GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8 |
Pixelformat for storing 1-dimensional integer data with 8 bits each. | |
#define | GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16 |
Pixelformat for storing 2-dimensional integer data with 8 bits each. | |
#define | GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24 |
Pixelformat for storing 3-dimensional integer data with 8 bits each. | |
#define | GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32 |
Pixelformat for storing 4-dimensional integer data with 8 bits each. | |
#define | GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16 |
Pixelformat for storing 1-dimensional integer data with 16 bits each. | |
#define | GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32 |
Pixelformat for storing 2-dimensional integer data with 16 bits each. | |
#define | GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48 |
Pixelformat for storing 3-dimensional integer data with 16 bits each. | |
#define | GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64 |
Pixelformat for storing 4-dimensional integer data with 16 bits each. | |
#define | GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT |
Pixelformat for storing 1-dimensional FLOAT data. | |
#define | GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT |
Pixelformat for storing 2-dimensional FLOAT data. | |
#define | GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT |
Pixelformat for storing 3-dimensional FLOAT data. | |
#define | GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT |
Pixelformat for storing 4-dimensional FLOAT data. | |
#define | gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY) |
Check if a pixelformat is grayscale. | |
#define | gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB) |
Check if a pixelformat is RGB based. | |
#define | gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV) |
Check if a pixelformat is YUV based. | |
#define | gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ) |
Check if a pixelformat is jpeg (full range) scaled. | |
#define | gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA) |
Check if a pixelformat has a transparency channel. | |
#define | gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR) |
Check if a pixelformat is planar. | |
Typedefs | |
typedef struct gavl_video_format_s | gavl_video_format_t |
Video format. | |
Enumerations | |
enum | gavl_pixelformat_t { GAVL_PIXELFORMAT_NONE = 0, GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY, GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY, GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY, GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA, GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB, GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB, GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB, GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB, GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB, GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB, GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB, GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB, GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB, GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB, GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA, GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV, GAVL_UYVY = 2 | GAVL_PIXFMT_YUV, GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV, GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA, GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ, GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV, GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV } |
Pixelformat definition. More... | |
enum | gavl_color_channel_t { GAVL_CCH_RED, GAVL_CCH_GREEN, GAVL_CCH_BLUE, GAVL_CCH_Y, GAVL_CCH_CB, GAVL_CCH_CR, GAVL_CCH_ALPHA } |
Color channel definitions. More... | |
enum | gavl_chroma_placement_t { GAVL_CHROMA_PLACEMENT_DEFAULT = 0, GAVL_CHROMA_PLACEMENT_MPEG2, GAVL_CHROMA_PLACEMENT_DVPAL } |
Chroma placement. More... | |
enum | gavl_framerate_mode_t { GAVL_FRAMERATE_UNKNOWN = -1, GAVL_FRAMERATE_CONSTANT = 0, GAVL_FRAMERATE_VARIABLE = 1, GAVL_FRAMERATE_STILL = 2 } |
Framerate mode. More... | |
enum | gavl_interlace_mode_t { GAVL_INTERLACE_UNKNOWN = -1, GAVL_INTERLACE_NONE = 0, GAVL_INTERLACE_TOP_FIRST = 1, GAVL_INTERLACE_BOTTOM_FIRST = 2, GAVL_INTERLACE_MIXED = 3, GAVL_INTERLACE_MIXED_TOP = 4, GAVL_INTERLACE_MIXED_BOTTOM = 5 } |
Interlace mode. More... | |
Functions | |
GAVL_PUBLIC int | gavl_pixelformat_num_planes (gavl_pixelformat_t pixelformat) |
Get the number of planes. | |
GAVL_PUBLIC void | gavl_pixelformat_chroma_sub (gavl_pixelformat_t pixelformat, int *sub_h, int *sub_v) |
Get the horizontal and vertical subsampling factors. | |
GAVL_PUBLIC int | gavl_pixelformat_bytes_per_component (gavl_pixelformat_t pixelformat) |
Get bytes per component for planar formats. | |
GAVL_PUBLIC int | gavl_pixelformat_bytes_per_pixel (gavl_pixelformat_t pixelformat) |
Get bytes per pixel for packed formats. | |
GAVL_PUBLIC int | gavl_pixelformat_bits_per_pixel (gavl_pixelformat_t pixelformat) |
Get the effective number of bits for one pixel. | |
GAVL_PUBLIC int | gavl_pixelformat_conversion_penalty (gavl_pixelformat_t src, gavl_pixelformat_t dst) |
Get the conversion penalty for pixelformat conversions. | |
GAVL_PUBLIC gavl_pixelformat_t | gavl_pixelformat_get_best (gavl_pixelformat_t src, const gavl_pixelformat_t *dst_supported, int *penalty) |
Get the best destination format for a given source format. | |
GAVL_PUBLIC const char * | gavl_pixelformat_to_string (gavl_pixelformat_t pixelformat) |
Translate a pixelformat into a human readable string. | |
GAVL_PUBLIC gavl_pixelformat_t | gavl_string_to_pixelformat (const char *name) |
Translate a pixelformat name into a pixelformat. | |
GAVL_PUBLIC int | gavl_num_pixelformats () |
Get total number of supported pixelformats. | |
GAVL_PUBLIC gavl_pixelformat_t | gavl_get_pixelformat (int index) |
Get the pixelformat from index. | |
GAVL_PUBLIC const char * | gavl_chroma_placement_to_string (gavl_chroma_placement_t mode) |
Translate a chroma placement into a human readable string. | |
GAVL_PUBLIC const char * | gavl_framerate_mode_to_string (gavl_framerate_mode_t mode) |
Translate a framerate mode into a human readable string. | |
GAVL_PUBLIC const char * | gavl_interlace_mode_to_string (gavl_interlace_mode_t mode) |
Translate an interlace mode into a human readable string. | |
GAVL_PUBLIC void | gavl_video_format_copy (gavl_video_format_t *dst, const gavl_video_format_t *src) |
Copy one video format to another. | |
GAVL_PUBLIC int | gavl_video_formats_equal (const gavl_video_format_t *format_1, const gavl_video_format_t *format_2) |
Compare 2 video formats. | |
GAVL_PUBLIC void | gavl_video_format_get_chroma_offset (const gavl_video_format_t *format, int field, int plane, float *off_x, float *off_y) |
Get the chroma offsets relative to the luma samples. | |
GAVL_PUBLIC void | gavl_video_format_fit_to_source (gavl_video_format_t *dst, const gavl_video_format_t *src) |
Set the image size of a destination format from a source format. | |
GAVL_PUBLIC int | gavl_video_format_get_image_size (const gavl_video_format_t *format) |
Get the unpadded image size. | |
GAVL_PUBLIC int | gavl_get_color_channel_format (const gavl_video_format_t *frame_format, gavl_video_format_t *channel_format, gavl_color_channel_t ch) |
Get the video format for extracting/merging one channel. | |
GAVL_PUBLIC void | gavl_get_field_format (const gavl_video_format_t *frame_format, gavl_video_format_t *field_format, int field) |
Get the video format of one field. | |
GAVL_PUBLIC void | gavl_video_format_dump (const gavl_video_format_t *format) |
Dump a video format to stderr. |
Definitions for several variations of video data.
#define GAVL_PIXFMT_PLANAR (1<<8) |
Flag for planar pixelformats
#define GAVL_PIXFMT_RGB (1<<9) |
Flag for rgb pixelformats
#define GAVL_PIXFMT_YUV (1<<10) |
Flag for yuv pixelformats
#define GAVL_PIXFMT_YUVJ (1<<11) |
Flag for yuvj pixelformats
#define GAVL_PIXFMT_ALPHA (1<<12) |
Alpha flag
#define GAVL_PIXFMT_GRAY (1<<13) |
Flag for grayscale pixelformats
#define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8 |
Pixelformat for storing 1-dimensional integer data with 8 bits each.
#define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16 |
Pixelformat for storing 2-dimensional integer data with 8 bits each.
#define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24 |
Pixelformat for storing 3-dimensional integer data with 8 bits each.
#define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32 |
Pixelformat for storing 4-dimensional integer data with 8 bits each.
#define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16 |
Pixelformat for storing 1-dimensional integer data with 16 bits each.
#define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32 |
Pixelformat for storing 2-dimensional integer data with 16 bits each.
#define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48 |
Pixelformat for storing 3-dimensional integer data with 16 bits each.
#define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64 |
Pixelformat for storing 4-dimensional integer data with 16 bits each.
#define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT |
Pixelformat for storing 1-dimensional FLOAT data.
#define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT |
Pixelformat for storing 2-dimensional FLOAT data.
#define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT |
Pixelformat for storing 3-dimensional FLOAT data.
#define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT |
Pixelformat for storing 4-dimensional FLOAT data.
#define gavl_pixelformat_is_gray | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_GRAY) |
Check if a pixelformat is grayscale.
fmt | A pixelformat |
#define gavl_pixelformat_is_rgb | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_RGB) |
Check if a pixelformat is RGB based.
fmt | A pixelformat |
#define gavl_pixelformat_is_yuv | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_YUV) |
Check if a pixelformat is YUV based.
fmt | A pixelformat |
#define gavl_pixelformat_is_jpeg_scaled | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_YUVJ) |
Check if a pixelformat is jpeg (full range) scaled.
fmt | A pixelformat |
#define gavl_pixelformat_has_alpha | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_ALPHA) |
Check if a pixelformat has a transparency channel.
fmt | A pixelformat |
#define gavl_pixelformat_is_planar | ( | fmt | ) | ((fmt) & GAVL_PIXFMT_PLANAR) |
Check if a pixelformat is planar.
fmt | A pixelformat |
typedef struct gavl_video_format_s gavl_video_format_t |
Video format.
enum gavl_pixelformat_t |
Pixelformat definition.
enum gavl_color_channel_t |
Color channel definitions.
Enum definitions for color channels
Chroma placement.
Specification of the 3 variants of 4:2:0 YCbCr as described at http://www.mir.com/DMG/chroma.html . For other pixelformats, it's meaningless and should be set to GAVL_CHROMA_PLACEMENT_DEFAULT.
Interlace mode.
GAVL_PUBLIC int gavl_pixelformat_num_planes | ( | gavl_pixelformat_t | pixelformat | ) |
Get the number of planes.
pixelformat | A pixelformat |
GAVL_PUBLIC void gavl_pixelformat_chroma_sub | ( | gavl_pixelformat_t | pixelformat, | |
int * | sub_h, | |||
int * | sub_v | |||
) |
Get the horizontal and vertical subsampling factors.
pixelformat | A pixelformat | |
sub_h | returns the horizontal subsampling factor | |
sub_v | returns the vertical subsampling factor |
E.g. for 4:2:0 subsampling: sub_h = 2, sub_v = 2
GAVL_PUBLIC int gavl_pixelformat_bytes_per_component | ( | gavl_pixelformat_t | pixelformat | ) |
Get bytes per component for planar formats.
pixelformat | A pixelformat |
GAVL_PUBLIC int gavl_pixelformat_bytes_per_pixel | ( | gavl_pixelformat_t | pixelformat | ) |
Get bytes per pixel for packed formats.
pixelformat | A pixelformat |
GAVL_PUBLIC int gavl_pixelformat_bits_per_pixel | ( | gavl_pixelformat_t | pixelformat | ) |
Get the effective number of bits for one pixel.
pixelformat | A pixelformat |
GAVL_PUBLIC int gavl_pixelformat_conversion_penalty | ( | gavl_pixelformat_t | src, | |
gavl_pixelformat_t | dst | |||
) |
Get the conversion penalty for pixelformat conversions.
src | Source pixelformat | |
dst | Destination pixelformat |
The number (the larger the worse) is calculated from several criteria and considers both speed and quality issues. Don't ever rely on specific absolute values, since they can change from version to version (except 0, which is returned when and only when src and dst are equal). Instead, only compare values returned for different combinations among each other.
GAVL_PUBLIC gavl_pixelformat_t gavl_pixelformat_get_best | ( | gavl_pixelformat_t | src, | |
const gavl_pixelformat_t * | dst_supported, | |||
int * | penalty | |||
) |
Get the best destination format for a given source format.
src | Source pixelformat | |
dst_supported | List of supported destination format | |
penalty | If non-null, returns the conversion penalty |
This function takes a source format and a list of supported destination formats (terminated with GAVL_PIXELFORMAT_NONE) and returns the format, which will result in the cheapest conversion (see gavl_pixelformat_conversion_penalty).
GAVL_PUBLIC const char* gavl_pixelformat_to_string | ( | gavl_pixelformat_t | pixelformat | ) |
Translate a pixelformat into a human readable string.
pixelformat | A pixelformat |
GAVL_PUBLIC gavl_pixelformat_t gavl_string_to_pixelformat | ( | const char * | name | ) |
Translate a pixelformat name into a pixelformat.
name | A string describing the pixelformat (returnd by gavl_pixelformat_to_string) |
GAVL_PUBLIC int gavl_num_pixelformats | ( | ) |
Get total number of supported pixelformats.
GAVL_PUBLIC gavl_pixelformat_t gavl_get_pixelformat | ( | int | index | ) |
Get the pixelformat from index.
index | index (must be between 0 and the result of gavl_num_pixelformats) |
GAVL_PUBLIC const char* gavl_chroma_placement_to_string | ( | gavl_chroma_placement_t | mode | ) |
Translate a chroma placement into a human readable string.
mode | A chroma placement |
GAVL_PUBLIC const char* gavl_framerate_mode_to_string | ( | gavl_framerate_mode_t | mode | ) |
Translate a framerate mode into a human readable string.
mode | A framerate mode |
GAVL_PUBLIC const char* gavl_interlace_mode_to_string | ( | gavl_interlace_mode_t | mode | ) |
Translate an interlace mode into a human readable string.
mode | An interlace mode |
GAVL_PUBLIC void gavl_video_format_copy | ( | gavl_video_format_t * | dst, | |
const gavl_video_format_t * | src | |||
) |
Copy one video format to another.
dst | Destination format | |
src | Source format |
GAVL_PUBLIC int gavl_video_formats_equal | ( | const gavl_video_format_t * | format_1, | |
const gavl_video_format_t * | format_2 | |||
) |
Compare 2 video formats.
format_1 | First format | |
format_2 | Second format |
GAVL_PUBLIC void gavl_video_format_get_chroma_offset | ( | const gavl_video_format_t * | format, | |
int | field, | |||
int | plane, | |||
float * | off_x, | |||
float * | off_y | |||
) |
Get the chroma offsets relative to the luma samples.
format | A video format | |
field | Index of the field (0 = top, 1 = bottom). For progressive format, this is unused | |
plane | Index of the plane (1 = Cb, 2 = Cr) | |
off_x | Returns the offset in x-direction | |
off_y | Returns the offset in y-direction |
GAVL_PUBLIC void gavl_video_format_fit_to_source | ( | gavl_video_format_t * | dst, | |
const gavl_video_format_t * | src | |||
) |
Set the image size of a destination format from a source format.
dst | Destination format | |
src | Source format |
Sets the image size of dst according src. Before you call this function, you must set the pixel_width and pixel_height of dst. This function will preserve the display aspect ratio, i.e. when the pixel aspect ratios are different in source and destination, the images will be scaled.
GAVL_PUBLIC int gavl_video_format_get_image_size | ( | const gavl_video_format_t * | format | ) |
Get the unpadded image size.
format | A video format |
GAVL_PUBLIC int gavl_get_color_channel_format | ( | const gavl_video_format_t * | frame_format, | |
gavl_video_format_t * | channel_format, | |||
gavl_color_channel_t | ch | |||
) |
Get the video format for extracting/merging one channel.
frame_format | The video format of the full frame | |
channel_format | Format of the extracted channel (grayscale) | |
ch | Channel |
Use this function in conjunction with gavl_video_frame_extract_channel and gavl_video_frame_insert_channel
Since 1.1.2
GAVL_PUBLIC void gavl_get_field_format | ( | const gavl_video_format_t * | frame_format, | |
gavl_video_format_t * | field_format, | |||
int | field | |||
) |
Get the video format of one field.
frame_format | The video format of the full frame | |
field_format | Format of the field | |
field | Field (0 or 1) |
Use this function if you need to split a frame into fields. It handles odd heights correctly
Since 1.2.1
GAVL_PUBLIC void gavl_video_format_dump | ( | const gavl_video_format_t * | format | ) |
Dump a video format to stderr.
format | A video format |