Revision b58e2985

View differences:

libavcodec/aacenc.c
537 537
                wi[ch].num_windows    = 1;
538 538
                wi[ch].grouping[0]    = 1;
539 539
            } else {
540
                wi[ch] = ff_psy_suggest_window(&s->psy, samples2, la, cur_channel,
541
                                               ics->window_sequence[0]);
540
                wi[ch] = s->psy.model->window(&s->psy, samples2, la, cur_channel,
541
                                              ics->window_sequence[0]);
542 542
            }
543 543
            ics->window_sequence[1] = ics->window_sequence[0];
544 544
            ics->window_sequence[0] = wi[ch].window_type[0];
......
570 570
            put_bits(&s->pb, 4, chan_el_counter[tag]++);
571 571
            for (ch = 0; ch < chans; ch++) {
572 572
                s->cur_channel = start_ch + ch;
573
                ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[ch].coeffs, &wi[ch]);
573
                s->psy.model->analyze(&s->psy, s->cur_channel, cpe->ch[ch].coeffs, &wi[ch]);
574 574
                s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda);
575 575
            }
576 576
            cpe->common_window = 0;
libavcodec/psymodel.c
45 45
    return 0;
46 46
}
47 47

  
48
FFPsyWindowInfo ff_psy_suggest_window(FFPsyContext *ctx,
49
                                      const int16_t *audio, const int16_t *la,
50
                                      int channel, int prev_type)
51
{
52
    return ctx->model->window(ctx, audio, la, channel, prev_type);
53
}
54

  
55
void ff_psy_set_band_info(FFPsyContext *ctx, int channel,
56
                          const float *coeffs, const FFPsyWindowInfo *wi)
57
{
58
    ctx->model->analyze(ctx, channel, coeffs, wi);
59
}
60

  
61 48
av_cold void ff_psy_end(FFPsyContext *ctx)
62 49
{
63 50
    if (ctx->model->end)
libavcodec/psymodel.h
80 80
typedef struct FFPsyModel {
81 81
    const char *name;
82 82
    int  (*init)   (FFPsyContext *apc);
83

  
84
    /**
85
     * Suggest window sequence for channel.
86
     *
87
     * @param ctx       model context
88
     * @param audio     samples for the current frame
89
     * @param la        lookahead samples (NULL when unavailable)
90
     * @param channel   number of channel element to analyze
91
     * @param prev_type previous window type
92
     *
93
     * @return suggested window information in a structure
94
     */
83 95
    FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type);
96

  
97
    /**
98
     * Perform psychoacoustic analysis and set band info (threshold, energy).
99
     *
100
     * @param ctx     model context
101
     * @param channel audio channel number
102
     * @param coeffs  pointer to the transformed coefficients
103
     * @param wi      window information
104
     */
84 105
    void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi);
106

  
85 107
    void (*end)    (FFPsyContext *apc);
86 108
} FFPsyModel;
87 109

  
......
101 123
                        const uint8_t **bands, const int* num_bands);
102 124

  
103 125
/**
104
 * Suggest window sequence for channel.
105
 *
106
 * @param ctx       model context
107
 * @param audio     samples for the current frame
108
 * @param la        lookahead samples (NULL when unavailable)
109
 * @param channel   number of channel element to analyze
110
 * @param prev_type previous window type
111
 *
112
 * @return suggested window information in a structure
113
 */
114
FFPsyWindowInfo ff_psy_suggest_window(FFPsyContext *ctx,
115
                                      const int16_t *audio, const int16_t *la,
116
                                      int channel, int prev_type);
117

  
118

  
119
/**
120
 * Perform psychoacoustic analysis and set band info (threshold, energy).
121
 *
122
 * @param ctx     model context
123
 * @param channel audio channel number
124
 * @param coeffs  pointer to the transformed coefficients
125
 * @param wi      window information
126
 */
127
void ff_psy_set_band_info(FFPsyContext *ctx, int channel, const float *coeffs,
128
                          const FFPsyWindowInfo *wi);
129

  
130
/**
131 126
 * Cleanup model context at the end.
132 127
 *
133 128
 * @param ctx model context

Also available in: Unified diff