35#define CONV_FUNC_NAME(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## dst_fmt
38#define CONV_FUNC(ofmt, otype, ifmt, expr)\
39static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end)\
41 uint8_t *end2 = end - 3*os;\
43 *(otype*)po = expr; pi += is; po += os;\
44 *(otype*)po = expr; pi += is; po += os;\
45 *(otype*)po = expr; pi += is; po += os;\
46 *(otype*)po = expr; pi += is; po += os;\
49 *(otype*)po = expr; pi += is; po += os;\
91#define FMT_PAIR_FUNC(out, in) [(out) + AV_SAMPLE_FMT_NB*(in)] = CONV_FUNC_NAME(out, in)
132static void cpy1(uint8_t **
dst,
const uint8_t **
src,
int len){
135static void cpy2(uint8_t **
dst,
const uint8_t **
src,
int len){
138static void cpy4(uint8_t **
dst,
const uint8_t **
src,
int len){
141static void cpy8(uint8_t **
dst,
const uint8_t **
src,
int len){
168 memset(
ctx->silence, 0x80,
sizeof(
ctx->silence));
170 if(out_fmt == in_fmt && !
ch_map) {
172 case 1:
ctx->simd_f = cpy1;
break;
173 case 2:
ctx->simd_f = cpy2;
break;
174 case 4:
ctx->simd_f = cpy4;
break;
175 case 8:
ctx->simd_f = cpy8;
break;
179#if ARCH_X86 && HAVE_X86ASM
199 const int os= (
out->planar ? 1 :
out->ch_count) *
out->bps;
200 unsigned misaligned = 0;
204 if (
ctx->in_simd_align_mask) {
205 int planes = in->planar ? in->ch_count : 1;
207 for (ch = 0; ch <
planes; ch++)
208 m |= (intptr_t)in->ch[ch];
209 misaligned |= m &
ctx->in_simd_align_mask;
211 if (
ctx->out_simd_align_mask) {
214 for (ch = 0; ch <
planes; ch++)
215 m |= (intptr_t)
out->ch[ch];
216 misaligned |= m &
ctx->out_simd_align_mask;
221 if(
ctx->simd_f && !
ctx->ch_map && !misaligned){
227 if(
out->planar == in->planar){
229 for(ch=0; ch<
planes; ch++){
230 ctx->simd_f(
out->ch+ch, (
const uint8_t **)in->ch+ch, off * (
out->planar ? 1 :
out->ch_count));
233 ctx->simd_f(
out->ch, (
const uint8_t **)in->ch, off);
240 for(ch=0; ch<
ctx->channels; ch++){
241 const int ich=
ctx->ch_map ?
ctx->ch_map[ch] : ch;
242 const int is= ich < 0 ? 0 : (in->planar ? 1 : in->ch_count) * in->bps;
243 const uint8_t *pi= ich < 0 ?
ctx->silence : in->ch[ich];
244 uint8_t *end, *po =
out->ch[ch];
248 ctx->conv_f(po+off*os, pi+off*
is,
is, os, end);
av_cold void swri_audio_convert_init_aarch64(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const int ch_map[SC_NB]
static AVFormatContext * ctx
av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)
#define FMT_PAIR_FUNC(out, in)
#define CONV_FUNC(ofmt, otype, ifmt, expr)
Audio format conversion routines.
AudioConvert * swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags)
Create an audio sample format converter context.
void swri_audio_convert_free(AudioConvert **ctx)
Free audio sample format converter context.
int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len)
Convert between audio sample formats.
void conv_func_type(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define is(width, name, range_min, range_max, subs,...)
#define flags(name, subs,...)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S64
signed 64 bits
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
@ AV_SAMPLE_FMT_NB
Number of sample formats. DO NOT USE if linking dynamically.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S16
signed 16 bits
Replacements for frequently missing libm functions.
static const struct @257111027162314367033347246032313251342043035002 planes[]
Memory handling functions.
void swri_audio_convert_init_x86(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)