1
0
mirror of https://github.com/ioacademy-jikim/multimedia synced 2025-06-07 07:56:26 +00:00

오디어 리샘플러수정

This commit is contained in:
juning kim 2015-11-01 02:08:00 +09:00
parent cd8732f3b1
commit 482d7c5d4f
3 changed files with 22 additions and 7 deletions

View File

@ -1,6 +1,5 @@
LOCAL_PATH:= $(call my-dir) LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \ LOCAL_SRC_FILES:= \
@ -25,3 +24,4 @@ LOCAL_MODULE:= test-resample
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View File

@ -19,7 +19,9 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <cutils/compiler.h> #include <cutils/compiler.h>
#include <utils/Compat.h>
#include <media/AudioBufferProvider.h> #include <media/AudioBufferProvider.h>
#include <system/audio.h> #include <system/audio.h>
@ -47,7 +49,7 @@ public:
DYN_HIGH_QUALITY=7, 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, static AudioResampler* create(audio_format_t format, int inChannelCount,
int32_t sampleRate, src_quality quality=DEFAULT_QUALITY); int32_t sampleRate, src_quality quality=DEFAULT_QUALITY);
@ -65,12 +67,18 @@ public:
// Resample int16_t samples from provider and accumulate into 'out'. // Resample int16_t samples from provider and accumulate into 'out'.
// A mono provider delivers a sequence of samples. // A mono provider delivers a sequence of samples.
// A stereo provider delivers a sequence of interleaved pairs 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. // In either case, 'out' holds interleaved pairs of fixed-point Q4.27.
// That is, for a mono provider, there is an implicit up-channeling. // That is, for a mono provider, there is an implicit up-channeling.
// Since this method accumulates, the caller is responsible for clearing 'out' initially. // 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; AudioBufferProvider* provider) = 0;
virtual void reset(); virtual void reset();
@ -168,7 +176,6 @@ private:
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
} } // namespace android
; // namespace android
#endif // ANDROID_AUDIO_RESAMPLER_H #endif // ANDROID_AUDIO_RESAMPLER_H

View File

@ -427,6 +427,14 @@ int main(int argc, char* argv[]) {
printf("quality: %d channels: %d msec: %" PRId64 " Mfrms/s: %.2lf\n", printf("quality: %d channels: %d msec: %" PRId64 " Mfrms/s: %.2lf\n",
quality, channels, time/1000000, output_frames * looplimit / (time / 1e9) / 1e6); quality, channels, time/1000000, output_frames * looplimit / (time / 1e9) / 1e6);
resampler->reset(); 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); memset(output_vaddr, 0, output_size);