FFmpeg  1.2.4
psymodel.h
Go to the documentation of this file.
1 /*
2  * audio encoder psychoacoustic model
3  * Copyright (C) 2008 Konstantin Shishkov
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_PSYMODEL_H
23 #define AVCODEC_PSYMODEL_H
24 
25 #include "avcodec.h"
26 
28 #define PSY_MAX_BANDS 128
29 
30 #define PSY_MAX_CHANS 20
31 
32 #define AAC_CUTOFF(s) (s->bit_rate ? FFMIN3(4000 + s->bit_rate/8, 12000 + s->bit_rate/32, s->sample_rate / 2) : (s->sample_rate / 2))
33 
37 typedef struct FFPsyBand {
38  int bits;
39  float energy;
40  float threshold;
41  float distortion;
43 } FFPsyBand;
44 
48 typedef struct FFPsyChannel {
50  float entropy;
51 } FFPsyChannel;
52 
56 typedef struct FFPsyChannelGroup {
61 
65 typedef struct FFPsyWindowInfo {
66  int window_type[3];
69  int grouping[8];
70  int *window_sizes;
72 
76 typedef struct FFPsyContext {
78  const struct FFPsyModel *model;
79 
82  int num_groups;
83 
85  int *num_bands;
86  int num_lens;
87 
88  struct {
89  int size;
90  int bits;
91  } bitres;
92 
94 } FFPsyContext;
95 
99 typedef struct FFPsyModel {
100  const char *name;
101  int (*init) (FFPsyContext *apc);
102 
114  FFPsyWindowInfo (*window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type);
115 
124  void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi);
125 
126  void (*end) (FFPsyContext *apc);
127 } FFPsyModel;
128 
142 int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
143  const uint8_t **bands, const int *num_bands,
144  int num_groups, const uint8_t *group_map);
145 
155 
161 void ff_psy_end(FFPsyContext *ctx);
162 
163 
164 /**************************************************************************
165  * Audio preprocessing stuff. *
166  * This should be moved into some audio filter eventually. *
167  **************************************************************************/
169 
174 
182 void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels);
183 
188 
189 #endif /* AVCODEC_PSYMODEL_H */