This fixes a segfault with assembly optimizations disabled.
---
libavcodec/ac3enc.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index e8ccde5..235d011 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -379,6 +379,7 @@ static void apply_channel_coupling(AC3EncodeContext *s)
/* calculate coupling channel from fbw channels */
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ int start0, len0;
AC3Block *block = &s->blocks[blk];
CoefType *cpl_coef = &block->mdct_coef[CPL_CH][s->start_freq[CPL_CH]];
if (!block->cpl_in_use)
@@ -391,17 +392,20 @@ static void apply_channel_coupling(AC3EncodeContext *s)
for (i = 0; i < num_cpl_coefs; i++)
cpl_coef[i] += ch_coef[i];
}
- /* note: coupling start bin % 4 will always be 1 and num_cpl_coefs
- will always be a multiple of 12, so we need to subtract 1 from
- the start and add 4 to the length when using optimized
- functions which require 16-byte alignment. */
+
+ /* align start to 16-byte boundary. align length to multiple of 32.
+ note: coupling start bin % 4 will always be 1 */
+ start0 = s->start_freq[CPL_CH] - 1;
+ len0 = FFALIGN(num_cpl_coefs + 1, 32);
+ start0 = FFMIN(256, start0 + len0) - len0;
+ cpl_coef = &block->mdct_coef[CPL_CH][start0];
/* coefficients must be clipped to +/- 1.0 in order to be encoded */
- s->dsp.vector_clipf(cpl_coef-1, cpl_coef-1, -1.0f, 1.0f, num_cpl_coefs+4);
+ s->dsp.vector_clipf(cpl_coef, cpl_coef, -1.0f, 1.0f, len0);
/* scale coupling coefficients from float to 24-bit fixed-point */
- s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][s->start_freq[CPL_CH]-1],
- cpl_coef-1, num_cpl_coefs+4);
+ s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][start0],
+ cpl_coef, len0);
}
/* calculate energy in each band in coupling channel and each fbw channel */
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel