AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL; ctx = av_mallocz(sizeof(*ctx)); if (!ctx) return NULL; ctx->channels = channels; ctx->conv_f = f; ctx->ch_map = ch_map; if (in_fmt == AV_SAMPLE_FMT_U8) memset(ctx->silence, 0x80, sizeof(ctx->silence)); if(out_fmt == in_fmt && !ch_map) ctx->simd_f = cpy; if(HAVE_YASM && HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels); return ctx; }
AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL; ctx = av_mallocz(sizeof(*ctx)); if (!ctx) return NULL; 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)){ case 1:ctx->simd_f = cpy1; break; case 2:ctx->simd_f = cpy2; break; case 4:ctx->simd_f = cpy4; break; case 8:ctx->simd_f = cpy8; break; } } #if (HAVE_YASM == 1) && (HAVE_MMX == 1) if(HAVE_YASM && HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels); #endif #if (ARCH_ARM == 1) if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels); #endif #if (ARCH_AARCH64 == 1) if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels); #endif return ctx; }