[FFmpeg-devel] [PATCH 2/3] proresdec2: Replace a VLA with a heap alloc
Michael Niedermayer
michaelni at gmx.at
Fri Sep 7 18:12:15 CEST 2012
On Fri, Sep 07, 2012 at 10:38:16AM -0400, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
> libavcodec/proresdec2.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
> index 0e32a97..6d141e2 100644
> --- a/libavcodec/proresdec2.c
> +++ b/libavcodec/proresdec2.c
> @@ -500,13 +500,24 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
> static int decode_picture(AVCodecContext *avctx)
> {
> ProresContext *ctx = avctx->priv_data;
> - int i, threads_ret[ctx->slice_count];
> + int i, ret;
> + int *threads_ret;
> +
> + threads_ret = av_malloc(ctx->slice_count * sizeof(*threads_ret));
> + if (!threads_ret)
> + return AVERROR(ENOMEM);
>
> avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count);
>
> - for (i = 0; i < ctx->slice_count; i++)
> - if (threads_ret[i] < 0)
> - return threads_ret[i];
> + for (i = 0; i < ctx->slice_count; i++) {
> + if (threads_ret[i] < 0) {
> + ret = threads_ret[i];
> + av_freep(&threads_ret);
> + return ret;
> + }
> + }
> +
> + av_freep(&threads_ret);
>
> return 0;
the array could be moved to ProresContext avoding teh alloc/free
cycle per picture
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120907/de4bad54/attachment.asc>
More information about the ffmpeg-devel
mailing list