60 static void ff_acelp_interpolatef_mips(
float *
out,
const float *
in,
61 const float *filter_coeffs,
int precision,
62 int frac_pos,
int filter_length,
int length)
65 int prec = precision * 4;
66 int fc_offset = precision - frac_pos;
67 float in_val_p, in_val_m, fc_val_p, fc_val_m;
69 for (n = 0; n <
length; n++) {
74 const float *p_in_p = &in[
n];
75 const float *p_in_m = &in[n-1];
76 const float *p_filter_coeffs_p = &filter_coeffs[frac_pos];
77 const float *p_filter_coeffs_m = filter_coeffs + fc_offset;
80 for (i = 0; i < filter_length;i++) {
82 "lwc1 %[in_val_p], 0(%[p_in_p]) \n\t"
83 "lwc1 %[fc_val_p], 0(%[p_filter_coeffs_p]) \n\t"
84 "lwc1 %[in_val_m], 0(%[p_in_m]) \n\t"
85 "lwc1 %[fc_val_m], 0(%[p_filter_coeffs_m]) \n\t"
87 "madd.s %[v],%[v], %[in_val_p],%[fc_val_p] \n\t"
89 PTR_ADDU "%[p_filter_coeffs_p],%[p_filter_coeffs_p], %[prec] \n\t"
90 PTR_ADDU "%[p_filter_coeffs_m],%[p_filter_coeffs_m], %[prec] \n\t"
91 "madd.s %[v],%[v],%[in_val_m], %[fc_val_m] \n\t"
93 : [
v]
"+&f" (
v),[p_in_p]
"+r" (p_in_p), [p_in_m]
"+r" (p_in_m),
94 [p_filter_coeffs_p]
"+r" (p_filter_coeffs_p),
95 [in_val_p]
"=&f" (in_val_p), [in_val_m]
"=&f" (in_val_m),
96 [fc_val_p]
"=&f" (fc_val_p), [fc_val_m]
"=&f" (fc_val_m),
97 [p_filter_coeffs_m]
"+r" (p_filter_coeffs_m)
106 static void ff_acelp_apply_order_2_transfer_function_mips(
float *out,
const float *in,
107 const float zero_coeffs[2],
108 const float pole_coeffs[2],
109 float gain,
float mem[2],
int n)
116 "lwc1 $f0, 0(%[mem]) \n\t"
117 "blez %[n], ff_acelp_apply_order_2_transfer_function_end%= \n\t"
118 "lwc1 $f1, 4(%[mem]) \n\t"
119 "lwc1 $f2, 0(%[pole_coeffs]) \n\t"
120 "lwc1 $f3, 4(%[pole_coeffs]) \n\t"
121 "lwc1 $f4, 0(%[zero_coeffs]) \n\t"
122 "lwc1 $f5, 4(%[zero_coeffs]) \n\t"
124 "ff_acelp_apply_order_2_transfer_function_madd%=: \n\t"
126 "lwc1 $f6, 0(%[in]) \n\t"
127 "mul.s $f9, $f3, $f1 \n\t"
128 "mul.s $f7, $f2, $f0 \n\t"
129 "msub.s $f7, $f7, %[gain], $f6 \n\t"
130 "sub.s $f7, $f7, $f9 \n\t"
131 "madd.s $f8, $f7, $f4, $f0 \n\t"
132 "madd.s $f8, $f8, $f5, $f1 \n\t"
133 "lwc1 $f11, 4(%[in]) \n\t"
134 "mul.s $f12, $f3, $f0 \n\t"
135 "mul.s $f13, $f2, $f7 \n\t"
136 "msub.s $f13, $f13, %[gain], $f11 \n\t"
137 "sub.s $f13, $f13, $f12 \n\t"
138 "madd.s $f14, $f13, $f4, $f7 \n\t"
139 "madd.s $f14, $f14, $f5, $f0 \n\t"
140 "swc1 $f8, 0(%[out]) \n\t"
141 "lwc1 $f6, 8(%[in]) \n\t"
142 "mul.s $f9, $f3, $f7 \n\t"
143 "mul.s $f15, $f2, $f13 \n\t"
144 "msub.s $f15, $f15, %[gain], $f6 \n\t"
145 "sub.s $f15, $f15, $f9 \n\t"
146 "madd.s $f8, $f15, $f4, $f13 \n\t"
147 "madd.s $f8, $f8, $f5, $f7 \n\t"
148 "swc1 $f14, 4(%[out]) \n\t"
149 "lwc1 $f11, 12(%[in]) \n\t"
150 "mul.s $f12, $f3, $f13 \n\t"
151 "mul.s $f16, $f2, $f15 \n\t"
152 "msub.s $f16, $f16, %[gain], $f11 \n\t"
153 "sub.s $f16, $f16, $f12 \n\t"
154 "madd.s $f14, $f16, $f4, $f15 \n\t"
155 "madd.s $f14, $f14, $f5, $f13 \n\t"
156 "swc1 $f8, 8(%[out]) \n\t"
157 "lwc1 $f6, 16(%[in]) \n\t"
158 "mul.s $f9, $f3, $f15 \n\t"
159 "mul.s $f7, $f2, $f16 \n\t"
160 "msub.s $f7, $f7, %[gain], $f6 \n\t"
161 "sub.s $f7, $f7, $f9 \n\t"
162 "madd.s $f8, $f7, $f4, $f16 \n\t"
163 "madd.s $f8, $f8, $f5, $f15 \n\t"
164 "swc1 $f14, 12(%[out]) \n\t"
165 "lwc1 $f11, 20(%[in]) \n\t"
166 "mul.s $f12, $f3, $f16 \n\t"
167 "mul.s $f13, $f2, $f7 \n\t"
168 "msub.s $f13, $f13, %[gain], $f11 \n\t"
169 "sub.s $f13, $f13, $f12 \n\t"
170 "madd.s $f14, $f13, $f4, $f7 \n\t"
171 "madd.s $f14, $f14, $f5, $f16 \n\t"
172 "swc1 $f8, 16(%[out]) \n\t"
173 "lwc1 $f6, 24(%[in]) \n\t"
174 "mul.s $f9, $f3, $f7 \n\t"
175 "mul.s $f15, $f2, $f13 \n\t"
176 "msub.s $f15, $f15, %[gain], $f6 \n\t"
177 "sub.s $f1, $f15, $f9 \n\t"
178 "madd.s $f8, $f1, $f4, $f13 \n\t"
179 "madd.s $f8, $f8, $f5, $f7 \n\t"
180 "swc1 $f14, 20(%[out]) \n\t"
181 "lwc1 $f11, 28(%[in]) \n\t"
182 "mul.s $f12, $f3, $f13 \n\t"
183 "mul.s $f16, $f2, $f1 \n\t"
184 "msub.s $f16, $f16, %[gain], $f11 \n\t"
185 "sub.s $f0, $f16, $f12 \n\t"
186 "madd.s $f14, $f0, $f4, $f1 \n\t"
187 "madd.s $f14, $f14, $f5, $f13 \n\t"
188 "swc1 $f8, 24(%[out]) \n\t"
191 "addiu %[n], -8 \n\t"
192 "swc1 $f14, -4(%[out]) \n\t"
193 "bnez %[n], ff_acelp_apply_order_2_transfer_function_madd%= \n\t"
194 "swc1 $f1, 4(%[mem]) \n\t"
195 "swc1 $f0, 0(%[mem]) \n\t"
197 "ff_acelp_apply_order_2_transfer_function_end%=: \n\t"
200 [in]
"+r" (in), [gain]
"+f" (gain),
201 [n]
"+r" (n), [
mem]
"+r" (
mem)
202 : [zero_coeffs]
"r" (zero_coeffs),
203 [pole_coeffs]
"r" (pole_coeffs)
204 :
"$f0",
"$f1",
"$f2",
"$f3",
"$f4",
"$f5",
205 "$f6",
"$f7",
"$f8",
"$f9",
"$f10",
"$f11",
206 "$f12",
"$f13",
"$f14",
"$f15",
"$f16",
"memory"
MIPS assembly defines from sys/asm.h but rewritten for use with C inline assembly (rather than from w...
void(* acelp_apply_order_2_transfer_function)(float *out, const float *in, const float zero_coeffs[2], const float pole_coeffs[2], float gain, float mem[2], int n)
Apply an order 2 rational transfer function in-place.
Macro definitions for various function/variable attributes.
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
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-> out
void ff_acelp_filter_init_mips(ACELPFContext *c)
void(* acelp_interpolatef)(float *out, const float *in, const float *filter_coeffs, int precision, int frac_pos, int filter_length, int length)
Floating point version of ff_acelp_interpolate()