| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * AAC decoder | ||
| 3 | * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) | ||
| 4 | * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) | ||
| 5 | * Copyright (c) 2008-2013 Alex Converse <alex.converse@gmail.com> | ||
| 6 | * | ||
| 7 | * AAC LATM decoder | ||
| 8 | * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz> | ||
| 9 | * Copyright (c) 2010 Janne Grunau <janne-libav@jannau.net> | ||
| 10 | * | ||
| 11 | * AAC decoder fixed-point implementation | ||
| 12 | * Copyright (c) 2013 | ||
| 13 | * MIPS Technologies, Inc., California. | ||
| 14 | * | ||
| 15 | * This file is part of FFmpeg. | ||
| 16 | * | ||
| 17 | * FFmpeg is free software; you can redistribute it and/or | ||
| 18 | * modify it under the terms of the GNU Lesser General Public | ||
| 19 | * License as published by the Free Software Foundation; either | ||
| 20 | * version 2.1 of the License, or (at your option) any later version. | ||
| 21 | * | ||
| 22 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 25 | * Lesser General Public License for more details. | ||
| 26 | * | ||
| 27 | * You should have received a copy of the GNU Lesser General Public | ||
| 28 | * License along with FFmpeg; if not, write to the Free Software | ||
| 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 30 | */ | ||
| 31 | |||
| 32 | #define USE_FIXED 0 | ||
| 33 | |||
| 34 | #include "libavutil/thread.h" | ||
| 35 | |||
| 36 | #include "libavcodec/aac_defines.h" | ||
| 37 | |||
| 38 | #include "libavcodec/avcodec.h" | ||
| 39 | #include "aacdec.h" | ||
| 40 | #include "libavcodec/aactab.h" | ||
| 41 | #include "libavcodec/sinewin.h" | ||
| 42 | #include "libavcodec/kbdwin.h" | ||
| 43 | #include "libavcodec/cbrt_data.h" | ||
| 44 | #include "libavutil/mathematics.h" | ||
| 45 | #include "libavcodec/aacsbr.h" | ||
| 46 | |||
| 47 | DECLARE_ALIGNED(32, static float, sine_96)[96]; | ||
| 48 | DECLARE_ALIGNED(32, static float, sine_120)[120]; | ||
| 49 | DECLARE_ALIGNED(32, static float, sine_768)[768]; | ||
| 50 | DECLARE_ALIGNED(32, static float, sine_960)[960]; | ||
| 51 | DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960]; | ||
| 52 | DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120]; | ||
| 53 | DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768]; | ||
| 54 | DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96]; | ||
| 55 | |||
| 56 | 169 | static void init_tables_float_fn(void) | |
| 57 | { | ||
| 58 | 169 | ff_cbrt_tableinit(); | |
| 59 | |||
| 60 | 169 | ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); | |
| 61 | 169 | ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); | |
| 62 | |||
| 63 | 169 | ff_kbd_window_init(aac_kbd_long_960, 4.0, 960); | |
| 64 | 169 | ff_kbd_window_init(aac_kbd_short_120, 6.0, 120); | |
| 65 | |||
| 66 | 169 | ff_sine_window_init(sine_960, 960); | |
| 67 | 169 | ff_sine_window_init(sine_120, 120); | |
| 68 | 169 | ff_init_ff_sine_windows(9); | |
| 69 | |||
| 70 | 169 | ff_aac_sbr_init(); | |
| 71 | |||
| 72 | 169 | ff_aac_float_common_init(); | |
| 73 | 169 | } | |
| 74 | |||
| 75 | static const float cce_scale[] = { | ||
| 76 | 1.09050773266525765921, //2^(1/8) | ||
| 77 | 1.18920711500272106672, //2^(1/4) | ||
| 78 | M_SQRT2, | ||
| 79 | 2, | ||
| 80 | }; | ||
| 81 | |||
| 82 | /** Dequantization-related **/ | ||
| 83 | #include "aacdec_tab.h" | ||
| 84 | #include "libavutil/intfloat.h" | ||
| 85 | |||
| 86 | #include "config.h" | ||
| 87 | #if ARCH_ARM | ||
| 88 | #include "libavcodec/arm/aac.h" | ||
| 89 | #endif | ||
| 90 | |||
| 91 | #ifndef VMUL2 | ||
| 92 | 1787686 | static inline float *VMUL2(float *dst, const float *v, unsigned idx, | |
| 93 | const float *scale) | ||
| 94 | { | ||
| 95 | 1787686 | float s = *scale; | |
| 96 | 1787686 | *dst++ = v[idx & 15] * s; | |
| 97 | 1787686 | *dst++ = v[idx>>4 & 15] * s; | |
| 98 | 1787686 | return dst; | |
| 99 | } | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef VMUL4 | ||
| 103 | 2154543 | static inline float *VMUL4(float *dst, const float *v, unsigned idx, | |
| 104 | const float *scale) | ||
| 105 | { | ||
| 106 | 2154543 | float s = *scale; | |
| 107 | 2154543 | *dst++ = v[idx & 3] * s; | |
| 108 | 2154543 | *dst++ = v[idx>>2 & 3] * s; | |
| 109 | 2154543 | *dst++ = v[idx>>4 & 3] * s; | |
| 110 | 2154543 | *dst++ = v[idx>>6 & 3] * s; | |
| 111 | 2154543 | return dst; | |
| 112 | } | ||
| 113 | #endif | ||
| 114 | |||
| 115 | #ifndef VMUL2S | ||
| 116 | 2255240 | static inline float *VMUL2S(float *dst, const float *v, unsigned idx, | |
| 117 | unsigned sign, const float *scale) | ||
| 118 | { | ||
| 119 | union av_intfloat32 s0, s1; | ||
| 120 | |||
| 121 | 2255240 | s0.f = s1.f = *scale; | |
| 122 | 2255240 | s0.i ^= sign >> 1 << 31; | |
| 123 | 2255240 | s1.i ^= sign << 31; | |
| 124 | |||
| 125 | 2255240 | *dst++ = v[idx & 15] * s0.f; | |
| 126 | 2255240 | *dst++ = v[idx>>4 & 15] * s1.f; | |
| 127 | |||
| 128 | 2255240 | return dst; | |
| 129 | } | ||
| 130 | #endif | ||
| 131 | |||
| 132 | #ifndef VMUL4S | ||
| 133 | 1755394 | static inline float *VMUL4S(float *dst, const float *v, unsigned idx, | |
| 134 | unsigned sign, const float *scale) | ||
| 135 | { | ||
| 136 | 1755394 | unsigned nz = idx >> 12; | |
| 137 | 1755394 | union av_intfloat32 s = { .f = *scale }; | |
| 138 | union av_intfloat32 t; | ||
| 139 | |||
| 140 | 1755394 | t.i = s.i ^ (sign & 1U<<31); | |
| 141 | 1755394 | *dst++ = v[idx & 3] * t.f; | |
| 142 | |||
| 143 | 1755394 | sign <<= nz & 1; nz >>= 1; | |
| 144 | 1755394 | t.i = s.i ^ (sign & 1U<<31); | |
| 145 | 1755394 | *dst++ = v[idx>>2 & 3] * t.f; | |
| 146 | |||
| 147 | 1755394 | sign <<= nz & 1; nz >>= 1; | |
| 148 | 1755394 | t.i = s.i ^ (sign & 1U<<31); | |
| 149 | 1755394 | *dst++ = v[idx>>4 & 3] * t.f; | |
| 150 | |||
| 151 | 1755394 | sign <<= nz & 1; | |
| 152 | 1755394 | t.i = s.i ^ (sign & 1U<<31); | |
| 153 | 1755394 | *dst++ = v[idx>>6 & 3] * t.f; | |
| 154 | |||
| 155 | 1755394 | return dst; | |
| 156 | } | ||
| 157 | #endif | ||
| 158 | |||
| 159 | #include "aacdec_float_coupling.h" | ||
| 160 | #include "aacdec_float_prediction.h" | ||
| 161 | #include "aacdec_dsp_template.c" | ||
| 162 | #include "aacdec_proc_template.c" | ||
| 163 | |||
| 164 | 283 | av_cold int ff_aac_decode_init_float(AVCodecContext *avctx) | |
| 165 | { | ||
| 166 | static AVOnce init_float_once = AV_ONCE_INIT; | ||
| 167 | 283 | AACDecContext *ac = avctx->priv_data; | |
| 168 | |||
| 169 | 283 | ac->is_fixed = 0; | |
| 170 | 283 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; | |
| 171 | |||
| 172 | 283 | aac_dsp_init(&ac->dsp); | |
| 173 | 283 | aac_proc_init(&ac->proc); | |
| 174 | |||
| 175 | 283 | ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); | |
| 176 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
|
283 | if (!ac->fdsp) |
| 177 | ✗ | return AVERROR(ENOMEM); | |
| 178 | |||
| 179 | 283 | ff_thread_once(&init_float_once, init_tables_float_fn); | |
| 180 | |||
| 181 | 283 | return ff_aac_decode_init(avctx); | |
| 182 | } | ||
| 183 |