[FFmpeg-cvslog] avfilter/vf_vectorscope: less aggressive memory allocation

Paul B Mahol git at videolan.org
Sun Mar 13 20:12:42 CET 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Mar 13 20:07:18 2016 +0100| [370cecc1e87dc2c33227cdd0935b44c3780fb825] | committer: Paul B Mahol

avfilter/vf_vectorscope: less aggressive memory allocation

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=370cecc1e87dc2c33227cdd0935b44c3780fb825
---

 libavfilter/vf_vectorscope.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index e49b9df..7d2123b 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -64,7 +64,8 @@ typedef struct VectorscopeContext {
     int flags;
     int colorspace;
     int cs;
-    uint8_t peak[4096][4096];
+    uint8_t *peak_memory;
+    uint8_t **peak;
 
     void (*vectorscope)(struct VectorscopeContext *s,
                         AVFrame *in, AVFrame *out, int pd);
@@ -252,10 +253,23 @@ static int query_formats(AVFilterContext *ctx)
 static int config_output(AVFilterLink *outlink)
 {
     VectorscopeContext *s = outlink->src->priv;
+    int i;
 
     s->intensity = s->fintensity * (s->size - 1);
     outlink->h = outlink->w = s->size;
     outlink->sample_aspect_ratio = (AVRational){1,1};
+
+    s->peak_memory = av_calloc(s->size, s->size);
+    if (!s->peak_memory)
+        return AVERROR(ENOMEM);
+
+    s->peak = av_calloc(s->size, sizeof(*s->peak));
+    if (!s->peak)
+        return AVERROR(ENOMEM);
+
+    for (i = 0; i < s->size; i++)
+        s->peak[i] = s->peak_memory + s->size * i;
+
     return 0;
 }
 
@@ -1298,6 +1312,14 @@ static int config_input(AVFilterLink *inlink)
     return 0;
 }
 
+static av_cold void uninit(AVFilterContext *ctx)
+{
+    VectorscopeContext *s = ctx->priv;
+
+    av_freep(&s->peak);
+    av_freep(&s->peak_memory);
+}
+
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
@@ -1323,6 +1345,7 @@ AVFilter ff_vf_vectorscope = {
     .priv_size     = sizeof(VectorscopeContext),
     .priv_class    = &vectorscope_class,
     .query_formats = query_formats,
+    .uninit        = uninit,
     .inputs        = inputs,
     .outputs       = outputs,
 };



More information about the ffmpeg-cvslog mailing list