~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/ac3enc.h

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:23:28 UTC
  • mfrom: (0.4.7 sid)
  • mto: This revision was merged to the branch mainline in revision 76.
  • Revision ID: package-import@ubuntu.com-20120112222328-8jqdyodym3p84ygu
Tags: 2:1.0~rc4.dfsg1+svn34540-1
* New upstream snapshot
* upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#if CONFIG_AC3ENC_FLOAT
51
51
#define AC3_NAME(x) ff_ac3_float_ ## x
52
52
#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
 
53
#define COEF_MIN (-16777215.0/16777216.0)
 
54
#define COEF_MAX ( 16777215.0/16777216.0)
 
55
#define NEW_CPL_COORD_THRESHOLD 0.03
53
56
typedef float SampleType;
54
57
typedef float CoefType;
55
58
typedef float CoefSumType;
56
59
#else
57
60
#define AC3_NAME(x) ff_ac3_fixed_ ## x
58
61
#define MAC_COEF(d,a,b) MAC64(d,a,b)
 
62
#define COEF_MIN -16777215
 
63
#define COEF_MAX  16777215
 
64
#define NEW_CPL_COORD_THRESHOLD 503317
59
65
typedef int16_t SampleType;
60
66
typedef int32_t CoefType;
61
67
typedef int64_t CoefSumType;
62
68
#endif
63
69
 
64
 
 
65
 
typedef struct AC3MDCTContext {
66
 
    const SampleType *window;           ///< MDCT window function
67
 
    FFTContext fft;                     ///< FFT context for MDCT calculation
68
 
} AC3MDCTContext;
 
70
/* common option values */
 
71
#define AC3ENC_OPT_NONE            -1
 
72
#define AC3ENC_OPT_AUTO            -1
 
73
#define AC3ENC_OPT_OFF              0
 
74
#define AC3ENC_OPT_ON               1
 
75
#define AC3ENC_OPT_NOT_INDICATED    0
 
76
#define AC3ENC_OPT_MODE_ON          2
 
77
#define AC3ENC_OPT_MODE_OFF         1
 
78
 
 
79
/* specific option values */
 
80
#define AC3ENC_OPT_LARGE_ROOM       1
 
81
#define AC3ENC_OPT_SMALL_ROOM       2
 
82
#define AC3ENC_OPT_DOWNMIX_LTRT     1
 
83
#define AC3ENC_OPT_DOWNMIX_LORO     2
 
84
#define AC3ENC_OPT_ADCONV_STANDARD  0
 
85
#define AC3ENC_OPT_ADCONV_HDCD      1
 
86
 
69
87
 
70
88
/**
71
89
 * Encoding Options used by AVOption.
92
110
    int dolby_surround_ex_mode;
93
111
    int dolby_headphone_mode;
94
112
    int ad_converter_type;
 
113
    int eac3_mixing_metadata;
 
114
    int eac3_info_metadata;
95
115
 
96
116
    /* other encoding options */
97
117
    int allow_per_frame_metadata;
122
142
    int      cpl_in_use;                        ///< coupling in use for this block     (cplinu)
123
143
    uint8_t  channel_in_cpl[AC3_MAX_CHANNELS];  ///< channel in coupling                (chincpl)
124
144
    int      num_cpl_channels;                  ///< number of channels in coupling
125
 
    uint8_t  new_cpl_coords;                    ///< send new coupling coordinates      (cplcoe)
 
145
    uint8_t  new_cpl_coords[AC3_MAX_CHANNELS];  ///< send new coupling coordinates      (cplcoe)
126
146
    uint8_t  cpl_master_exp[AC3_MAX_CHANNELS];  ///< coupling coord master exponents    (mstrcplco)
127
147
    int      new_snr_offsets;                   ///< send new SNR offsets
128
148
    int      new_cpl_leak;                      ///< send new coupling leak info
139
159
    PutBitContext pb;                       ///< bitstream writer context
140
160
    DSPContext dsp;
141
161
    AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
142
 
    AC3MDCTContext *mdct;                   ///< MDCT context
 
162
    FFTContext mdct;                        ///< FFT context for MDCT calculation
 
163
    const SampleType *mdct_window;          ///< MDCT window function array
143
164
 
144
165
    AC3Block blocks[AC3_MAX_BLOCKS];        ///< per-block info
145
166
 
151
172
    int bit_rate;                           ///< target bit rate, in bits-per-second
152
173
    int sample_rate;                        ///< sampling frequency, in Hz
153
174
 
 
175
    int num_blks_code;                      ///< number of blocks code                  (numblkscod)
 
176
    int num_blocks;                         ///< number of blocks per frame
154
177
    int frame_size_min;                     ///< minimum frame size in case rounding is necessary
155
178
    int frame_size;                         ///< current frame size in bytes
156
179
    int frame_size_code;                    ///< frame size code                        (frmsizecod)
217
240
    uint8_t *cpl_coord_mant_buffer;
218
241
 
219
242
    uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
 
243
    uint8_t frame_exp_strategy[AC3_MAX_CHANNELS];           ///< frame exp strategy index
 
244
    int use_frame_exp_strategy;                             ///< indicates use of frame exp strategy
220
245
    uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE
221
246
    uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
222
247
    int ref_bap_set;                                         ///< indicates if ref_bap pointers have been set
223
248
 
224
249
    /* fixed vs. float function pointers */
225
 
    void (*mdct_end)(AC3MDCTContext *mdct);
226
 
    int  (*mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits);
227
 
    void (*apply_window)(DSPContext *dsp, SampleType *output,
228
 
                         const SampleType *input, const SampleType *window,
229
 
                         unsigned int len);
230
 
    int  (*normalize_samples)(struct AC3EncodeContext *s);
231
 
    void (*scale_coefficients)(struct AC3EncodeContext *s);
 
250
    void (*mdct_end)(struct AC3EncodeContext *s);
 
251
    int  (*mdct_init)(struct AC3EncodeContext *s);
232
252
 
233
253
    /* fixed vs. float templated function pointers */
234
254
    int  (*allocate_sample_buffers)(struct AC3EncodeContext *s);
235
 
    void (*deinterleave_input_samples)(struct AC3EncodeContext *s,
236
 
                                       const SampleType *samples);
237
 
    void (*apply_mdct)(struct AC3EncodeContext *s);
238
 
    void (*apply_channel_coupling)(struct AC3EncodeContext *s);
239
 
    void (*compute_rematrixing_strategy)(struct AC3EncodeContext *s);
240
255
 
241
256
    /* AC-3 vs. E-AC-3 function pointers */
242
257
    void (*output_frame_header)(struct AC3EncodeContext *s);
243
258
} AC3EncodeContext;
244
259
 
245
260
 
246
 
extern const int64_t ff_ac3_channel_layouts[19];
 
261
extern const uint64_t ff_ac3_channel_layouts[19];
247
262
 
248
263
int ff_ac3_encode_init(AVCodecContext *avctx);
249
264
 
250
 
int ff_ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame,
251
 
                        int buf_size, void *data);
252
 
 
253
265
int ff_ac3_encode_close(AVCodecContext *avctx);
254
266
 
 
267
int ff_ac3_validate_metadata(AC3EncodeContext *s);
 
268
 
 
269
void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
 
270
 
 
271
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
 
272
 
 
273
void ff_ac3_apply_rematrixing(AC3EncodeContext *s);
 
274
 
 
275
void ff_ac3_process_exponents(AC3EncodeContext *s);
 
276
 
 
277
int ff_ac3_compute_bit_allocation(AC3EncodeContext *s);
 
278
 
 
279
void ff_ac3_group_exponents(AC3EncodeContext *s);
 
280
 
 
281
void ff_ac3_quantize_mantissas(AC3EncodeContext *s);
 
282
 
 
283
void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
 
284
 
255
285
 
256
286
/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
257
287
 
258
 
void ff_ac3_fixed_mdct_end(AC3MDCTContext *mdct);
259
 
void ff_ac3_float_mdct_end(AC3MDCTContext *mdct);
260
 
 
261
 
int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
262
 
                           int nbits);
263
 
int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
264
 
                           int nbits);
265
 
 
266
 
void ff_ac3_fixed_apply_window(DSPContext *dsp, SampleType *output,
267
 
                               const SampleType *input,
268
 
                               const SampleType *window, unsigned int len);
269
 
void ff_ac3_float_apply_window(DSPContext *dsp, SampleType *output,
270
 
                               const SampleType *input,
271
 
                               const SampleType *window, unsigned int len);
272
 
 
273
 
int ff_ac3_fixed_normalize_samples(AC3EncodeContext *s);
274
 
 
275
 
void ff_ac3_fixed_scale_coefficients(AC3EncodeContext *s);
276
 
void ff_ac3_float_scale_coefficients(AC3EncodeContext *s);
 
288
void ff_ac3_fixed_mdct_end(AC3EncodeContext *s);
 
289
void ff_ac3_float_mdct_end(AC3EncodeContext *s);
 
290
 
 
291
int ff_ac3_fixed_mdct_init(AC3EncodeContext *s);
 
292
int ff_ac3_float_mdct_init(AC3EncodeContext *s);
277
293
 
278
294
 
279
295
/* prototypes for functions in ac3enc_template.c */
281
297
int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s);
282
298
int ff_ac3_float_allocate_sample_buffers(AC3EncodeContext *s);
283
299
 
284
 
void ff_ac3_fixed_deinterleave_input_samples(AC3EncodeContext *s,
285
 
                                             const SampleType *samples);
286
 
void ff_ac3_float_deinterleave_input_samples(AC3EncodeContext *s,
287
 
                                             const SampleType *samples);
288
 
 
289
 
void ff_ac3_fixed_apply_mdct(AC3EncodeContext *s);
290
 
void ff_ac3_float_apply_mdct(AC3EncodeContext *s);
291
 
 
292
 
void ff_ac3_fixed_apply_channel_coupling(AC3EncodeContext *s);
293
 
void ff_ac3_float_apply_channel_coupling(AC3EncodeContext *s);
294
 
 
295
 
void ff_ac3_fixed_compute_rematrixing_strategy(AC3EncodeContext *s);
296
 
void ff_ac3_float_compute_rematrixing_strategy(AC3EncodeContext *s);
 
300
int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, unsigned char *frame,
 
301
                              int buf_size, void *data);
 
302
int ff_ac3_float_encode_frame(AVCodecContext *avctx, unsigned char *frame,
 
303
                              int buf_size, void *data);
297
304
 
298
305
#endif /* AVCODEC_AC3ENC_H */