| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2014 James Almer | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include "libavutil/attributes.h" | ||
| 22 | #include "libavcodec/flacdsp.h" | ||
| 23 | #include "libavutil/x86/cpu.h" | ||
| 24 | #include "config.h" | ||
| 25 | |||
| 26 | void ff_flac_lpc_16_sse4(int32_t *samples, const int coeffs[32], int order, | ||
| 27 | int qlevel, int len); | ||
| 28 | void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order, | ||
| 29 | int qlevel, int len); | ||
| 30 | void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order, | ||
| 31 | int qlevel, int len); | ||
| 32 | |||
| 33 | void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len); | ||
| 34 | void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int wasted, int len); | ||
| 35 | |||
| 36 | #define DECORRELATE_FUNCS(fmt, opt) \ | ||
| 37 | void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 38 | int len, int shift); \ | ||
| 39 | void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 40 | int len, int shift); \ | ||
| 41 | void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 42 | int len, int shift) | ||
| 43 | |||
| 44 | #define DECORRELATE_IFUNCS(fmt, opt) \ | ||
| 45 | void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 46 | int len, int shift); \ | ||
| 47 | void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 48 | int len, int shift); \ | ||
| 49 | void ff_flac_decorrelate_indep6_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 50 | int len, int shift); \ | ||
| 51 | void ff_flac_decorrelate_indep8_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ | ||
| 52 | int len, int shift) | ||
| 53 | |||
| 54 | DECORRELATE_FUNCS(16, sse2); | ||
| 55 | DECORRELATE_FUNCS(16, avx); | ||
| 56 | DECORRELATE_FUNCS(32, sse2); | ||
| 57 | DECORRELATE_FUNCS(32, avx); | ||
| 58 | DECORRELATE_IFUNCS(16, ssse3); | ||
| 59 | DECORRELATE_IFUNCS(16, avx); | ||
| 60 | DECORRELATE_IFUNCS(32, ssse3); | ||
| 61 | DECORRELATE_IFUNCS(32, avx); | ||
| 62 | |||
| 63 | 6508 | av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels) | |
| 64 | { | ||
| 65 | #if HAVE_X86ASM | ||
| 66 | 6508 | int cpu_flags = av_get_cpu_flags(); | |
| 67 | |||
| 68 |
2/2✓ Branch 0 taken 3763 times.
✓ Branch 1 taken 2745 times.
|
6508 | if (EXTERNAL_SSE2(cpu_flags)) { |
| 69 | 3763 | c->wasted32 = ff_flac_wasted_32_sse2; | |
| 70 |
2/2✓ Branch 0 taken 3412 times.
✓ Branch 1 taken 351 times.
|
3763 | if (fmt == AV_SAMPLE_FMT_S16) { |
| 71 | 3412 | c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2; | |
| 72 | 3412 | c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2; | |
| 73 | 3412 | c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2; | |
| 74 |
1/2✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
|
351 | } else if (fmt == AV_SAMPLE_FMT_S32) { |
| 75 | 351 | c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2; | |
| 76 | 351 | c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2; | |
| 77 | 351 | c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2; | |
| 78 | } | ||
| 79 | } | ||
| 80 |
2/2✓ Branch 0 taken 3743 times.
✓ Branch 1 taken 2765 times.
|
6508 | if (EXTERNAL_SSSE3(cpu_flags)) { |
| 81 |
2/2✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 341 times.
|
3743 | if (fmt == AV_SAMPLE_FMT_S16) { |
| 82 |
2/2✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 1680 times.
|
3402 | if (channels == 2) |
| 83 | 1722 | c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3; | |
| 84 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1673 times.
|
1680 | else if (channels == 4) |
| 85 | 7 | c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3; | |
| 86 |
2/2✓ Branch 0 taken 807 times.
✓ Branch 1 taken 866 times.
|
1673 | else if (channels == 6) |
| 87 | 807 | c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3; | |
| 88 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 859 times.
|
866 | else if (ARCH_X86_64 && channels == 8) |
| 89 | 7 | c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3; | |
| 90 |
1/2✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
|
341 | } else if (fmt == AV_SAMPLE_FMT_S32) { |
| 91 |
2/2✓ Branch 0 taken 317 times.
✓ Branch 1 taken 24 times.
|
341 | if (channels == 2) |
| 92 | 317 | c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3; | |
| 93 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 17 times.
|
24 | else if (channels == 4) |
| 94 | 7 | c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3; | |
| 95 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 7 times.
|
17 | else if (channels == 6) |
| 96 | 10 | c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3; | |
| 97 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | else if (ARCH_X86_64 && channels == 8) |
| 98 | 7 | c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3; | |
| 99 | } | ||
| 100 | } | ||
| 101 |
2/2✓ Branch 0 taken 3733 times.
✓ Branch 1 taken 2775 times.
|
6508 | if (EXTERNAL_SSE4(cpu_flags)) { |
| 102 | 3733 | c->lpc16 = ff_flac_lpc_16_sse4; | |
| 103 | 3733 | c->lpc32 = ff_flac_lpc_32_sse4; | |
| 104 | 3733 | c->wasted33 = ff_flac_wasted_33_sse4; | |
| 105 | } | ||
| 106 |
2/2✓ Branch 0 taken 3703 times.
✓ Branch 1 taken 2805 times.
|
6508 | if (EXTERNAL_AVX(cpu_flags)) { |
| 107 |
2/2✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 321 times.
|
3703 | if (fmt == AV_SAMPLE_FMT_S16) { |
| 108 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3379 times.
|
3382 | if (ARCH_X86_64 && channels == 8) |
| 109 | 3 | c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx; | |
| 110 |
1/2✓ Branch 0 taken 321 times.
✗ Branch 1 not taken.
|
321 | } else if (fmt == AV_SAMPLE_FMT_S32) { |
| 111 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 318 times.
|
321 | if (channels == 4) |
| 112 | 3 | c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx; | |
| 113 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 312 times.
|
318 | else if (channels == 6) |
| 114 | 6 | c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx; | |
| 115 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 309 times.
|
312 | else if (ARCH_X86_64 && channels == 8) |
| 116 | 3 | c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx; | |
| 117 | } | ||
| 118 | } | ||
| 119 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6508 times.
|
6508 | if (EXTERNAL_XOP(cpu_flags)) { |
| 120 | ✗ | c->lpc32 = ff_flac_lpc_32_xop; | |
| 121 | } | ||
| 122 | #endif /* HAVE_X86ASM */ | ||
| 123 | 6508 | } | |
| 124 |