mirror of
https://github.com/ioacademy-jikim/multimedia
synced 2025-06-06 15:36:13 +00:00
오디어 리샘플러수정
This commit is contained in:
parent
cd8732f3b1
commit
482d7c5d4f
@ -1,6 +1,5 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
@ -25,3 +24,4 @@ LOCAL_MODULE:= test-resample
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/compiler.h>
|
||||
#include <utils/Compat.h>
|
||||
|
||||
#include <media/AudioBufferProvider.h>
|
||||
#include <system/audio.h>
|
||||
@ -47,7 +49,7 @@ public:
|
||||
DYN_HIGH_QUALITY=7,
|
||||
};
|
||||
|
||||
static const float UNITY_GAIN_FLOAT = 1.0f;
|
||||
static const CONSTEXPR float UNITY_GAIN_FLOAT = 1.0f;
|
||||
|
||||
static AudioResampler* create(audio_format_t format, int inChannelCount,
|
||||
int32_t sampleRate, src_quality quality=DEFAULT_QUALITY);
|
||||
@ -65,12 +67,18 @@ public:
|
||||
// Resample int16_t samples from provider and accumulate into 'out'.
|
||||
// A mono provider delivers a sequence of samples.
|
||||
// A stereo provider delivers a sequence of interleaved pairs of samples.
|
||||
// Multi-channel providers are not supported.
|
||||
//
|
||||
// In either case, 'out' holds interleaved pairs of fixed-point Q4.27.
|
||||
// That is, for a mono provider, there is an implicit up-channeling.
|
||||
// Since this method accumulates, the caller is responsible for clearing 'out' initially.
|
||||
// FIXME assumes provider is always successful; it should return the actual frame count.
|
||||
virtual void resample(int32_t* out, size_t outFrameCount,
|
||||
//
|
||||
// For a float resampler, 'out' holds interleaved pairs of float samples.
|
||||
//
|
||||
// Multichannel interleaved frames for n > 2 is supported for quality DYN_LOW_QUALITY,
|
||||
// DYN_MED_QUALITY, and DYN_HIGH_QUALITY.
|
||||
//
|
||||
// Returns the number of frames resampled into the out buffer.
|
||||
virtual size_t resample(int32_t* out, size_t outFrameCount,
|
||||
AudioBufferProvider* provider) = 0;
|
||||
|
||||
virtual void reset();
|
||||
@ -168,7 +176,6 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
}
|
||||
; // namespace android
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_AUDIO_RESAMPLER_H
|
||||
|
@ -427,6 +427,14 @@ int main(int argc, char* argv[]) {
|
||||
printf("quality: %d channels: %d msec: %" PRId64 " Mfrms/s: %.2lf\n",
|
||||
quality, channels, time/1000000, output_frames * looplimit / (time / 1e9) / 1e6);
|
||||
resampler->reset();
|
||||
|
||||
// TODO fix legacy bug: reset does not clear buffers.
|
||||
// delete and recreate resampler here.
|
||||
delete resampler;
|
||||
resampler = AudioResampler::create(format, channels,
|
||||
output_freq, quality);
|
||||
resampler->setSampleRate(input_freq);
|
||||
resampler->setVolume(AudioResampler::UNITY_GAIN_FLOAT, AudioResampler::UNITY_GAIN_FLOAT);
|
||||
}
|
||||
|
||||
memset(output_vaddr, 0, output_size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user