OLD | NEW |
1 /* | 1 /* |
2 * Atrac 1 compatible decoder | 2 * Atrac 1 compatible decoder |
3 * Copyright (c) 2009 Maxim Poliakovski | 3 * Copyright (c) 2009 Maxim Poliakovski |
4 * Copyright (c) 2009 Benjamin Larsson | 4 * Copyright (c) 2009 Benjamin Larsson |
5 * | 5 * |
6 * This file is part of FFmpeg. | 6 * This file is part of FFmpeg. |
7 * | 7 * |
8 * FFmpeg is free software; you can redistribute it and/or | 8 * FFmpeg is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 /* Many thanks to Tim Craig for all the help! */ | 29 /* Many thanks to Tim Craig for all the help! */ |
30 | 30 |
31 #include <math.h> | 31 #include <math.h> |
32 #include <stddef.h> | 32 #include <stddef.h> |
33 #include <stdio.h> | 33 #include <stdio.h> |
34 | 34 |
35 #include "avcodec.h" | 35 #include "avcodec.h" |
36 #include "get_bits.h" | 36 #include "get_bits.h" |
37 #include "dsputil.h" | 37 #include "dsputil.h" |
| 38 #include "fft.h" |
38 | 39 |
39 #include "atrac.h" | 40 #include "atrac.h" |
40 #include "atrac1data.h" | 41 #include "atrac1data.h" |
41 | 42 |
42 #define AT1_MAX_BFU 52 ///< max number of block floating un
its in a sound unit | 43 #define AT1_MAX_BFU 52 ///< max number of block floating un
its in a sound unit |
43 #define AT1_SU_SIZE 212 ///< number of bytes in a sound unit | 44 #define AT1_SU_SIZE 212 ///< number of bytes in a sound unit |
44 #define AT1_SU_SAMPLES 512 ///< number of samples in a sound un
it | 45 #define AT1_SU_SAMPLES 512 ///< number of samples in a sound un
it |
45 #define AT1_FRAME_SIZE AT1_SU_SIZE * 2 | 46 #define AT1_FRAME_SIZE AT1_SU_SIZE * 2 |
46 #define AT1_SU_MAX_BITS AT1_SU_SIZE * 8 | 47 #define AT1_SU_MAX_BITS AT1_SU_SIZE * 8 |
47 #define AT1_MAX_CHANNELS 2 | 48 #define AT1_MAX_CHANNELS 2 |
48 | 49 |
49 #define AT1_QMF_BANDS 3 | 50 #define AT1_QMF_BANDS 3 |
50 #define IDX_LOW_BAND 0 | 51 #define IDX_LOW_BAND 0 |
51 #define IDX_MID_BAND 1 | 52 #define IDX_MID_BAND 1 |
52 #define IDX_HIGH_BAND 2 | 53 #define IDX_HIGH_BAND 2 |
53 | 54 |
54 /** | 55 /** |
55 * Sound unit struct, one unit is used per channel | 56 * Sound unit struct, one unit is used per channel |
56 */ | 57 */ |
57 typedef struct { | 58 typedef struct { |
58 int log2_block_count[AT1_QMF_BANDS]; ///< log2 number of
blocks in a band | 59 int log2_block_count[AT1_QMF_BANDS]; ///< log2 number of
blocks in a band |
59 int num_bfus; ///< number of Block
Floating Units | 60 int num_bfus; ///< number of Block
Floating Units |
60 float* spectrum[2]; | 61 float* spectrum[2]; |
61 DECLARE_ALIGNED_16(float, spec1)[AT1_SU_SAMPLES]; ///< mdct buffer | 62 DECLARE_ALIGNED(16, float, spec1)[AT1_SU_SAMPLES]; ///< mdct buffer |
62 DECLARE_ALIGNED_16(float, spec2)[AT1_SU_SAMPLES]; ///< mdct buffer | 63 DECLARE_ALIGNED(16, float, spec2)[AT1_SU_SAMPLES]; ///< mdct buffer |
63 DECLARE_ALIGNED_16(float, fst_qmf_delay)[46]; ///< delay line for th
e 1st stacked QMF filter | 64 DECLARE_ALIGNED(16, float, fst_qmf_delay)[46]; ///< delay line for t
he 1st stacked QMF filter |
64 DECLARE_ALIGNED_16(float, snd_qmf_delay)[46]; ///< delay line for th
e 2nd stacked QMF filter | 65 DECLARE_ALIGNED(16, float, snd_qmf_delay)[46]; ///< delay line for t
he 2nd stacked QMF filter |
65 DECLARE_ALIGNED_16(float, last_qmf_delay)[256+23]; ///< delay line for th
e last stacked QMF filter | 66 DECLARE_ALIGNED(16, float, last_qmf_delay)[256+23]; ///< delay line for t
he last stacked QMF filter |
66 } AT1SUCtx; | 67 } AT1SUCtx; |
67 | 68 |
68 /** | 69 /** |
69 * The atrac1 context, holds all needed parameters for decoding | 70 * The atrac1 context, holds all needed parameters for decoding |
70 */ | 71 */ |
71 typedef struct { | 72 typedef struct { |
72 AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound u
nit | 73 AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound u
nit |
73 DECLARE_ALIGNED_16(float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectrum
buffer | 74 DECLARE_ALIGNED(16, float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectru
m buffer |
74 | 75 |
75 DECLARE_ALIGNED_16(float, low)[256]; | 76 DECLARE_ALIGNED(16, float, low)[256]; |
76 DECLARE_ALIGNED_16(float, mid)[256]; | 77 DECLARE_ALIGNED(16, float, mid)[256]; |
77 DECLARE_ALIGNED_16(float, high)[512]; | 78 DECLARE_ALIGNED(16, float, high)[512]; |
78 float* bands[3]; | 79 float* bands[3]; |
79 DECLARE_ALIGNED_16(float, out_samples)[AT1_MAX_CHANNELS][AT1_SU_SAMPLES]; | 80 DECLARE_ALIGNED(16, float, out_samples)[AT1_MAX_CHANNELS][AT1_SU_SAMPLES]; |
80 FFTContext mdct_ctx[3]; | 81 FFTContext mdct_ctx[3]; |
81 int channels; | 82 int channels; |
82 DSPContext dsp; | 83 DSPContext dsp; |
83 } AT1Ctx; | 84 } AT1Ctx; |
84 | 85 |
85 /** size of the transform in samples in the long mode for each QMF band */ | 86 /** size of the transform in samples in the long mode for each QMF band */ |
86 static const uint16_t samples_per_band[3] = {128, 128, 256}; | 87 static const uint16_t samples_per_band[3] = {128, 128, 256}; |
87 static const uint8_t mdct_long_nbits[3] = {7, 7, 8}; | 88 static const uint8_t mdct_long_nbits[3] = {7, 7, 8}; |
88 | 89 |
89 | 90 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } else { /* word_len = 0 -> empty BFU, zero all specs in the emty BF
U */ | 245 } else { /* word_len = 0 -> empty BFU, zero all specs in the emty BF
U */ |
245 memset(&spec[pos], 0, num_specs * sizeof(float)); | 246 memset(&spec[pos], 0, num_specs * sizeof(float)); |
246 } | 247 } |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
250 return 0; | 251 return 0; |
251 } | 252 } |
252 | 253 |
253 | 254 |
254 void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx* su, float *pOut) | 255 static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx* su, float *pOut) |
255 { | 256 { |
256 float temp[256]; | 257 float temp[256]; |
257 float iqmf_temp[512 + 46]; | 258 float iqmf_temp[512 + 46]; |
258 | 259 |
259 /* combine low and middle bands */ | 260 /* combine low and middle bands */ |
260 atrac_iqmf(q->bands[0], q->bands[1], 128, temp, su->fst_qmf_delay, iqmf_temp
); | 261 atrac_iqmf(q->bands[0], q->bands[1], 128, temp, su->fst_qmf_delay, iqmf_temp
); |
261 | 262 |
262 /* delay the signal of the high band by 23 samples */ | 263 /* delay the signal of the high band by 23 samples */ |
263 memcpy( su->last_qmf_delay, &su->last_qmf_delay[256], sizeof(float) * 23
); | 264 memcpy( su->last_qmf_delay, &su->last_qmf_delay[256], sizeof(float) * 23
); |
264 memcpy(&su->last_qmf_delay[23], q->bands[2], sizeof(float) * 256
); | 265 memcpy(&su->last_qmf_delay[23], q->bands[2], sizeof(float) * 256
); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 AVCodec atrac1_decoder = { | 373 AVCodec atrac1_decoder = { |
373 .name = "atrac1", | 374 .name = "atrac1", |
374 .type = CODEC_TYPE_AUDIO, | 375 .type = CODEC_TYPE_AUDIO, |
375 .id = CODEC_ID_ATRAC1, | 376 .id = CODEC_ID_ATRAC1, |
376 .priv_data_size = sizeof(AT1Ctx), | 377 .priv_data_size = sizeof(AT1Ctx), |
377 .init = atrac1_decode_init, | 378 .init = atrac1_decode_init, |
378 .close = atrac1_decode_end, | 379 .close = atrac1_decode_end, |
379 .decode = atrac1_decode_frame, | 380 .decode = atrac1_decode_frame, |
380 .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Codi
ng)"), | 381 .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Codi
ng)"), |
381 }; | 382 }; |
OLD | NEW |