|
|
|
@ -40,6 +40,23 @@ typedef struct FFPsyBand { |
|
|
|
|
float perceptual_weight; |
|
|
|
|
} FFPsyBand; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* single channel psychoacoustic information |
|
|
|
|
*/ |
|
|
|
|
typedef struct FFPsyChannel { |
|
|
|
|
FFPsyBand psy_bands[PSY_MAX_BANDS]; ///< channel bands information
|
|
|
|
|
float entropy; ///< total PE for this channel
|
|
|
|
|
} FFPsyChannel; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* psychoacoustic information for an arbitrary group of channels |
|
|
|
|
*/ |
|
|
|
|
typedef struct FFPsyChannelGroup { |
|
|
|
|
FFPsyChannel *ch[PSY_MAX_CHANS]; ///< pointers to the individual channels in the group
|
|
|
|
|
uint8_t num_ch; ///< number of channels in this group
|
|
|
|
|
uint8_t coupling[PSY_MAX_BANDS]; ///< allow coupling for this band in the group
|
|
|
|
|
} FFPsyChannelGroup; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* windowing related information |
|
|
|
|
*/ |
|
|
|
@ -58,14 +75,14 @@ typedef struct FFPsyContext { |
|
|
|
|
AVCodecContext *avctx; ///< encoder context
|
|
|
|
|
const struct FFPsyModel *model; ///< encoder-specific model functions
|
|
|
|
|
|
|
|
|
|
FFPsyBand *psy_bands; ///< frame bands information
|
|
|
|
|
FFPsyChannel *ch; ///< single channel information
|
|
|
|
|
FFPsyChannelGroup *group; ///< channel group information
|
|
|
|
|
int num_groups; ///< number of channel groups
|
|
|
|
|
|
|
|
|
|
uint8_t **bands; ///< scalefactor band sizes for possible frame sizes
|
|
|
|
|
int *num_bands; ///< number of scalefactor bands for possible frame sizes
|
|
|
|
|
int num_lens; ///< number of scalefactor band sets
|
|
|
|
|
|
|
|
|
|
float pe[PSY_MAX_CHANS]; ///< total PE for each channel in the frame
|
|
|
|
|
|
|
|
|
|
struct { |
|
|
|
|
int size; ///< size of the bitresevoir in bits
|
|
|
|
|
int bits; ///< number of bits used in the bitresevoir
|
|
|
|
@ -95,7 +112,7 @@ typedef struct FFPsyModel { |
|
|
|
|
FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Perform psychoacoustic analysis and set band info (threshold, energy). |
|
|
|
|
* Perform psychoacoustic analysis and set band info (threshold, energy) for a single channel. |
|
|
|
|
* |
|
|
|
|
* @param ctx model context |
|
|
|
|
* @param channel audio channel number |
|
|
|
@ -104,6 +121,16 @@ typedef struct FFPsyModel { |
|
|
|
|
*/ |
|
|
|
|
void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Perform psychoacoustic analysis and set band info (threshold, energy) for a group of channels. |
|
|
|
|
* |
|
|
|
|
* @param ctx model context |
|
|
|
|
* @param channel channel number of the first channel in the group to perform analysis on |
|
|
|
|
* @param coeffs array of pointers to the transformed coefficients |
|
|
|
|
* @param wi window information for the channels in the group |
|
|
|
|
*/ |
|
|
|
|
void (*analyze_group)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi); |
|
|
|
|
|
|
|
|
|
void (*end) (FFPsyContext *apc); |
|
|
|
|
} FFPsyModel; |
|
|
|
|
|
|
|
|
@ -115,12 +142,24 @@ typedef struct FFPsyModel { |
|
|
|
|
* @param num_lens number of possible frame lengths |
|
|
|
|
* @param bands scalefactor band lengths for all frame lengths |
|
|
|
|
* @param num_bands number of scalefactor bands for all frame lengths |
|
|
|
|
* @param num_groups number of channel groups |
|
|
|
|
* @param group_map array with # of channels in group - 1, for each group |
|
|
|
|
* |
|
|
|
|
* @return zero if successful, a negative value if not |
|
|
|
|
*/ |
|
|
|
|
av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, |
|
|
|
|
int num_lens, |
|
|
|
|
const uint8_t **bands, const int* num_bands); |
|
|
|
|
av_cold 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); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine what group a channel belongs to. |
|
|
|
|
* |
|
|
|
|
* @param ctx psymodel context |
|
|
|
|
* @param channel channel to locate the group for |
|
|
|
|
* |
|
|
|
|
* @return pointer to the FFPsyChannelGroup this channel belongs to |
|
|
|
|
*/ |
|
|
|
|
FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cleanup model context at the end. |
|
|
|
|