[FFmpeg-devel] [PATCH 2/3] proresdec2: Replace a VLA with a heap alloc

Michael Niedermayer michaelni at gmx.at
Fri Sep 7 19:29:19 CEST 2012


On Fri, Sep 07, 2012 at 01:17:44PM -0400, Derek Buitenhuis wrote:
> On 07/09/2012 12:29 PM, Derek Buitenhuis wrote:
> >> the array could be moved to ProresContext avoding teh alloc/free
> >> cycle per picture
> > 
> > I didn't think once per frame was that bad.
> > 
> > Will do, though.
> 
> Actually, it seems ProresContext is shared, so adding it might be ugly.
> 
> Opinions?

what about the patch below ?

--- a/libavcodec/proresdec.h
+++ b/libavcodec/proresdec.h
@@ -31,6 +31,7 @@ typedef struct {
     unsigned mb_y;
     unsigned mb_count;
     unsigned data_size;
+    int ret;
 } SliceContext;

 typedef struct {
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 0e32a97..cd487b2 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -431,6 +431,7 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
     int16_t qmat_chroma_scaled[64];
     int mb_x_shift;

+    slice->ret = -1;
     //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",
     //       jobnr, slice->mb_count, slice->mb_x, slice->mb_y);

@@ -494,19 +495,20 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
                             qmat_chroma_scaled, log2_chroma_blocks_per_mb);
     }

+    slice->ret = 0;
     return 0;
 }

 static int decode_picture(AVCodecContext *avctx)
 {
     ProresContext *ctx = avctx->priv_data;
-    int i, threads_ret[ctx->slice_count];
+    int i;

-    avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count);
+    avctx->execute2(avctx, decode_slice_thread, NULL, NULL, ctx->slice_count);

     for (i = 0; i < ctx->slice_count; i++)
-        if (threads_ret[i] < 0)
-            return threads_ret[i];
+        if (ctx->slices[i].ret < 0)
+            return ctx->slices[i].ret;

     return 0;
 }

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- 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/9d0c844e/attachment.asc>


More information about the ffmpeg-devel mailing list