| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Common code for AAC cube-root table | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <math.h> | ||
| 24 | |||
| 25 | #include "cbrt_data.h" | ||
| 26 | #include "libavutil/attributes.h" | ||
| 27 | #ifdef HAVE_AV_CONFIG_H // Only include libm.h when building for the target, not the host | ||
| 28 | #include "libavutil/libm.h" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | 187 | av_cold void ff_cbrt_dbl_tableinit(double tmp_lut[TMP_LUT_SIZE]) | |
| 32 | { | ||
| 33 |
2/2✓ Branch 0 taken 765952 times.
✓ Branch 1 taken 187 times.
|
766139 | for (int idx = 0; idx < TMP_LUT_SIZE; ++idx) |
| 34 | 765952 | tmp_lut[idx] = 1; | |
| 35 | |||
| 36 | /* have to take care of non-squarefree numbers; notice that sqrt(LUT_SIZE) = 90; | ||
| 37 | * idx == 44 corresponds to 89. */ | ||
| 38 |
2/2✓ Branch 0 taken 8228 times.
✓ Branch 1 taken 187 times.
|
8415 | for (int idx = 1; idx < 45; ++idx) { |
| 39 |
2/2✓ Branch 0 taken 4301 times.
✓ Branch 1 taken 3927 times.
|
8228 | if (tmp_lut[idx] == 1) { |
| 40 | 4301 | int i = 2 * idx + 1; | |
| 41 | 4301 | double cbrt_val = i * cbrt(i); | |
| 42 |
2/2✓ Branch 0 taken 11407 times.
✓ Branch 1 taken 4301 times.
|
15708 | for (int k = i; k < LUT_SIZE; k *= i) { |
| 43 | // We only have to handle k, 3 * k, 5 * k,..., | ||
| 44 | // because only these are odd. The corresponding indices are | ||
| 45 | // k >> 1, (k >> 1) + k, (k >> 1) + 2 * k,... | ||
| 46 |
2/2✓ Branch 0 taken 1197548 times.
✓ Branch 1 taken 11407 times.
|
1208955 | for (int idx2 = k >> 1; idx2 < TMP_LUT_SIZE; idx2 += k) |
| 47 | 1197548 | tmp_lut[idx2] *= cbrt_val; | |
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 |
2/2✓ Branch 0 taken 757537 times.
✓ Branch 1 taken 187 times.
|
757724 | for (int idx = 45; idx < TMP_LUT_SIZE; ++idx) { |
| 53 |
2/2✓ Branch 0 taken 187748 times.
✓ Branch 1 taken 569789 times.
|
757537 | if (tmp_lut[idx] == 1) { |
| 54 | 187748 | int i = 2 * idx + 1; | |
| 55 | 187748 | double cbrt_val = i * cbrt(i); | |
| 56 |
2/2✓ Branch 0 taken 535381 times.
✓ Branch 1 taken 187748 times.
|
723129 | for (int idx2 = idx; idx2 < TMP_LUT_SIZE; idx2 += i) |
| 57 | 535381 | tmp_lut[idx2] *= cbrt_val; | |
| 58 | } | ||
| 59 | } | ||
| 60 | 187 | } | |
| 61 |