26
26
extern const FFPsyModel ff_aac_psy_model;
28
av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx,
30
const uint8_t **bands, const int* num_bands)
28
av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
29
const uint8_t **bands, const int* num_bands,
30
int num_groups, const uint8_t *group_map)
32
34
ctx->avctx = avctx;
33
ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
35
ctx->ch = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
36
ctx->group = av_mallocz(sizeof(ctx->group[0]) * num_groups);
34
37
ctx->bands = av_malloc (sizeof(ctx->bands[0]) * num_lens);
35
38
ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
36
39
memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens);
37
40
memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens);
42
/* assign channels to groups (with virtual channels for coupling) */
43
for (i = 0; i < num_groups; i++) {
44
/* NOTE: Add 1 to handle the AAC chan_config without modification.
45
* This has the side effect of allowing an array of 0s to map
46
* to one channel per group.
48
ctx->group[i].num_ch = group_map[i] + 1;
49
for (j = 0; j < ctx->group[i].num_ch * 2; j++)
50
ctx->group[i].ch[j] = &ctx->ch[k++];
38
53
switch (ctx->avctx->codec_id) {
40
55
ctx->model = &ff_aac_psy_model;
63
FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel)
68
ch += ctx->group[i++].num_ch;
70
return &ctx->group[i-1];
48
73
av_cold void ff_psy_end(FFPsyContext *ctx)
50
75
if (ctx->model->end)
51
76
ctx->model->end(ctx);
52
77
av_freep(&ctx->bands);
53
78
av_freep(&ctx->num_bands);
54
av_freep(&ctx->psy_bands);
79
av_freep(&ctx->group);
57
83
typedef struct FFPsyPreprocessContext{