FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
audioconvert.c File Reference

audio conversion More...

#include "libavutil/avstring.h"
#include "libavutil/avassert.h"
#include "libavutil/libm.h"
#include "libavutil/samplefmt.h"
#include "audioconvert.h"

Go to the source code of this file.

Macros

#define CONV_FUNC_NAME(dst_fmt, src_fmt)   conv_ ## src_fmt ## _to_ ## dst_fmt
 
#define CONV_FUNC(ofmt, otype, ifmt, expr)
 
#define FMT_PAIR_FUNC(out, in)   [(out) + AV_SAMPLE_FMT_NB*(in)] = CONV_FUNC_NAME(out, in)
 

Functions

 CONV_FUNC (AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi-0x80U)<< 8) CONV_FUNC(AV_SAMPLE_FMT_S32
 
 if (off==len)
 

Variables

 int32_t
 
 AV_SAMPLE_FMT_U8
 
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64,
int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t
*) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch 
ch
 
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64,
int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t
*) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE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T), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch const uint8_t **in ch off *out 
planar
 
 else
 
 return
 

Detailed Description

audio conversion

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file audioconvert.c.

Macro Definition Documentation

#define CONV_FUNC_NAME (   dst_fmt,
  src_fmt 
)    conv_ ## src_fmt ## _to_ ## dst_fmt

Definition at line 35 of file audioconvert.c.

#define CONV_FUNC (   ofmt,
  otype,
  ifmt,
  expr 
)
Value:
static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end)\
{\
uint8_t *end2 = end - 3*os;\
while(po < end2){\
*(otype*)po = expr; pi += is; po += os;\
*(otype*)po = expr; pi += is; po += os;\
*(otype*)po = expr; pi += is; po += os;\
*(otype*)po = expr; pi += is; po += os;\
}\
while(po < end){\
*(otype*)po = expr; pi += is; po += os;\
}\
}
#define CONV_FUNC_NAME(dst_fmt, src_fmt)
Definition: audioconvert.c:35
uint8_t
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90

Definition at line 38 of file audioconvert.c.

#define FMT_PAIR_FUNC (   out,
  in 
)    [(out) + AV_SAMPLE_FMT_NB*(in)] = CONV_FUNC_NAME(out, in)

Function Documentation

CONV_FUNC ( AV_SAMPLE_FMT_S16  ,
int16_t  ,
AV_SAMPLE_FMT_U8  ,
(*(const uint8_t *) pi-0x80U)<<  8 
)
if ( off  = len)

Definition at line 232 of file audioconvert.c.

Variable Documentation

int32_t

Definition at line 56 of file audioconvert.c.

Referenced by av_audio_convert().

AV_SAMPLE_FMT_U8

Definition at line 56 of file audioconvert.c.

Referenced by av_audio_convert().

uint8_t pi<<24)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t*)pi-0x80U))<<56)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_U8,(*(constuint8_t*)pi-0x80)*(1.0f/(1<<7)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_U8,(*(constuint8_t*)pi-0x80)*(1.0/(1<<7)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S16,(*(constint16_t*)pi>>8)+0x80)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t*)pi)<<48)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S16,*(constint16_t*)pi*(1.0f/(1<<15)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S16,*(constint16_t*)pi*(1.0/(1<<15)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S32,(*(constint32_t*)pi>>24)+0x80)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t*)pi)<<32)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S32,*(constint32_t*)pi*(1.0f/(1U<<31)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S32,*(constint32_t*)pi*(1.0/(1U<<31)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S64,(*(constint64_t*)pi>>56)+0x80)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S64,*(constint64_t*)pi*(1.0f/(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S64,*(constint64_t*)pi*(1.0/(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_FLT,av_clip_uint8(lrintf(*(constfloat*)pi*(1<<7))+0x80))CONV_FUNC(AV_SAMPLE_FMT_S16,int16_t,AV_SAMPLE_FMT_FLT,av_clip_int16(lrintf(*(constfloat*)pi*(1<<15))))CONV_FUNC(AV_SAMPLE_FMT_S32,int32_t,AV_SAMPLE_FMT_FLT,av_clipl_int32(llrintf(*(constfloat*)pi*(1U<<31))))CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_FLT,llrintf(*(constfloat*)pi*(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_DBL,av_clip_uint8(lrint(*(constdouble*)pi*(1<<7))+0x80))CONV_FUNC(AV_SAMPLE_FMT_S16,int16_t,AV_SAMPLE_FMT_DBL,av_clip_int16(lrint(*(constdouble*)pi*(1<<15))))CONV_FUNC(AV_SAMPLE_FMT_S32,int32_t,AV_SAMPLE_FMT_DBL,av_clipl_int32(llrint(*(constdouble*)pi*(1U<<31))))CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_DBL,llrint(*(constdouble*)pi*(INT64_C(1)<<63)))#defineFMT_PAIR_FUNC(out,in)staticconv_func_type*constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64,AV_SAMPLE_FMT_U8),FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8,AV_SAMPLE_FMT_S16),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_S16),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE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PLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64,AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,len);}staticvoidcpy2(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,2*len);}staticvoidcpy4(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,4*len);}staticvoidcpy8(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,8*len);}AudioConvert*swri_audio_convert_alloc(enumAVSampleFormatout_fmt,enumAVSampleFormatin_fmt,intchannels,constint*ch_map,intflags){AudioConvert*ctx;conv_func_type*f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB*av_get_packed_sample_fmt(in_fmt)];if(!f)returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx)returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P)memset(ctx->silence,0x80,sizeof(ctx->silence));if(out_fmt==in_fmt&&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM&&1)swri_audio_convert_init_x86(ctx,out_fmt,in_fmt,channels);if(ARCH_ARM)swri_audio_convert_init_arm(ctx,out_fmt,in_fmt,channels);if(ARCH_AARCH64)swri_audio_convert_init_aarch64(ctx,out_fmt,in_fmt,channels);returnctx;}voidswri_audio_convert_free(AudioConvert**ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert*ctx,AudioData*out,AudioData*in,intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch<planes;ch++)m|=(intptr_t)in->ch[ch];misaligned|=m&ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch<planes;ch++)m|=(intptr_t)out->ch[ch];misaligned|=m&ctx->out_simd_align_mask;}if(ctx->simd_f&&!ctx->ch_map&&!misaligned){off=len&~15;av_assert1(off>=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off>0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch<planes;ch++){ctx->simd_f(out-> ch const uint8_t** in ch ch
Examples:
decode_audio.c.

Definition at line 56 of file audioconvert.c.

Referenced by aac_encode_frame(), ac3_decode_frame(), acalc_magnitudes(), add_noise(), adjust_frame_information(), adpcm_decode_frame(), adpcm_encode_frame(), adx_decode(), adx_decode_frame(), adx_encode_frame(), aea_read_probe(), alac_decode_close(), alac_decode_frame(), alac_entropy_coder(), alac_linear_predictor(), alloc_buffers(), alloc_sample_buffer(), alloc_x96_sample_buffer(), allocate_buffers(), allocate_sample_buffers(), ape_decode_frame(), append_extra_bits(), apply_channel_coupling(), apply_lpc(), apply_mdct(), apply_window_and_mdct(), asf_read_content_desc(), atrac1_decode_frame(), atrac3p_decode_init(), audiogen(), av_audio_convert(), av_bprint_channel_layout(), av_dump_format(), av_frame_ref(), av_samples_fill_arrays(), avcodec_fill_audio_frame(), average_quantized_coeffs(), avpriv_aac_parse_header(), avresample_open(), avresample_set_channel_mapping(), bit_alloc(), bit_alloc_init(), bit_alloc_masking(), buf_set(), build_sb_samples_from_noise(), calc_channel_magnitudes(), calc_channel_phases(), calc_masking(), calc_predictor_params(), calc_transform_coeffs_cpl(), calculate_sign_huff(), cbr_bit_allocation(), celt_apply_preemph_filter(), celt_encode_frame(), celt_frame_map_norm_bands(), celt_frame_mdct(), celt_frame_setup_input(), celt_quant_coarse(), celt_quant_final(), celt_quant_fine(), channelmap_filter_frame(), check_append_extra_bits(), chs_assemble_freq_bands(), chs_assemble_msbs_lsbs(), chs_get_lsb_width(), combine_residual_frame(), compare_decoding_params(), compute_bit_allocation(), compute_chapters_end(), compute_exp_strategy(), config_input(), config_output(), convert_samples(), copy(), copy_input_samples(), copy_samples(), count_exponent_bits(), count_frame_bits(), count_mantissa_bits(), coupling_coordinates(), coupling_strategy(), dec_bark_env(), decode_audio_block(), decode_audio_s16(), decode_block(), decode_channel(), decode_channel_residues(), decode_element(), decode_exp_vlc(), decode_frame(), decode_grid(), decode_lpc(), decode_part_stereo(), decode_residual_spectrum(), decode_str(), decode_transform_coeffs(), decode_transform_coeffs_ch(), deshake_transform_c(), do_imdct(), dpcm_decode_frame(), draw_curves(), eightsvx_decode_frame(), encode_block(), encode_exp_vlc(), encode_exponents(), encode_frame(), encode_mb_internal(), encode_residual_ch(), erase_adpcm_history(), erase_x96_adpcm_history(), extract_audio(), extract_exponents(), extract_line(), ff_aac_ltp_insert_new_frame(), ff_ac3_compute_coupling_strategy(), ff_ac3_encode_close(), ff_ac3_group_exponents(), ff_ac3_quantize_mantissas(), ff_audio_resample(), ff_dca_core_filter_fixed(), ff_dca_lbr_flush(), ff_dca_lbr_parse(), ff_dither_alloc(), ff_dither_free(), ff_eac3_apply_spectral_extension(), ff_eac3_decode_transform_coeffs_aht_ch(), ff_eac3_get_frame_exp_strategy(), ff_eac3_output_frame_header(), ff_eac3_parse_header(), ff_eac3_set_cpl_states(), ff_mpc_dequantize_and_synth(), ff_opencl_apply_unsharp(), ff_opencl_unsharp_process_inout_buf(), ff_psy_find_group(), ff_psy_preprocess(), ff_sbr_apply(), fill_coding_method_array(), fill_tone_level_array(), filter(), filter_frame(), filter_frame_fixed(), filter_frame_float(), filter_ts(), find_peaks(), fix_coding_method_array(), force_lossy_output(), frame_configure_elements(), fsb_read_packet(), ftp_get_line(), generate_kernel(), genh_read_header(), genh_read_packet(), get(), get_asf_string(), get_audio_frame_duration(), get_nb_samples(), get_speaker_pos(), http_get_line(), http_handshake(), idct_mb(), imc_decode_block(), imdct_and_window(), init_exp(), init_frame(), init_quantization_noise(), init_sample_buffers(), init_tone_level_dequantization(), inverse_channel_transform(), invert_initial_buffer(), join_config_output(), libopus_decode_init(), main(), map_prm_ch_to_spkr(), mkv_write_tags(), mov_read_chapters(), mp3lame_encode_frame(), mp3lame_encode_init(), mp_decode_frame(), mp_decode_layer1(), mp_decode_layer2(), mp_decode_layer3(), mpc7_decode_frame(), mpc8_decode_frame(), mpc_synth(), mxf_utf16len(), nut_write_header(), on2avc_read_channel_data(), on2avc_reconstruct_channel_ext(), optimize_colors(), opus_encode_init(), output_audio_block(), parse_ch(), parse_coding_header(), parse_frame_data(), parse_grid_1_chunk(), parse_grid_2(), parse_grid_3(), parse_high_res_grid(), parse_lpc(), parse_subframe_audio(), parse_subframe_header(), parse_tonal(), parse_x96_coding_header(), parse_x96_frame_data(), parse_x96_subframe_audio(), parse_x96_subframe_header(), parse_xbr_subframe(), plot_channel(), plot_freq(), plot_freqs(), process_subpacket_9(), psy_3gpp_analyze(), push_single_pic(), put_primary_audio_header(), put_str16(), put_subframe(), put_subframe_samples(), qdm2_decode(), qdm2_fft_tone_synthesizer(), qdm2_synthesis_filter(), quantize_all(), random_ts(), read16_fft_bin(), read8_fft_bin(), read_block_data(), read_channel_params(), read_decoding_params(), read_fft_data(), read_header(), read_key(), read_map(), read_matrix_params(), read_noise_data(), read_restart_header(), reconstruct_frame(), remove_dithering(), remove_wasted_bits(), request_frame(), reset_block_bap(), revert_channel_correlation(), rsd_read_packet(), run_channel_fft(), sbr_dequant(), scale_coefficients(), scale_magnitudes(), seek_chapter(), set(), set_bandwidth(), shift(), shift_history(), spx_coordinates(), spx_strategy(), store_icy(), subband_transform(), swr_convert_internal(), swri_noise_shaping_TMPL(), synth_lpc(), synth_tones(), synth_window(), synthfilt_build_sb_samples(), transform_channel(), try_push_frame(), update_frame_pool(), video_audio_display(), vorbis_decode_frame(), vorbis_parse_audio_packet(), vorbis_residue_decode_internal(), wma_decode_block(), wma_decode_frame(), write_block_data(), write_chapter(), write_char(), write_decoding_params(), write_frame(), write_restart_header(), write_subframes(), and write_trailer().

uint8_t pi<<24)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t*)pi-0x80U))<<56)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_U8,(*(constuint8_t*)pi-0x80)*(1.0f/(1<<7)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_U8,(*(constuint8_t*)pi-0x80)*(1.0/(1<<7)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S16,(*(constint16_t*)pi>>8)+0x80)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t*)pi)<<48)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S16,*(constint16_t*)pi*(1.0f/(1<<15)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S16,*(constint16_t*)pi*(1.0/(1<<15)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S32,(*(constint32_t*)pi>>24)+0x80)CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t*)pi)<<32)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S32,*(constint32_t*)pi*(1.0f/(1U<<31)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S32,*(constint32_t*)pi*(1.0/(1U<<31)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_S64,(*(constint64_t*)pi>>56)+0x80)CONV_FUNC(AV_SAMPLE_FMT_FLT,float,AV_SAMPLE_FMT_S64,*(constint64_t*)pi*(1.0f/(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_DBL,double,AV_SAMPLE_FMT_S64,*(constint64_t*)pi*(1.0/(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_FLT,av_clip_uint8(lrintf(*(constfloat*)pi*(1<<7))+0x80))CONV_FUNC(AV_SAMPLE_FMT_S16,int16_t,AV_SAMPLE_FMT_FLT,av_clip_int16(lrintf(*(constfloat*)pi*(1<<15))))CONV_FUNC(AV_SAMPLE_FMT_S32,int32_t,AV_SAMPLE_FMT_FLT,av_clipl_int32(llrintf(*(constfloat*)pi*(1U<<31))))CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_FLT,llrintf(*(constfloat*)pi*(INT64_C(1)<<63)))CONV_FUNC(AV_SAMPLE_FMT_U8,uint8_t,AV_SAMPLE_FMT_DBL,av_clip_uint8(lrint(*(constdouble*)pi*(1<<7))+0x80))CONV_FUNC(AV_SAMPLE_FMT_S16,int16_t,AV_SAMPLE_FMT_DBL,av_clip_int16(lrint(*(constdouble*)pi*(1<<15))))CONV_FUNC(AV_SAMPLE_FMT_S32,int32_t,AV_SAMPLE_FMT_DBL,av_clipl_int32(llrint(*(constdouble*)pi*(1U<<31))))CONV_FUNC(AV_SAMPLE_FMT_S64,int64_t,AV_SAMPLE_FMT_DBL,llrint(*(constdou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PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_FLT),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE_FMT_FLT),FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_FLT),FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL,AV_SAMPLE_FMT_FLT),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64,AV_SAMPLE_FMT_FLT),FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64,AV_SAMPLE_FMT_DBL),FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL,AV_SAMPLE_FMT_S64),FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64,AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,len);}staticvoidcpy2(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,2*len);}staticvoidcpy4(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,4*len);}staticvoidcpy8(uint8_t**dst,constuint8_t**src,intlen){memcpy(*dst,*src,8*len);}AudioConvert*swri_audio_convert_alloc(enumAVSampleFormatout_fmt,enumAVSampleFormatin_fmt,intchannels,constint*ch_map,intflags){AudioConvert*ctx;conv_func_type*f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB*av_get_packed_sample_fmt(in_fmt)];if(!f)returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx)returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P)memset(ctx->silence,0x80,sizeof(ctx->silence));if(out_fmt==in_fmt&&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM&&1)swri_audio_convert_init_x86(ctx,out_fmt,in_fmt,channels);if(ARCH_ARM)swri_audio_convert_init_arm(ctx,out_fmt,in_fmt,channels);if(ARCH_AARCH64)swri_audio_convert_init_aarch64(ctx,out_fmt,in_fmt,channels);returnctx;}voidswri_audio_convert_free(AudioConvert**ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert*ctx,AudioData*out,AudioData*in,intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch<planes;ch++)m|=(intptr_t)in->ch[ch];misaligned|=m&ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch<planes;ch++)m|=(intptr_t)out->ch[ch];misaligned|=m&ctx->out_simd_align_mask;}if(ctx->simd_f&&!ctx->ch_map&&!misaligned){off=len&~15;av_assert1(off>=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off>0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch<planes;ch++){ctx->simd_f(out-> ch const uint8_t** in ch off* out planar
else
Initial value:
{
ctx->simd_f(out->ch, (const uint8_t **)in->ch, off)
uint8_t
AVFormatContext * ctx
Definition: movenc.c:48
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
FILE * out
Definition: movenc.c:54

Definition at line 228 of file audioconvert.c.

return

Definition at line 246 of file audioconvert.c.