| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Header file for hardcoded shared mpegaudiodec tables | ||
| 3 | * | ||
| 4 | * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | ||
| 5 | * Copyright (c) 2020 Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | ||
| 6 | * | ||
| 7 | * This file is part of FFmpeg. | ||
| 8 | * | ||
| 9 | * FFmpeg is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU Lesser General Public | ||
| 11 | * License as published by the Free Software Foundation; either | ||
| 12 | * version 2.1 of the License, or (at your option) any later version. | ||
| 13 | * | ||
| 14 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 17 | * Lesser General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU Lesser General Public | ||
| 20 | * License along with FFmpeg; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H | ||
| 25 | #define AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H | ||
| 26 | |||
| 27 | #include <stdint.h> | ||
| 28 | |||
| 29 | #define TABLE_4_3_SIZE ((8191 + 16)*4) | ||
| 30 | |||
| 31 | #if CONFIG_HARDCODED_TABLES | ||
| 32 | #define mpegaudiodec_common_tableinit() | ||
| 33 | #include "libavcodec/mpegaudiodec_common_tables.h" | ||
| 34 | #else | ||
| 35 | #include <math.h> | ||
| 36 | #include "libavutil/attributes.h" | ||
| 37 | |||
| 38 | int8_t ff_table_4_3_exp [TABLE_4_3_SIZE]; | ||
| 39 | uint32_t ff_table_4_3_value[TABLE_4_3_SIZE]; | ||
| 40 | |||
| 41 | #define FRAC_BITS 23 | ||
| 42 | #define IMDCT_SCALAR 1.759 | ||
| 43 | |||
| 44 | 90 | static av_cold void mpegaudiodec_common_tableinit(void) | |
| 45 | { | ||
| 46 | static const double exp2_lut[4] = { | ||
| 47 | 1.00000000000000000000, /* 2 ^ (0 * 0.25) */ | ||
| 48 | 1.18920711500272106672, /* 2 ^ (1 * 0.25) */ | ||
| 49 | M_SQRT2 , /* 2 ^ (2 * 0.25) */ | ||
| 50 | 1.68179283050742908606, /* 2 ^ (3 * 0.25) */ | ||
| 51 | }; | ||
| 52 | 90 | double pow43_val = 0; | |
| 53 | |||
| 54 |
2/2✓ Branch 0 taken 2954430 times.
✓ Branch 1 taken 90 times.
|
2954520 | for (int i = 1; i < TABLE_4_3_SIZE; i++) { |
| 55 | double f, fm; | ||
| 56 | int e, m; | ||
| 57 | 2954430 | double value = i / 4; | |
| 58 |
2/2✓ Branch 0 taken 738540 times.
✓ Branch 1 taken 2215890 times.
|
2954430 | if ((i & 3) == 0) |
| 59 | 738540 | pow43_val = value / IMDCT_SCALAR * cbrt(value); | |
| 60 | 2954430 | f = pow43_val * exp2_lut[i & 3]; | |
| 61 | 2954430 | fm = frexp(f, &e); | |
| 62 | 2954430 | m = llrint(fm * (1LL << 31)); | |
| 63 | 2954430 | e += FRAC_BITS - 31 + 5 - 100; | |
| 64 | |||
| 65 | /* normalized to FRAC_BITS */ | ||
| 66 | 2954430 | ff_table_4_3_value[i] = m; | |
| 67 | 2954430 | ff_table_4_3_exp [i] = -e; | |
| 68 | } | ||
| 69 | 90 | } | |
| 70 | |||
| 71 | #endif /* CONFIG_HARDCODED_TABLES */ | ||
| 72 | #endif /* AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H */ | ||
| 73 |