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;
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;
65
typedef struct AC3MDCTContext {
66
const SampleType *window; ///< MDCT window function
67
FFTContext fft; ///< FFT context for MDCT calculation
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
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
71
89
* Encoding Options used by AVOption.
217
240
uint8_t *cpl_coord_mant_buffer;
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
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,
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);
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);
241
256
/* AC-3 vs. E-AC-3 function pointers */
242
257
void (*output_frame_header)(struct AC3EncodeContext *s);
243
258
} AC3EncodeContext;
246
extern const int64_t ff_ac3_channel_layouts[19];
261
extern const uint64_t ff_ac3_channel_layouts[19];
248
263
int ff_ac3_encode_init(AVCodecContext *avctx);
250
int ff_ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame,
251
int buf_size, void *data);
253
265
int ff_ac3_encode_close(AVCodecContext *avctx);
267
int ff_ac3_validate_metadata(AC3EncodeContext *s);
269
void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
271
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
273
void ff_ac3_apply_rematrixing(AC3EncodeContext *s);
275
void ff_ac3_process_exponents(AC3EncodeContext *s);
277
int ff_ac3_compute_bit_allocation(AC3EncodeContext *s);
279
void ff_ac3_group_exponents(AC3EncodeContext *s);
281
void ff_ac3_quantize_mantissas(AC3EncodeContext *s);
283
void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
256
286
/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
258
void ff_ac3_fixed_mdct_end(AC3MDCTContext *mdct);
259
void ff_ac3_float_mdct_end(AC3MDCTContext *mdct);
261
int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
263
int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
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);
273
int ff_ac3_fixed_normalize_samples(AC3EncodeContext *s);
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);
291
int ff_ac3_fixed_mdct_init(AC3EncodeContext *s);
292
int ff_ac3_float_mdct_init(AC3EncodeContext *s);
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);
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);
289
void ff_ac3_fixed_apply_mdct(AC3EncodeContext *s);
290
void ff_ac3_float_apply_mdct(AC3EncodeContext *s);
292
void ff_ac3_fixed_apply_channel_coupling(AC3EncodeContext *s);
293
void ff_ac3_float_apply_channel_coupling(AC3EncodeContext *s);
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);
298
305
#endif /* AVCODEC_AC3ENC_H */