63 const int16_t *consts,
77 t1[
i >> 1] +=
in[hop +
i] * consts[hop +
i];
83 memset(
t1, 0,
sizeof(
t1));
95 const int16_t *consts)
101 const int16_t *consts)
166 int nsamples,
int nchannels)
171 if (position < nsamples) {
172 for (
c = 0;
c < nchannels;
c++)
174 36 *
sizeof(int16_t));
179 for (; nsamples >= 8; nsamples -= 8, pcm += 16 * nchannels) {
181 for (
c = 0;
c < nchannels;
c++) {
182 int16_t *x = &
X[
c][position];
183 x[0] =
AV_RN16(pcm + 14*nchannels + 2*
c);
184 x[1] =
AV_RN16(pcm + 6*nchannels + 2*
c);
185 x[2] =
AV_RN16(pcm + 12*nchannels + 2*
c);
186 x[3] =
AV_RN16(pcm + 8*nchannels + 2*
c);
187 x[4] =
AV_RN16(pcm + 0*nchannels + 2*
c);
188 x[5] =
AV_RN16(pcm + 4*nchannels + 2*
c);
189 x[6] =
AV_RN16(pcm + 2*nchannels + 2*
c);
190 x[7] =
AV_RN16(pcm + 10*nchannels + 2*
c);
199 int nsamples,
int nchannels)
204 if (position < nsamples) {
205 for (
c = 0;
c < nchannels;
c++)
207 72 *
sizeof(int16_t));
211 if (position % 16 == 8) {
214 for (
c = 0;
c < nchannels;
c++) {
215 int16_t *x = &
X[
c][position];
216 x[0] =
AV_RN16(pcm + 14*nchannels + 2*
c);
217 x[2] =
AV_RN16(pcm + 12*nchannels + 2*
c);
218 x[3] =
AV_RN16(pcm + 0*nchannels + 2*
c);
219 x[4] =
AV_RN16(pcm + 10*nchannels + 2*
c);
220 x[5] =
AV_RN16(pcm + 2*nchannels + 2*
c);
221 x[6] =
AV_RN16(pcm + 8*nchannels + 2*
c);
222 x[7] =
AV_RN16(pcm + 4*nchannels + 2*
c);
223 x[8] =
AV_RN16(pcm + 6*nchannels + 2*
c);
225 pcm += 16 * nchannels;
229 for (; nsamples >= 16; nsamples -= 16, pcm += 32 * nchannels) {
231 for (
c = 0;
c < nchannels;
c++) {
232 int16_t *x = &
X[
c][position];
233 x[0] =
AV_RN16(pcm + 30*nchannels + 2*
c);
234 x[1] =
AV_RN16(pcm + 14*nchannels + 2*
c);
235 x[2] =
AV_RN16(pcm + 28*nchannels + 2*
c);
236 x[3] =
AV_RN16(pcm + 16*nchannels + 2*
c);
237 x[4] =
AV_RN16(pcm + 26*nchannels + 2*
c);
238 x[5] =
AV_RN16(pcm + 18*nchannels + 2*
c);
239 x[6] =
AV_RN16(pcm + 24*nchannels + 2*
c);
240 x[7] =
AV_RN16(pcm + 20*nchannels + 2*
c);
241 x[8] =
AV_RN16(pcm + 22*nchannels + 2*
c);
242 x[9] =
AV_RN16(pcm + 6*nchannels + 2*
c);
243 x[10] =
AV_RN16(pcm + 12*nchannels + 2*
c);
244 x[11] =
AV_RN16(pcm + 0*nchannels + 2*
c);
245 x[12] =
AV_RN16(pcm + 10*nchannels + 2*
c);
246 x[13] =
AV_RN16(pcm + 2*nchannels + 2*
c);
247 x[14] =
AV_RN16(pcm + 8*nchannels + 2*
c);
248 x[15] =
AV_RN16(pcm + 4*nchannels + 2*
c);
254 for (
c = 0;
c < nchannels;
c++) {
255 int16_t *x = &
X[
c][position];
256 x[-7] =
AV_RN16(pcm + 14*nchannels + 2*
c);
257 x[1] =
AV_RN16(pcm + 6*nchannels + 2*
c);
258 x[2] =
AV_RN16(pcm + 12*nchannels + 2*
c);
259 x[3] =
AV_RN16(pcm + 0*nchannels + 2*
c);
260 x[4] =
AV_RN16(pcm + 10*nchannels + 2*
c);
261 x[5] =
AV_RN16(pcm + 2*nchannels + 2*
c);
262 x[6] =
AV_RN16(pcm + 8*nchannels + 2*
c);
263 x[7] =
AV_RN16(pcm + 4*nchannels + 2*
c);
271 uint32_t scale_factor[2][8],
289 uint32_t scale_factor[2][8],
301 tmp0 =
FFABS(sb_sample_f[
blk][0][sb]);
302 tmp1 =
FFABS(sb_sample_f[
blk][1][sb]);
317 tmp0 = sb_sample_f[
blk][0][sb];
318 tmp1 = sb_sample_f[
blk][1][sb];
319 sb_sample_j[
blk][0] = (tmp0 >> 1) + (tmp1 >> 1);
320 sb_sample_j[
blk][1] = (tmp0 >> 1) - (tmp1 >> 1);
346 if ((scale_factor[0][sb] + scale_factor[1][sb]) > x + y) {
348 scale_factor[0][sb] = x;
349 scale_factor[1][sb] = y;
351 sb_sample_f[
blk][0][sb] = sb_sample_j[
blk][0];
352 sb_sample_f[
blk][1][sb] = sb_sample_j[
blk][1];
370 if (
s->increment == 1)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
SBC common definitions for the encoder and decoder.
static int sbc_calc_scalefactors_j(int32_t sb_sample_f[16][2][8], uint32_t scale_factor[2][8], int blocks, int subbands)
static void sbc_analyze_4_simd(const int16_t *in, int32_t *out, const int16_t *consts)
static int sbc_enc_process_input_4s(int position, const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE], int nsamples, int nchannels)
static void sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], uint32_t scale_factor[2][8], int blocks, int channels, int subbands)
static int sbc_enc_process_input_8s(int position, const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE], int nsamples, int nchannels)
static av_always_inline void sbc_analyze_simd(const int16_t *in, int32_t *out, const int16_t *consts, unsigned subbands)
static void sbc_analyze_4b_8s_simd(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
av_cold void ff_sbcdsp_init(SBCDSPContext *s)
static void sbc_analyze_8_simd(const int16_t *in, int32_t *out, const int16_t *consts)
static void sbc_analyze_4b_4s_simd(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
static void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
static void sbc_analyze_1b_8s_simd_odd(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
SBC basic "building bricks".
#define SBC_X_BUFFER_SIZE
void ff_sbcdsp_init_x86(SBCDSPContext *s)
const int16_t ff_sbcdsp_analysis_consts_fixed4_simd_even[40+16]
const int16_t ff_sbcdsp_analysis_consts_fixed8_simd_even[80+64]
const int16_t ff_sbcdsp_analysis_consts_fixed4_simd_odd[40+16]
const int16_t ff_sbcdsp_analysis_consts_fixed8_simd_odd[80+64]
#define SBC_COS_TABLE_FIXED_SCALE
#define SBC_PROTO_FIXED_SCALE
av_cold void ff_sbcdsp_init_arm(SBCDSPContext *s)