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 Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
35 typedef struct FFPsyBand {
36  int bits;
37  float energy;
38  float threshold;
39  float distortion;
41 } FFPsyBand;
42 
46 typedef struct FFPsyChannel {
48  float entropy;
49 } FFPsyChannel;
50 
54 typedef struct FFPsyChannelGroup {
56  uint8_t num_ch;
59 
63 typedef struct FFPsyWindowInfo {
64  int window_type[3];
67  int grouping[8];
68  int *window_sizes;
70 
74 typedef struct FFPsyContext {
76  const struct FFPsyModel *model;
77 
80  int num_groups;
81 
82  uint8_t **bands;
83  int *num_bands;
84  int num_lens;
85 
86  struct {
87  int size;
88  int bits;
89  } bitres;
90 
92 } FFPsyContext;
93 
97 typedef struct FFPsyModel {
98  const char *name;
99  int (*init) (FFPsyContext *apc);
100 
112  FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type);
113 
122  void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi);
123 
124  void (*end) (FFPsyContext *apc);
125 } FFPsyModel;
126 
140 av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
141  const uint8_t **bands, const int* num_bands,
142  int num_groups, const uint8_t *group_map);
143 
153 
159 av_cold void ff_psy_end(FFPsyContext *ctx);
160 
161 
162 /**************************************************************************
163  * Audio preprocessing stuff. *
164  * This should be moved into some audio filter eventually. *
165  **************************************************************************/
167 
172 
183  const int16_t *audio, int16_t *dest,
184  int tag, int channels);
185 
190 
191 #endif /* AVCODEC_PSYMODEL_H */