123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- #ifndef AVCODEC_PSYMODEL_H
- #define AVCODEC_PSYMODEL_H
- #include "avcodec.h"
- #define PSY_MAX_BANDS 128
- #define PSY_MAX_CHANS 20
- #define AAC_CUTOFF_FROM_BITRATE(bit_rate,channels,sample_rate) (bit_rate ? FFMIN3(FFMIN3( \
- FFMAX(bit_rate/channels/5, bit_rate/channels*15/32 - 5500), \
- 3000 + bit_rate/channels/4, \
- 12000 + bit_rate/channels/16), \
- 22000, \
- sample_rate / 2): (sample_rate / 2))
- #define AAC_CUTOFF(s) ( \
- (s->flags & AV_CODEC_FLAG_QSCALE) \
- ? s->sample_rate / 2 \
- : AAC_CUTOFF_FROM_BITRATE(s->bit_rate, s->channels, s->sample_rate) \
- )
- typedef struct FFPsyBand {
- int bits;
- float energy;
- float threshold;
- float spread;
- } FFPsyBand;
- typedef struct FFPsyChannel {
- FFPsyBand psy_bands[PSY_MAX_BANDS];
- float entropy;
- } FFPsyChannel;
- typedef struct FFPsyChannelGroup {
- FFPsyChannel *ch[PSY_MAX_CHANS];
- uint8_t num_ch;
- uint8_t coupling[PSY_MAX_BANDS];
- } FFPsyChannelGroup;
- typedef struct FFPsyWindowInfo {
- int window_type[3];
- int window_shape;
- int num_windows;
- int grouping[8];
- float clipping[8];
- int *window_sizes;
- } FFPsyWindowInfo;
- typedef struct FFPsyContext {
- AVCodecContext *avctx;
- const struct FFPsyModel *model;
- FFPsyChannel *ch;
- FFPsyChannelGroup *group;
- int num_groups;
- int cutoff;
- uint8_t **bands;
- int *num_bands;
- int num_lens;
- struct {
- int size;
- int bits;
- int alloc;
- } bitres;
- void* model_priv_data;
- } FFPsyContext;
- typedef struct FFPsyModel {
- const char *name;
- int (*init) (FFPsyContext *apc);
-
- FFPsyWindowInfo (*window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type);
-
- void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi);
- void (*end) (FFPsyContext *apc);
- } FFPsyModel;
- int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
- const uint8_t **bands, const int *num_bands,
- int num_groups, const uint8_t *group_map);
- FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel);
- void ff_psy_end(FFPsyContext *ctx);
- struct FFPsyPreprocessContext;
- struct FFPsyPreprocessContext *ff_psy_preprocess_init(AVCodecContext *avctx);
- void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels);
- void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx);
- #endif
|