00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_PSYMODEL_H
00023 #define AVCODEC_PSYMODEL_H
00024
00025 #include "avcodec.h"
00026
00028 #define PSY_MAX_BANDS 128
00029
00030 #define PSY_MAX_CHANS 20
00031
00032 #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))
00033
00037 typedef struct FFPsyBand {
00038 int bits;
00039 float energy;
00040 float threshold;
00041 float distortion;
00042 float perceptual_weight;
00043 } FFPsyBand;
00044
00048 typedef struct FFPsyChannel {
00049 FFPsyBand psy_bands[PSY_MAX_BANDS];
00050 float entropy;
00051 } FFPsyChannel;
00052
00056 typedef struct FFPsyChannelGroup {
00057 FFPsyChannel *ch[PSY_MAX_CHANS];
00058 uint8_t num_ch;
00059 uint8_t coupling[PSY_MAX_BANDS];
00060 } FFPsyChannelGroup;
00061
00065 typedef struct FFPsyWindowInfo {
00066 int window_type[3];
00067 int window_shape;
00068 int num_windows;
00069 int grouping[8];
00070 int *window_sizes;
00071 } FFPsyWindowInfo;
00072
00076 typedef struct FFPsyContext {
00077 AVCodecContext *avctx;
00078 const struct FFPsyModel *model;
00079
00080 FFPsyChannel *ch;
00081 FFPsyChannelGroup *group;
00082 int num_groups;
00083
00084 uint8_t **bands;
00085 int *num_bands;
00086 int num_lens;
00087
00088 struct {
00089 int size;
00090 int bits;
00091 } bitres;
00092
00093 void* model_priv_data;
00094 } FFPsyContext;
00095
00099 typedef struct FFPsyModel {
00100 const char *name;
00101 int (*init) (FFPsyContext *apc);
00102
00114 FFPsyWindowInfo (*window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type);
00115
00124 void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi);
00125
00126 void (*end) (FFPsyContext *apc);
00127 } FFPsyModel;
00128
00142 av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
00143 const uint8_t **bands, const int* num_bands,
00144 int num_groups, const uint8_t *group_map);
00145
00154 FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel);
00155
00161 av_cold void ff_psy_end(FFPsyContext *ctx);
00162
00163
00164
00165
00166
00167
00168 struct FFPsyPreprocessContext;
00169
00173 av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *avctx);
00174
00182 void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels);
00183
00187 av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx);
00188
00189 #endif