gavl
gavldsp.h
1/*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2024 Members of the Gmerlin project
5 * http://github.com/bplaum
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * *****************************************************************/
20
21
22
23#ifndef GAVLDSP_H_INCLUDED
24#define GAVLDSP_H_INCLUDED
25
26#include <gavl/gavldefs.h>
27
40
45
46typedef struct gavl_dsp_context_s gavl_dsp_context_t;
47
53
54typedef struct
55 {
68
69 int (*sad_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
70 int stride_1, int stride_2,
71 int w, int h);
72
85
86 int (*sad_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
87 int stride_1, int stride_2,
88 int w, int h);
89
99
100 int (*sad_8)(const uint8_t * src_1, const uint8_t * src_2,
101 int stride_1, int stride_2,
102 int w, int h);
103
113
114 int (*sad_16)(const uint8_t * src_1, const uint8_t * src_2,
115 int stride_1, int stride_2,
116 int w, int h);
117
127 float (*sad_f)(const uint8_t * src_1, const uint8_t * src_2,
128 int stride_1, int stride_2,
129 int w, int h);
130
137
138 void (*average_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
139 uint8_t * dst, int num);
140
147 void (*average_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
148 uint8_t * dst, int num);
149
156 void (*average_8)(const uint8_t * src_1, const uint8_t * src_2,
157 uint8_t * dst, int num);
158
165 void (*average_16)(const uint8_t * src_1, const uint8_t * src_2,
166 uint8_t * dst, int num);
167
174
175 void (*average_f)(const uint8_t * src_1, const uint8_t * src_2,
176 uint8_t * dst, int num);
177
178
188
189 void (*interpolate_rgb15)(const uint8_t * src_1, const uint8_t * src_2,
190 uint8_t * dst, int num, float);
191
201 void (*interpolate_rgb16)(const uint8_t * src_1, const uint8_t * src_2,
202 uint8_t * dst, int num, float fac);
203
213 void (*interpolate_8)(const uint8_t * src_1, const uint8_t * src_2,
214 uint8_t * dst, int num, float fac);
215
225 void (*interpolate_16)(const uint8_t * src_1, const uint8_t * src_2,
226 uint8_t * dst, int num, float fac);
227
237
238 void (*interpolate_f)(const uint8_t * src_1, const uint8_t * src_2,
239 uint8_t * dst, int num, float fac);
240
245 void (*bswap_16)(void * ptr, int len);
246
251 void (*bswap_32)(void * ptr, int len);
252
257 void (*bswap_64)(void * ptr, int len);
258
267
268 void (*add_u8)(const void * src1, const void * src2, void * dst, int num);
269
278 void (*add_u8_s)(const void * src1, const void * src2, void * dst, int num);
279
288 void (*add_s8)(const void * src1, const void * src2, void * dst, int num);
289
298 void (*add_u16)(const void * src1, const void * src2, void * dst, int num);
299
308 void (*add_u16_s)(const void * src1, const void * src2, void * dst, int num);
309
318 void (*add_s16)(const void * src1, const void * src2, void * dst, int num);
319
328 void (*add_s32)(const void * src1, const void * src2, void * dst, int num);
329
338 void (*add_float)(const void * src1, const void * src2, void * dst, int num);
339
348 void (*add_double)(const void * src1, const void * src2, void * dst, int num);
349
358
359 void (*sub_u8)(const void * src1, const void * src2, void * dst, int num);
360
369 void (*sub_u8_s)(const void * src1, const void * src2, void * dst, int num);
370
379 void (*sub_s8)(const void * src1, const void * src2, void * dst, int num);
380
389 void (*sub_u16)(const void * src1, const void * src2, void * dst, int num);
390
399 void (*sub_u16_s)(const void * src1, const void * src2, void * dst, int num);
400
409 void (*sub_s16)(const void * src1, const void * src2, void * dst, int num);
410
419 void (*sub_s32)(const void * src1, const void * src2, void * dst, int num);
420
429 void (*sub_float)(const void * src1, const void * src2, void * dst, int num);
430
439 void (*sub_double)(const void * src1, const void * src2, void * dst, int num);
440
446 void (*shift_up_16)(void * ptr, int num, int bits);
447
453 void (*shift_down_16)(void * ptr, int num, int bits);
454
461 void (*shift_up_copy_16)(void * dst, const void * src, int num, int bits);
462
469 void (*shift_down_copy_16)(void * dst, const void * src, int num, int bits);
470
476
477 void (*shuffle_8_4)(void * dst, const void * src, int num, int * indices);
478
484
485 void (*shuffle_16_4)(void * dst, const void * src, int num, int * indices);
486
487
488
490
497
498GAVL_PUBLIC
500
507
508GAVL_PUBLIC
510 int q);
511
519
520GAVL_PUBLIC
522 int flags);
523
524
533
534GAVL_PUBLIC gavl_dsp_funcs_t *
536
540
541GAVL_PUBLIC
543
546
557
573
574GAVL_PUBLIC
576 gavl_video_format_t * format,
577 gavl_video_frame_t * src_1,
578 gavl_video_frame_t * src_2,
579 gavl_video_frame_t * dst,
580 float factor);
581
593
594GAVL_PUBLIC
596 gavl_audio_frame_t * frame,
597 const gavl_audio_format_t * format);
598
616
617GAVL_PUBLIC
619 gavl_video_frame_t * frame,
620 const gavl_video_format_t * format);
621
636
637GAVL_PUBLIC void
639 gavl_video_frame_t * frame,
640 const gavl_video_format_t * format, int bits);
641
642
643GAVL_PUBLIC void
644gavl_dsp_video_frame_shift_bits_copy(gavl_dsp_context_t * ctx,
645 gavl_video_frame_t * dst,
646 const gavl_video_frame_t * src,
647 const gavl_video_format_t * format, int bits);
648
649void
650gavl_dsp_video_frame_shuffle_4(gavl_dsp_context_t * ctx, gavl_video_frame_t * frame,
651 const gavl_video_format_t * format, int * src_indices);
652
653void
654gavl_dsp_video_frame_shuffle_4_copy(gavl_dsp_context_t * ctx,
655 gavl_video_frame_t * dst,
656 const gavl_video_frame_t * src,
657 const gavl_video_format_t * format,
658 int * src_indices);
659
660
664
665#endif // GAVLDSP_H_INCLUDED
GAVL_PUBLIC void gavl_dsp_context_destroy(gavl_dsp_context_t *ctx)
Destroy a DSP context.
GAVL_PUBLIC void gavl_dsp_context_set_quality(gavl_dsp_context_t *ctx, int q)
Set the quality for a DSP context.
GAVL_PUBLIC gavl_dsp_funcs_t * gavl_dsp_context_get_funcs(gavl_dsp_context_t *ctx)
Get the functions.
GAVL_PUBLIC gavl_dsp_context_t * gavl_dsp_context_create(void)
Create a DSP context.
GAVL_PUBLIC void gavl_dsp_context_set_accel_flags(gavl_dsp_context_t *ctx, int flags)
Set the acceleration flags for a DSP context.
struct gavl_dsp_context_s gavl_dsp_context_t
Opaque DSP context.
Definition gavldsp.h:46
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_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_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_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.
struct gavl_video_format_s gavl_video_format_t
Video format.
Definition gavl.h:102
Audio Format.
Definition gavl.h:273
Generic container for audio samples.
Definition gavl.h:624
Function table.
Definition gavldsp.h:55
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
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
void(* shift_up_copy_16)(void *dst, const void *src, int num, int bits)
Shift up and copy.
Definition gavldsp.h:461
void(* sub_u8)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint8_t vectors.
Definition gavldsp.h:359
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
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
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
void(* shuffle_8_4)(void *dst, const void *src, int num, int *indices)
Shuffle bytes in 4 byte words.
Definition gavldsp.h:477
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
void(* sub_float)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 float vectors.
Definition gavldsp.h:429
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
void(* add_s32)(const void *src1, const void *src2, void *dst, int num)
Add 2 int32_t vectors.
Definition gavldsp.h:328
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
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
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
void(* add_s8)(const void *src1, const void *src2, void *dst, int num)
Add 2 int8_t vectors.
Definition gavldsp.h:288
void(* shift_up_16)(void *ptr, int num, int bits)
Shift up.
Definition gavldsp.h:446
void(* bswap_32)(void *ptr, int len)
Do 32 byte endian swapping.
Definition gavldsp.h:251
void(* add_double)(const void *src1, const void *src2, void *dst, int num)
Add 2 float vectors.
Definition gavldsp.h:348
void(* sub_s32)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int32_t vectors.
Definition gavldsp.h:419
void(* add_u16)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint16_t vectors.
Definition gavldsp.h:298
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
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
void(* shift_down_copy_16)(void *dst, const void *src, int num, int bits)
Shift down.
Definition gavldsp.h:469
void(* add_u8)(const void *src1, const void *src2, void *dst, int num)
Add 2 uint8_t vectors.
Definition gavldsp.h:268
void(* sub_s8)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int8_t vectors.
Definition gavldsp.h:379
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
void(* add_s16)(const void *src1, const void *src2, void *dst, int num)
Add 2 int16_t vectors.
Definition gavldsp.h:318
void(* add_float)(const void *src1, const void *src2, void *dst, int num)
Add 2 float vectors.
Definition gavldsp.h:338
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
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
void(* shift_down_16)(void *ptr, int num, int bits)
Shift down.
Definition gavldsp.h:453
void(* sub_double)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 float vectors.
Definition gavldsp.h:439
void(* bswap_16)(void *ptr, int len)
Do 16 bit endian swapping.
Definition gavldsp.h:245
void(* sub_s16)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 int16_t vectors.
Definition gavldsp.h:409
void(* sub_u16)(const void *src1, const void *src2, void *dst, int num)
Subtract 2 uint16_t vectors.
Definition gavldsp.h:389
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
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
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
void(* bswap_64)(void *ptr, int len)
Do 64 byte endian swapping.
Definition gavldsp.h:257
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
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