gavldsp.h
/*****************************************************************
* gavl - a general purpose audio/video processing library
*
* Copyright (c) 2001 - 2024 Members of the Gmerlin project
* http://github.com/bplaum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#ifndef GAVLDSP_H_INCLUDED
#define GAVLDSP_H_INCLUDED
#include <gavl/gavldefs.h>
typedef struct gavl_dsp_context_s gavl_dsp_context_t;
typedef struct
{
int (*sad_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
int stride_1, int stride_2,
int w, int h);
int (*sad_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
int stride_1, int stride_2,
int w, int h);
int (*sad_8)(const uint8_t * src_1, const uint8_t * src_2,
int stride_1, int stride_2,
int w, int h);
int (*sad_16)(const uint8_t * src_1, const uint8_t * src_2,
int stride_1, int stride_2,
int w, int h);
float (*sad_f)(const uint8_t * src_1, const uint8_t * src_2,
int stride_1, int stride_2,
int w, int h);
void (*average_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num);
void (*average_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num);
void (*average_8)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num);
void (*average_16)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num);
void (*average_f)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num);
void (*interpolate_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num, float);
void (*interpolate_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num, float fac);
void (*interpolate_8)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num, float fac);
void (*interpolate_16)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num, float fac);
void (*interpolate_f)(const uint8_t * src_1, const uint8_t * src_2,
uint8_t * dst, int num, float fac);
void (*bswap_16)(void * ptr, int len);
void (*bswap_32)(void * ptr, int len);
void (*bswap_64)(void * ptr, int len);
void (*add_u8)(const void * src1, const void * src2, void * dst, int num);
void (*add_u8_s)(const void * src1, const void * src2, void * dst, int num);
void (*add_s8)(const void * src1, const void * src2, void * dst, int num);
void (*add_u16)(const void * src1, const void * src2, void * dst, int num);
void (*add_u16_s)(const void * src1, const void * src2, void * dst, int num);
void (*add_s16)(const void * src1, const void * src2, void * dst, int num);
void (*add_s32)(const void * src1, const void * src2, void * dst, int num);
void (*add_float)(const void * src1, const void * src2, void * dst, int num);
void (*add_double)(const void * src1, const void * src2, void * dst, int num);
void (*sub_u8)(const void * src1, const void * src2, void * dst, int num);
void (*sub_u8_s)(const void * src1, const void * src2, void * dst, int num);
void (*sub_s8)(const void * src1, const void * src2, void * dst, int num);
void (*sub_u16)(const void * src1, const void * src2, void * dst, int num);
void (*sub_u16_s)(const void * src1, const void * src2, void * dst, int num);
void (*sub_s16)(const void * src1, const void * src2, void * dst, int num);
void (*sub_s32)(const void * src1, const void * src2, void * dst, int num);
void (*sub_float)(const void * src1, const void * src2, void * dst, int num);
void (*sub_double)(const void * src1, const void * src2, void * dst, int num);
void (*shift_up_16)(void * ptr, int num, int bits);
void (*shift_down_16)(void * ptr, int num, int bits);
void (*shift_up_copy_16)(void * dst, const void * src, int num, int bits);
void (*shift_down_copy_16)(void * dst, const void * src, int num, int bits);
void (*shuffle_8_4)(void * dst, const void * src, int num, int * indices);
void (*shuffle_16_4)(void * dst, const void * src, int num, int * indices);
} gavl_dsp_funcs_t;
GAVL_PUBLIC
gavl_dsp_context_t * gavl_dsp_context_create(void);
GAVL_PUBLIC
void gavl_dsp_context_set_quality(gavl_dsp_context_t * ctx,
int q);
GAVL_PUBLIC
void gavl_dsp_context_set_accel_flags(gavl_dsp_context_t * ctx,
int flags);
GAVL_PUBLIC gavl_dsp_funcs_t *
gavl_dsp_context_get_funcs(gavl_dsp_context_t * ctx);
GAVL_PUBLIC
void gavl_dsp_context_destroy(gavl_dsp_context_t * ctx);
GAVL_PUBLIC
int gavl_dsp_interpolate_video_frame(gavl_dsp_context_t * ctx,
gavl_video_format_t * format,
gavl_video_frame_t * src_1,
gavl_video_frame_t * src_2,
gavl_video_frame_t * dst,
float factor);
GAVL_PUBLIC
int gavl_dsp_audio_frame_swap_endian(gavl_dsp_context_t * ctx,
gavl_audio_frame_t * frame,
const gavl_audio_format_t * format);
GAVL_PUBLIC
int gavl_dsp_video_frame_swap_endian(gavl_dsp_context_t * ctx,
gavl_video_frame_t * frame,
const gavl_video_format_t * format);
GAVL_PUBLIC void
gavl_dsp_video_frame_shift_bits(gavl_dsp_context_t * ctx,
gavl_video_frame_t * frame,
const gavl_video_format_t * format, int bits);
GAVL_PUBLIC void
gavl_dsp_video_frame_shift_bits_copy(gavl_dsp_context_t * ctx,
gavl_video_frame_t * dst,
const gavl_video_frame_t * src,
const gavl_video_format_t * format, int bits);
void
gavl_dsp_video_frame_shuffle_4(gavl_dsp_context_t * ctx, gavl_video_frame_t * frame,
const gavl_video_format_t * format, int * src_indices);
void
gavl_dsp_video_frame_shuffle_4_copy(gavl_dsp_context_t * ctx,
gavl_video_frame_t * dst,
const gavl_video_frame_t * src,
const gavl_video_format_t * format,
int * src_indices);
#endif // GAVLDSP_H_INCLUDED
gavl_dsp_context_destroy
GAVL_PUBLIC void gavl_dsp_context_destroy(gavl_dsp_context_t *ctx)
Destroy a DSP context.
gavl_dsp_context_set_quality
GAVL_PUBLIC void gavl_dsp_context_set_quality(gavl_dsp_context_t *ctx, int q)
Set the quality for a DSP context.
gavl_dsp_context_get_funcs
GAVL_PUBLIC gavl_dsp_funcs_t * gavl_dsp_context_get_funcs(gavl_dsp_context_t *ctx)
Get the functions.
gavl_dsp_context_create
GAVL_PUBLIC gavl_dsp_context_t * gavl_dsp_context_create(void)
Create a DSP context.
gavl_dsp_context_set_accel_flags
GAVL_PUBLIC void gavl_dsp_context_set_accel_flags(gavl_dsp_context_t *ctx, int flags)
Set the acceleration flags for a DSP context.
gavl_dsp_context_t
struct gavl_dsp_context_s gavl_dsp_context_t
Opaque DSP context.
Definition gavldsp.h:46
gavl_dsp_video_frame_swap_endian
GAVL_PUBLIC int gavl_dsp_video_frame_swap_endian(gavl_dsp_context_t *ctx, gavl_video_frame_t *frame, const gavl_video_format_t *format)
Swap endianness a video frame.
gavl_dsp_audio_frame_swap_endian
GAVL_PUBLIC int gavl_dsp_audio_frame_swap_endian(gavl_dsp_context_t *ctx, gavl_audio_frame_t *frame, const gavl_audio_format_t *format)
Swap endianness an audio frame.
gavl_dsp_video_frame_shift_bits
GAVL_PUBLIC void gavl_dsp_video_frame_shift_bits(gavl_dsp_context_t *ctx, gavl_video_frame_t *frame, const gavl_video_format_t *format, int bits)
Shift bits in a video frame.
gavl_dsp_interpolate_video_frame
GAVL_PUBLIC int gavl_dsp_interpolate_video_frame(gavl_dsp_context_t *ctx, gavl_video_format_t *format, gavl_video_frame_t *src_1, gavl_video_frame_t *src_2, gavl_video_frame_t *dst, float factor)
Do a linear interpolation of a video frame.
gavl_video_format_t
struct gavl_video_format_s gavl_video_format_t
Video format.
Definition gavl.h:102
gavl_audio_format_t
Audio Format.
Definition gavl.h:273
gavl_audio_frame_t
Generic container for audio samples.
Definition gavl.h:624
gavl_dsp_funcs_t
Function table.
Definition gavldsp.h:55
gavl_dsp_funcs_t::sad_8
int(* sad_8)(const uint8_t *src_1, const uint8_t *src_2, int stride_1, int stride_2, int w, int h)
Get the sum of absolute differences (8 bit).
Definition gavldsp.h:100
gavl_dsp_funcs_t::sad_rgb16
int(* sad_rgb16)(const uint8_t *src_1, const uint8_t *src_2, int stride_1, int stride_2, int w, int h)
Get the sum of absolute differences (RGB/BGR16).
Definition gavldsp.h:86
gavl_dsp_funcs_t::shift_up_copy_16
void(* shift_up_copy_16)(void *dst, const void *src, int num, int bits)
Shift up and copy.
Definition gavldsp.h:461
gavl_dsp_funcs_t::sub_u8
void(* sub_u8)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint8_t vectors.
Definition gavldsp.h:359
gavl_dsp_funcs_t::average_16
void(* average_16)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num)
Average 2 scanlines (16 bit).
Definition gavldsp.h:165
gavl_dsp_funcs_t::sub_u16_s
void(* sub_u16_s)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint16_t vectors (for audio stored as unsigned).
Definition gavldsp.h:399
gavl_dsp_funcs_t::average_f
void(* average_f)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num)
Average 2 scanlines (float).
Definition gavldsp.h:175
gavl_dsp_funcs_t::shuffle_8_4
void(* shuffle_8_4)(void *dst, const void *src, int num, int *indices)
Shuffle bytes in 4 byte words.
Definition gavldsp.h:477
gavl_dsp_funcs_t::interpolate_8
void(* interpolate_8)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num, float fac)
Interpolate 2 scanlines (8 bit).
Definition gavldsp.h:213
gavl_dsp_funcs_t::sub_float
void(* sub_float)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 float vectors.
Definition gavldsp.h:429
gavl_dsp_funcs_t::average_rgb15
void(* average_rgb15)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num)
Average 2 scanlines (RGB/BGR15).
Definition gavldsp.h:138
gavl_dsp_funcs_t::add_s32
void(* add_s32)(const void *src1, const void *src2, void *dst, int num)
Add 2 int32_t vectors.
Definition gavldsp.h:328
gavl_dsp_funcs_t::sad_16
int(* sad_16)(const uint8_t *src_1, const uint8_t *src_2, int stride_1, int stride_2, int w, int h)
Get the sum of absolute differences (16 bit).
Definition gavldsp.h:114
gavl_dsp_funcs_t::add_u16_s
void(* add_u16_s)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint16_t vectors (for audio stored as unsigned).
Definition gavldsp.h:308
gavl_dsp_funcs_t::add_u8_s
void(* add_u8_s)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint8_t vectors (for audio stored as unsigned).
Definition gavldsp.h:278
gavl_dsp_funcs_t::add_s8
void(* add_s8)(const void *src1, const void *src2, void *dst, int num)
Add 2 int8_t vectors.
Definition gavldsp.h:288
gavl_dsp_funcs_t::shift_up_16
void(* shift_up_16)(void *ptr, int num, int bits)
Shift up.
Definition gavldsp.h:446
gavl_dsp_funcs_t::bswap_32
void(* bswap_32)(void *ptr, int len)
Do 32 byte endian swapping.
Definition gavldsp.h:251
gavl_dsp_funcs_t::add_double
void(* add_double)(const void *src1, const void *src2, void *dst, int num)
Add 2 float vectors.
Definition gavldsp.h:348
gavl_dsp_funcs_t::sub_s32
void(* sub_s32)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int32_t vectors.
Definition gavldsp.h:419
gavl_dsp_funcs_t::add_u16
void(* add_u16)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint16_t vectors.
Definition gavldsp.h:298
gavl_dsp_funcs_t::sad_f
float(* sad_f)(const uint8_t *src_1, const uint8_t *src_2, int stride_1, int stride_2, int w, int h)
Get the sum of absolute differences (float).
Definition gavldsp.h:127
gavl_dsp_funcs_t::interpolate_16
void(* interpolate_16)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num, float fac)
Interpolate 2 scanlines (16 bit).
Definition gavldsp.h:225
gavl_dsp_funcs_t::shift_down_copy_16
void(* shift_down_copy_16)(void *dst, const void *src, int num, int bits)
Shift down.
Definition gavldsp.h:469
gavl_dsp_funcs_t::add_u8
void(* add_u8)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint8_t vectors.
Definition gavldsp.h:268
gavl_dsp_funcs_t::sub_s8
void(* sub_s8)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int8_t vectors.
Definition gavldsp.h:379
gavl_dsp_funcs_t::interpolate_rgb15
void(* interpolate_rgb15)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num, float)
Interpolate 2 scanlines (RGB/BGR15).
Definition gavldsp.h:189
gavl_dsp_funcs_t::add_s16
void(* add_s16)(const void *src1, const void *src2, void *dst, int num)
Add 2 int16_t vectors.
Definition gavldsp.h:318
gavl_dsp_funcs_t::add_float
void(* add_float)(const void *src1, const void *src2, void *dst, int num)
Add 2 float vectors.
Definition gavldsp.h:338
gavl_dsp_funcs_t::average_rgb16
void(* average_rgb16)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num)
Average 2 scanlines (RGB/BGR16).
Definition gavldsp.h:147
gavl_dsp_funcs_t::sub_u8_s
void(* sub_u8_s)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint8_t vectors (for audio stored as unsigned).
Definition gavldsp.h:369
gavl_dsp_funcs_t::shift_down_16
void(* shift_down_16)(void *ptr, int num, int bits)
Shift down.
Definition gavldsp.h:453
gavl_dsp_funcs_t::sub_double
void(* sub_double)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 float vectors.
Definition gavldsp.h:439
gavl_dsp_funcs_t::bswap_16
void(* bswap_16)(void *ptr, int len)
Do 16 bit endian swapping.
Definition gavldsp.h:245
gavl_dsp_funcs_t::sub_s16
void(* sub_s16)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int16_t vectors.
Definition gavldsp.h:409
gavl_dsp_funcs_t::sub_u16
void(* sub_u16)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint16_t vectors.
Definition gavldsp.h:389
gavl_dsp_funcs_t::sad_rgb15
int(* sad_rgb15)(const uint8_t *src_1, const uint8_t *src_2, int stride_1, int stride_2, int w, int h)
Get the sum of absolute differences (RGB/BGR15).
Definition gavldsp.h:69
gavl_dsp_funcs_t::shuffle_16_4
void(* shuffle_16_4)(void *dst, const void *src, int num, int *indices)
Shuffle 16 bit words in groups of 4.
Definition gavldsp.h:485
gavl_dsp_funcs_t::interpolate_rgb16
void(* interpolate_rgb16)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num, float fac)
Interpolate 2 scanlines (RGB/BGR16).
Definition gavldsp.h:201
gavl_dsp_funcs_t::bswap_64
void(* bswap_64)(void *ptr, int len)
Do 64 byte endian swapping.
Definition gavldsp.h:257
gavl_dsp_funcs_t::average_8
void(* average_8)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num)
Average 2 scanlines (8 bit).
Definition gavldsp.h:156
gavl_dsp_funcs_t::interpolate_f
void(* interpolate_f)(const uint8_t *src_1, const uint8_t *src_2, uint8_t *dst, int num, float fac)
Interpolate 2 scanlines (float).
Definition gavldsp.h:238