---
libavcodec/ac3enc.c | 64 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 44 insertions(+), 20 deletions(-)
diff --git libavcodec/ac3enc.c libavcodec/ac3enc.c
index 1de3ee6..106cc05 100644
--- libavcodec/ac3enc.c
+++ libavcodec/ac3enc.c
@@ -96,20 +96,26 @@ typedef struct AC3EncOptions {
/* encoding options */
} AC3EncOptions;
+#if !CONFIG_FLOAT
typedef struct IComplex {
SampleType re,im;
} IComplex;
+#endif
typedef struct AC3MDCTContext {
const SampleType *window; ///< MDCT window function
AVCodecContext *avctx; ///< parent context for av_log()
int nbits; ///< log2(transform size)
+#if CONFIG_FLOAT
+ FFTContext fft; ///< FFT Context for MDCT calculation
+#else
SampleType *costab; ///< FFT cos table
SampleType *sintab; ///< FFT sin table
SampleType *xcos1; ///< MDCT cos table
SampleType *xsin1; ///< MDCT sin table
SampleType *rot_tmp; ///< temp buffer for pre-rotated samples
IComplex *cplx_tmp; ///< temp buffer for complex pre-rotated samples
+#endif
} AC3MDCTContext;
typedef struct AC3Block {
@@ -272,20 +278,27 @@ static const AVClass class = { "ac3", av_default_item_name, options, LIBAVUTIL_V
*/
int exponent_group_tab[3][256];
+#if CONFIG_FLOAT
static av_cold void mdct_end(AC3MDCTContext *mdct)
{
- mdct->nbits = 0;
+ mdct->nbits = 0;
+ ff_mdct_end(&mdct->fft);
+ av_freep(&mdct->window);
+}
+#else
+static av_cold void mdct_end(AC3MDCTContext *mdct)
+{
+ mdct->nbits = 0;
av_freep(&mdct->costab);
av_freep(&mdct->sintab);
av_freep(&mdct->xcos1);
av_freep(&mdct->xsin1);
av_freep(&mdct->rot_tmp);
av_freep(&mdct->cplx_tmp);
-#if CONFIG_FLOAT
- av_freep(&mdct->window);
-#endif
}
+#endif
+#if !CONFIG_FLOAT
static av_cold int fft_init(AC3MDCTContext *mdct, int ln)
{
int i, n, n2;
@@ -311,28 +324,31 @@ fft_alloc_fail:
mdct_end(mdct);
return AVERROR(ENOMEM);
}
+#endif
-static av_cold int window_init(AC3MDCTContext *mdct)
-{
#if CONFIG_FLOAT
+static av_cold int mdct_init(AC3MDCTContext *mdct, int nbits)
+{
SampleType *window;
+ int n = 1 << nbits;
int n2 = (1 << mdct->nbits) >> 1;
+ mdct->nbits = nbits;
+
window = av_malloc(n2 * sizeof(*window));
if (!window)
return AVERROR(ENOMEM);
ff_kbd_window_init(window, 5.0, n2);
mdct->window = window;
-#else
- mdct->window = ff_ac3_window;
-#endif
- return 0;
-}
+ return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
+}
+#else
static av_cold int mdct_init(AC3MDCTContext *mdct, int nbits)
{
- int i, n, n2, n4;
int ret;
+ int n = 1 << nbits;
+ int i, n2, n4;
mdct->nbits = nbits;
@@ -340,11 +356,8 @@ static av_cold int mdct_init(AC3MDCTContext *mdct, int nbits)
if (ret)
return ret;
- ret = window_init(mdct);
- if (ret)
- return ret;
+ mdct->window = ff_ac3_window;
- n = 1 << nbits;
n2 = n >> 1;
n4 = n >> 2;
@@ -369,6 +382,9 @@ mdct_alloc_fail:
mdct_end(mdct);
return AVERROR(ENOMEM);
}
+#endif
+
+#if !CONFIG_FLOAT
/* butter fly op */
#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
@@ -493,6 +509,12 @@ static void calc_mdct(AC3MDCTContext *mdct, CoefType *out, SampleType *in)
CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i]);
}
}
+#else /* CONFIG_FLOAT */
+static void calc_mdct(AC3MDCTContext *mdct, CoefType *out, SampleType *in)
+{
+ ff_mdct_calc(&mdct->fft, out, in);
+}
+#endif /* !CONFIG_FLOAT */
#if !CONFIG_FLOAT
/* compute log2(max(abs(tab[]))) */
@@ -534,6 +556,11 @@ static int normalize_samples(AC3EncodeContext *s)
lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
return v - 9;
}
+#else /* CONFIG_FLOAT */
+static int normalize_samples(AC3EncodeContext *s)
+{
+ return 0;
+}
#endif /* !CONFIG_FLOAT */
static void apply_window(SampleType *output, const SampleType *input,
@@ -563,11 +590,8 @@ static void apply_mdct(AC3EncodeContext *s)
apply_window(s->windowed_samples, input_samples, s->mdct.window,
AC3_WINDOW_SIZE);
-#if CONFIG_FLOAT
- s->blocks[blk].exp_shift[ch] = 0;
-#else
+
s->blocks[blk].exp_shift[ch] = normalize_samples(s);
-#endif
calc_mdct(&s->mdct, s->blocks[blk].mdct_coef[ch], s->windowed_samples);
}
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc