28#ifndef GAVL_H_INCLUDED
29#define GAVL_H_INCLUDED
33#include <gavl/gavldefs.h>
34#include <gavl/gavltime.h>
35#include <gavl/timecode.h>
36#include <gavl/threadpool.h>
107typedef struct gavl_hw_context_s gavl_hw_context_t;
141#define GAVL_QUALITY_FASTEST 1
149#define GAVL_QUALITY_BEST 5
157#define GAVL_QUALITY_DEFAULT 2
170#define GAVL_ACCEL_MMX (1<<0)
171#define GAVL_ACCEL_MMXEXT (1<<1)
172#define GAVL_ACCEL_SSE (1<<2)
173#define GAVL_ACCEL_SSE2 (1<<3)
174#define GAVL_ACCEL_SSE3 (1<<4)
175#define GAVL_ACCEL_3DNOW (1<<5)
176#define GAVL_ACCEL_3DNOWEXT (1<<6)
177#define GAVL_ACCEL_SSSE3 (1<<7)
178#define GAVL_ACCEL_AVX (1<<8)
179#define GAVL_ACCEL_AVX2 (1<<9)
180#define GAVL_ACCEL_NEON (1<<10)
210#define GAVL_MAX_CHANNELS 128
853 uint8_t * data,
int len);
858 gavl_packet_t * pkt);
861void gavl_packet_to_audio_frame_metadata(
const gavl_packet_t * p,
gavl_audio_frame_t * frame);
915 const char * name_base);
932#define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
937#define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
942#define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
947#define GAVL_AUDIO_FRONT_TO_REAR_MASK \
948(GAVL_AUDIO_FRONT_TO_REAR_COPY | \
949GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
950 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
956#define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
959#define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
962#define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
966#define GAVL_AUDIO_STEREO_TO_MONO_MASK \
967(GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
968GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
969GAVL_AUDIO_STEREO_TO_MONO_MIX)
974#define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
983 GAVL_AUDIO_DITHER_NONE = 0,
984 GAVL_AUDIO_DITHER_AUTO = 1,
985 GAVL_AUDIO_DITHER_RECT = 2,
986 GAVL_AUDIO_DITHER_TRI = 3,
987 GAVL_AUDIO_DITHER_SHAPED = 4,
1114 const double ** matrix);
1439#define GAVL_MAX_PLANES 4
1440#define GAVL_MAX_COLOR_CHANNELS 4
1754 float zoom,
float squeeze);
1761 float zoom,
float squeeze,
int do_orient);
1788#define GAVL_PIXFMT_PLANAR (1<<8)
1793#define GAVL_PIXFMT_RGB (1<<9)
1798#define GAVL_PIXFMT_YUV (1<<10)
1803#define GAVL_PIXFMT_YUVJ (1<<11)
1808#define GAVL_PIXFMT_ALPHA (1<<12)
1813#define GAVL_PIXFMT_GRAY (1<<13)
1959#define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
1962#define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
1965#define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
1968#define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
1972#define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
1975#define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
1978#define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
1981#define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
1985#define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
1988#define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
1991#define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
1994#define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
2024#define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
2033#define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
2041#define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
2049#define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
2057#define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
2065#define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
2386#define GAVL_IMAGE_ORIENT_FLIP_H (1<<2)
2391 GAVL_IMAGE_ORIENT_NORMAL = 0,
2392 GAVL_IMAGE_ORIENT_ROT90_CW = 1,
2393 GAVL_IMAGE_ORIENT_ROT180_CW = 2,
2394 GAVL_IMAGE_ORIENT_ROT270_CW = 3,
2396 GAVL_IMAGE_ORIENT_FH = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_NORMAL),
2397 GAVL_IMAGE_ORIENT_FH_ROT90_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT90_CW),
2398 GAVL_IMAGE_ORIENT_FH_ROT180_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT180_CW),
2399 GAVL_IMAGE_ORIENT_FH_ROT270_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT270_CW),
2401 } gavl_image_orientation_t;
2435 gavl_image_orientation_t orientation;
2477 float * off_x,
float * off_y);
2533 int pad_h,
int pad_v);
2611GAVL_PUBLIC
const char *
2612gavl_image_orientation_to_string(gavl_image_orientation_t orient);
2615gavl_image_orientation_is_transposed(gavl_image_orientation_t orient);
2743 const float * color);
2759 const gavl_video_frame_t * src1,
2760 const gavl_video_frame_t * src2,
2777 const gavl_video_frame_t * src1,
2778 const gavl_video_frame_t * src2,
2809 const gavl_video_frame_t * src2,
2810 gavl_video_frame_t * dst,
2828 gavl_video_frame_t * dst,
2829 const gavl_video_frame_t * src);
2845 gavl_video_frame_t * dst,
2846 const gavl_video_frame_t * src,
int plane);
2861 gavl_video_frame_t * dst,
2862 const gavl_video_frame_t * src);
2877 gavl_video_frame_t * dst,
2878 const gavl_video_frame_t * src);
2893 gavl_video_frame_t * dst,
2894 const gavl_video_frame_t * src);
2910 const gavl_video_frame_t * src);
2932 const gavl_video_frame_t * src,
2933 gavl_video_frame_t * dst,
2953 const gavl_video_frame_t * src,
2954 gavl_video_frame_t * dst,
2974 const char * namebase);
2988 const gavl_video_frame_t * frame);
3034 const gavl_video_frame_t * frame);
3054 const gavl_video_frame_t * src,
3055 gavl_video_frame_t * dst);
3075 const gavl_video_frame_t * src,
3076 gavl_video_frame_t * dst);
3092 const gavl_video_frame_t * f1,
3093 const gavl_video_frame_t * f2);
3098 const gavl_video_frame_t * in_frame,
3099 gavl_video_frame_t * out_frame);
3102void gavl_video_frame_to_packet_metadata(
const gavl_video_frame_t * frame,
3103 gavl_packet_t * pkt);
3106void gavl_packet_to_video_frame_metadata(
const gavl_packet_t * p, gavl_video_frame_t * frame);
3109void gavl_video_frame_set_from_packet(gavl_video_frame_t * frame,
3132#define GAVL_FORCE_DEINTERLACE (1<<0)
3138#define GAVL_CONVOLVE_CHROMA (1<<1)
3144#define GAVL_CONVOLVE_NORMALIZE (1<<2)
3153#define GAVL_RESAMPLE_CHROMA (1<<3)
3161#define GAVL_FORCE_SW (1<<4)
3343 int conversion_flags);
3422 const double * color);
3656 const gavl_video_frame_t * input_frame,
3657 gavl_video_frame_t * output_frame);
3761 int h_radius,
const float * h_coeffs,
3762 int v_radius,
const float * v_coeffs);
3773 const gavl_video_frame_t * input_frame,
3774 gavl_video_frame_t * output_frame);
3844 const gavl_video_frame_t * input_frame,
3845 gavl_video_frame_t * output_frame);
3958 gavl_video_frame_t * dst_frame);
4061 gavl_video_frame_t * in_frame,
4062 gavl_video_frame_t * out_frame);
4214 int64_t frame,
int * duration);
4229 int64_t * start_time);
4244 int64_t * start_time,
4275 int64_t * start_time,
4320 const char * filename);
4348#define GAVL_BAYER_GREEN_FIRST (1<<0)
4349#define GAVL_BAYER_BLUE_LINE (1<<1)
4353#define GAVL_BAYER_GBRG (GAVL_BAYER_GREEN_FIRST|GAVL_BAYER_BLUE_LINE)
4357#define GAVL_BAYER_GRBG (GAVL_BAYER_GREEN_FIRST)
4361#define GAVL_BAYER_BGGR (GAVL_BAYER_BLUE_LINE)
4365#define GAVL_BAYER_RGGB 0
4369 gavl_video_frame_t * src, gavl_video_frame_t * dst,
GAVL_PUBLIC gavl_deinterlace_mode_t gavl_video_options_get_deinterlace_mode(const gavl_video_options_t *opt)
Get the deinterlace mode.
#define GAVL_MAX_COLOR_CHANNELS
Definition gavl.h:1440
GAVL_PUBLIC void gavl_video_options_set_deinterlace_mode(gavl_video_options_t *opt, gavl_deinterlace_mode_t deinterlace_mode)
Set the deinterlace mode.
GAVL_PUBLIC int gavl_accel_supported(void)
Get the supported acceleration flags.
GAVL_PUBLIC gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t *cnv)
gets options of an audio converter
GAVL_PUBLIC void gavl_audio_converter_resample(gavl_audio_converter_t *cnv, gavl_audio_frame_t *input_frame, gavl_audio_frame_t *output_frame, double ratio)
Convert audio.
GAVL_PUBLIC void gavl_audio_converter_destroy(gavl_audio_converter_t *cnv)
Destroys an audio converter and frees all associated memory.
struct gavl_audio_converter_s gavl_audio_converter_t
Opaque audio converter structure.
Definition gavl.h:1195
GAVL_PUBLIC gavl_audio_converter_t * gavl_audio_converter_create(void)
Creates an audio converter.
GAVL_PUBLIC void gavl_audio_convert(gavl_audio_converter_t *cnv, const gavl_audio_frame_t *input_frame, gavl_audio_frame_t *output_frame)
Convert audio.
GAVL_PUBLIC int gavl_audio_converter_init(gavl_audio_converter_t *cnv, const gavl_audio_format_t *input_format, const gavl_audio_format_t *output_format)
Initialize an audio converter.
GAVL_PUBLIC int gavl_audio_converter_init_resample(gavl_audio_converter_t *cnv, const gavl_audio_format_t *format)
Initialize an audio converter just for resampling.
GAVL_PUBLIC int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t *cnv, double ratio)
Set samplerate conversion ratio.
GAVL_PUBLIC int gavl_audio_converter_reinit(gavl_audio_converter_t *cnv)
Reinitialize an audio converter.
GAVL_PUBLIC void gavl_audio_frame_destroy(gavl_audio_frame_t *frame)
Destroy an audio frame.
GAVL_PUBLIC void gavl_audio_frame_from_data(gavl_audio_frame_t *f, const gavl_audio_format_t *format, uint8_t *data, int len)
Set the channel pointers of an audio frame.
GAVL_PUBLIC void gavl_audio_frame_mute(gavl_audio_frame_t *frame, const gavl_audio_format_t *format)
Mute an audio frame.
GAVL_PUBLIC void gavl_audio_frame_null(gavl_audio_frame_t *frame)
Zero all pointers in the audio frame.
GAVL_PUBLIC void gavl_audio_frame_set_channels(gavl_audio_frame_t *f, const gavl_audio_format_t *format, uint8_t *data)
Set the channel pointers of an audio frame.
GAVL_PUBLIC void gavl_audio_frame_mute_samples(gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int num_samples)
Mute a number of samples at the start of an audio frame.
GAVL_PUBLIC int gavl_audio_frame_copy(const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src, int dst_pos, int src_pos, int dst_size, int src_size)
Copy audio data from one frame to another.
GAVL_PUBLIC int gavl_audio_frame_skip(const gavl_audio_format_t *format, gavl_audio_frame_t *f, int num_samples)
Skip samples in am audio frame.
GAVL_PUBLIC gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t *format)
Create audio frame.
GAVL_PUBLIC void gavl_audio_frame_get_subframe(const gavl_audio_format_t *format, gavl_audio_frame_t *src, gavl_audio_frame_t *dst, int start, int len)
Set an audio frame to a subframe of another frame.
GAVL_PUBLIC void gavl_audio_frame_mute_channel(gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int channel)
Mute a single channel of an audio frame.
GAVL_PUBLIC int gavl_audio_frame_plot(const gavl_audio_format_t *format, const gavl_audio_frame_t *frame, const char *name_base)
Plot an audio frame to an ASCII file.
GAVL_PUBLIC int gavl_audio_frames_equal(const gavl_audio_format_t *format, const gavl_audio_frame_t *f1, const gavl_audio_frame_t *f2)
Check if 2 audio frames are bit-identical.
GAVL_PUBLIC void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src)
Copy audio data from one frame to another.
GAVL_PUBLIC int gavl_audio_frame_continuous(const gavl_audio_format_t *format, const gavl_audio_frame_t *f)
Check if an audio frames is continuous in memory.
struct gavl_audio_options_s gavl_audio_options_t
Opaque container for audio conversion options.
Definition gavl.h:1010
GAVL_PUBLIC void gavl_audio_options_set_resample_mode(gavl_audio_options_t *opt, gavl_resample_mode_t mode)
Set the resample mode for the converter.
GAVL_PUBLIC gavl_audio_options_t * gavl_audio_options_create(void)
Create an options container.
GAVL_PUBLIC void gavl_audio_options_copy(gavl_audio_options_t *dst, const gavl_audio_options_t *src)
Copy audio options.
gavl_audio_dither_mode_t
Dither mode.
Definition gavl.h:982
GAVL_PUBLIC void gavl_audio_options_set_conversion_flags(gavl_audio_options_t *opt, int flags)
Set the conversion flags.
GAVL_PUBLIC gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(const gavl_audio_options_t *opt)
Get the dither mode for the converter.
GAVL_PUBLIC void gavl_audio_options_set_defaults(gavl_audio_options_t *opt)
Set all options to their defaults.
GAVL_PUBLIC void gavl_audio_options_set_mix_matrix(gavl_audio_options_t *opt, const double **matrix)
Set a user defined mix matrix.
GAVL_PUBLIC void gavl_audio_options_set_dither_mode(gavl_audio_options_t *opt, gavl_audio_dither_mode_t mode)
Set the dither mode for the converter.
gavl_resample_mode_t
Resample mode.
Definition gavl.h:995
GAVL_PUBLIC const double ** gavl_audio_options_get_mix_matrix(const gavl_audio_options_t *opt)
Get the mix matrix.
GAVL_PUBLIC int gavl_audio_options_get_quality(const gavl_audio_options_t *opt)
Get the quality level for a converter.
GAVL_PUBLIC gavl_resample_mode_t gavl_audio_options_get_resample_mode(const gavl_audio_options_t *opt)
Get the resample mode for the converter.
GAVL_PUBLIC void gavl_audio_options_destroy(gavl_audio_options_t *opt)
Destroy audio options.
GAVL_PUBLIC int gavl_audio_options_get_conversion_flags(const gavl_audio_options_t *opt)
Get the conversion flags.
GAVL_PUBLIC void gavl_audio_options_set_quality(gavl_audio_options_t *opt, int quality)
Set the quality level for the converter.
@ GAVL_RESAMPLE_SINC_BEST
Definition gavl.h:1001
@ GAVL_RESAMPLE_ZOH
Definition gavl.h:997
@ GAVL_RESAMPLE_LINEAR
Definition gavl.h:998
@ GAVL_RESAMPLE_AUTO
Definition gavl.h:996
@ GAVL_RESAMPLE_SINC_MEDIUM
Definition gavl.h:1000
@ GAVL_RESAMPLE_SINC_FAST
Definition gavl.h:999
GAVL_PUBLIC int gavl_frame_table_save(const gavl_frame_table_t *t, const char *filename)
Save a frame table to a file.
GAVL_PUBLIC int64_t gavl_frame_table_end_time(const gavl_frame_table_t *t)
get the end time of the last frame
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_load(const char *filename)
Load a frame table from a file.
GAVL_PUBLIC int64_t gavl_frame_table_frame_to_time(const gavl_frame_table_t *t, int64_t frame, int *duration)
Convert a frame index to a timestamp.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create(void)
Create a frame table.
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_frame_to_timecode(const gavl_frame_table_t *t, int64_t frame, int64_t *start_time, const gavl_timecode_format_t *fmt)
Convert a frame index to a timecode.
GAVL_PUBLIC void gavl_frame_table_dump(const gavl_frame_table_t *t)
Dump a frame table to stderr for debugging.
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_time_to_timecode(const gavl_frame_table_t *t, int64_t time, int64_t *start_time, const gavl_timecode_format_t *fmt)
Convert a timestamp to a timecode.
GAVL_PUBLIC int64_t gavl_frame_table_time_to_frame(const gavl_frame_table_t *t, int64_t time, int64_t *start_time)
Convert a timestamp to a frame index.
GAVL_PUBLIC int64_t gavl_frame_table_duration(const gavl_frame_table_t *t)
get the total duration of all frames
GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t *t)
Destroy a frame table and free all memory.
GAVL_PUBLIC int64_t gavl_frame_table_num_frames(const gavl_frame_table_t *t)
get the total number of frames
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration, int64_t num_frames, gavl_timecode_t start_timecode)
Create a frame table for constant framerate video.
GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t *t, int64_t duration)
Append an entry.
GAVL_PUBLIC void gavl_frame_table_append_timecode(gavl_frame_table_t *t, int64_t pts, gavl_timecode_t tc)
Append a timecodes.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration, gavl_timecode_format_t *fmt_ret)
Create a frame table for an audio stream.
GAVL_PUBLIC int64_t gavl_frame_table_timecode_to_time(const gavl_frame_table_t *t, gavl_timecode_t tc, const gavl_timecode_format_t *fmt)
Convert a timecode to a timestamp.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_copy(const gavl_frame_table_t *tab)
Copy a frame table to another.
GAVL_PUBLIC void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the bottom border.
GAVL_PUBLIC int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t *r)
Check if a float rectangle is empty.
GAVL_PUBLIC int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t *r)
Check if an integer rectangle is empty.
GAVL_PUBLIC void gavl_rectangle_f_crop_left(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the left border.
GAVL_PUBLIC void gavl_rectangle_i_align(gavl_rectangle_i_t *r, int h_align, int v_align)
Align a rectangle.
GAVL_PUBLIC void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t *src_rect, gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Crop 2 rectangles to their formats when scaling is available.
GAVL_PUBLIC void gavl_rectangle_i_copy(gavl_rectangle_i_t *dst, const gavl_rectangle_i_t *src)
Copy an integer rectangle.
GAVL_PUBLIC void gavl_rectangle_f_crop_right(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the right border.
GAVL_PUBLIC void gavl_rectangle_i_dump(const gavl_rectangle_i_t *r)
Dump a rectangle to stderr.
GAVL_PUBLIC void gavl_rectangle_i_crop_top(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the top border.
GAVL_PUBLIC void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Crop an integer rectangle so it fits into the image size of a video format.
GAVL_PUBLIC void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t *src_rect, gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Set 2 rectangles as source and destination when no scaling is available.
GAVL_PUBLIC void gavl_rectangle_fit_aspect(gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_rectangle_f_t *src_rect, const gavl_video_format_t *dst_format, float zoom, float squeeze)
Calculate a destination rectangle for scaling.
GAVL_PUBLIC void gavl_rectangle_i_to_f(gavl_rectangle_f_t *dst, const gavl_rectangle_i_t *src)
Convert an integer rectangle to a floating point rectangle.
GAVL_PUBLIC void gavl_rectangle_i_set_all(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Let an integer rectangle span the whole image size of a video format.
GAVL_PUBLIC void gavl_rectangle_f_set_all(gavl_rectangle_f_t *r, const gavl_video_format_t *format)
Let a float rectangle span the whole image size of a video format.
GAVL_PUBLIC void gavl_rectangle_f_copy(gavl_rectangle_f_t *dst, const gavl_rectangle_f_t *src)
Copy a float rectangle.
GAVL_PUBLIC void gavl_rectangle_f_to_i(gavl_rectangle_i_t *dst, const gavl_rectangle_f_t *src)
Convert a floating point rectangle to an integer rectangle.
GAVL_PUBLIC void gavl_rectangle_f_crop_top(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the top border.
GAVL_PUBLIC void gavl_rectangle_f_dump(const gavl_rectangle_f_t *r)
Dump a floating point rectangle to stderr.
GAVL_PUBLIC void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the bottom border.
GAVL_PUBLIC void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Align a rectangle to a format.
GAVL_PUBLIC void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t *r, const gavl_video_format_t *format)
Crop a floating point rectangle so it fits into the image size of a video format.
GAVL_PUBLIC void gavl_rectangle_i_crop_left(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the left border.
GAVL_PUBLIC void gavl_rectangle_i_crop_right(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the right border.
struct gavl_video_sink_s gavl_video_sink_t
Video sink.
Definition gavl.h:83
struct gavl_audio_sink_s gavl_audio_sink_t
Audio sink.
Definition gavl.h:74
struct gavl_packet_sink_s gavl_packet_sink_t
Packet sink.
Definition gavl.h:92
struct gavl_video_source_s gavl_video_source_t
Forward declaration of the video source.
Definition gavl.h:50
struct gavl_audio_source_s gavl_audio_source_t
Forward declaration of the audio source.
Definition gavl.h:58
struct gavl_packet_source_s gavl_packet_source_t
Forward declaration of the packet source.
Definition gavl.h:66
uint64_t gavl_timecode_t
Typedef for timecodes.
Definition timecode.h:44
GAVL_PUBLIC void gavl_overlay_blend(gavl_overlay_blend_context_t *ctx, gavl_video_frame_t *dst_frame)
Blend overlay onto video frame.
GAVL_PUBLIC gavl_overlay_blend_context_t * gavl_overlay_blend_context_create(void)
Create a blend context.
GAVL_PUBLIC void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t *ctx, gavl_overlay_t *ovl)
Set a new overlay.
gavl_video_frame_t gavl_overlay_t
Overlay structure.
Definition gavl.h:3882
GAVL_PUBLIC int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t *ctx, const gavl_video_format_t *frame_format, gavl_video_format_t *overlay_format)
Initialize the blend context.
struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t
Opaque blend context.
Definition gavl.h:3890
GAVL_PUBLIC void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t *ctx)
Destroy a blend context and free all associated memory.
GAVL_PUBLIC gavl_video_sink_t * gavl_overlay_blend_context_get_sink(gavl_overlay_blend_context_t *ctx)
Get the sink for overlays.
GAVL_PUBLIC gavl_video_options_t * gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t *ctx)
Get options from a blend context.
GAVL_PUBLIC int gavl_video_converter_init(gavl_video_converter_t *cnv, const gavl_video_format_t *input_format, const gavl_video_format_t *output_format)
Initialize a video converter.
GAVL_PUBLIC gavl_video_converter_t * gavl_video_converter_create(void)
Creates a video converter.
struct gavl_video_converter_s gavl_video_converter_t
Opaque video converter structure.
Definition gavl.h:3574
GAVL_PUBLIC void gavl_video_convert(gavl_video_converter_t *cnv, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Convert video.
GAVL_PUBLIC int gavl_video_converter_reinit(gavl_video_converter_t *cnv)
Reinitialize a video converter.
GAVL_PUBLIC void gavl_video_converter_destroy(gavl_video_converter_t *cnv)
Destroys a video converter and frees all associated memory.
GAVL_PUBLIC gavl_video_options_t * gavl_video_converter_get_options(gavl_video_converter_t *cnv)
gets options of a video converter
GAVL_PUBLIC int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t *deinterlacer, const gavl_video_format_t *src_format)
Initialize a video deinterlacer.
GAVL_PUBLIC gavl_video_deinterlacer_t * gavl_video_deinterlacer_create(void)
Create a video deinterlacer.
struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t
Opaque deinterlacer structure.
Definition gavl.h:3791
GAVL_PUBLIC void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t *deinterlacer)
Destroy a video deinterlacer.
GAVL_PUBLIC gavl_video_options_t * gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t *deinterlacer)
gets options of a deinterlacer
GAVL_PUBLIC void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t *deinterlacer, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Deinterlace video.
GAVL_PUBLIC void gavl_video_frame_copy(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another.
GAVL_PUBLIC void gavl_video_frame_copy_plane(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src, int plane)
Copy a single plane from one video frame to another.
GAVL_PUBLIC void gavl_video_frame_destroy(gavl_video_frame_t *frame)
Destroy a video frame.
GAVL_PUBLIC void gavl_video_frame_copy_flip_x(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with horizontal flipping.
GAVL_PUBLIC void gavl_video_frame_set_strides(gavl_video_frame_t *frame, const gavl_video_format_t *format)
Set the strides according to the format.
GAVL_PUBLIC int gavl_video_frame_insert_channel(const gavl_video_format_t *format, gavl_color_channel_t ch, const gavl_video_frame_t *src, gavl_video_frame_t *dst)
Insert one channel from a grayscale image into a video frame.
GAVL_PUBLIC void gavl_video_frame_set_planes(gavl_video_frame_t *frame, const gavl_video_format_t *format, uint8_t *buffer)
Set the frames according to the format.
GAVL_PUBLIC void gavl_video_frame_copy_flip_xy(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with horizontal and vertical flipping.
GAVL_PUBLIC void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat, const gavl_video_frame_t *src, gavl_video_frame_t *dst, const gavl_rectangle_i_t *src_rect)
Get a subframe of another frame.
GAVL_PUBLIC void gavl_video_frame_copy_metadata(gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy metadata of one video frame to another.
GAVL_PUBLIC void gavl_video_frame_fill(gavl_video_frame_t *frame, const gavl_video_format_t *format, const float *color)
Fill the frame with a user specified color.
GAVL_PUBLIC void gavl_video_frame_dump(gavl_video_frame_t *frame, const gavl_video_format_t *format, const char *namebase)
Dump a video frame to files.
GAVL_PUBLIC void gavl_video_frame_copy_flip_y(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with vertical flipping.
GAVL_PUBLIC void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat, const gavl_video_frame_t *src, gavl_video_frame_t *dst, int field)
Get a field from a frame.
GAVL_PUBLIC void gavl_video_frame_psnr(double *psnr, const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, const gavl_video_format_t *format)
Calculate the PSNR of 2 source frames.
GAVL_PUBLIC void gavl_video_frame_absdiff(gavl_video_frame_t *dst, const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, const gavl_video_format_t *format)
Fill the frame with the absolute difference of 2 source frames.
GAVL_PUBLIC int gavl_video_frame_ssim(const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, gavl_video_frame_t *dst, const gavl_video_format_t *format)
Calculate the SSIM of 2 source frames.
GAVL_PUBLIC int gavl_video_frame_extract_channel(const gavl_video_format_t *format, gavl_color_channel_t ch, const gavl_video_frame_t *src, gavl_video_frame_t *dst)
Extract one channel of a video frame into a grayscale image.
GAVL_PUBLIC gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t *format)
Create video frame.
GAVL_PUBLIC void gavl_video_frame_null(gavl_video_frame_t *frame)
Zero all pointers in the video frame.
GAVL_PUBLIC void gavl_video_frame_clear(gavl_video_frame_t *frame, const gavl_video_format_t *format)
Fill the frame with black color.
GAVL_PUBLIC int gavl_video_frame_continuous(const gavl_video_format_t *format, const gavl_video_frame_t *frame)
Check if a video frame uses a continuous memory block.
GAVL_PUBLIC int gavl_video_frames_equal(const gavl_video_format_t *format, const gavl_video_frame_t *f1, const gavl_video_frame_t *f2)
Check if 2 video frames are bit-identical.
GAVL_PUBLIC gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t *format)
Create video frame without padding.
GAVL_PUBLIC void gavl_video_frame_dump_metadata(const gavl_video_format_t *format, const gavl_video_frame_t *frame)
Dump a metadata of a video frame.
GAVL_PUBLIC void gavl_video_options_set_quality(gavl_video_options_t *opt, int quality)
Set the quality level for the converter.
GAVL_PUBLIC void gavl_video_options_set_alpha_mode(gavl_video_options_t *opt, gavl_alpha_mode_t alpha_mode)
Set the alpha mode.
GAVL_PUBLIC void gavl_video_options_get_rectangles(const gavl_video_options_t *opt, gavl_rectangle_f_t *src_rect, gavl_rectangle_i_t *dst_rect)
Get source and destination rectangles.
GAVL_PUBLIC void gavl_video_options_get_background_color(const gavl_video_options_t *opt, double *color)
Get the background color for alpha blending.
GAVL_PUBLIC gavl_alpha_mode_t gavl_video_options_get_alpha_mode(const gavl_video_options_t *opt)
Get the alpha mode.
GAVL_PUBLIC void gavl_video_options_set_rectangles(gavl_video_options_t *opt, const gavl_rectangle_f_t *src_rect, const gavl_rectangle_i_t *dst_rect)
Set source and destination rectangles.
GAVL_PUBLIC void gavl_video_options_destroy(gavl_video_options_t *opt)
Destroy video options.
GAVL_PUBLIC int gavl_video_options_get_quality(const gavl_video_options_t *opt)
Get the quality level for the converter.
GAVL_PUBLIC void gavl_video_options_set_scale_mode(gavl_video_options_t *opt, gavl_scale_mode_t scale_mode)
Set the scale mode.
gavl_deinterlace_mode_t
Definition gavl.h:3183
GAVL_PUBLIC gavl_deinterlace_drop_mode_t gavl_video_options_get_deinterlace_drop_mode(const gavl_video_options_t *opt)
Get the deinterlace drop mode.
GAVL_PUBLIC void gavl_video_options_copy(gavl_video_options_t *dst, const gavl_video_options_t *src)
Copy video options.
gavl_deinterlace_drop_mode_t
Specifies which field to drop when deinterlacing.
Definition gavl.h:3197
struct gavl_video_options_s gavl_video_options_t
Definition gavl.h:3242
GAVL_PUBLIC int gavl_video_options_get_scale_order(const gavl_video_options_t *opt)
Get the scale order for GAVL_SCALE_SINC_LANCZOS.
GAVL_PUBLIC float gavl_video_options_get_downscale_blur(const gavl_video_options_t *opt)
Get blur factor for downscaling.
gavl_alpha_mode_t
Definition gavl.h:3171
GAVL_PUBLIC void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t *opt, gavl_deinterlace_drop_mode_t deinterlace_drop_mode)
Set the deinterlace drop mode.
GAVL_PUBLIC gavl_downscale_filter_t gavl_video_options_get_downscale_filter(const gavl_video_options_t *opt)
Get the antialiasing filter for downscaling.
GAVL_PUBLIC gavl_video_options_t * gavl_video_options_create(void)
Create an options container.
GAVL_PUBLIC void gavl_video_options_set_defaults(gavl_video_options_t *opt)
Set all options to their defaults.
GAVL_PUBLIC void gavl_video_options_set_conversion_flags(gavl_video_options_t *opt, int conversion_flags)
Set the conversion flags.
gavl_scale_mode_t
Definition gavl.h:3207
GAVL_PUBLIC void gavl_video_options_set_downscale_blur(gavl_video_options_t *opt, float f)
Set blur factor for downscaling.
GAVL_PUBLIC void gavl_video_options_set_background_color(gavl_video_options_t *opt, const double *color)
Set the background color for alpha blending.
GAVL_PUBLIC void gavl_video_options_set_downscale_filter(gavl_video_options_t *opt, gavl_downscale_filter_t f)
Set antialiasing filter for downscaling.
GAVL_PUBLIC int gavl_video_options_get_conversion_flags(const gavl_video_options_t *opt)
Get the conversion flags.
GAVL_PUBLIC void gavl_video_options_set_scale_order(gavl_video_options_t *opt, int order)
Set the scale order for GAVL_SCALE_SINC_LANCZOS.
gavl_downscale_filter_t
Definition gavl.h:3229
GAVL_PUBLIC gavl_scale_mode_t gavl_video_options_get_scale_mode(const gavl_video_options_t *opt)
Get the scale mode.
@ GAVL_DEINTERLACE_NONE
Definition gavl.h:3184
@ GAVL_DEINTERLACE_SCALE
Definition gavl.h:3186
@ GAVL_DEINTERLACE_BLEND
Definition gavl.h:3187
@ GAVL_DEINTERLACE_COPY
Definition gavl.h:3185
@ GAVL_DEINTERLACE_DROP_TOP
Definition gavl.h:3198
@ GAVL_DEINTERLACE_DROP_BOTTOM
Definition gavl.h:3199
@ GAVL_ALPHA_IGNORE
Definition gavl.h:3172
@ GAVL_ALPHA_BLEND_COLOR
Definition gavl.h:3173
@ GAVL_SCALE_NONE
Definition gavl.h:3216
@ GAVL_SCALE_NEAREST
Definition gavl.h:3209
@ GAVL_SCALE_CUBIC_MITCHELL
Definition gavl.h:3213
@ GAVL_SCALE_AUTO
Definition gavl.h:3208
@ GAVL_SCALE_SINC_LANCZOS
Definition gavl.h:3215
@ GAVL_SCALE_CUBIC_CATMULL
Definition gavl.h:3214
@ GAVL_SCALE_CUBIC_BSPLINE
Definition gavl.h:3212
@ GAVL_SCALE_QUADRATIC
Definition gavl.h:3211
@ GAVL_SCALE_BILINEAR
Definition gavl.h:3210
@ GAVL_DOWNSCALE_FILTER_AUTO
Auto selection based on quality.
Definition gavl.h:3230
@ GAVL_DOWNSCALE_FILTER_NONE
Fastest method, might produce heavy aliasing artifacts.
Definition gavl.h:3231
@ GAVL_DOWNSCALE_FILTER_WIDE
Widen the filter curve according to the scaling ratio.
Definition gavl.h:3232
@ GAVL_DOWNSCALE_FILTER_GAUSS
Do a Gaussian preblur.
Definition gavl.h:3233
GAVL_PUBLIC int gavl_video_scaler_init(gavl_video_scaler_t *scaler, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Initialize a video scaler.
GAVL_PUBLIC void gavl_video_scaler_destroy(gavl_video_scaler_t *scaler)
Destroy a video scaler.
GAVL_PUBLIC gavl_video_options_t * gavl_video_scaler_get_options(gavl_video_scaler_t *scaler)
gets options of a scaler
GAVL_PUBLIC gavl_video_scaler_t * gavl_video_scaler_create(void)
Create a video scaler.
struct gavl_video_scaler_s gavl_video_scaler_t
Opaque scaler structure.
Definition gavl.h:3691
GAVL_PUBLIC void gavl_video_scaler_scale(gavl_video_scaler_t *scaler, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Scale video.
GAVL_PUBLIC int gavl_video_scaler_init_convolve(gavl_video_scaler_t *scaler, const gavl_video_format_t *format, int h_radius, const float *h_coeffs, int v_radius, const float *v_coeffs)
Initialize a video scaler as a generic convolver.
#define GAVL_MAX_PLANES
Definition gavl.h:1439
GAVL_PUBLIC void gavl_volume_control_set_volume(gavl_volume_control_t *ctrl, float volume)
Set volume for a volume control.
GAVL_PUBLIC void gavl_volume_control_apply(gavl_volume_control_t *ctrl, gavl_audio_frame_t *frame)
Apply a volume control for an audio frame.
GAVL_PUBLIC float gavl_volume_to_float(int volume, float one, int steps)
Convert an integer audio volume to a float (in dB).
GAVL_PUBLIC void gavl_volume_control_destroy(gavl_volume_control_t *ctrl)
Destroys a volume control and frees all associated memory.
GAVL_PUBLIC void gavl_volume_control_set_format(gavl_volume_control_t *ctrl, const gavl_audio_format_t *format)
Set format for a volume control.
struct gavl_volume_control_s gavl_volume_control_t
Opaque structure for a volume control.
Definition gavl.h:1357
GAVL_PUBLIC gavl_volume_control_t * gavl_volume_control_create(void)
Create volume control.
GAVL_PUBLIC int gavl_volume_to_int(float volume, float one, int steps)
Convert an audio volume (in dB) to an integer.
Generic container for audio samples.
Definition gavl.h:628
int channel_stride
Definition gavl.h:633
gavl_audio_samples_t samples
Definition gavl.h:629
int valid_samples
Definition gavl.h:631
gavl_hw_context_t * hwctx
Definition gavl.h:635
int64_t timestamp
Definition gavl.h:632
void * storage
Definition gavl.h:636
gavl_audio_channels_t channels
Definition gavl.h:630
int64_t num_frames
Number of frames.
int64_t duration
Duration of each of these frames.
gavl_timecode_t tc
Timecode associated with this timestamp.
int64_t pts
Timestamp of this frame.
frame table structure
Definition gavl.h:4100
int num_timecodes
Number of timecodes.
Definition gavl.h:4112
int64_t offset
Timestamp of the first frame.
Definition gavl.h:4101
int64_t entries_alloc
Number of allocated entries (never touch this).
Definition gavl.h:4104
int64_t num_entries
Number of entries.
Definition gavl.h:4103
int timecodes_alloc
Number of allocated timecodes (never touch this).
Definition gavl.h:4113
Packet structure.
Definition compression.h:424
Floating point rectangle.
Definition gavl.h:1465
double x
Definition gavl.h:1466
double y
Definition gavl.h:1467
double w
Definition gavl.h:1468
double h
Definition gavl.h:1469
Integer rectangle.
Definition gavl.h:1453
int32_t x
Definition gavl.h:1454
int32_t h
Definition gavl.h:1457
int32_t y
Definition gavl.h:1455
int32_t w
Definition gavl.h:1456
uint8_t * planes[GAVL_MAX_PLANES]
Definition gavl.h:2642
int64_t duration
Definition gavl.h:2647
int strides[GAVL_MAX_PLANES]
Definition gavl.h:2643
void * client_data
Definition gavl.h:2645
int32_t dst_y
y offset in the destination frame. (since 1.5.0) */
Definition gavl.h:2655
void * storage
Definition gavl.h:2658
int64_t timestamp
Definition gavl.h:2646
int32_t dst_x
x offset in the destination frame. (since 1.5.0) */
Definition gavl.h:2654
gavl_rectangle_i_t src_rect
Valid rectangle in this frame (since 1.5.0) */.
Definition gavl.h:2653
gavl_hw_context_t * hwctx
Handle for accessing the frame.
Definition gavl.h:2657
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2648
gavl_timecode_t timecode
Definition gavl.h:2649
Container for noninterleaved audio samples.
Definition gavl.h:596
int16_t * s_16[GAVL_MAX_CHANNELS]
Definition gavl.h:601
int32_t * s_32[GAVL_MAX_CHANNELS]
Definition gavl.h:604
float * f[GAVL_MAX_CHANNELS]
Definition gavl.h:606
double * d[GAVL_MAX_CHANNELS]
Definition gavl.h:607
int8_t * s_8[GAVL_MAX_CHANNELS]
Definition gavl.h:598
uint8_t * u_8[GAVL_MAX_CHANNELS]
Definition gavl.h:597
uint32_t * u_32[GAVL_MAX_CHANNELS]
Definition gavl.h:603
uint16_t * u_16[GAVL_MAX_CHANNELS]
Definition gavl.h:600
Container for interleaved audio samples.
Definition gavl.h:576
uint32_t * u_32
Definition gavl.h:583
int8_t * s_8
Definition gavl.h:578
uint16_t * u_16
Definition gavl.h:580
int16_t * s_16
Definition gavl.h:581
uint8_t * u_8
Definition gavl.h:577
float * f
Definition gavl.h:586
double * d
Definition gavl.h:587
int32_t * s_32
Definition gavl.h:584