[FFmpeg-devel] [PATCH] Port gradfun to libavfilter (GCI)
Stefano Sabatini
stefano.sabatini-lala
Tue Dec 7 20:13:18 CET 2010
On date Monday 2010-12-06 21:11:34 -0500, Nolan L encoded:
> On Wed, Dec 1, 2010 at 10:13 PM, Nolan L <nol888 at gmail.com> wrote:
> >
> > (Hopefully) the final revision of this port. The clarification of "direct
> > rendering" allowed me to make the necessary code change to implement the
> > libavfilter equivalent.
> >
>
> Fixed up confusion regarding when setting src==dst is acceptable, and
> allocate a new buffer when this is not acceptable. Fix various
> nits. Implementation of start_frame logic described by Stefano's suggestion.
[...]
> +static int config_input(AVFilterLink *inlink)
> +{
> + GradFunContext *gf = inlink->dst->priv;
> + int hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w;
> + int vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
> +
> + av_free(gf->buf);
> + gf->buf = av_mallocz((FFALIGN(inlink->w, 16) * (gf->radius + 1) / 2 + 32) * sizeof(uint16_t));
> +
> + gf->chroma_w = -((-inlink->w) >> hsub);
> + gf->chroma_h = -((-inlink->h) >> vsub);
is this -((-foo)>>bar) required? (why not simply foo>>bar)?
> + gf->chroma_r = av_clip(((((gf->radius >> hsub) + (gf->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
> +
> + return (!gf->buf) ? AVERROR(ENOMEM) : 0;
> +}
> +
> +static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
> +{
> + AVFilterLink *outlink = inlink->dst->outputs[0];
> + AVFilterBufferRef *outpicref;
> +
> + if ((inpicref->perms & AV_PERM_PRESERVE) == AV_PERM_PRESERVE) {
drop the "== AV_PERM_PRESERVE"
> + outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
> + avfilter_copy_buffer_ref_props(outpicref, inpicref);
> + outpicref->video->w = outlink->w;
> + outpicref->video->h = outlink->h;
useless (well technically it is not yet clear the semantics of video->w,h)
> + } else {
> + outpicref = inpicref;
> + }
> +
> + outlink->out_buf = outpicref;
> + avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
> +}
> +
> +static void end_frame(AVFilterLink *inlink)
> +{
> + GradFunContext *gf = inlink->dst->priv;
> + AVFilterBufferRef *inpic = inlink->cur_buf;
> + AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf;
AVFilterLink *outlink = ... may improve legibility.
[...]
--
FFmpeg = Foolish and Fiendish Multipurpose Peaceful Ecletic Game
More information about the ffmpeg-devel
mailing list