summaryrefslogtreecommitdiff
path: root/libavcodec/ac3enc.h
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-06-10 14:57:19 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-06-13 16:49:35 -0400
commite0cc66df61664bb6f9271d9aae3c778e1f906b4c (patch)
treee727a74f9c318b4c40f83e22d4ddaa7282c54c94 /libavcodec/ac3enc.h
parente754dfc0bba4f81fe797f240fca94fea5dfd925e (diff)
ac3enc: split templated float vs. fixed functions into a separate file.
Function pointers are used for templated functions instead of needlessly duplicating many functions.
Diffstat (limited to 'libavcodec/ac3enc.h')
-rw-r--r--libavcodec/ac3enc.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index ccdb963a7c..e9d7e0a83a 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -40,18 +40,28 @@
#define CONFIG_AC3ENC_FLOAT 0
#endif
+#define OFFSET(param) offsetof(AC3EncodeContext, options.param)
+#define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
+
+#define AC3ENC_TYPE_AC3_FIXED 0
+#define AC3ENC_TYPE_AC3 1
+#define AC3ENC_TYPE_EAC3 2
+
#if CONFIG_AC3ENC_FLOAT
+#define AC3_NAME(x) ff_ac3_float_ ## x
#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
typedef float SampleType;
typedef float CoefType;
typedef float CoefSumType;
#else
+#define AC3_NAME(x) ff_ac3_fixed_ ## x
#define MAC_COEF(d,a,b) MAC64(d,a,b)
typedef int16_t SampleType;
typedef int32_t CoefType;
typedef int64_t CoefSumType;
#endif
+
typedef struct AC3MDCTContext {
const SampleType *window; ///< MDCT window function
FFTContext fft; ///< FFT context for MDCT calculation
@@ -132,6 +142,7 @@ typedef struct AC3EncodeContext {
AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info
+ int fixed_point; ///< indicates if fixed-point encoder is being used
int eac3; ///< indicates if this is E-AC-3 vs. AC-3
int bitstream_id; ///< bitstream id (bsid)
int bitstream_mode; ///< bitstream mode (bsmod)
@@ -209,7 +220,75 @@ typedef struct AC3EncodeContext {
uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
int ref_bap_set; ///< indicates if ref_bap pointers have been set
+ /* fixed vs. float function pointers */
+ void (*mdct_end)(AC3MDCTContext *mdct);
+ int (*mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits);
+ void (*apply_window)(DSPContext *dsp, SampleType *output,
+ const SampleType *input, const SampleType *window,
+ unsigned int len);
+ int (*normalize_samples)(struct AC3EncodeContext *s);
+ void (*scale_coefficients)(struct AC3EncodeContext *s);
+
+ /* fixed vs. float templated function pointers */
+ void (*deinterleave_input_samples)(struct AC3EncodeContext *s,
+ const SampleType *samples);
+ void (*apply_mdct)(struct AC3EncodeContext *s);
+ void (*apply_channel_coupling)(struct AC3EncodeContext *s);
+ void (*compute_rematrixing_strategy)(struct AC3EncodeContext *s);
+
+ /* AC-3 vs. E-AC-3 function pointers */
void (*output_frame_header)(struct AC3EncodeContext *s);
} AC3EncodeContext;
+
+extern const int64_t ff_ac3_channel_layouts[19];
+
+int ff_ac3_encode_init(AVCodecContext *avctx);
+
+int ff_ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame,
+ int buf_size, void *data);
+
+int ff_ac3_encode_close(AVCodecContext *avctx);
+
+
+/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
+
+void ff_ac3_fixed_mdct_end(AC3MDCTContext *mdct);
+void ff_ac3_float_mdct_end(AC3MDCTContext *mdct);
+
+int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
+ int nbits);
+int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
+ int nbits);
+
+void ff_ac3_fixed_apply_window(DSPContext *dsp, SampleType *output,
+ const SampleType *input,
+ const SampleType *window, unsigned int len);
+void ff_ac3_float_apply_window(DSPContext *dsp, SampleType *output,
+ const SampleType *input,
+ const SampleType *window, unsigned int len);
+
+int ff_ac3_fixed_normalize_samples(AC3EncodeContext *s);
+int ff_ac3_float_normalize_samples(AC3EncodeContext *s);
+
+void ff_ac3_fixed_scale_coefficients(AC3EncodeContext *s);
+void ff_ac3_float_scale_coefficients(AC3EncodeContext *s);
+
+
+/* prototypes for functions in ac3enc_template.c */
+
+void ff_ac3_fixed_deinterleave_input_samples(AC3EncodeContext *s,
+ const SampleType *samples);
+void ff_ac3_float_deinterleave_input_samples(AC3EncodeContext *s,
+ const SampleType *samples);
+
+void ff_ac3_fixed_apply_mdct(AC3EncodeContext *s);
+void ff_ac3_float_apply_mdct(AC3EncodeContext *s);
+
+void ff_ac3_fixed_apply_channel_coupling(AC3EncodeContext *s);
+void ff_ac3_float_apply_channel_coupling(AC3EncodeContext *s);
+
+void ff_ac3_fixed_compute_rematrixing_strategy(AC3EncodeContext *s);
+void ff_ac3_float_compute_rematrixing_strategy(AC3EncodeContext *s);
+
#endif /* AVCODEC_AC3ENC_H */