Mercurial > libavcodec.hg
diff ac3dec.c @ 5307:1bcccd2de20d libavcodec
AC-3 decoder, soc revision 33, Jul 17 12:13:40 2006 UTC by cloud9
getting weired output
but its working
author | jbr |
---|---|
date | Sat, 14 Jul 2007 15:49:12 +0000 |
parents | abc5c130b448 |
children | 82b41f5a86ef |
line wrap: on
line diff
--- a/ac3dec.c Sat Jul 14 15:48:28 2007 +0000 +++ b/ac3dec.c Sat Jul 14 15:49:12 2007 +0000 @@ -1482,7 +1482,7 @@ av_log(NULL, AV_LOG_INFO, "\n"); } -static void window_and_de_interleave(float *output) +/*static void window_and_de_interleave(float *output) { int n2, n4, n8; int k; @@ -1493,22 +1493,26 @@ for (k = 0; k < n8; k++) { output[2 * k] *= window[2 * k]; + output[n2 - 2 * k - 1] *= window[n2 - 2 * k - 1]; + output[2 * k + 1] *= window[2 * k + 1]; - output[n4 + 2 * k] *= window[n4 + 2 * k]; - output[n4 + 2 * k + 1] *= window[n4 + 2 * k + 1]; + output[n2 - 2 * k - 2] *= window[n2 - 2 * k - 2]; + output[n2 + 2 * k] *= window[n2 - 2 * k - 1]; + output[n - 2 * k - 1] *= window[n - 2 * k - 1]; + output[n2 + 2 * k + 1] *= window[n2 - 2 * k - 2]; - output[3 * n4 + 2 * k] *= window[n4 -2 * k - 1]; + output[n - 2 * k - 2] *= window[n - 2 * k - 2]; output[3 * n4 + 2 * k + 1] *= window[n4 - 2 * k - 2]; } -} +}*/ static inline void overlap_and_add(float *tmp_output, float *delay, float *output) { int n; for (n = 0; n < BLOCK_SIZE; n++) { - output[n] = 2 * (tmp_output[n] + delay[n]); + output[n] = 2 * (tmp_output[n] * window[n] + delay[n] * window[255 - n]); delay[n] = tmp_output[BLOCK_SIZE + n]; } } @@ -1522,14 +1526,14 @@ if (ctx->output & AC3_OUTPUT_LFEON) { av_log(NULL, AV_LOG_INFO, "imdct lfe\n"); ff_imdct_calc(&ctx->imdct_ctx_512, ab->tmp_output, ab->transform_coeffs[0], ab->tmp_imdct); - window_and_de_interleave(ab->tmp_output); + //window_and_de_interleave(ab->tmp_output); overlap_and_add(ab->tmp_output, ab->delay[0], ab->output[0]); } for (i = 0; i < ctx->bsi.nfchans; i++) { if (!(((ab->blksw) >> i) & 1)) { av_log(NULL, AV_LOG_INFO, "imdct channel %d - block switching not enabled\n", i); ff_imdct_calc(&ctx->imdct_ctx_512, ab->tmp_output, ab->transform_coeffs[i + 1], ab->tmp_imdct); - window_and_de_interleave(ab->tmp_output); + //window_and_de_interleave(ab->tmp_output); overlap_and_add(ab->tmp_output, ab->delay[i + 1], ab->output[i + 1]); } else { av_log(NULL, AV_LOG_INFO, "imdct channel %d skipping - block switching enabled\n", i); @@ -1813,8 +1817,8 @@ do_rematrixing(ctx); do_imdct(ctx); - for(i = 0; i < nfchans; i++) - dump_floats("channel output", 10, ab->output[i + 1], BLOCK_SIZE); + /*for(i = 0; i < nfchans; i++) + dump_floats("channel output", 10, ab->output[i + 1], BLOCK_SIZE);*/ do_downmix(ctx); @@ -1828,7 +1832,7 @@ static inline int16_t convert(float f) { - short s; + /*short s; f = f * NORMFACT; if (f >= 0) s = (short)(f + 0.5); @@ -1839,7 +1843,10 @@ if (s < (short) -MAXSAMPLE) s = (short) -MAXSAMPLE; - return s; + return s;*/ + int a; + a = lrintf(f * 32767.0); + return ((int16_t)a); } static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) @@ -1915,6 +1922,7 @@ for (;j < avctx->channels; j++) { for(k = 0; k < BLOCK_SIZE; k++) { value = convert(ab->output[j][k]); + av_log(NULL, AV_LOG_INFO, "%d\t", value); *(out_samples++) = value; } }