Go to the documentation of this file.
35 #define CONV_FUNC_NAME(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## dst_fmt
38 #define CONV_FUNC(ofmt, otype, ifmt, expr)\
39 static 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)
132 static void cpy1(uint8_t **dst,
const uint8_t **
src,
int len){
135 static void cpy2(uint8_t **dst,
const uint8_t **
src,
int len){
136 memcpy(*dst, *
src, 2*
len);
138 static void cpy4(uint8_t **dst,
const uint8_t **
src,
int len){
139 memcpy(*dst, *
src, 4*
len);
141 static void cpy8(uint8_t **dst,
const uint8_t **
src,
int len){
142 memcpy(*dst, *
src, 8*
len);
166 ctx->ch_map = ch_map;
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 && HAVE_MMX
199 const int os= (
out->planar ? 1 :
out->ch_count) *
out->bps;
200 unsigned misaligned = 0;
204 if (
ctx->in_simd_align_mask) {
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){
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;
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);
The official guide to swscale for confused that is
void swri_audio_convert_init_x86(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
#define CONV_FUNC(ofmt, otype, ifmt, expr)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int planar
1 if planar audio, 0 otherwise
int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len)
Convert between audio sample formats.
uint8_t * ch[SWR_CH_MAX]
samples buffer per channel
int ch_count
number of channels
static const struct @328 planes[]
av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)
av_cold void swri_audio_convert_init_aarch64(struct AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels)
@ AV_SAMPLE_FMT_NB
Number of sample formats. DO NOT USE if linking dynamically.
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
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.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define FMT_PAIR_FUNC(out, in)
void swri_audio_convert_free(AudioConvert **ctx)
Free audio sample format converter context.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
void() conv_func_type(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end)
#define flags(name, subs,...)
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_S64
signed 64 bits