yading@10
|
1 /*
|
yading@10
|
2 * AAC encoder
|
yading@10
|
3 * Copyright (C) 2008 Konstantin Shishkov
|
yading@10
|
4 *
|
yading@10
|
5 * This file is part of FFmpeg.
|
yading@10
|
6 *
|
yading@10
|
7 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
8 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
9 * License as published by the Free Software Foundation; either
|
yading@10
|
10 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
11 *
|
yading@10
|
12 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
15 * Lesser General Public License for more details.
|
yading@10
|
16 *
|
yading@10
|
17 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
18 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
20 */
|
yading@10
|
21
|
yading@10
|
22 #ifndef AVCODEC_AACENC_H
|
yading@10
|
23 #define AVCODEC_AACENC_H
|
yading@10
|
24
|
yading@10
|
25 #include "libavutil/float_dsp.h"
|
yading@10
|
26 #include "avcodec.h"
|
yading@10
|
27 #include "put_bits.h"
|
yading@10
|
28
|
yading@10
|
29 #include "aac.h"
|
yading@10
|
30 #include "audio_frame_queue.h"
|
yading@10
|
31 #include "psymodel.h"
|
yading@10
|
32
|
yading@10
|
33 #define AAC_CODER_NB 4
|
yading@10
|
34
|
yading@10
|
35 typedef struct AACEncOptions {
|
yading@10
|
36 int stereo_mode;
|
yading@10
|
37 int aac_coder;
|
yading@10
|
38 } AACEncOptions;
|
yading@10
|
39
|
yading@10
|
40 struct AACEncContext;
|
yading@10
|
41
|
yading@10
|
42 typedef struct AACCoefficientsEncoder {
|
yading@10
|
43 void (*search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s,
|
yading@10
|
44 SingleChannelElement *sce, const float lambda);
|
yading@10
|
45 void (*encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce,
|
yading@10
|
46 int win, int group_len, const float lambda);
|
yading@10
|
47 void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size,
|
yading@10
|
48 int scale_idx, int cb, const float lambda);
|
yading@10
|
49 void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda);
|
yading@10
|
50 } AACCoefficientsEncoder;
|
yading@10
|
51
|
yading@10
|
52 extern AACCoefficientsEncoder ff_aac_coders[];
|
yading@10
|
53
|
yading@10
|
54 /**
|
yading@10
|
55 * AAC encoder context
|
yading@10
|
56 */
|
yading@10
|
57 typedef struct AACEncContext {
|
yading@10
|
58 AVClass *av_class;
|
yading@10
|
59 AACEncOptions options; ///< encoding options
|
yading@10
|
60 PutBitContext pb;
|
yading@10
|
61 FFTContext mdct1024; ///< long (1024 samples) frame transform context
|
yading@10
|
62 FFTContext mdct128; ///< short (128 samples) frame transform context
|
yading@10
|
63 AVFloatDSPContext fdsp;
|
yading@10
|
64 float *planar_samples[6]; ///< saved preprocessed input
|
yading@10
|
65
|
yading@10
|
66 int samplerate_index; ///< MPEG-4 samplerate index
|
yading@10
|
67 int channels; ///< channel count
|
yading@10
|
68 const uint8_t *chan_map; ///< channel configuration map
|
yading@10
|
69
|
yading@10
|
70 ChannelElement *cpe; ///< channel elements
|
yading@10
|
71 FFPsyContext psy;
|
yading@10
|
72 struct FFPsyPreprocessContext* psypp;
|
yading@10
|
73 AACCoefficientsEncoder *coder;
|
yading@10
|
74 int cur_channel;
|
yading@10
|
75 int last_frame;
|
yading@10
|
76 float lambda;
|
yading@10
|
77 AudioFrameQueue afq;
|
yading@10
|
78 DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients
|
yading@10
|
79 DECLARE_ALIGNED(32, float, scoefs)[1024]; ///< scaled coefficients
|
yading@10
|
80
|
yading@10
|
81 struct {
|
yading@10
|
82 float *samples;
|
yading@10
|
83 } buffer;
|
yading@10
|
84 } AACEncContext;
|
yading@10
|
85
|
yading@10
|
86 extern float ff_aac_pow34sf_tab[428];
|
yading@10
|
87
|
yading@10
|
88 void ff_aac_coder_init_mips(AACEncContext *c);
|
yading@10
|
89
|
yading@10
|
90 #endif /* AVCODEC_AACENC_H */
|