[FFmpeg-devel] [PATCH] lavfi/af_atempo: use av_malloc for rDFT buffers.
Takis Issaris
takis.issaris at uhasselt.be
Tue Aug 28 18:34:56 CEST 2012
Hi Nicolas,
2012/8/28 Nicolas George <nicolas.george at normalesup.org>:
> Memory obtained from av_realloc is not aligned enough for AVX.
> The buffers are always completely filled, data does not need
> to be preserved.
>
> Fix trac ticket #1692.
Works for me.
Thanks!
With friendly regards,
Takis
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/af_atempo.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
> index 7971aef..4c4d376 100644
> --- a/libavfilter/af_atempo.c
> +++ b/libavfilter/af_atempo.c
> @@ -219,6 +219,18 @@ static void yae_release_buffers(ATempoContext *atempo)
> field = new_field; \
> } while (0)
>
> +/* av_realloc is not aligned enough; fortunately, the data does not need to
> + * be preserved */
> +#define RE_MALLOC_OR_FAIL(field, field_size) \
> + do { \
> + av_freep(&field); \
> + field = av_malloc((field_size)); \
> + if (!field) { \
> + yae_release_buffers(atempo); \
> + return AVERROR(ENOMEM); \
> + } \
> + } while (0)
> +
> /**
> * Prepare filter for processing audio data of given format,
> * sample rate and number of channels.
> @@ -253,8 +265,8 @@ static int yae_reset(ATempoContext *atempo,
> // initialize audio fragment buffers:
> REALLOC_OR_FAIL(atempo->frag[0].data, atempo->window * atempo->stride);
> REALLOC_OR_FAIL(atempo->frag[1].data, atempo->window * atempo->stride);
> - REALLOC_OR_FAIL(atempo->frag[0].xdat, atempo->window * sizeof(FFTComplex));
> - REALLOC_OR_FAIL(atempo->frag[1].xdat, atempo->window * sizeof(FFTComplex));
> + RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, atempo->window * sizeof(FFTComplex));
> + RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, atempo->window * sizeof(FFTComplex));
>
> // initialize rDFT contexts:
> av_rdft_end(atempo->real_to_complex);
> @@ -275,7 +287,7 @@ static int yae_reset(ATempoContext *atempo,
> return AVERROR(ENOMEM);
> }
>
> - REALLOC_OR_FAIL(atempo->correlation, atempo->window * sizeof(FFTComplex));
> + RE_MALLOC_OR_FAIL(atempo->correlation, atempo->window * sizeof(FFTComplex));
>
> atempo->ring = atempo->window * 3;
> REALLOC_OR_FAIL(atempo->buffer, atempo->ring * atempo->stride);
> --
> 1.7.10.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
--
Met vriendelijke groeten,
Takis
More information about the ffmpeg-devel
mailing list