1 /* 2 * Copyright (C) 2014 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 #ifndef ANDROID_AUDIO_SAMPLE_H 18 #define ANDROID_AUDIO_SAMPLE_H 19 20 #include <stdint.h> 21 #include <sys/cdefs.h> 22 23 __BEGIN_DECLS 24 25 /* A single signed sample expressed as minifloat, in linear range 26 * -2.0f < x < 2.0f 27 * normalized precision about 4 decimal digits, and dynamic range of approximately -104 dB to +6 dB. 28 * Representation has 13 significand bits (1 sign, 12 mantissa, 1 hidden) and 3 exponent bits. 29 * There is no signed zero because of lack of hardware support for efficient comparisons, 30 * no infinity, and no NaN. 31 */ 32 typedef int16_t sample_minifloat_t; 33 sample_minifloat_t sample_from_float(float f); 34 float float_from_sample(sample_minifloat_t sample); 35 36 __END_DECLS 37 38 #endif // ANDROID_AUDIO_SAMPLE_H 39