X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_colorconstancy.c;h=e44d9afa0197c7d47645ab5a26570942760761b4;hb=a04ad248a05e7b613abe09b3bb067f555108d794;hp=e3bb39e51ba0807c4766c36b3b81a6ce2fa15e9a;hpb=0084eed5bffebd7f3915bc0f9eba7350e8bc0ef7;p=ffmpeg diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c index e3bb39e51ba..e44d9afa019 100644 --- a/libavfilter/vf_colorconstancy.c +++ b/libavfilter/vf_colorconstancy.c @@ -121,7 +121,6 @@ static int set_gauss(AVFilterContext *ctx) for (; i >= 0; --i) { av_freep(&s->gauss[i]); } - av_log(ctx, AV_LOG_ERROR, "Out of memory while allocating gauss buffers.\n"); return AVERROR(ENOMEM); } } @@ -223,7 +222,6 @@ static int setup_derivative_buffers(AVFilterContext* ctx, ThreadData *td) td->data[b][p] = av_mallocz_array(s->planeheight[p] * s->planewidth[p], sizeof(*td->data[b][p])); if (!td->data[b][p]) { cleanup_derivative_buffers(td, b + 1, p); - av_log(ctx, AV_LOG_ERROR, "Out of memory while allocating derivatives buffers.\n"); return AVERROR(ENOMEM); } } @@ -280,7 +278,7 @@ static int slice_get_derivative(AVFilterContext* ctx, void* arg, int jobnr, int dst[INDX2D(r, c, width)] = 0; for (g = 0; g < filtersize; ++g) { dst[INDX2D(r, c, width)] += GAUSS(src, r, c + GINDX(filtersize, g), - in_linesize, height, width, gauss[GINDX(filtersize, g)]); + in_linesize, height, width, gauss[g]); } } } @@ -295,7 +293,7 @@ static int slice_get_derivative(AVFilterContext* ctx, void* arg, int jobnr, int dst[INDX2D(r, c, width)] = 0; for (g = 0; g < filtersize; ++g) { dst[INDX2D(r, c, width)] += GAUSS(src, r + GINDX(filtersize, g), c, - width, height, width, gauss[GINDX(filtersize, g)]); + width, height, width, gauss[g]); } } } @@ -682,24 +680,30 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; int ret; + int direct = 0; ret = illumination_estimation(ctx, in); if (ret) { + av_frame_free(&in); return ret; } if (av_frame_is_writable(in)) { + direct = 1; out = in; } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { - av_log(ctx, AV_LOG_ERROR, "Out of memory while allocating output video buffer.\n"); + av_frame_free(&in); return AVERROR(ENOMEM); } av_frame_copy_props(out, in); } chromatic_adaptation(ctx, in, out); + if (!direct) + av_frame_free(&in); + return ff_filter_frame(outlink, out); } @@ -743,7 +747,7 @@ static const AVOption greyedge_options[] = { AVFILTER_DEFINE_CLASS(greyedge); -AVFilter ff_vf_greyedge = { +const AVFilter ff_vf_greyedge = { .name = GREY_EDGE, .description = NULL_IF_CONFIG_SMALL("Estimates scene illumination by grey edge assumption."), .priv_size = sizeof(ColorConstancyContext),