diff options
| author | Mathias Agopian <mathias@google.com> | 2012-10-29 19:01:57 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-29 19:01:58 -0700 |
| commit | 4b5517970b2050cea4d5fa99b8a20a0d1b45c29a (patch) | |
| tree | 245c478dfd4235544a5f61a36d5f080fddd784e9 | |
| parent | 24cde8216d5aba49104967e97807ce2ff114bf70 (diff) | |
| parent | 9aec8c3f7f72cd36a8e3d7aafc1149f50514087a (diff) | |
| download | frameworks_av-4b5517970b2050cea4d5fa99b8a20a0d1b45c29a.zip frameworks_av-4b5517970b2050cea4d5fa99b8a20a0d1b45c29a.tar.gz frameworks_av-4b5517970b2050cea4d5fa99b8a20a0d1b45c29a.tar.bz2 | |
Merge "test-resample: clip instead of overflowing"
| -rw-r--r-- | services/audioflinger/test-resample.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp index a55a32b..a8e23e4 100644 --- a/services/audioflinger/test-resample.cpp +++ b/services/audioflinger/test-resample.cpp @@ -206,7 +206,10 @@ int main(int argc, char* argv[]) { int32_t* out = (int32_t*) output_vaddr; int16_t* convert = (int16_t*) malloc(out_frames * sizeof(int16_t)); for (size_t i = 0; i < out_frames; i++) { - convert[i] = out[i * 2] >> 12; + int32_t s = out[i * 2] >> 12; + if (s > 32767) s = 32767; + else if (s < -32768) s = -32768; + convert[i] = int16_t(s); } // write output to disk |
