Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 17 | #define LOG_TAG "AudioResamplerSinc" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 20 | #include <string.h> |
| 21 | #include "AudioResamplerSinc.h" |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 22 | #include <dlfcn.h> |
| 23 | #include <cutils/properties.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <utils/Log.h> |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | // ---------------------------------------------------------------------------- |
| 29 | |
| 30 | |
| 31 | /* |
| 32 | * These coeficients are computed with the "fir" utility found in |
| 33 | * tools/resampler_tools |
Mathias Agopian | b4b75b4 | 2012-10-29 17:13:20 -0700 | [diff] [blame^] | 34 | * cmd-line: fir -v 1.3 -l 7 -s 48000 -c 20478 |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 35 | */ |
| 36 | const int32_t AudioResamplerSinc::mFirCoefsUp[] = { |
Mathias Agopian | b4b75b4 | 2012-10-29 17:13:20 -0700 | [diff] [blame^] | 37 | 0x6e350b14, 0x6e32e1de, 0x6e2c6665, 0x6e219925, 0x6e127aed, 0x6dff0cdf, 0x6de7506d, 0x6dcb475f, 0x6daaf3cd, 0x6d865820, 0x6d5d7714, 0x6d3053b9, 0x6cfef16b, 0x6cc953db, 0x6c8f7f09, 0x6c517746, 0x6c0f4131, 0x6bc8e1ba, 0x6b7e5e1f, 0x6b2fbbee, 0x6add0100, 0x6a86337e, 0x6a2b59dc, 0x69cc7adc, 0x69699d89, 0x6902c93b, 0x68980593, 0x68295a7c, 0x67b6d02a, 0x67406f18, 0x66c64009, 0x66484c06, 0x65c69c5e, 0x65413aa3, 0x64b830ad, 0x642b8896, 0x639b4cb9, 0x630787b3, 0x62704460, 0x61d58ddd, 0x61376f83, 0x6095f4e8, 0x5ff129de, 0x5f491a73, 0x5e9dd2ed, 0x5def5fcc, 0x5d3dcdc4, 0x5c8929c4, 0x5bd180ec, 0x5b16e092, 0x5a59563d, 0x5998efa7, 0x58d5bab8, 0x580fc589, 0x57471e5f, 0x567bd3ac, 0x55adf40b, 0x54dd8e43, 0x540ab142, 0x53356c1d, 0x525dce0d, 0x5183e672, 0x50a7c4cd, 0x4fc978c0, 0x4ee9120c, 0x4e06a094, 0x4d223454, 0x4c3bdd65, 0x4b53abfc, 0x4a69b064, 0x497dfb00, 0x48909c49, 0x47a1a4cd, 0x46b1252c, 0x45bf2e16, 0x44cbd04d, 0x43d71ca1, 0x42e123ed, 0x41e9f71a, 0x40f1a71a, 0x3ff844e5, 0x3efde17e, 0x3e028dea, 0x3d065b33, 0x3c095a67, 0x3b0b9c92, 0x3a0d32c2, 0x390e2e01, 0x380e9f57, 0x370e97c6, 0x360e284c, 0x350d61da, 0x340c555d, 0x330b13b5, 0x3209adb4, 0x31083422, 0x3006b7b5, 0x2f054914, 0x2e03f8d4, 0x2d02d775, 0x2c01f564, 0x2b0162f9, 0x2a013072, 0x29016df5, 0x28022b90, 0x27037934, 0x260566b4, 0x250803c7, 0x240b6004, 0x230f8ae2, 0x221493b5, 0x211a89b0, 0x20217be0, 0x1f29792e, 0x1e32905a, 0x1d3ccfff, 0x1c48468e, 0x1b55024e, 0x1a63115b, 0x197281a5, 0x188360ef, 0x1795bccc, 0x16a9a2a1, 0x15bf1fa4, 0x14d640d8, 0x13ef130e, 0x1309a2e4, 0x1225fcc4, |
| 38 | 0x11442ce3, 0x10643f3f, 0x0f863fa3, 0x0eaa399d, 0x0dd03888, 0x0cf84782, 0x0c227171, 0x0b4ec101, 0x0a7d40a1, 0x09adfa86, 0x08e0f8a7, 0x081644be, 0x074de849, 0x0687ec84, 0x05c45a70, 0x05033acc, 0x04449618, 0x03887494, 0x02cede3e, 0x0217dad5, 0x016371d3, 0x00b1aa73, 0x00028bac, 0xff561c34, 0xfeac627c, 0xfe0564b3, 0xfd6128c4, 0xfcbfb457, 0xfc210cd1, 0xfb853752, 0xfaec38b4, 0xfa561591, 0xf9c2d23c, 0xf93272c4, 0xf8a4faf4, 0xf81a6e54, 0xf792d025, 0xf70e2367, 0xf68c6ad3, 0xf60da8df, 0xf591dfbf, 0xf5191161, 0xf4a33f70, 0xf4306b54, 0xf3c09632, 0xf353c0ed, 0xf2e9ec23, 0xf2831834, 0xf21f4539, 0xf1be730e, 0xf160a14c, 0xf105cf4a, 0xf0adfc22, 0xf05926ab, 0xf0074d7e, 0xefb86ef7, 0xef6c892f, 0xef239a07, 0xeedd9f1e, 0xee9a95d8, 0xee5a7b5f, 0xee1d4c9f, 0xede3064a, 0xedaba4d8, 0xed772488, 0xed458160, 0xed16b72d, 0xeceac186, 0xecc19bcc, 0xec9b4129, 0xec77ac93, 0xec56d8cb, 0xec38c05f, 0xec1d5dac, 0xec04aadb, 0xebeea1e6, 0xebdb3c96, 0xebca7487, 0xebbc4325, 0xebb0a1af, 0xeba78939, 0xeba0f2ab, 0xeb9cd6c3, 0xeb9b2e16, 0xeb9bf110, 0xeb9f17f7, 0xeba49ae9, 0xebac71df, 0xebb694b0, 0xebc2fb0d, 0xebd19c85, 0xebe27089, 0xebf56e66, 0xec0a8d4c, 0xec21c44d, 0xec3b0a5e, 0xec565658, 0xec739ef9, 0xec92dae5, 0xecb400aa, 0xecd706bc, 0xecfbe378, 0xed228d2a, 0xed4afa04, 0xed75202a, 0xeda0f5ab, 0xedce7087, 0xedfd86ac, 0xee2e2dfd, 0xee605c4c, 0xee940760, 0xeec924f5, 0xeeffaabc, 0xef378e5d, 0xef70c579, 0xefab45a8, 0xefe7047f, 0xf023f78b, 0xf0621459, 0xf0a1506f, 0xf0e1a155, 0xf122fc90, 0xf16557a8, 0xf1a8a824, 0xf1ece390, 0xf231ff7a, 0xf277f176, 0xf2beaf1b, |
| 39 | 0xf3062e09, 0xf34e63e8, 0xf3974666, 0xf3e0cb3f, 0xf42ae835, 0xf4759318, 0xf4c0c1c3, 0xf50c6a21, 0xf5588229, 0xf5a4ffe1, 0xf5f1d961, 0xf63f04d0, 0xf68c7868, 0xf6da2a76, 0xf7281159, 0xf7762387, 0xf7c45788, 0xf812a3fd, 0xf860ff9b, 0xf8af6130, 0xf8fdbfa2, 0xf94c11f0, 0xf99a4f34, 0xf9e86ea0, 0xfa366783, 0xfa843147, 0xfad1c372, 0xfb1f15a8, 0xfb6c1fab, 0xfbb8d95a, 0xfc053ab4, 0xfc513bd7, 0xfc9cd501, 0xfce7fe91, 0xfd32b105, 0xfd7ce501, 0xfdc69347, 0xfe0fb4bc, 0xfe58426a, 0xfea0357e, 0xfee78746, 0xff2e3137, 0xff742ceb, 0xffb9741e, 0xfffe00b5, 0x0041ccb6, 0x0084d252, 0x00c70bdc, 0x010873cf, 0x014904ce, 0x0188b9a0, 0x01c78d36, 0x02057aa6, 0x02427d2e, 0x027e9035, 0x02b9af49, 0x02f3d61f, 0x032d0094, 0x03652aae, 0x039c509c, 0x03d26eb2, 0x0407816e, 0x043b8577, 0x046e779c, 0x04a054d1, 0x04d11a37, 0x0500c513, 0x052f52d5, 0x055cc111, 0x05890d88, 0x05b4361d, 0x05de38df, 0x06071402, 0x062ec5e2, 0x06554d01, 0x067aa809, 0x069ed5ca, 0x06c1d539, 0x06e3a573, 0x070445ba, 0x0723b575, 0x0741f431, 0x075f01a0, 0x077add97, 0x07958811, 0x07af012c, 0x07c7492a, 0x07de606f, 0x07f44784, 0x0808ff11, 0x081c87e3, 0x082ee2e6, 0x0840112b, 0x085013de, 0x085eec50, 0x086c9bf0, 0x0879244c, 0x08848710, 0x088ec607, 0x0897e31b, 0x089fe052, 0x08a6bfcd, 0x08ac83ce, 0x08b12eac, 0x08b4c2e0, 0x08b742f8, 0x08b8b19f, 0x08b91198, 0x08b865bf, 0x08b6b10a, 0x08b3f685, 0x08b03952, 0x08ab7cac, 0x08a5c3e1, 0x089f1258, 0x08976b89, 0x088ed303, 0x08854c65, 0x087adb64, 0x086f83c5, 0x0863495f, 0x0856301c, 0x08483bf4, 0x083970ee, 0x0829d322, 0x081966b5, 0x08082fdb, 0x07f632d4, |
| 40 | 0x07e373ec, 0x07cff77c, 0x07bbc1e7, 0x07a6d79d, 0x07913d14, 0x077af6ce, 0x07640956, 0x074c793d, 0x07344b1b, 0x071b8393, 0x07022749, 0x06e83ae8, 0x06cdc322, 0x06b2c4ac, 0x0697443c, 0x067b4690, 0x065ed064, 0x0641e678, 0x06248d8e, 0x0606ca65, 0x05e8a1c1, 0x05ca1862, 0x05ab3308, 0x058bf671, 0x056c675a, 0x054c8a7b, 0x052c648a, 0x050bfa3b, 0x04eb5039, 0x04ca6b2f, 0x04a94fbf, 0x04880288, 0x0466881f, 0x0444e515, 0x04231df2, 0x04013738, 0x03df355d, 0x03bd1cd3, 0x039af1fe, 0x0378b93c, 0x035676dd, 0x03342f2b, 0x0311e661, 0x02efa0b0, 0x02cd623e, 0x02ab2f23, 0x02890b6c, 0x0266fb19, 0x0245021b, 0x02232456, 0x020165a2, 0x01dfc9c5, 0x01be547a, 0x019d096b, 0x017bec31, 0x015b005a, 0x013a4960, 0x0119caaf, 0x00f987a2, 0x00d98384, 0x00b9c18c, 0x009a44e6, 0x007b10a6, 0x005c27d3, 0x003d8d61, 0x001f4432, 0x00014f15, 0xffe3b0c9, 0xffc66bf8, 0xffa9833b, 0xff8cf919, 0xff70d004, 0xff550a5e, 0xff39aa73, 0xff1eb27e, 0xff0424a6, 0xfeea02ff, 0xfed04f89, 0xfeb70c33, 0xfe9e3ad6, 0xfe85dd38, 0xfe6df50d, 0xfe5683f5, 0xfe3f8b7b, 0xfe290d18, 0xfe130a32, 0xfdfd841c, 0xfde87c13, 0xfdd3f344, 0xfdbfeac5, 0xfdac639e, 0xfd995ebf, 0xfd86dd07, 0xfd74df43, 0xfd63662b, 0xfd527267, 0xfd42048a, 0xfd321d16, 0xfd22bc79, 0xfd13e312, 0xfd05912a, 0xfcf7c6fb, 0xfcea84ac, 0xfcddca53, 0xfcd197f5, 0xfcc5ed84, 0xfcbacae2, 0xfcb02fe3, 0xfca61c45, 0xfc9c8fba, 0xfc9389e1, 0xfc8b0a4c, 0xfc83107b, 0xfc7b9bdf, 0xfc74abda, 0xfc6e3fbf, 0xfc6856d2, 0xfc62f049, 0xfc5e0b4b, 0xfc59a6f2, 0xfc55c249, 0xfc525c50, 0xfc4f73f6, 0xfc4d0822, 0xfc4b17a9, 0xfc49a159, 0xfc48a3ef, 0xfc481e21, |
| 41 | 0xfc480e96, 0xfc4873eb, 0xfc494cb3, 0xfc4a9776, 0xfc4c52b2, 0xfc4e7cd9, 0xfc511457, 0xfc54178c, 0xfc5784d0, 0xfc5b5a72, 0xfc5f96ba, 0xfc6437e5, 0xfc693c2c, 0xfc6ea1be, 0xfc7466c4, 0xfc7a895f, 0xfc8107ac, 0xfc87dfbf, 0xfc8f0fa9, 0xfc969573, 0xfc9e6f23, 0xfca69ab8, 0xfcaf162e, 0xfcb7df7d, 0xfcc0f498, 0xfcca536e, 0xfcd3f9ed, 0xfcdde5fe, 0xfce81587, 0xfcf2866f, 0xfcfd3696, 0xfd0823de, 0xfd134c26, 0xfd1ead4c, 0xfd2a452e, 0xfd3611a8, 0xfd421096, 0xfd4e3fd4, 0xfd5a9d41, 0xfd6726b7, 0xfd73da17, 0xfd80b53d, 0xfd8db60c, 0xfd9ada65, 0xfda8202c, 0xfdb58547, 0xfdc3079e, 0xfdd0a51d, 0xfdde5bb2, 0xfdec294d, 0xfdfa0be4, 0xfe08016e, 0xfe1607e7, 0xfe241d50, 0xfe323fac, 0xfe406d04, 0xfe4ea365, 0xfe5ce0e3, 0xfe6b2393, 0xfe796993, 0xfe87b104, 0xfe95f80f, 0xfea43ce1, 0xfeb27dae, 0xfec0b8af, 0xfeceec25, 0xfedd1655, 0xfeeb358e, 0xfef94823, 0xff074c6f, 0xff1540d4, 0xff2323bc, 0xff30f397, 0xff3eaedd, 0xff4c540e, 0xff59e1b1, 0xff675655, 0xff74b091, 0xff81ef04, 0xff8f1056, 0xff9c1334, 0xffa8f658, 0xffb5b87f, 0xffc25874, 0xffced505, 0xffdb2d0d, 0xffe75f6c, 0xfff36b0d, 0xffff4ee4, 0x000b09ea, 0x00169b25, 0x002201a1, 0x002d3c75, 0x00384abe, 0x00432ba4, 0x004dde58, 0x00586211, 0x0062b611, 0x006cd9a4, 0x0076cc1c, 0x00808cd5, 0x008a1b34, 0x009376a6, 0x009c9ea1, 0x00a592a5, 0x00ae5238, 0x00b6dcea, 0x00bf3254, 0x00c75217, 0x00cf3bdd, 0x00d6ef55, 0x00de6c3c, 0x00e5b252, 0x00ecc163, 0x00f39941, 0x00fa39c5, 0x0100a2d4, 0x0106d456, 0x010cce3d, 0x01129084, 0x01181b2c, 0x011d6e3c, 0x012289c6, 0x01276de1, 0x012c1aab, 0x01309049, 0x0134cee8, 0x0138d6bc, |
| 42 | 0x013ca7ff, 0x014042f1, 0x0143a7d9, 0x0146d705, 0x0149d0c8, 0x014c957d, 0x014f2584, 0x01518141, 0x0153a922, 0x01559d96, 0x01575f14, 0x0158ee18, 0x015a4b23, 0x015b76bb, 0x015c716b, 0x015d3bc3, 0x015dd658, 0x015e41c1, 0x015e7e9d, 0x015e8d8e, 0x015e6f37, 0x015e2444, 0x015dad61, 0x015d0b3e, 0x015c3e92, 0x015b4812, 0x015a287a, 0x0158e089, 0x015770fe, 0x0155da9d, 0x01541e2e, 0x01523c78, 0x01503646, 0x014e0c67, 0x014bbfa8, 0x014950dc, 0x0146c0d5, 0x01441068, 0x0141406b, 0x013e51b5, 0x013b4520, 0x01381b84, 0x0134d5bd, 0x013174a6, 0x012df91b, 0x012a63f9, 0x0126b61d, 0x0122f065, 0x011f13ad, 0x011b20d4, 0x011718b7, 0x0112fc33, 0x010ecc25, 0x010a896b, 0x010634df, 0x0101cf5d, 0x00fd59bf, 0x00f8d4df, 0x00f44196, 0x00efa0ba, 0x00eaf323, 0x00e639a4, 0x00e17512, 0x00dca63d, 0x00d7cdf8, 0x00d2ed0f, 0x00ce044f, 0x00c91484, 0x00c41e76, 0x00bf22ec, 0x00ba22ab, 0x00b51e74, 0x00b01708, 0x00ab0d25, 0x00a60185, 0x00a0f4e1, 0x009be7f0, 0x0096db64, 0x0091cfed, 0x008cc63b, 0x0087bef8, 0x0082bacb, 0x007dba5a, 0x0078be46, 0x0073c72f, 0x006ed5b1, 0x0069ea64, 0x006505de, 0x006028b0, 0x005b536b, 0x00568698, 0x0051c2c2, 0x004d086c, 0x00485818, 0x0043b244, 0x003f176c, 0x003a8805, 0x00360484, 0x00318d58, 0x002d22ef, 0x0028c5b2, 0x00247606, 0x0020344d, 0x001c00e5, 0x0017dc2b, 0x0013c674, 0x000fc015, 0x000bc95f, 0x0007e29d, 0x00040c1a, 0x0000461a, 0xfffc90e1, 0xfff8ecac, 0xfff559b7, 0xfff1d83a, 0xffee686a, 0xffeb0a76, 0xffe7be8d, 0xffe484d8, 0xffe15d7f, 0xffde48a4, 0xffdb4669, 0xffd856ea, 0xffd57a40, 0xffd2b083, 0xffcff9c5, 0xffcd5617, 0xffcac586, |
| 43 | 0xffc8481c, 0xffc5dde0, 0xffc386d6, 0xffc142ff, 0xffbf125a, 0xffbcf4e3, 0xffbaea92, 0xffb8f35c, 0xffb70f36, 0xffb53e10, 0xffb37fd9, 0xffb1d47b, 0xffb03be0, 0xffaeb5ee, 0xffad428a, 0xffabe196, 0xffaa92f1, 0xffa95679, 0xffa82c09, 0xffa7137b, 0xffa60ca5, 0xffa5175d, 0xffa43376, 0xffa360c1, 0xffa29f0e, 0xffa1ee2b, 0xffa14de4, 0xffa0be03, 0xffa03e51, 0xff9fce96, 0xff9f6e98, 0xff9f1e1a, 0xff9edce1, 0xff9eaaae, 0xff9e8741, 0xff9e725b, 0xff9e6bb9, 0xff9e7319, 0xff9e8837, 0xff9eaace, 0xff9eda9a, 0xff9f1753, 0xff9f60b3, 0xff9fb672, 0xffa01848, 0xffa085ea, 0xffa0ff11, 0xffa18371, 0xffa212c1, 0xffa2acb5, 0xffa35102, 0xffa3ff5d, 0xffa4b779, 0xffa5790c, 0xffa643ca, 0xffa71765, 0xffa7f392, 0xffa8d805, 0xffa9c472, 0xffaab88d, 0xffabb40a, 0xffacb69e, 0xffadbffe, 0xffaecfde, 0xffafe5f5, 0xffb101f7, 0xffb2239b, 0xffb34a98, 0xffb476a5, 0xffb5a779, 0xffb6dccd, 0xffb8165a, 0xffb953d8, 0xffba9503, 0xffbbd996, 0xffbd214b, 0xffbe6bdf, 0xffbfb910, 0xffc1089c, 0xffc25a41, 0xffc3adbf, 0xffc502d8, 0xffc6594c, 0xffc7b0df, 0xffc90953, 0xffca626e, 0xffcbbbf5, 0xffcd15b0, 0xffce6f64, 0xffcfc8dd, 0xffd121e3, 0xffd27a41, 0xffd3d1c4, 0xffd52839, 0xffd67d6f, 0xffd7d135, 0xffd9235c, 0xffda73b6, 0xffdbc216, 0xffdd0e51, 0xffde583d, 0xffdf9fb0, 0xffe0e483, 0xffe2268e, 0xffe365ad, 0xffe4a1bb, 0xffe5da95, 0xffe7101a, 0xffe84229, 0xffe970a2, 0xffea9b69, 0xffebc25f, 0xffece56a, 0xffee046f, 0xffef1f56, 0xfff03605, 0xfff14867, 0xfff25666, 0xfff35fee, 0xfff464ec, 0xfff5654e, 0xfff66102, 0xfff757fa, 0xfff84a27, 0xfff9377c, 0xfffa1fed, 0xfffb036e, 0xfffbe1f5, |
| 44 | 0xfffcbb7a, 0xfffd8ff5, 0xfffe5f5f, 0xffff29b1, 0xffffeee9, 0x0000af01, 0x000169f7, 0x00021fca, 0x0002d077, 0x00037c01, 0x00042267, 0x0004c3ab, 0x00055fd1, 0x0005f6dc, 0x000688d1, 0x000715b4, 0x00079d8d, 0x00082061, 0x00089e39, 0x0009171e, 0x00098b17, 0x0009fa30, 0x000a6472, 0x000ac9ea, 0x000b2aa2, 0x000b86a7, 0x000bde06, 0x000c30cd, 0x000c7f0a, 0x000cc8cc, 0x000d0e21, 0x000d4f1a, 0x000d8bc7, 0x000dc438, 0x000df87f, 0x000e28ac, 0x000e54d2, 0x000e7d03, 0x000ea151, 0x000ec1cf, 0x000ede91, 0x000ef7a9, 0x000f0d2c, 0x000f1f2d, 0x000f2dc1, 0x000f38fb, 0x000f40f1, 0x000f45b7, 0x000f4762, 0x000f4606, 0x000f41ba, 0x000f3a91, 0x000f30a2, 0x000f2401, 0x000f14c4, 0x000f0300, 0x000eeeca, 0x000ed838, 0x000ebf60, 0x000ea455, 0x000e872d, 0x000e67fe, 0x000e46dd, 0x000e23dd, 0x000dff15, 0x000dd898, 0x000db07b, 0x000d86d3, 0x000d5bb3, 0x000d2f30, 0x000d015d, 0x000cd24d, 0x000ca215, 0x000c70c7, 0x000c3e76, 0x000c0b34, 0x000bd715, 0x000ba229, 0x000b6c83, 0x000b3634, 0x000aff4e, 0x000ac7e1, 0x000a8ffe, 0x000a57b5, 0x000a1f17, 0x0009e632, 0x0009ad16, 0x000973d2, 0x00093a74, 0x0009010b, 0x0008c7a5, 0x00088e4f, 0x00085517, 0x00081c09, 0x0007e331, 0x0007aa9c, 0x00077255, 0x00073a68, 0x000702e0, 0x0006cbc7, 0x00069527, 0x00065f0b, 0x0006297b, 0x0005f481, 0x0005c026, 0x00058c71, 0x0005596b, 0x0005271b, 0x0004f588, 0x0004c4ba, 0x000494b7, 0x00046585, 0x00043729, 0x000409aa, 0x0003dd0b, 0x0003b152, 0x00038683, 0x00035ca3, 0x000333b4, 0x00030bba, 0x0002e4b8, 0x0002beb1, 0x000299a7, 0x0002759c, 0x00025292, 0x0002308a, 0x00020f86, 0x0001ef85, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 45 | 0x00000000 // this one is needed for lerping the last coefficient |
| 46 | }; |
| 47 | |
| 48 | /* |
Mathias Agopian | 443e696 | 2012-10-26 13:48:42 -0700 | [diff] [blame] | 49 | * These coefficients are optimized for 48KHz -> 44.1KHz |
| 50 | * cmd-line: fir -v 0.3 -l 7 -s 48000 -c 16600 |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 51 | */ |
| 52 | const int32_t AudioResamplerSinc::mFirCoefsDown[] = { |
Mathias Agopian | b4b75b4 | 2012-10-29 17:13:20 -0700 | [diff] [blame^] | 53 | 0x6e350b14, 0x6e3396e0, 0x6e2f3a59, 0x6e27f5b7, 0x6e1dc95c, 0x6e10b5cc, 0x6e00bbb6, 0x6deddbeb, 0x6dd81765, 0x6dbf6f44, 0x6da3e4cd, 0x6d85796c, 0x6d642eb2, 0x6d400656, 0x6d190235, 0x6cef2453, 0x6cc26ed6, 0x6c92e40c, 0x6c608668, 0x6c2b5882, 0x6bf35d14, 0x6bb89701, 0x6b7b094e, 0x6b3ab724, 0x6af7a3d1, 0x6ab1d2c7, 0x6a69479a, 0x6a1e0603, 0x69d011df, 0x697f6f2a, 0x692c2207, 0x68d62eb9, 0x687d99a6, 0x68226753, 0x67c49c6c, 0x67643db8, 0x67015023, 0x669bd8b9, 0x6633dca5, 0x65c96131, 0x655c6bca, 0x64ed01f9, 0x647b2967, 0x6406e7dc, 0x6390433c, 0x6317418a, 0x629be8e8, 0x621e3f92, 0x619e4be2, 0x611c144d, 0x60979f66, 0x6010f3d8, 0x5f88186c, 0x5efd1402, 0x5e6fed97, 0x5de0ac3f, 0x5d4f5729, 0x5cbbf59c, 0x5c268ef6, 0x5b8f2aad, 0x5af5d04f, 0x5a5a8780, 0x59bd57fa, 0x591e498d, 0x587d641d, 0x57daafa5, 0x57363432, 0x568ff9e4, 0x55e808f2, 0x553e69a1, 0x5493244a, 0x53e64158, 0x5337c946, 0x5287c4a0, 0x51d63c02, 0x51233816, 0x506ec197, 0x4fb8e14d, 0x4f01a00d, 0x4e4906ba, 0x4d8f1e43, 0x4cd3efa4, 0x4c1783e5, 0x4b59e415, 0x4a9b1952, 0x49db2cc2, 0x491a2792, 0x485812fb, 0x4794f83d, 0x46d0e09d, 0x460bd56a, 0x4545dff9, 0x447f09a2, 0x43b75bc5, 0x42eedfc5, 0x42259f0a, 0x415ba2fe, 0x4090f510, 0x3fc59eaf, 0x3ef9a94d, 0x3e2d1e5c, 0x3d600751, 0x3c926d9d, 0x3bc45ab4, 0x3af5d807, 0x3a26ef05, 0x3957a91c, 0x38880fb6, 0x37b82c3b, 0x36e8080c, 0x3617ac89, 0x3547230a, 0x347674e3, 0x33a5ab62, 0x32d4cfcc, 0x3203eb61, 0x31330758, 0x30622ce0, 0x2f91651f, 0x2ec0b931, 0x2df03228, 0x2d1fd90d, 0x2c4fb6dd, 0x2b7fd488, 0x2ab03af3, 0x29e0f2f8, 0x29120562, 0x28437aef, |
| 54 | 0x27755c4f, 0x26a7b223, 0x25da84fc, 0x250ddd60, 0x2441c3bf, 0x2376407c, 0x22ab5be9, 0x21e11e45, 0x21178fc0, 0x204eb874, 0x1f86a06c, 0x1ebf4f9d, 0x1df8cdea, 0x1d332322, 0x1c6e56ff, 0x1baa7127, 0x1ae77929, 0x1a257682, 0x19647094, 0x18a46eb0, 0x17e5780d, 0x172793cc, 0x166ac8f6, 0x15af1e7c, 0x14f49b39, 0x143b45ed, 0x13832540, 0x12cc3fc3, 0x12169bea, 0x11624012, 0x10af327e, 0x0ffd7955, 0x0f4d1aa4, 0x0e9e1c5e, 0x0df0845b, 0x0d445856, 0x0c999df2, 0x0bf05ab1, 0x0b4893fd, 0x0aa24f23, 0x09fd9152, 0x095a5f9d, 0x08b8befc, 0x0818b447, 0x077a443b, 0x06dd7376, 0x0642467a, 0x05a8c1a9, 0x0510e949, 0x047ac182, 0x03e64e5e, 0x035393c6, 0x02c29588, 0x02335752, 0x01a5dcb3, 0x011a291e, 0x00903fe2, 0x00082435, 0xff81d92b, 0xfefd61b9, 0xfe7ac0b7, 0xfdf9f8da, 0xfd7b0cbe, 0xfcfdfeda, 0xfc82d18a, 0xfc098709, 0xfb922173, 0xfb1ca2c7, 0xfaa90ce2, 0xfa376185, 0xf9c7a24e, 0xf959d0c2, 0xf8edee41, 0xf883fc11, 0xf81bfb56, 0xf7b5ed19, 0xf751d240, 0xf6efab96, 0xf68f79c7, 0xf6313d60, 0xf5d4f6d0, 0xf57aa669, 0xf5224c5f, 0xf4cbe8c7, 0xf4777b9a, 0xf42504b2, 0xf3d483cf, 0xf385f890, 0xf339627b, 0xf2eec0f5, 0xf2a6134a, 0xf25f58aa, 0xf21a9025, 0xf1d7b8b4, 0xf196d132, 0xf157d85d, 0xf11accdc, 0xf0dfad37, 0xf0a677de, 0xf06f2b25, 0xf039c548, 0xf0064466, 0xefd4a686, 0xefa4e997, 0xef770b6c, 0xef4b09c2, 0xef20e23d, 0xeef89266, 0xeed217b2, 0xeead6f7d, 0xee8a9709, 0xee698b87, 0xee4a4a0b, 0xee2ccf97, 0xee111915, 0xedf7235b, 0xeddeeb29, 0xedc86d28, 0xedb3a5ef, 0xeda09201, 0xed8f2dcb, 0xed7f75a8, 0xed7165e0, 0xed64faa7, 0xed5a301f, 0xed510259, 0xed496d53, 0xed436cfb, |
| 55 | 0xed3efd2c, 0xed3c19b3, 0xed3abe4b, 0xed3ae6a1, 0xed3c8e50, 0xed3fb0e7, 0xed4449e5, 0xed4a54ba, 0xed51ccca, 0xed5aad6a, 0xed64f1e4, 0xed709574, 0xed7d934a, 0xed8be68a, 0xed9b8a4d, 0xedac79a2, 0xedbeaf8c, 0xedd22705, 0xede6dafd, 0xedfcc65a, 0xee13e3f9, 0xee2c2eb1, 0xee45a14f, 0xee603697, 0xee7be949, 0xee98b41b, 0xeeb691c0, 0xeed57ce1, 0xeef57025, 0xef16662c, 0xef385992, 0xef5b44ed, 0xef7f22d2, 0xefa3edcf, 0xefc9a072, 0xeff03543, 0xf017a6cb, 0xf03fef90, 0xf0690a14, 0xf092f0da, 0xf0bd9e66, 0xf0e90d37, 0xf11537d0, 0xf14218b3, 0xf16faa62, 0xf19de762, 0xf1ccca37, 0xf1fc4d68, 0xf22c6b80, 0xf25d1f0a, 0xf28e6296, 0xf2c030b5, 0xf2f283fe, 0xf325570c, 0xf358a47c, 0xf38c66f3, 0xf3c09918, 0xf3f5359a, 0xf42a372c, 0xf45f9888, 0xf495546e, 0xf4cb65a6, 0xf501c6fd, 0xf5387349, 0xf56f6567, 0xf5a6983c, 0xf5de06b6, 0xf615abcb, 0xf64d827a, 0xf68585cb, 0xf6bdb0d0, 0xf6f5fea5, 0xf72e6a6e, 0xf766ef5c, 0xf79f88a9, 0xf7d8319a, 0xf810e580, 0xf8499fb6, 0xf8825ba4, 0xf8bb14bc, 0xf8f3c67e, 0xf92c6c75, 0xf9650239, 0xf99d836f, 0xf9d5ebc7, 0xfa0e3702, 0xfa4660ea, 0xfa7e6559, 0xfab64038, 0xfaeded7a, 0xfb256924, 0xfb5caf47, 0xfb93bc03, 0xfbca8b87, 0xfc011a11, 0xfc3763ec, 0xfc6d6574, 0xfca31b14, 0xfcd88147, 0xfd0d9494, 0xfd425197, 0xfd76b4f7, 0xfdaabb6d, 0xfdde61c2, 0xfe11a4ce, 0xfe44817b, 0xfe76f4c2, 0xfea8fbab, 0xfeda9350, 0xff0bb8dd, 0xff3c698b, 0xff6ca2a6, 0xff9c618a, 0xffcba3a4, 0xfffa6672, 0x0028a781, 0x00566471, 0x00839af2, 0x00b048c5, 0x00dc6bbc, 0x010801b9, 0x013308b1, 0x015d7ea7, 0x018761b2, 0x01b0aff7, 0x01d967af, 0x02018722, 0x02290ca8, |
| 56 | 0x024ff6ac, 0x027643a9, 0x029bf22a, 0x02c100cc, 0x02e56e3b, 0x03093935, 0x032c608a, 0x034ee316, 0x0370bfca, 0x0391f5a5, 0x03b283b7, 0x03d26920, 0x03f1a510, 0x041036c8, 0x042e1d98, 0x044b58e0, 0x0467e810, 0x0483caa7, 0x049f0035, 0x04b98858, 0x04d362bd, 0x04ec8f23, 0x05050d54, 0x051cdd2c, 0x0533fe94, 0x054a7186, 0x05603607, 0x05754c2f, 0x0589b41f, 0x059d6e0a, 0x05b07a30, 0x05c2d8dd, 0x05d48a6e, 0x05e58f49, 0x05f5e7e6, 0x060594c8, 0x0614967d, 0x0622eda3, 0x06309ae3, 0x063d9ef2, 0x0649fa93, 0x0655ae94, 0x0660bbce, 0x066b2327, 0x0674e591, 0x067e0406, 0x06867f90, 0x068e5940, 0x06959234, 0x069c2b92, 0x06a2268e, 0x06a78463, 0x06ac4657, 0x06b06dba, 0x06b3fbe5, 0x06b6f23a, 0x06b95226, 0x06bb1d1c, 0x06bc549a, 0x06bcfa25, 0x06bd0f4b, 0x06bc95a2, 0x06bb8ec8, 0x06b9fc61, 0x06b7e01a, 0x06b53ba8, 0x06b210c4, 0x06ae6130, 0x06aa2eb4, 0x06a57b1f, 0x06a04844, 0x069a97fe, 0x06946c2c, 0x068dc6b3, 0x0686a97f, 0x067f167e, 0x06770fa5, 0x066e96eb, 0x0665ae50, 0x065c57d2, 0x06529578, 0x0648694a, 0x063dd555, 0x0632dba8, 0x06277e55, 0x061bbf72, 0x060fa118, 0x0603255f, 0x05f64e66, 0x05e91e4b, 0x05db972f, 0x05cdbb32, 0x05bf8c7a, 0x05b10d2b, 0x05a23f6a, 0x0593255f, 0x0583c12f, 0x05741504, 0x05642304, 0x0553ed58, 0x05437626, 0x0532bf98, 0x0521cbd2, 0x05109cfc, 0x04ff353b, 0x04ed96b2, 0x04dbc386, 0x04c9bdd6, 0x04b787c3, 0x04a5236c, 0x049292eb, 0x047fd85d, 0x046cf5d7, 0x0459ed70, 0x0446c13b, 0x04337347, 0x042005a1, 0x040c7a55, 0x03f8d368, 0x03e512de, 0x03d13ab8, 0x03bd4cf2, 0x03a94b85, 0x03953865, 0x03811584, 0x036ce4cd, 0x0358a82a, 0x0344617e, |
| 57 | 0x033012a8, 0x031bbd84, 0x030763e8, 0x02f307a3, 0x02deaa84, 0x02ca4e50, 0x02b5f4c9, 0x02a19fac, 0x028d50b0, 0x02790987, 0x0264cbdc, 0x02509956, 0x023c7395, 0x02285c34, 0x021454c8, 0x02005edf, 0x01ec7c02, 0x01d8adb3, 0x01c4f56f, 0x01b154ab, 0x019dccd7, 0x018a5f5c, 0x01770d9d, 0x0163d8f6, 0x0150c2bb, 0x013dcc3d, 0x012af6c3, 0x0118438f, 0x0105b3da, 0x00f348da, 0x00e103ba, 0x00cee5a2, 0x00bcefb0, 0x00ab22fc, 0x00998098, 0x0088098e, 0x0076bee2, 0x0065a18f, 0x0054b28b, 0x0043f2c4, 0x00336322, 0x00230484, 0x0012d7c4, 0x0002ddb3, 0xfff3171d, 0xffe384c5, 0xffd42769, 0xffc4ffbe, 0xffb60e73, 0xffa75430, 0xff98d197, 0xff8a8740, 0xff7c75bf, 0xff6e9da0, 0xff60ff68, 0xff539b96, 0xff4672a1, 0xff3984fa, 0xff2cd30a, 0xff205d36, 0xff1423d9, 0xff08274a, 0xfefc67d8, 0xfef0e5cb, 0xfee5a167, 0xfeda9ae7, 0xfecfd280, 0xfec54861, 0xfebafcb4, 0xfeb0ef9c, 0xfea72133, 0xfe9d9192, 0xfe9440c8, 0xfe8b2edf, 0xfe825bdc, 0xfe79c7bd, 0xfe71727b, 0xfe695c0a, 0xfe618456, 0xfe59eb47, 0xfe5290bf, 0xfe4b749d, 0xfe4496b6, 0xfe3df6dd, 0xfe3794e0, 0xfe317085, 0xfe2b8991, 0xfe25dfc1, 0xfe2072ce, 0xfe1b426d, 0xfe164e4c, 0xfe119618, 0xfe0d1976, 0xfe08d808, 0xfe04d16d, 0xfe01053d, 0xfdfd730d, 0xfdfa1a6f, 0xfdf6faf0, 0xfdf41419, 0xfdf1656f, 0xfdeeee74, 0xfdecaea5, 0xfdeaa57e, 0xfde8d275, 0xfde734fe, 0xfde5cc89, 0xfde49884, 0xfde39857, 0xfde2cb6c, 0xfde23124, 0xfde1c8e3, 0xfde19207, 0xfde18beb, 0xfde1b5ea, 0xfde20f5a, 0xfde29790, 0xfde34dde, 0xfde43196, 0xfde54205, 0xfde67e78, 0xfde7e638, 0xfde97890, 0xfdeb34c5, 0xfded1a1e, 0xfdef27de, 0xfdf15d47, 0xfdf3b99b, |
| 58 | 0xfdf63c19, 0xfdf8e401, 0xfdfbb090, 0xfdfea102, 0xfe01b494, 0xfe04ea81, 0xfe084202, 0xfe0bba52, 0xfe0f52a9, 0xfe130a40, 0xfe16e050, 0xfe1ad410, 0xfe1ee4b9, 0xfe231181, 0xfe2759a0, 0xfe2bbc4e, 0xfe3038c2, 0xfe34ce35, 0xfe397bdd, 0xfe3e40f4, 0xfe431cb3, 0xfe480e52, 0xfe4d150b, 0xfe523019, 0xfe575eb6, 0xfe5ca01f, 0xfe61f390, 0xfe675846, 0xfe6ccd7f, 0xfe72527c, 0xfe77e67d, 0xfe7d88c3, 0xfe833890, 0xfe88f52a, 0xfe8ebdd5, 0xfe9491d7, 0xfe9a707a, 0xfea05906, 0xfea64ac7, 0xfeac4509, 0xfeb2471b, 0xfeb8504c, 0xfebe5fee, 0xfec47555, 0xfeca8fd6, 0xfed0aec7, 0xfed6d183, 0xfedcf763, 0xfee31fc4, 0xfee94a07, 0xfeef758b, 0xfef5a1b3, 0xfefbcde6, 0xff01f989, 0xff082408, 0xff0e4ccd, 0xff147346, 0xff1a96e4, 0xff20b71a, 0xff26d35c, 0xff2ceb21, 0xff32fde4, 0xff390b21, 0xff3f1255, 0xff451303, 0xff4b0cac, 0xff50fed8, 0xff56e90f, 0xff5ccadb, 0xff62a3ca, 0xff68736c, 0xff6e3954, 0xff73f516, 0xff79a64a, 0xff7f4c8b, 0xff84e775, 0xff8a76a7, 0xff8ff9c4, 0xff957070, 0xff9ada53, 0xffa03716, 0xffa58665, 0xffaac7ef, 0xffaffb66, 0xffb5207e, 0xffba36ee, 0xffbf3e6f, 0xffc436bd, 0xffc91f96, 0xffcdf8bc, 0xffd2c1f1, 0xffd77afc, 0xffdc23a6, 0xffe0bbb9, 0xffe54303, 0xffe9b954, 0xffee1e7f, 0xfff27259, 0xfff6b4b9, 0xfffae579, 0xffff0475, 0x0003118c, 0x00070ca0, 0x000af592, 0x000ecc4a, 0x001290ae, 0x001642aa, 0x0019e22a, 0x001d6f1c, 0x0020e971, 0x0024511d, 0x0027a615, 0x002ae850, 0x002e17c8, 0x00313479, 0x00343e5f, 0x0037357c, 0x003a19cf, 0x003ceb5e, 0x003faa2d, 0x00425644, 0x0044efac, 0x00477671, 0x0049ea9f, 0x004c4c45, 0x004e9b74, 0x0050d83e, 0x005302b6, |
| 59 | 0x00551af3, 0x0057210c, 0x00591518, 0x005af733, 0x005cc777, 0x005e8604, 0x006032f6, 0x0061ce6f, 0x0063588f, 0x0064d17a, 0x00663953, 0x00679041, 0x0068d669, 0x006a0bf4, 0x006b310a, 0x006c45d6, 0x006d4a83, 0x006e3f3d, 0x006f2431, 0x006ff98f, 0x0070bf84, 0x00717641, 0x00721df8, 0x0072b6da, 0x00734119, 0x0073bcea, 0x00742a81, 0x00748a12, 0x0074dbd4, 0x00751ffc, 0x007556c1, 0x0075805b, 0x00759d03, 0x0075acef, 0x0075b05a, 0x0075a77d, 0x00759291, 0x007571d1, 0x00754578, 0x00750dc0, 0x0074cae5, 0x00747d22, 0x007424b3, 0x0073c1d3, 0x007354bf, 0x0072ddb2, 0x00725cea, 0x0071d2a2, 0x00713f16, 0x0070a284, 0x006ffd28, 0x006f4f3d, 0x006e9901, 0x006ddaaf, 0x006d1484, 0x006c46bc, 0x006b7192, 0x006a9542, 0x0069b208, 0x0068c81e, 0x0067d7c0, 0x0066e128, 0x0065e490, 0x0064e233, 0x0063da4a, 0x0062cd0f, 0x0061baba, 0x0060a384, 0x005f87a5, 0x005e6754, 0x005d42c9, 0x005c1a3b, 0x005aeddf, 0x0059bdeb, 0x00588a94, 0x00575410, 0x00561a91, 0x0054de4b, 0x00539f71, 0x00525e36, 0x00511acb, 0x004fd560, 0x004e8e26, 0x004d454d, 0x004bfb04, 0x004aaf78, 0x004962d9, 0x00481551, 0x0046c70e, 0x0045783b, 0x00442903, 0x0042d990, 0x00418a0a, 0x00403a9b, 0x003eeb6a, 0x003d9c9e, 0x003c4e5d, 0x003b00cc, 0x0039b411, 0x0038684f, 0x00371da9, 0x0035d441, 0x00348c38, 0x003345b0, 0x003200c9, 0x0030bda0, 0x002f7c55, 0x002e3d04, 0x002cffcb, 0x002bc4c5, 0x002a8c0d, 0x002955be, 0x002821f0, 0x0026f0bc, 0x0025c23b, 0x00249683, 0x00236daa, 0x002247c5, 0x002124ea, 0x0020052b, 0x001ee89d, 0x001dcf51, 0x001cb958, 0x001ba6c4, 0x001a97a5, 0x00198c08, 0x001883fe, 0x00177f93, |
| 60 | 0x00167ed5, 0x001581cf, 0x0014888e, 0x0013931b, 0x0012a181, 0x0011b3ca, 0x0010c9fd, 0x000fe423, 0x000f0244, 0x000e2465, 0x000d4a8c, 0x000c74bf, 0x000ba303, 0x000ad55c, 0x000a0bcc, 0x00094656, 0x000884fe, 0x0007c7c3, 0x00070ea8, 0x000659ad, 0x0005a8d0, 0x0004fc13, 0x00045373, 0x0003aeee, 0x00030e82, 0x0002722d, 0x0001d9eb, 0x000145b8, 0x0000b58f, 0x0000296d, 0xffffa14b, 0xffff1d24, 0xfffe9cf2, 0xfffe20ae, 0xfffda852, 0xfffd33d5, 0xfffcc331, 0xfffc565d, 0xfffbed50, 0xfffb8802, 0xfffb2669, 0xfffac87d, 0xfffa6e32, 0xfffa1780, 0xfff9c45a, 0xfff974b8, 0xfff9288e, 0xfff8dfcf, 0xfff89a72, 0xfff8586a, 0xfff819ac, 0xfff7de2a, 0xfff7a5d9, 0xfff770ab, 0xfff73e95, 0xfff70f89, 0xfff6e37b, 0xfff6ba5c, 0xfff6941f, 0xfff670b7, 0xfff65016, 0xfff6322f, 0xfff616f3, 0xfff5fe55, 0xfff5e846, 0xfff5d4b8, 0xfff5c39d, 0xfff5b4e7, 0xfff5a888, 0xfff59e71, 0xfff59694, 0xfff590e2, 0xfff58d4d, 0xfff58bc8, 0xfff58c42, 0xfff58eaf, 0xfff592ff, 0xfff59925, 0xfff5a112, 0xfff5aab7, 0xfff5b608, 0xfff5c2f6, 0xfff5d172, 0xfff5e16f, 0xfff5f2df, 0xfff605b5, 0xfff619e2, 0xfff62f59, 0xfff6460d, 0xfff65df0, 0xfff676f6, 0xfff69110, 0xfff6ac32, 0xfff6c850, 0xfff6e55d, 0xfff7034b, 0xfff72210, 0xfff7419e, 0xfff761ea, 0xfff782e7, 0xfff7a48b, 0xfff7c6c9, 0xfff7e996, 0xfff80ce7, 0xfff830b1, 0xfff854ea, 0xfff87986, 0xfff89e7c, 0xfff8c3c0, 0xfff8e949, 0xfff90f0e, 0xfff93504, 0xfff95b23, 0xfff98160, 0xfff9a7b4, 0xfff9ce14, 0xfff9f47a, 0xfffa1adc, 0xfffa4131, 0xfffa6774, 0xfffa8d9a, 0xfffab39e, 0xfffad977, 0xfffaff1f, 0xfffb248f, 0xfffb49c1, 0xfffb6eac, 0xfffb934d, |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 61 | 0x00000000 // this one is needed for lerping the last coefficient |
| 62 | }; |
| 63 | |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 64 | // we use 15 bits to interpolate between these samples |
| 65 | // this cannot change because the mul below rely on it. |
| 66 | static const int pLerpBits = 15; |
| 67 | |
| 68 | static pthread_once_t once_control = PTHREAD_ONCE_INIT; |
| 69 | static readCoefficientsFn readResampleCoefficients = NULL; |
| 70 | |
| 71 | /*static*/ AudioResamplerSinc::Constants AudioResamplerSinc::highQualityConstants; |
| 72 | /*static*/ AudioResamplerSinc::Constants AudioResamplerSinc::veryHighQualityConstants; |
| 73 | |
| 74 | void AudioResamplerSinc::init_routine() |
| 75 | { |
| 76 | // for high quality resampler, the parameters for coefficients are compile-time constants |
| 77 | Constants *c = &highQualityConstants; |
| 78 | c->coefsBits = RESAMPLE_FIR_LERP_INT_BITS; |
| 79 | c->cShift = kNumPhaseBits - c->coefsBits; |
| 80 | c->cMask = ((1<< c->coefsBits)-1) << c->cShift; |
| 81 | c->pShift = kNumPhaseBits - c->coefsBits - pLerpBits; |
| 82 | c->pMask = ((1<< pLerpBits)-1) << c->pShift; |
| 83 | c->halfNumCoefs = RESAMPLE_FIR_NUM_COEF; |
| 84 | |
| 85 | // for very high quality resampler, the parameters are load-time constants |
| 86 | veryHighQualityConstants = highQualityConstants; |
| 87 | |
| 88 | // Open the dll to get the coefficients for VERY_HIGH_QUALITY |
| 89 | void *resampleCoeffLib = dlopen("libaudio-resampler.so", RTLD_NOW); |
| 90 | ALOGV("Open libaudio-resampler library = %p", resampleCoeffLib); |
| 91 | if (resampleCoeffLib == NULL) { |
| 92 | ALOGE("Could not open audio-resampler library: %s", dlerror()); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | readResampleCoefficients = (readCoefficientsFn) dlsym(resampleCoeffLib, |
| 97 | "readResamplerCoefficients"); |
| 98 | readResampleFirNumCoeffFn readResampleFirNumCoeff = (readResampleFirNumCoeffFn) |
| 99 | dlsym(resampleCoeffLib, "readResampleFirNumCoeff"); |
| 100 | readResampleFirLerpIntBitsFn readResampleFirLerpIntBits = (readResampleFirLerpIntBitsFn) |
| 101 | dlsym(resampleCoeffLib, "readResampleFirLerpIntBits"); |
| 102 | if (!readResampleCoefficients || !readResampleFirNumCoeff || !readResampleFirLerpIntBits) { |
| 103 | readResampleCoefficients = NULL; |
| 104 | dlclose(resampleCoeffLib); |
| 105 | resampleCoeffLib = NULL; |
| 106 | ALOGE("Could not find symbol: %s", dlerror()); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | c = &veryHighQualityConstants; |
| 111 | // we have 16 coefs samples per zero-crossing |
| 112 | c->coefsBits = readResampleFirLerpIntBits(); |
| 113 | ALOGV("coefsBits = %d", c->coefsBits); |
| 114 | c->cShift = kNumPhaseBits - c->coefsBits; |
| 115 | c->cMask = ((1<<c->coefsBits)-1) << c->cShift; |
| 116 | c->pShift = kNumPhaseBits - c->coefsBits - pLerpBits; |
| 117 | c->pMask = ((1<<pLerpBits)-1) << c->pShift; |
| 118 | // number of zero-crossing on each side |
| 119 | c->halfNumCoefs = readResampleFirNumCoeff(); |
| 120 | ALOGV("halfNumCoefs = %d", c->halfNumCoefs); |
| 121 | // note that we "leak" resampleCoeffLib until the process exits |
| 122 | } |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 123 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 124 | // ---------------------------------------------------------------------------- |
| 125 | |
| 126 | static inline |
| 127 | int32_t mulRL(int left, int32_t in, uint32_t vRL) |
| 128 | { |
| 129 | #if defined(__arm__) && !defined(__thumb__) |
| 130 | int32_t out; |
| 131 | if (left) { |
| 132 | asm( "smultb %[out], %[in], %[vRL] \n" |
| 133 | : [out]"=r"(out) |
| 134 | : [in]"%r"(in), [vRL]"r"(vRL) |
| 135 | : ); |
| 136 | } else { |
| 137 | asm( "smultt %[out], %[in], %[vRL] \n" |
| 138 | : [out]"=r"(out) |
| 139 | : [in]"%r"(in), [vRL]"r"(vRL) |
| 140 | : ); |
| 141 | } |
| 142 | return out; |
| 143 | #else |
| 144 | if (left) { |
| 145 | return int16_t(in>>16) * int16_t(vRL&0xFFFF); |
| 146 | } else { |
| 147 | return int16_t(in>>16) * int16_t(vRL>>16); |
| 148 | } |
| 149 | #endif |
| 150 | } |
| 151 | |
| 152 | static inline |
| 153 | int32_t mulAdd(int16_t in, int32_t v, int32_t a) |
| 154 | { |
| 155 | #if defined(__arm__) && !defined(__thumb__) |
| 156 | int32_t out; |
| 157 | asm( "smlawb %[out], %[v], %[in], %[a] \n" |
| 158 | : [out]"=r"(out) |
| 159 | : [in]"%r"(in), [v]"r"(v), [a]"r"(a) |
| 160 | : ); |
| 161 | return out; |
| 162 | #else |
| 163 | return a + in * (v>>16); |
| 164 | // improved precision |
| 165 | // return a + in * (v>>16) + ((in * (v & 0xffff)) >> 16); |
| 166 | #endif |
| 167 | } |
| 168 | |
| 169 | static inline |
| 170 | int32_t mulAddRL(int left, uint32_t inRL, int32_t v, int32_t a) |
| 171 | { |
| 172 | #if defined(__arm__) && !defined(__thumb__) |
| 173 | int32_t out; |
| 174 | if (left) { |
| 175 | asm( "smlawb %[out], %[v], %[inRL], %[a] \n" |
| 176 | : [out]"=r"(out) |
| 177 | : [inRL]"%r"(inRL), [v]"r"(v), [a]"r"(a) |
| 178 | : ); |
| 179 | } else { |
| 180 | asm( "smlawt %[out], %[v], %[inRL], %[a] \n" |
| 181 | : [out]"=r"(out) |
| 182 | : [inRL]"%r"(inRL), [v]"r"(v), [a]"r"(a) |
| 183 | : ); |
| 184 | } |
| 185 | return out; |
| 186 | #else |
| 187 | if (left) { |
| 188 | return a + (int16_t(inRL&0xFFFF) * (v>>16)); |
| 189 | //improved precision |
| 190 | // return a + (int16_t(inRL&0xFFFF) * (v>>16)) + ((int16_t(inRL&0xFFFF) * (v & 0xffff)) >> 16); |
| 191 | } else { |
| 192 | return a + (int16_t(inRL>>16) * (v>>16)); |
| 193 | } |
| 194 | #endif |
| 195 | } |
| 196 | |
| 197 | // ---------------------------------------------------------------------------- |
| 198 | |
| 199 | AudioResamplerSinc::AudioResamplerSinc(int bitDepth, |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 200 | int inChannelCount, int32_t sampleRate, src_quality quality) |
| 201 | : AudioResampler(bitDepth, inChannelCount, sampleRate, quality), |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 202 | mState(0) |
| 203 | { |
| 204 | /* |
| 205 | * Layout of the state buffer for 32 tap: |
| 206 | * |
| 207 | * "present" sample beginning of 2nd buffer |
| 208 | * v v |
| 209 | * 0 01 2 23 3 |
| 210 | * 0 F0 0 F0 F |
| 211 | * [pppppppppppppppInnnnnnnnnnnnnnnnpppppppppppppppInnnnnnnnnnnnnnnn] |
| 212 | * ^ ^ head |
| 213 | * |
| 214 | * p = past samples, convoluted with the (p)ositive side of sinc() |
| 215 | * n = future samples, convoluted with the (n)egative side of sinc() |
| 216 | * r = extra space for implementing the ring buffer |
| 217 | * |
| 218 | */ |
| 219 | |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 220 | // Load the constants for coefficients |
| 221 | int ok = pthread_once(&once_control, init_routine); |
| 222 | if (ok != 0) { |
| 223 | ALOGE("%s pthread_once failed: %d", __func__, ok); |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 224 | } |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 225 | mConstants = (quality == VERY_HIGH_QUALITY) ? &veryHighQualityConstants : &highQualityConstants; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 226 | } |
| 227 | |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 228 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 229 | AudioResamplerSinc::~AudioResamplerSinc() |
| 230 | { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 231 | delete[] mState; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void AudioResamplerSinc::init() { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 235 | const Constants *c = mConstants; |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 236 | |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 237 | const size_t numCoefs = 2*c->halfNumCoefs; |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 238 | const size_t stateSize = numCoefs * mChannelCount * 2; |
| 239 | mState = new int16_t[stateSize]; |
| 240 | memset(mState, 0, sizeof(int16_t)*stateSize); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 241 | mImpulse = mState + (c->halfNumCoefs-1)*mChannelCount; |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 242 | mRingFull = mImpulse + (numCoefs+1)*mChannelCount; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount, |
| 246 | AudioBufferProvider* provider) |
| 247 | { |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 248 | |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 249 | // FIXME store current state (up or down sample) and only load the coefs when the state |
| 250 | // changes. Or load two pointers one for up and one for down in the init function. |
| 251 | // Not critical now since the read functions are fast, but would be important if read was slow. |
Mathias Agopian | 61ea117 | 2012-10-21 03:04:05 -0700 | [diff] [blame] | 252 | if (mConstants == &veryHighQualityConstants && readResampleCoefficients) { |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 253 | ALOGV("get coefficient from libmm-audio resampler library"); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 254 | mFirCoefs = (mInSampleRate <= mSampleRate) ? readResampleCoefficients(true) : |
| 255 | readResampleCoefficients(false); |
| 256 | } else { |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 257 | ALOGV("Use default coefficients"); |
| 258 | mFirCoefs = (mInSampleRate <= mSampleRate) ? mFirCoefsUp : mFirCoefsDown; |
| 259 | } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 260 | |
| 261 | // select the appropriate resampler |
| 262 | switch (mChannelCount) { |
| 263 | case 1: |
| 264 | resample<1>(out, outFrameCount, provider); |
| 265 | break; |
| 266 | case 2: |
| 267 | resample<2>(out, outFrameCount, provider); |
| 268 | break; |
| 269 | } |
SathishKumar Mani | 76b1116 | 2012-01-17 10:49:47 -0800 | [diff] [blame] | 270 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | |
| 274 | template<int CHANNELS> |
| 275 | void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount, |
| 276 | AudioBufferProvider* provider) |
| 277 | { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 278 | const Constants *c = mConstants; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 279 | int16_t* impulse = mImpulse; |
| 280 | uint32_t vRL = mVolumeRL; |
| 281 | size_t inputIndex = mInputIndex; |
| 282 | uint32_t phaseFraction = mPhaseFraction; |
| 283 | uint32_t phaseIncrement = mPhaseIncrement; |
| 284 | size_t outputIndex = 0; |
| 285 | size_t outputSampleCount = outFrameCount * 2; |
| 286 | size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate; |
| 287 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 288 | while (outputIndex < outputSampleCount) { |
| 289 | // buffer is empty, fetch a new one |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 290 | while (mBuffer.frameCount == 0) { |
| 291 | mBuffer.frameCount = inFrameCount; |
John Grossman | 4ff14ba | 2012-02-08 16:37:41 -0800 | [diff] [blame] | 292 | provider->getNextBuffer(&mBuffer, |
| 293 | calculateOutputPTS(outputIndex / 2)); |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 294 | if (mBuffer.raw == NULL) { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 295 | goto resample_exit; |
| 296 | } |
| 297 | const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits; |
| 298 | if (phaseIndex == 1) { |
| 299 | // read one frame |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 300 | read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 301 | } else if (phaseIndex == 2) { |
| 302 | // read 2 frames |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 303 | read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 304 | inputIndex++; |
| 305 | if (inputIndex >= mBuffer.frameCount) { |
| 306 | inputIndex -= mBuffer.frameCount; |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 307 | provider->releaseBuffer(&mBuffer); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 308 | } else { |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 309 | read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 310 | } |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 311 | } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 312 | } |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 313 | int16_t *in = mBuffer.i16; |
| 314 | const size_t frameCount = mBuffer.frameCount; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 315 | |
| 316 | // Always read-in the first samples from the input buffer |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 317 | int16_t* head = impulse + c->halfNumCoefs*CHANNELS; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 318 | head[0] = in[inputIndex*CHANNELS + 0]; |
| 319 | if (CHANNELS == 2) |
| 320 | head[1] = in[inputIndex*CHANNELS + 1]; |
| 321 | |
| 322 | // handle boundary case |
| 323 | int32_t l, r; |
| 324 | while (outputIndex < outputSampleCount) { |
| 325 | filterCoefficient<CHANNELS>(l, r, phaseFraction, impulse); |
| 326 | out[outputIndex++] += 2 * mulRL(1, l, vRL); |
| 327 | out[outputIndex++] += 2 * mulRL(0, r, vRL); |
| 328 | |
| 329 | phaseFraction += phaseIncrement; |
| 330 | const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits; |
| 331 | if (phaseIndex == 1) { |
| 332 | inputIndex++; |
| 333 | if (inputIndex >= frameCount) |
| 334 | break; // need a new buffer |
| 335 | read<CHANNELS>(impulse, phaseFraction, in, inputIndex); |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 336 | } else if (phaseIndex == 2) { // maximum value |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 337 | inputIndex++; |
| 338 | if (inputIndex >= frameCount) |
| 339 | break; // 0 frame available, 2 frames needed |
| 340 | // read first frame |
| 341 | read<CHANNELS>(impulse, phaseFraction, in, inputIndex); |
| 342 | inputIndex++; |
| 343 | if (inputIndex >= frameCount) |
| 344 | break; // 0 frame available, 1 frame needed |
| 345 | // read second frame |
| 346 | read<CHANNELS>(impulse, phaseFraction, in, inputIndex); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | // if done with buffer, save samples |
| 351 | if (inputIndex >= frameCount) { |
| 352 | inputIndex -= frameCount; |
Glenn Kasten | d198b61 | 2012-02-02 14:09:43 -0800 | [diff] [blame] | 353 | provider->releaseBuffer(&mBuffer); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | resample_exit: |
| 358 | mImpulse = impulse; |
| 359 | mInputIndex = inputIndex; |
| 360 | mPhaseFraction = phaseFraction; |
| 361 | } |
| 362 | |
| 363 | template<int CHANNELS> |
| 364 | /*** |
| 365 | * read() |
| 366 | * |
| 367 | * This function reads only one frame from input buffer and writes it in |
| 368 | * state buffer |
| 369 | * |
| 370 | **/ |
| 371 | void AudioResamplerSinc::read( |
| 372 | int16_t*& impulse, uint32_t& phaseFraction, |
Glenn Kasten | 54c3b66 | 2012-01-06 07:46:30 -0800 | [diff] [blame] | 373 | const int16_t* in, size_t inputIndex) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 374 | { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 375 | const Constants *c = mConstants; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 376 | const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits; |
| 377 | impulse += CHANNELS; |
| 378 | phaseFraction -= 1LU<<kNumPhaseBits; |
| 379 | if (impulse >= mRingFull) { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 380 | const size_t stateSize = (c->halfNumCoefs*2)*CHANNELS; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 381 | memcpy(mState, mState+stateSize, sizeof(int16_t)*stateSize); |
| 382 | impulse -= stateSize; |
| 383 | } |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 384 | int16_t* head = impulse + c->halfNumCoefs*CHANNELS; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 385 | head[0] = in[inputIndex*CHANNELS + 0]; |
| 386 | if (CHANNELS == 2) |
| 387 | head[1] = in[inputIndex*CHANNELS + 1]; |
| 388 | } |
| 389 | |
| 390 | template<int CHANNELS> |
| 391 | void AudioResamplerSinc::filterCoefficient( |
Glenn Kasten | 54c3b66 | 2012-01-06 07:46:30 -0800 | [diff] [blame] | 392 | int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 393 | { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 394 | const Constants *c = mConstants; |
| 395 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 396 | // compute the index of the coefficient on the positive side and |
| 397 | // negative side |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 398 | uint32_t indexP = (phase & c->cMask) >> c->cShift; |
| 399 | uint16_t lerpP = (phase & c->pMask) >> c->pShift; |
| 400 | uint32_t indexN = (-phase & c->cMask) >> c->cShift; |
| 401 | uint16_t lerpN = (-phase & c->pMask) >> c->pShift; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 402 | if ((indexP == 0) && (lerpP == 0)) { |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 403 | indexN = c->cMask >> c->cShift; |
| 404 | lerpN = c->pMask >> c->pShift; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | l = 0; |
| 408 | r = 0; |
Glenn Kasten | 54c3b66 | 2012-01-06 07:46:30 -0800 | [diff] [blame] | 409 | const int32_t* coefs = mFirCoefs; |
| 410 | const int16_t *sP = samples; |
| 411 | const int16_t *sN = samples+CHANNELS; |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 412 | for (unsigned int i=0 ; i < c->halfNumCoefs/4 ; i++) { |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 413 | interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP); |
| 414 | interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 415 | sP -= CHANNELS; sN += CHANNELS; coefs += 1 << c->coefsBits; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 416 | interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP); |
| 417 | interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 418 | sP -= CHANNELS; sN += CHANNELS; coefs += 1 << c->coefsBits; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 419 | interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP); |
| 420 | interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 421 | sP -= CHANNELS; sN += CHANNELS; coefs += 1 << c->coefsBits; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 422 | interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP); |
| 423 | interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN); |
Glenn Kasten | ac60205 | 2012-10-01 14:04:31 -0700 | [diff] [blame] | 424 | sP -= CHANNELS; sN += CHANNELS; coefs += 1 << c->coefsBits; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | |
| 428 | template<int CHANNELS> |
| 429 | void AudioResamplerSinc::interpolate( |
| 430 | int32_t& l, int32_t& r, |
Glenn Kasten | 54c3b66 | 2012-01-06 07:46:30 -0800 | [diff] [blame] | 431 | const int32_t* coefs, int16_t lerp, const int16_t* samples) |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 432 | { |
| 433 | int32_t c0 = coefs[0]; |
| 434 | int32_t c1 = coefs[1]; |
| 435 | int32_t sinc = mulAdd(lerp, (c1-c0)<<1, c0); |
| 436 | if (CHANNELS == 2) { |
Glenn Kasten | 54c3b66 | 2012-01-06 07:46:30 -0800 | [diff] [blame] | 437 | uint32_t rl = *reinterpret_cast<const uint32_t*>(samples); |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 438 | l = mulAddRL(1, rl, sinc, l); |
| 439 | r = mulAddRL(0, rl, sinc, r); |
| 440 | } else { |
| 441 | r = l = mulAdd(samples[0], sinc, l); |
| 442 | } |
| 443 | } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 444 | // ---------------------------------------------------------------------------- |
| 445 | }; // namespace android |