[FFmpeg-devel] [PATCH] lavfi/select: add support to branch option
Stefano Sabatini
stefasab at gmail.com
Wed Apr 17 01:40:23 CEST 2013
On date Tuesday 2013-04-16 22:50:55 +0200, Clément Bœsch encoded:
> On Mon, Apr 15, 2013 at 09:05:55PM +0200, Stefano Sabatini wrote:
[...]
> > + select->select_out =
> > + res == 0 ? -1 : /* drop */
> > + isnan(res) || res < 0 ? 0 : /* first output */
> > + FFMIN(ceilf(res)-1, select->nb_outputs); /* other outputs */
>
> select->nb_outputs - 1?
yes
> Also, if you want a compact if/else code, please use something like
>
> if (res == 0) select->select_out = -1; // drop
> else if (isnan(res) || res < 0) select->select_out = 0; // first output
> else select->select_out = FFMIN(...); // other outputs
>
> ...instead of hardly readable nested ?:
>
> > + av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f out:%d\n", res, select->select_out);
> >
>
> nit: put "out" into parenthesis to show that it's directly related to the
> select value.
changed in a different way (more grep-friendly)
>
> > if (res) {
> > select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
> > @@ -326,11 +345,12 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame)
> >
> > static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> > {
> > - SelectContext *select = inlink->dst->priv;
> > + AVFilterContext *ctx = inlink->dst;
> > + SelectContext *select = ctx->priv;
> >
> > - select_frame(inlink->dst, frame);
> > + select_frame(ctx, frame);
> > if (select->select)
> > - return ff_filter_frame(inlink->dst->outputs[0], frame);
> > + return ff_filter_frame(ctx->outputs[select->select_out], frame);
> >
> > av_frame_free(&frame);
> > return 0;
> > @@ -341,13 +361,13 @@ static int request_frame(AVFilterLink *outlink)
> > AVFilterContext *ctx = outlink->src;
> > SelectContext *select = ctx->priv;
> > AVFilterLink *inlink = outlink->src->inputs[0];
> > - select->select = 0;
> > + int out_no = FF_OUTLINK_IDX(outlink);
> >
>
> > do {
> > int ret = ff_request_frame(inlink);
> > if (ret < 0)
> > return ret;
> > - } while (!select->select);
> > + } while (select->select_out != out_no);
> >
>
> Is this code still required with the new request frame system? (if you
> have the flag set)
The flag is not set yet.
Updated, will push tomorrow if I read no more comments (Nicolas?).
--
FFmpeg = Frenzy and Fostering Magic Proud Enhancing Governor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-lavfi-select-add-support-for-dynamic-number-of-outpu.patch
Type: text/x-diff
Size: 8320 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130417/d553f623/attachment.bin>
More information about the ffmpeg-devel
mailing list