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
*/
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
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 group of channels.
*
- * @param ctx model context
- * @param channel audio channel number
- * @param coeffs pointer to the transformed coefficients
- * @param wi window information
+ * @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)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi);
+ void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi);
void (*end) (FFPsyContext *apc);
} 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.