Libav
atrac3plus.h
Go to the documentation of this file.
1 /*
2  * ATRAC3+ compatible decoder
3  *
4  * Copyright (c) 2010-2013 Maxim Poliakovski
5  *
6  * This file is part of Libav.
7  *
8  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
28 #ifndef AVCODEC_ATRAC3PLUS_H
29 #define AVCODEC_ATRAC3PLUS_H
30 
31 #include <stdint.h>
32 
33 #include "libavutil/float_dsp.h"
34 #include "atrac.h"
35 #include "avcodec.h"
36 #include "fft.h"
37 #include "get_bits.h"
38 
40 #define ATRAC3P_SUBBANDS 16
41 #define ATRAC3P_SUBBAND_SAMPLES 128
42 #define ATRAC3P_FRAME_SAMPLES (ATRAC3P_SUBBAND_SAMPLES * ATRAC3P_SUBBANDS)
43 
44 #define ATRAC3P_PQF_FIR_LEN 12
45 
46 
47 #define ATRAC3P_POWER_COMP_OFF 15
48 
49 
55 };
56 
58 typedef struct Atrac3pIPQFChannelCtx {
61  int pos;
63 
65 typedef struct Atrac3pWaveEnvelope {
68  int start_pos;
69  int stop_pos;
71 
73 typedef struct Atrac3pWavesData {
76  int num_wavs;
79 
81 typedef struct Atrac3pWaveParam {
82  int freq_index;
83  int amp_sf;
84  int amp_index;
87 
89 typedef struct Atrac3pChanParams {
90  int ch_num;
92  int fill_mode;
94  int table_type;
95  int qu_wordlen[32];
96  int qu_sf_idx[32];
97  int qu_tab_idx[32];
98  int16_t spectrum[2048];
100 
101  /* imdct window shape history (2 frames) for overlapping. */
105 
106  /* gain control data history (2 frames) for overlapping. */
111 
112  /* tones data history (2 frames) for overlapping. */
117 
118 /* Per-unit sine wave parameters */
119 typedef struct Atrac3pWaveSynthParams {
129 
131 typedef struct Atrac3pChanUnitCtx {
132  /* channel unit variables */
133  int unit_type;
138  int mute_flag;
146 
147  /* Variables related to GHA tones */
151 
155 
161 void ff_atrac3p_init_vlcs(AVCodec *codec);
162 
173  int num_channels, AVCodecContext *avctx);
174 
181 void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx);
182 
186 void ff_atrac3p_init_wave_synth(void);
187 
198  int ch_num, int sb, float *out);
199 
209 void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index,
210  float *sp, int rng_index, int sb_num);
211 
223 void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
224  float *pOut, int wind_id, int sb);
225 
236  const float *in, float *out);
237 
238 extern const uint16_t ff_atrac3p_qu_to_spec_pos[33];
239 extern const float ff_atrac3p_sf_tab[64];
240 extern const float ff_atrac3p_mant_tab[8];
241 
242 #endif /* AVCODEC_ATRAC3PLUS_H */