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