gavl
Data Structures | Macros | Typedefs | Enumerations | Functions
Video format definitions

Definitions for several variations of video data. More...

Data Structures

struct  gavl_video_format_s
 Video format. More...
 

Macros

#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. More...
 
#define GAVL_PIXELFORMAT_2D_8   GAVL_GRAYA_16
 Pixelformat for storing 2-dimensional integer data with 8 bits each. More...
 
#define GAVL_PIXELFORMAT_3D_8   GAVL_RGB_24
 Pixelformat for storing 3-dimensional integer data with 8 bits each. More...
 
#define GAVL_PIXELFORMAT_4D_8   GAVL_RGBA_32
 Pixelformat for storing 4-dimensional integer data with 8 bits each. More...
 
#define GAVL_PIXELFORMAT_1D_16   GAVL_GRAY_16
 Pixelformat for storing 1-dimensional integer data with 16 bits each. More...
 
#define GAVL_PIXELFORMAT_2D_16   GAVL_GRAYA_32
 Pixelformat for storing 2-dimensional integer data with 16 bits each. More...
 
#define GAVL_PIXELFORMAT_3D_16   GAVL_RGB_48
 Pixelformat for storing 3-dimensional integer data with 16 bits each. More...
 
#define GAVL_PIXELFORMAT_4D_16   GAVL_RGBA_64
 Pixelformat for storing 4-dimensional integer data with 16 bits each. More...
 
#define GAVL_PIXELFORMAT_1D_FLOAT   GAVL_GRAY_FLOAT
 Pixelformat for storing 1-dimensional FLOAT data. More...
 
#define GAVL_PIXELFORMAT_2D_FLOAT   GAVL_GRAYA_FLOAT
 Pixelformat for storing 2-dimensional FLOAT data. More...
 
#define GAVL_PIXELFORMAT_3D_FLOAT   GAVL_RGB_FLOAT
 Pixelformat for storing 3-dimensional FLOAT data. More...
 
#define GAVL_PIXELFORMAT_4D_FLOAT   GAVL_RGBA_FLOAT
 Pixelformat for storing 4-dimensional FLOAT data. More...
 
#define gavl_pixelformat_is_gray(fmt)   ((fmt) & GAVL_PIXFMT_GRAY)
 Check if a pixelformat is grayscale. More...
 
#define gavl_pixelformat_is_rgb(fmt)   ((fmt) & GAVL_PIXFMT_RGB)
 Check if a pixelformat is RGB based. More...
 
#define gavl_pixelformat_is_yuv(fmt)   ((fmt) & GAVL_PIXFMT_YUV)
 Check if a pixelformat is YUV based. More...
 
#define gavl_pixelformat_is_jpeg_scaled(fmt)   ((fmt) & GAVL_PIXFMT_YUVJ)
 Check if a pixelformat is jpeg (full range) scaled. More...
 
#define gavl_pixelformat_has_alpha(fmt)   ((fmt) & GAVL_PIXFMT_ALPHA)
 Check if a pixelformat has a transparency channel. More...
 
#define gavl_pixelformat_is_planar(fmt)   ((fmt) & GAVL_PIXFMT_PLANAR)
 Check if a pixelformat is planar. More...
 

Typedefs

typedef struct gavl_video_format_s gavl_video_format_t
 Video format. More...
 

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. More...
 
GAVL_PUBLIC void gavl_pixelformat_chroma_sub (gavl_pixelformat_t pixelformat, int *sub_h, int *sub_v)
 Get the horizontal and vertical subsampling factors. More...
 
GAVL_PUBLIC int gavl_pixelformat_bytes_per_component (gavl_pixelformat_t pixelformat)
 Get bytes per component for planar formats. More...
 
GAVL_PUBLIC int gavl_pixelformat_bytes_per_pixel (gavl_pixelformat_t pixelformat)
 Get bytes per pixel for packed formats. More...
 
GAVL_PUBLIC int gavl_pixelformat_bits_per_pixel (gavl_pixelformat_t pixelformat)
 Get the effective number of bits for one pixel. More...
 
GAVL_PUBLIC int gavl_pixelformat_conversion_penalty (gavl_pixelformat_t src, gavl_pixelformat_t dst)
 Get the conversion penalty for pixelformat conversions. More...
 
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. More...
 
GAVL_PUBLIC const char * gavl_pixelformat_to_string (gavl_pixelformat_t pixelformat)
 Translate a pixelformat into a human readable string. More...
 
GAVL_PUBLIC gavl_pixelformat_t gavl_string_to_pixelformat (const char *name)
 Translate a pixelformat name into a pixelformat. More...
 
GAVL_PUBLIC int gavl_num_pixelformats ()
 Get total number of supported pixelformats. More...
 
GAVL_PUBLIC gavl_pixelformat_t gavl_get_pixelformat (int index)
 Get the pixelformat from index. More...
 
GAVL_PUBLIC const char * gavl_chroma_placement_to_string (gavl_chroma_placement_t mode)
 Translate a chroma placement into a human readable string. More...
 
GAVL_PUBLIC const char * gavl_framerate_mode_to_string (gavl_framerate_mode_t mode)
 Translate a framerate mode into a human readable string. More...
 
GAVL_PUBLIC const char * gavl_interlace_mode_to_string (gavl_interlace_mode_t mode)
 Translate an interlace mode into a human readable string. More...
 
GAVL_PUBLIC void gavl_video_format_copy (gavl_video_format_t *dst, const gavl_video_format_t *src)
 Copy one video format to another. More...
 
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. More...
 
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. More...
 
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. More...
 
GAVL_PUBLIC int gavl_video_format_get_image_size (const gavl_video_format_t *format)
 Get the unpadded image size. More...
 
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. More...
 
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. More...
 
GAVL_PUBLIC void gavl_video_format_dump (const gavl_video_format_t *format)
 Dump a video format to stderr. More...
 

Detailed Description

Definitions for several variations of video data.

Macro Definition Documentation

◆ GAVL_PIXFMT_PLANAR

#define GAVL_PIXFMT_PLANAR   (1<<8)

Flag for planar pixelformats

◆ GAVL_PIXFMT_RGB

#define GAVL_PIXFMT_RGB   (1<<9)

Flag for rgb pixelformats

◆ GAVL_PIXFMT_YUV

#define GAVL_PIXFMT_YUV   (1<<10)

Flag for yuv pixelformats

◆ GAVL_PIXFMT_YUVJ

#define GAVL_PIXFMT_YUVJ   (1<<11)

Flag for yuvj pixelformats

◆ GAVL_PIXFMT_ALPHA

#define GAVL_PIXFMT_ALPHA   (1<<12)

Alpha flag

◆ GAVL_PIXFMT_GRAY

#define GAVL_PIXFMT_GRAY   (1<<13)

Flag for grayscale pixelformats

◆ GAVL_PIXELFORMAT_1D_8

#define GAVL_PIXELFORMAT_1D_8   GAVL_GRAY_8

Pixelformat for storing 1-dimensional integer data with 8 bits each.

◆ GAVL_PIXELFORMAT_2D_8

#define GAVL_PIXELFORMAT_2D_8   GAVL_GRAYA_16

Pixelformat for storing 2-dimensional integer data with 8 bits each.

◆ GAVL_PIXELFORMAT_3D_8

#define GAVL_PIXELFORMAT_3D_8   GAVL_RGB_24

Pixelformat for storing 3-dimensional integer data with 8 bits each.

◆ GAVL_PIXELFORMAT_4D_8

#define GAVL_PIXELFORMAT_4D_8   GAVL_RGBA_32

Pixelformat for storing 4-dimensional integer data with 8 bits each.

◆ GAVL_PIXELFORMAT_1D_16

#define GAVL_PIXELFORMAT_1D_16   GAVL_GRAY_16

Pixelformat for storing 1-dimensional integer data with 16 bits each.

◆ GAVL_PIXELFORMAT_2D_16

#define GAVL_PIXELFORMAT_2D_16   GAVL_GRAYA_32

Pixelformat for storing 2-dimensional integer data with 16 bits each.

◆ GAVL_PIXELFORMAT_3D_16

#define GAVL_PIXELFORMAT_3D_16   GAVL_RGB_48

Pixelformat for storing 3-dimensional integer data with 16 bits each.

◆ GAVL_PIXELFORMAT_4D_16

#define GAVL_PIXELFORMAT_4D_16   GAVL_RGBA_64

Pixelformat for storing 4-dimensional integer data with 16 bits each.

◆ GAVL_PIXELFORMAT_1D_FLOAT

#define GAVL_PIXELFORMAT_1D_FLOAT   GAVL_GRAY_FLOAT

Pixelformat for storing 1-dimensional FLOAT data.

◆ GAVL_PIXELFORMAT_2D_FLOAT

#define GAVL_PIXELFORMAT_2D_FLOAT   GAVL_GRAYA_FLOAT

Pixelformat for storing 2-dimensional FLOAT data.

◆ GAVL_PIXELFORMAT_3D_FLOAT

#define GAVL_PIXELFORMAT_3D_FLOAT   GAVL_RGB_FLOAT

Pixelformat for storing 3-dimensional FLOAT data.

◆ GAVL_PIXELFORMAT_4D_FLOAT

#define GAVL_PIXELFORMAT_4D_FLOAT   GAVL_RGBA_FLOAT

Pixelformat for storing 4-dimensional FLOAT data.

◆ gavl_pixelformat_is_gray

#define gavl_pixelformat_is_gray (   fmt)    ((fmt) & GAVL_PIXFMT_GRAY)

Check if a pixelformat is grayscale.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat is grayscale, 0 else

◆ gavl_pixelformat_is_rgb

#define gavl_pixelformat_is_rgb (   fmt)    ((fmt) & GAVL_PIXFMT_RGB)

Check if a pixelformat is RGB based.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat is RGB based, 0 else

◆ gavl_pixelformat_is_yuv

#define gavl_pixelformat_is_yuv (   fmt)    ((fmt) & GAVL_PIXFMT_YUV)

Check if a pixelformat is YUV based.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat is YUV based, 0 else

◆ gavl_pixelformat_is_jpeg_scaled

#define gavl_pixelformat_is_jpeg_scaled (   fmt)    ((fmt) & GAVL_PIXFMT_YUVJ)

Check if a pixelformat is jpeg (full range) scaled.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat is jpeg scaled, 0 else

◆ gavl_pixelformat_has_alpha

#define gavl_pixelformat_has_alpha (   fmt)    ((fmt) & GAVL_PIXFMT_ALPHA)

Check if a pixelformat has a transparency channel.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat has a transparency channel, 0 else

◆ gavl_pixelformat_is_planar

#define gavl_pixelformat_is_planar (   fmt)    ((fmt) & GAVL_PIXFMT_PLANAR)

Check if a pixelformat is planar.

Parameters
fmtA pixelformat
Returns
1 if the pixelformat is planar, 0 else

Typedef Documentation

◆ gavl_video_format_t

Video format.

Enumeration Type Documentation

◆ gavl_pixelformat_t

Pixelformat definition.

Enumerator
GAVL_PIXELFORMAT_NONE 

Undefined.

GAVL_GRAY_8 

8 bit gray, scaled 0x00..0xff

GAVL_GRAY_16 

16 bit gray, scaled 0x0000..0xffff

GAVL_GRAY_FLOAT 

floating point gray, scaled 0.0..1.0

GAVL_GRAYA_16 

8 bit gray + alpha, scaled 0x00..0xff

GAVL_GRAYA_32 

16 bit gray + alpha, scaled 0x0000..0xffff

GAVL_GRAYA_FLOAT 

floating point gray + alpha, scaled 0.0..1.0

GAVL_RGB_15 

15 bit RGB. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x7C00, for green: 0x03e0, for blue: 0x001f

GAVL_BGR_15 

15 bit BGR. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x001f, for green: 0x03e0, for blue: 0x7C00

GAVL_RGB_16 

16 bit RGB. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0xf800, for green: 0x07e0, for blue: 0x001f

GAVL_BGR_16 

16 bit BGR. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x001f, for green: 0x07e0, for blue: 0xf800

GAVL_RGB_24 

24 bit RGB. Each color is an uint8_t. Color order is RGBRGB

GAVL_BGR_24 

24 bit BGR. Each color is an uint8_t. Color order is BGRBGR

GAVL_RGB_32 

32 bit RGB. Each color is an uint8_t. Color order is RGBXRGBX, where X is unused

GAVL_BGR_32 

32 bit BGR. Each color is an uint8_t. Color order is BGRXBGRX, where X is unused

GAVL_RGBA_32 

32 bit RGBA. Each color is an uint8_t. Color order is RGBARGBA

GAVL_RGB_48 

48 bit RGB. Each color is an uint16_t in native byte order. Color order is RGBRGB

GAVL_RGBA_64 

64 bit RGBA. Each color is an uint16_t in native byte order. Color order is RGBARGBA

GAVL_RGB_FLOAT 

float RGB. Each color is a float (0.0 .. 1.0) in native byte order. Color order is RGBRGB

GAVL_RGBA_FLOAT 

float RGBA. Each color is a float (0.0 .. 1.0) in native byte order. Color order is RGBARGBA

GAVL_YUY2 

Packed YCbCr 4:2:2. Each component is an uint8_t. Component order is Y1 U1 Y2 V1

GAVL_UYVY 

Packed YCbCr 4:2:2. Each component is an uint8_t. Component order is U1 Y1 V1 Y2

GAVL_YUVA_32 

Packed YCbCrA 4:4:4:4. Each component is an uint8_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..255.

GAVL_YUVA_64 

Packed YCbCrA 4:4:4:4. Each component is an uint16_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..65535.

GAVL_YUV_FLOAT 

Packed YCbCr 4:4:4. Each component is a float. Luma is scaled 0.0..1.0, chroma is -0.5..0.5

GAVL_YUVA_FLOAT 

Packed YCbCrA 4:4:4:4. Each component is a float. Luma is scaled 0.0..1.0, chroma is -0.5..0.5

GAVL_YUV_420_P 

Packed YCbCrA 4:4:4:4. Each component is an uint16_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..65535.

GAVL_YUV_422_P 

Planar YCbCr 4:2:2. Each component is an uint8_t

GAVL_YUV_444_P 

Planar YCbCr 4:4:4. Each component is an uint8_t

GAVL_YUV_411_P 

Planar YCbCr 4:1:1. Each component is an uint8_t

GAVL_YUV_410_P 

Planar YCbCr 4:1:0. Each component is an uint8_t

GAVL_YUVJ_420_P 

Planar YCbCr 4:2:0. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

GAVL_YUVJ_422_P 

Planar YCbCr 4:2:2. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

GAVL_YUVJ_444_P 

Planar YCbCr 4:4:4. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

GAVL_YUV_444_P_16 

16 bit Planar YCbCr 4:4:4. Each component is an uint16_t in native byte order.

GAVL_YUV_422_P_16 

16 bit Planar YCbCr 4:2:2. Each component is an uint16_t in native byte order.

◆ gavl_color_channel_t

Color channel definitions.

Enum definitions for color channels

Enumerator
GAVL_CCH_RED 

Red.

GAVL_CCH_GREEN 

Green.

GAVL_CCH_BLUE 

Blue.

GAVL_CCH_Y 

Luminance (also grayscale)

GAVL_CCH_CB 

Chrominance blue (aka U)

GAVL_CCH_CR 

Chrominance red (aka V)

GAVL_CCH_ALPHA 

Transparency (or, to be more precise opacity)

◆ gavl_chroma_placement_t

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.

Enumerator
GAVL_CHROMA_PLACEMENT_DEFAULT 

MPEG-1/JPEG

GAVL_CHROMA_PLACEMENT_MPEG2 

MPEG-2

GAVL_CHROMA_PLACEMENT_DVPAL 

DV PAL

◆ gavl_framerate_mode_t

Framerate mode.

Enumerator
GAVL_FRAMERATE_UNKNOWN 

Unknown (never use in public APIs)

GAVL_FRAMERATE_CONSTANT 

Constant framerate

GAVL_FRAMERATE_VARIABLE 

Variable framerate

GAVL_FRAMERATE_STILL 

Still image

◆ gavl_interlace_mode_t

Interlace mode.

Enumerator
GAVL_INTERLACE_UNKNOWN 

Unknown interlacing (never use in public APIs)

GAVL_INTERLACE_NONE 

Progressive

GAVL_INTERLACE_TOP_FIRST 

Top field first

GAVL_INTERLACE_BOTTOM_FIRST 

Bottom field first

GAVL_INTERLACE_MIXED 

Use interlace_mode of the frames

GAVL_INTERLACE_MIXED_TOP 

Progressive + top

GAVL_INTERLACE_MIXED_BOTTOM 

Progressive + bottom

Function Documentation

◆ gavl_pixelformat_num_planes()

GAVL_PUBLIC int gavl_pixelformat_num_planes ( gavl_pixelformat_t  pixelformat)

Get the number of planes.

Parameters
pixelformatA pixelformat
Returns
The number of planes (1 for packet formats)

◆ gavl_pixelformat_chroma_sub()

GAVL_PUBLIC void gavl_pixelformat_chroma_sub ( gavl_pixelformat_t  pixelformat,
int *  sub_h,
int *  sub_v 
)

Get the horizontal and vertical subsampling factors.

Parameters
pixelformatA pixelformat
sub_hreturns the horizontal subsampling factor
sub_vreturns the vertical subsampling factor

E.g. for 4:2:0 subsampling: sub_h = 2, sub_v = 2

◆ gavl_pixelformat_bytes_per_component()

GAVL_PUBLIC int gavl_pixelformat_bytes_per_component ( gavl_pixelformat_t  pixelformat)

Get bytes per component for planar formats.

Parameters
pixelformatA pixelformat
Returns
The number of bytes per component for planar formats, 0 for packed formats

◆ gavl_pixelformat_bytes_per_pixel()

GAVL_PUBLIC int gavl_pixelformat_bytes_per_pixel ( gavl_pixelformat_t  pixelformat)

Get bytes per pixel for packed formats.

Parameters
pixelformatA pixelformat
Returns
The number of bytes per pixel for packed formats, 0 for planar formats

◆ gavl_pixelformat_bits_per_pixel()

GAVL_PUBLIC int gavl_pixelformat_bits_per_pixel ( gavl_pixelformat_t  pixelformat)

Get the effective number of bits for one pixel.

Parameters
pixelformatA pixelformat
Returns
Number of bits per pixel

◆ gavl_pixelformat_conversion_penalty()

GAVL_PUBLIC int gavl_pixelformat_conversion_penalty ( gavl_pixelformat_t  src,
gavl_pixelformat_t  dst 
)

Get the conversion penalty for pixelformat conversions.

Parameters
srcSource pixelformat
dstDestination pixelformat
Returns
A number denoting the "cost" of the conversion

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_pixelformat_get_best()

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.

Parameters
srcSource pixelformat
dst_supportedList of supported destination format
penaltyIf non-null, returns the conversion penalty
Returns
The best supported destination pixelformat

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_pixelformat_to_string()

GAVL_PUBLIC const char * gavl_pixelformat_to_string ( gavl_pixelformat_t  pixelformat)

Translate a pixelformat into a human readable string.

Parameters
pixelformatA pixelformat
Returns
A string describing the pixelformat

◆ gavl_string_to_pixelformat()

GAVL_PUBLIC gavl_pixelformat_t gavl_string_to_pixelformat ( const char *  name)

Translate a pixelformat name into a pixelformat.

Parameters
nameA string describing the pixelformat (returnd by gavl_pixelformat_to_string)
Returns
The pixelformat or GAVL_PIXELFORMAT_NONE if no match.

◆ gavl_num_pixelformats()

GAVL_PUBLIC int gavl_num_pixelformats ( )

Get total number of supported pixelformats.

Returns
total number of supported pixelformats

◆ gavl_get_pixelformat()

GAVL_PUBLIC gavl_pixelformat_t gavl_get_pixelformat ( int  index)

Get the pixelformat from index.

Parameters
indexindex (must be between 0 and the result of gavl_num_pixelformats)
Returns
The pixelformat corresponding to index or GAVL_PIXELFORMAT_NONE.

◆ gavl_chroma_placement_to_string()

GAVL_PUBLIC const char * gavl_chroma_placement_to_string ( gavl_chroma_placement_t  mode)

Translate a chroma placement into a human readable string.

Parameters
modeA chroma placement
Returns
A string describing the chroma placement

◆ gavl_framerate_mode_to_string()

GAVL_PUBLIC const char * gavl_framerate_mode_to_string ( gavl_framerate_mode_t  mode)

Translate a framerate mode into a human readable string.

Parameters
modeA framerate mode
Returns
A string describing the framerate mode

◆ gavl_interlace_mode_to_string()

GAVL_PUBLIC const char * gavl_interlace_mode_to_string ( gavl_interlace_mode_t  mode)

Translate an interlace mode into a human readable string.

Parameters
modeAn interlace mode
Returns
A string describing the interlace mode

◆ gavl_video_format_copy()

GAVL_PUBLIC void gavl_video_format_copy ( gavl_video_format_t dst,
const gavl_video_format_t src 
)

Copy one video format to another.

Parameters
dstDestination format
srcSource format

◆ gavl_video_formats_equal()

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.

Parameters
format_1First format
format_2Second format
Returns
1 if the formats are equal, 0 else

◆ gavl_video_format_get_chroma_offset()

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.

Parameters
formatA video format
fieldIndex of the field (0 = top, 1 = bottom). For progressive format, this is unused
planeIndex of the plane (1 = Cb, 2 = Cr)
off_xReturns the offset in x-direction
off_yReturns the offset in y-direction

◆ gavl_video_format_fit_to_source()

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.

Parameters
dstDestination format
srcSource 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_video_format_get_image_size()

GAVL_PUBLIC int gavl_video_format_get_image_size ( const gavl_video_format_t format)

Get the unpadded image size.

Parameters
formatA video format
Returns
The image size in bytes of an unpadded frame

◆ gavl_get_color_channel_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.

Parameters
frame_formatThe video format of the full frame
channel_formatFormat of the extracted channel (grayscale)
chChannel
Returns
1 on success, 0 if the requested channel is not available in the format

Use this function in conjunction with gavl_video_frame_extract_channel and gavl_video_frame_insert_channel

Since 1.1.2

◆ gavl_get_field_format()

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.

Parameters
frame_formatThe video format of the full frame
field_formatFormat of the field
fieldField (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_video_format_dump()

GAVL_PUBLIC void gavl_video_format_dump ( const gavl_video_format_t format)

Dump a video format to stderr.

Parameters
formatA video format