blob: 245bfdfda8e046ffb0d7d23478c0e21210e2c662 [file] [log] [blame]
Mathias Agopian65ab4712010-07-14 17:59:35 -07001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "AudioResampler"
18//#define LOG_NDEBUG 0
19
20#include <stdint.h>
21#include <stdlib.h>
22#include <sys/types.h>
23#include <cutils/log.h>
24#include <cutils/properties.h>
25#include "AudioResampler.h"
26#include "AudioResamplerSinc.h"
27#include "AudioResamplerCubic.h"
28
Jim Huang0c0a1c02011-04-06 14:19:29 +080029#ifdef __arm__
30#include <machine/cpu-features.h>
31#endif
32
Mathias Agopian65ab4712010-07-14 17:59:35 -070033namespace android {
34
Jim Huang0c0a1c02011-04-06 14:19:29 +080035#ifdef __ARM_HAVE_HALFWORD_MULTIPLY // optimized asm option
Mathias Agopian65ab4712010-07-14 17:59:35 -070036 #define ASM_ARM_RESAMP1 // enable asm optimisation for ResamplerOrder1
Jim Huang0c0a1c02011-04-06 14:19:29 +080037#endif // __ARM_HAVE_HALFWORD_MULTIPLY
Mathias Agopian65ab4712010-07-14 17:59:35 -070038// ----------------------------------------------------------------------------
39
40class AudioResamplerOrder1 : public AudioResampler {
41public:
42 AudioResamplerOrder1(int bitDepth, int inChannelCount, int32_t sampleRate) :
43 AudioResampler(bitDepth, inChannelCount, sampleRate), mX0L(0), mX0R(0) {
44 }
45 virtual void resample(int32_t* out, size_t outFrameCount,
46 AudioBufferProvider* provider);
47private:
48 // number of bits used in interpolation multiply - 15 bits avoids overflow
49 static const int kNumInterpBits = 15;
50
51 // bits to shift the phase fraction down to avoid overflow
52 static const int kPreInterpShift = kNumPhaseBits - kNumInterpBits;
53
54 void init() {}
55 void resampleMono16(int32_t* out, size_t outFrameCount,
56 AudioBufferProvider* provider);
57 void resampleStereo16(int32_t* out, size_t outFrameCount,
58 AudioBufferProvider* provider);
59#ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1
60 void AsmMono16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
61 size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
62 uint32_t &phaseFraction, uint32_t phaseIncrement);
63 void AsmStereo16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
64 size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
65 uint32_t &phaseFraction, uint32_t phaseIncrement);
66#endif // ASM_ARM_RESAMP1
67
68 static inline int32_t Interp(int32_t x0, int32_t x1, uint32_t f) {
69 return x0 + (((x1 - x0) * (int32_t)(f >> kPreInterpShift)) >> kNumInterpBits);
70 }
71 static inline void Advance(size_t* index, uint32_t* frac, uint32_t inc) {
72 *frac += inc;
73 *index += (size_t)(*frac >> kNumPhaseBits);
74 *frac &= kPhaseMask;
75 }
76 int mX0L;
77 int mX0R;
78};
79
80// ----------------------------------------------------------------------------
81AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
82 int32_t sampleRate, int quality) {
83
84 // can only create low quality resample now
85 AudioResampler* resampler;
86
87 char value[PROPERTY_VALUE_MAX];
88 if (property_get("af.resampler.quality", value, 0)) {
89 quality = atoi(value);
90 LOGD("forcing AudioResampler quality to %d", quality);
91 }
92
93 if (quality == DEFAULT)
94 quality = LOW_QUALITY;
95
96 switch (quality) {
97 default:
98 case LOW_QUALITY:
99 LOGV("Create linear Resampler");
100 resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate);
101 break;
102 case MED_QUALITY:
103 LOGV("Create cubic Resampler");
104 resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate);
105 break;
106 case HIGH_QUALITY:
107 LOGV("Create sinc Resampler");
108 resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate);
109 break;
110 }
111
112 // initialize resampler
113 resampler->init();
114 return resampler;
115}
116
117AudioResampler::AudioResampler(int bitDepth, int inChannelCount,
118 int32_t sampleRate) :
119 mBitDepth(bitDepth), mChannelCount(inChannelCount),
120 mSampleRate(sampleRate), mInSampleRate(sampleRate), mInputIndex(0),
121 mPhaseFraction(0) {
122 // sanity check on format
123 if ((bitDepth != 16) ||(inChannelCount < 1) || (inChannelCount > 2)) {
124 LOGE("Unsupported sample format, %d bits, %d channels", bitDepth,
125 inChannelCount);
126 // LOG_ASSERT(0);
127 }
128
129 // initialize common members
130 mVolume[0] = mVolume[1] = 0;
131 mBuffer.frameCount = 0;
132
133 // save format for quick lookup
134 if (inChannelCount == 1) {
135 mFormat = MONO_16_BIT;
136 } else {
137 mFormat = STEREO_16_BIT;
138 }
139}
140
141AudioResampler::~AudioResampler() {
142}
143
144void AudioResampler::setSampleRate(int32_t inSampleRate) {
145 mInSampleRate = inSampleRate;
146 mPhaseIncrement = (uint32_t)((kPhaseMultiplier * inSampleRate) / mSampleRate);
147}
148
149void AudioResampler::setVolume(int16_t left, int16_t right) {
150 // TODO: Implement anti-zipper filter
151 mVolume[0] = left;
152 mVolume[1] = right;
153}
154
155// ----------------------------------------------------------------------------
156
157void AudioResamplerOrder1::resample(int32_t* out, size_t outFrameCount,
158 AudioBufferProvider* provider) {
159
160 // should never happen, but we overflow if it does
161 // LOG_ASSERT(outFrameCount < 32767);
162
163 // select the appropriate resampler
164 switch (mChannelCount) {
165 case 1:
166 resampleMono16(out, outFrameCount, provider);
167 break;
168 case 2:
169 resampleStereo16(out, outFrameCount, provider);
170 break;
171 }
172}
173
174void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount,
175 AudioBufferProvider* provider) {
176
177 int32_t vl = mVolume[0];
178 int32_t vr = mVolume[1];
179
180 size_t inputIndex = mInputIndex;
181 uint32_t phaseFraction = mPhaseFraction;
182 uint32_t phaseIncrement = mPhaseIncrement;
183 size_t outputIndex = 0;
184 size_t outputSampleCount = outFrameCount * 2;
185 size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate;
186
187 // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
188 // outFrameCount, inputIndex, phaseFraction, phaseIncrement);
189
190 while (outputIndex < outputSampleCount) {
191
192 // buffer is empty, fetch a new one
193 while (mBuffer.frameCount == 0) {
194 mBuffer.frameCount = inFrameCount;
195 provider->getNextBuffer(&mBuffer);
196 if (mBuffer.raw == NULL) {
197 goto resampleStereo16_exit;
198 }
199
200 // LOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
201 if (mBuffer.frameCount > inputIndex) break;
202
203 inputIndex -= mBuffer.frameCount;
204 mX0L = mBuffer.i16[mBuffer.frameCount*2-2];
205 mX0R = mBuffer.i16[mBuffer.frameCount*2-1];
206 provider->releaseBuffer(&mBuffer);
207 // mBuffer.frameCount == 0 now so we reload a new buffer
208 }
209
210 int16_t *in = mBuffer.i16;
211
212 // handle boundary case
213 while (inputIndex == 0) {
214 // LOGE("boundary case\n");
215 out[outputIndex++] += vl * Interp(mX0L, in[0], phaseFraction);
216 out[outputIndex++] += vr * Interp(mX0R, in[1], phaseFraction);
217 Advance(&inputIndex, &phaseFraction, phaseIncrement);
218 if (outputIndex == outputSampleCount)
219 break;
220 }
221
222 // process input samples
223 // LOGE("general case\n");
224
225#ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1
226 if (inputIndex + 2 < mBuffer.frameCount) {
227 int32_t* maxOutPt;
228 int32_t maxInIdx;
229
230 maxOutPt = out + (outputSampleCount - 2); // 2 because 2 frames per loop
231 maxInIdx = mBuffer.frameCount - 2;
232 AsmStereo16Loop(in, maxOutPt, maxInIdx, outputIndex, out, inputIndex, vl, vr,
233 phaseFraction, phaseIncrement);
234 }
235#endif // ASM_ARM_RESAMP1
236
237 while (outputIndex < outputSampleCount && inputIndex < mBuffer.frameCount) {
238 out[outputIndex++] += vl * Interp(in[inputIndex*2-2],
239 in[inputIndex*2], phaseFraction);
240 out[outputIndex++] += vr * Interp(in[inputIndex*2-1],
241 in[inputIndex*2+1], phaseFraction);
242 Advance(&inputIndex, &phaseFraction, phaseIncrement);
243 }
244
245 // LOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
246
247 // if done with buffer, save samples
248 if (inputIndex >= mBuffer.frameCount) {
249 inputIndex -= mBuffer.frameCount;
250
251 // LOGE("buffer done, new input index %d", inputIndex);
252
253 mX0L = mBuffer.i16[mBuffer.frameCount*2-2];
254 mX0R = mBuffer.i16[mBuffer.frameCount*2-1];
255 provider->releaseBuffer(&mBuffer);
256
257 // verify that the releaseBuffer resets the buffer frameCount
258 // LOG_ASSERT(mBuffer.frameCount == 0);
259 }
260 }
261
262 // LOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
263
264resampleStereo16_exit:
265 // save state
266 mInputIndex = inputIndex;
267 mPhaseFraction = phaseFraction;
268}
269
270void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount,
271 AudioBufferProvider* provider) {
272
273 int32_t vl = mVolume[0];
274 int32_t vr = mVolume[1];
275
276 size_t inputIndex = mInputIndex;
277 uint32_t phaseFraction = mPhaseFraction;
278 uint32_t phaseIncrement = mPhaseIncrement;
279 size_t outputIndex = 0;
280 size_t outputSampleCount = outFrameCount * 2;
281 size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate;
282
283 // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
284 // outFrameCount, inputIndex, phaseFraction, phaseIncrement);
285 while (outputIndex < outputSampleCount) {
286 // buffer is empty, fetch a new one
287 while (mBuffer.frameCount == 0) {
288 mBuffer.frameCount = inFrameCount;
289 provider->getNextBuffer(&mBuffer);
290 if (mBuffer.raw == NULL) {
291 mInputIndex = inputIndex;
292 mPhaseFraction = phaseFraction;
293 goto resampleMono16_exit;
294 }
295 // LOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
296 if (mBuffer.frameCount > inputIndex) break;
297
298 inputIndex -= mBuffer.frameCount;
299 mX0L = mBuffer.i16[mBuffer.frameCount-1];
300 provider->releaseBuffer(&mBuffer);
301 // mBuffer.frameCount == 0 now so we reload a new buffer
302 }
303 int16_t *in = mBuffer.i16;
304
305 // handle boundary case
306 while (inputIndex == 0) {
307 // LOGE("boundary case\n");
308 int32_t sample = Interp(mX0L, in[0], phaseFraction);
309 out[outputIndex++] += vl * sample;
310 out[outputIndex++] += vr * sample;
311 Advance(&inputIndex, &phaseFraction, phaseIncrement);
312 if (outputIndex == outputSampleCount)
313 break;
314 }
315
316 // process input samples
317 // LOGE("general case\n");
318
319#ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1
320 if (inputIndex + 2 < mBuffer.frameCount) {
321 int32_t* maxOutPt;
322 int32_t maxInIdx;
323
324 maxOutPt = out + (outputSampleCount - 2);
325 maxInIdx = (int32_t)mBuffer.frameCount - 2;
326 AsmMono16Loop(in, maxOutPt, maxInIdx, outputIndex, out, inputIndex, vl, vr,
327 phaseFraction, phaseIncrement);
328 }
329#endif // ASM_ARM_RESAMP1
330
331 while (outputIndex < outputSampleCount && inputIndex < mBuffer.frameCount) {
332 int32_t sample = Interp(in[inputIndex-1], in[inputIndex],
333 phaseFraction);
334 out[outputIndex++] += vl * sample;
335 out[outputIndex++] += vr * sample;
336 Advance(&inputIndex, &phaseFraction, phaseIncrement);
337 }
338
339
340 // LOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
341
342 // if done with buffer, save samples
343 if (inputIndex >= mBuffer.frameCount) {
344 inputIndex -= mBuffer.frameCount;
345
346 // LOGE("buffer done, new input index %d", inputIndex);
347
348 mX0L = mBuffer.i16[mBuffer.frameCount-1];
349 provider->releaseBuffer(&mBuffer);
350
351 // verify that the releaseBuffer resets the buffer frameCount
352 // LOG_ASSERT(mBuffer.frameCount == 0);
353 }
354 }
355
356 // LOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
357
358resampleMono16_exit:
359 // save state
360 mInputIndex = inputIndex;
361 mPhaseFraction = phaseFraction;
362}
363
364#ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1
365
366/*******************************************************************
367*
368* AsmMono16Loop
369* asm optimized monotonic loop version; one loop is 2 frames
370* Input:
371* in : pointer on input samples
372* maxOutPt : pointer on first not filled
373* maxInIdx : index on first not used
374* outputIndex : pointer on current output index
375* out : pointer on output buffer
376* inputIndex : pointer on current input index
377* vl, vr : left and right gain
378* phaseFraction : pointer on current phase fraction
379* phaseIncrement
380* Ouput:
381* outputIndex :
382* out : updated buffer
383* inputIndex : index of next to use
384* phaseFraction : phase fraction for next interpolation
385*
386*******************************************************************/
387void AudioResamplerOrder1::AsmMono16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
388 size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
389 uint32_t &phaseFraction, uint32_t phaseIncrement)
390{
391#define MO_PARAM5 "36" // offset of parameter 5 (outputIndex)
392
393 asm(
394 "stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n"
395 // get parameters
396 " ldr r6, [sp, #" MO_PARAM5 " + 20]\n" // &phaseFraction
397 " ldr r6, [r6]\n" // phaseFraction
398 " ldr r7, [sp, #" MO_PARAM5 " + 8]\n" // &inputIndex
399 " ldr r7, [r7]\n" // inputIndex
400 " ldr r8, [sp, #" MO_PARAM5 " + 4]\n" // out
401 " ldr r0, [sp, #" MO_PARAM5 " + 0]\n" // &outputIndex
402 " ldr r0, [r0]\n" // outputIndex
403 " add r8, r0, asl #2\n" // curOut
404 " ldr r9, [sp, #" MO_PARAM5 " + 24]\n" // phaseIncrement
405 " ldr r10, [sp, #" MO_PARAM5 " + 12]\n" // vl
406 " ldr r11, [sp, #" MO_PARAM5 " + 16]\n" // vr
407
408 // r0 pin, x0, Samp
409
410 // r1 in
411 // r2 maxOutPt
412 // r3 maxInIdx
413
414 // r4 x1, i1, i3, Out1
415 // r5 out0
416
417 // r6 frac
418 // r7 inputIndex
419 // r8 curOut
420
421 // r9 inc
422 // r10 vl
423 // r11 vr
424
425 // r12
426 // r13 sp
427 // r14
428
429 // the following loop works on 2 frames
430
431 ".Y4L01:\n"
432 " cmp r8, r2\n" // curOut - maxCurOut
433 " bcs .Y4L02\n"
434
435#define MO_ONE_FRAME \
436 " add r0, r1, r7, asl #1\n" /* in + inputIndex */\
437 " ldrsh r4, [r0]\n" /* in[inputIndex] */\
438 " ldr r5, [r8]\n" /* out[outputIndex] */\
439 " ldrsh r0, [r0, #-2]\n" /* in[inputIndex-1] */\
440 " bic r6, r6, #0xC0000000\n" /* phaseFraction & ... */\
441 " sub r4, r4, r0\n" /* in[inputIndex] - in[inputIndex-1] */\
442 " mov r4, r4, lsl #2\n" /* <<2 */\
443 " smulwt r4, r4, r6\n" /* (x1-x0)*.. */\
444 " add r6, r6, r9\n" /* phaseFraction + phaseIncrement */\
445 " add r0, r0, r4\n" /* x0 - (..) */\
446 " mla r5, r0, r10, r5\n" /* vl*interp + out[] */\
447 " ldr r4, [r8, #4]\n" /* out[outputIndex+1] */\
448 " str r5, [r8], #4\n" /* out[outputIndex++] = ... */\
449 " mla r4, r0, r11, r4\n" /* vr*interp + out[] */\
450 " add r7, r7, r6, lsr #30\n" /* inputIndex + phaseFraction>>30 */\
451 " str r4, [r8], #4\n" /* out[outputIndex++] = ... */
452
453 MO_ONE_FRAME // frame 1
454 MO_ONE_FRAME // frame 2
455
456 " cmp r7, r3\n" // inputIndex - maxInIdx
457 " bcc .Y4L01\n"
458 ".Y4L02:\n"
459
460 " bic r6, r6, #0xC0000000\n" // phaseFraction & ...
461 // save modified values
462 " ldr r0, [sp, #" MO_PARAM5 " + 20]\n" // &phaseFraction
463 " str r6, [r0]\n" // phaseFraction
464 " ldr r0, [sp, #" MO_PARAM5 " + 8]\n" // &inputIndex
465 " str r7, [r0]\n" // inputIndex
466 " ldr r0, [sp, #" MO_PARAM5 " + 4]\n" // out
467 " sub r8, r0\n" // curOut - out
468 " asr r8, #2\n" // new outputIndex
469 " ldr r0, [sp, #" MO_PARAM5 " + 0]\n" // &outputIndex
470 " str r8, [r0]\n" // save outputIndex
471
472 " ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc}\n"
473 );
474}
475
476/*******************************************************************
477*
478* AsmStereo16Loop
479* asm optimized stereo loop version; one loop is 2 frames
480* Input:
481* in : pointer on input samples
482* maxOutPt : pointer on first not filled
483* maxInIdx : index on first not used
484* outputIndex : pointer on current output index
485* out : pointer on output buffer
486* inputIndex : pointer on current input index
487* vl, vr : left and right gain
488* phaseFraction : pointer on current phase fraction
489* phaseIncrement
490* Ouput:
491* outputIndex :
492* out : updated buffer
493* inputIndex : index of next to use
494* phaseFraction : phase fraction for next interpolation
495*
496*******************************************************************/
497void AudioResamplerOrder1::AsmStereo16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
498 size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
499 uint32_t &phaseFraction, uint32_t phaseIncrement)
500{
501#define ST_PARAM5 "40" // offset of parameter 5 (outputIndex)
502 asm(
503 "stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}\n"
504 // get parameters
505 " ldr r6, [sp, #" ST_PARAM5 " + 20]\n" // &phaseFraction
506 " ldr r6, [r6]\n" // phaseFraction
507 " ldr r7, [sp, #" ST_PARAM5 " + 8]\n" // &inputIndex
508 " ldr r7, [r7]\n" // inputIndex
509 " ldr r8, [sp, #" ST_PARAM5 " + 4]\n" // out
510 " ldr r0, [sp, #" ST_PARAM5 " + 0]\n" // &outputIndex
511 " ldr r0, [r0]\n" // outputIndex
512 " add r8, r0, asl #2\n" // curOut
513 " ldr r9, [sp, #" ST_PARAM5 " + 24]\n" // phaseIncrement
514 " ldr r10, [sp, #" ST_PARAM5 " + 12]\n" // vl
515 " ldr r11, [sp, #" ST_PARAM5 " + 16]\n" // vr
516
517 // r0 pin, x0, Samp
518
519 // r1 in
520 // r2 maxOutPt
521 // r3 maxInIdx
522
523 // r4 x1, i1, i3, out1
524 // r5 out0
525
526 // r6 frac
527 // r7 inputIndex
528 // r8 curOut
529
530 // r9 inc
531 // r10 vl
532 // r11 vr
533
534 // r12 temporary
535 // r13 sp
536 // r14
537
538 ".Y5L01:\n"
539 " cmp r8, r2\n" // curOut - maxCurOut
540 " bcs .Y5L02\n"
541
542#define ST_ONE_FRAME \
543 " bic r6, r6, #0xC0000000\n" /* phaseFraction & ... */\
544\
545 " add r0, r1, r7, asl #2\n" /* in + 2*inputIndex */\
546\
547 " ldrsh r4, [r0]\n" /* in[2*inputIndex] */\
548 " ldr r5, [r8]\n" /* out[outputIndex] */\
549 " ldrsh r12, [r0, #-4]\n" /* in[2*inputIndex-2] */\
550 " sub r4, r4, r12\n" /* in[2*InputIndex] - in[2*InputIndex-2] */\
551 " mov r4, r4, lsl #2\n" /* <<2 */\
552 " smulwt r4, r4, r6\n" /* (x1-x0)*.. */\
553 " add r12, r12, r4\n" /* x0 - (..) */\
554 " mla r5, r12, r10, r5\n" /* vl*interp + out[] */\
555 " ldr r4, [r8, #4]\n" /* out[outputIndex+1] */\
556 " str r5, [r8], #4\n" /* out[outputIndex++] = ... */\
557\
558 " ldrsh r12, [r0, #+2]\n" /* in[2*inputIndex+1] */\
559 " ldrsh r0, [r0, #-2]\n" /* in[2*inputIndex-1] */\
560 " sub r12, r12, r0\n" /* in[2*InputIndex] - in[2*InputIndex-2] */\
561 " mov r12, r12, lsl #2\n" /* <<2 */\
562 " smulwt r12, r12, r6\n" /* (x1-x0)*.. */\
563 " add r12, r0, r12\n" /* x0 - (..) */\
564 " mla r4, r12, r11, r4\n" /* vr*interp + out[] */\
565 " str r4, [r8], #4\n" /* out[outputIndex++] = ... */\
566\
567 " add r6, r6, r9\n" /* phaseFraction + phaseIncrement */\
568 " add r7, r7, r6, lsr #30\n" /* inputIndex + phaseFraction>>30 */
569
570 ST_ONE_FRAME // frame 1
571 ST_ONE_FRAME // frame 1
572
573 " cmp r7, r3\n" // inputIndex - maxInIdx
574 " bcc .Y5L01\n"
575 ".Y5L02:\n"
576
577 " bic r6, r6, #0xC0000000\n" // phaseFraction & ...
578 // save modified values
579 " ldr r0, [sp, #" ST_PARAM5 " + 20]\n" // &phaseFraction
580 " str r6, [r0]\n" // phaseFraction
581 " ldr r0, [sp, #" ST_PARAM5 " + 8]\n" // &inputIndex
582 " str r7, [r0]\n" // inputIndex
583 " ldr r0, [sp, #" ST_PARAM5 " + 4]\n" // out
584 " sub r8, r0\n" // curOut - out
585 " asr r8, #2\n" // new outputIndex
586 " ldr r0, [sp, #" ST_PARAM5 " + 0]\n" // &outputIndex
587 " str r8, [r0]\n" // save outputIndex
588
589 " ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, r12, pc}\n"
590 );
591}
592
593#endif // ASM_ARM_RESAMP1
594
595
596// ----------------------------------------------------------------------------
597}
598; // namespace android
599