[FFmpeg-devel] [PATCH] lavfi/yadif: add support to named constants
Stefano Sabatini
stefasab at gmail.com
Thu Jan 3 09:21:17 CET 2013
On date Thursday 2013-01-03 02:06:41 +0100, Clément Bœsch encoded:
> On Thu, Jan 03, 2013 at 02:01:29AM +0100, Stefano Sabatini wrote:
> > TODO: update docs, bump micro
> > ---
> > libavfilter/vf_yadif.c | 20 +++++++++++++++++---
> > libavfilter/yadif.h | 41 +++++++++++++++++++++--------------------
> > 2 files changed, 38 insertions(+), 23 deletions(-)
> >
> > diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
> > index 824137b..24834f1 100644
> > --- a/libavfilter/vf_yadif.c
> > +++ b/libavfilter/vf_yadif.c
> > @@ -300,10 +300,24 @@ static int request_frame(AVFilterLink *link)
> > #define OFFSET(x) offsetof(YADIFContext, x)
> > #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> >
> > +#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
> > +
> > static const AVOption yadif_options[] = {
> > - { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
> > - { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS },
> > - { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS },
> > + { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "mode"},
>
> maybe use the corresponding YADIF_MODE_* values, at least for the default.
>
> > + CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
> > + CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
> > + CONST("send_frame_nocheck", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOCHECK, "mode"),
> > + CONST("send_field_nocheck", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOCHECK, "mode"),
> > +
> > + { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" },
>
> ditto
>
> > + CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
> > + CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
> > + CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
> > +
> > + { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
>
> ditto
changed
> > + CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
> > + CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
> > +
> > {NULL},
> > };
> >
> > diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
> > index 22904fb..bc46df3 100644
> > --- a/libavfilter/yadif.h
> > +++ b/libavfilter/yadif.h
> > @@ -22,32 +22,33 @@
> > #include "libavutil/pixdesc.h"
> > #include "avfilter.h"
> >
> > +enum YADIFMode {
> > + YADIF_MODE_SEND_FRAME = 0, ///< send 1 frame for each frame
> > + YADIF_MODE_SEND_FIELD = 1, ///< send 1 frame for each field
> > + YADIF_MODE_SEND_FRAME_NOCHECK = 2, ///< send 1 frame for each frame but skips spatial interlacing check
> > + YADIF_MODE_SEND_FIELD_NOCHECK = 3, ///< send 1 frame for each field but skips spatial interlacing check
>
> NB_YADIF_MODE for the limits in the AVOptions?
No compelling reason as this could not be used for parity.
> > +};
> > +
> > +enum YADIFParity {
> > + YADIF_PARITY_TFF = 0, ///< top field first
> > + YADIF_PARITY_BFF = 1, ///< bottom field first
> > + YADIF_PARITY_AUTO = -1, ///< auto detection
> > +};
> > +
> > +enum YADIFDeint {
> > + YADIF_DEINT_ALL = 0, ///< deinterlace all frames
> > + YADIF_DEINT_INTERLACED = 1, ///< only deinterlace frames marked as interlaced
> > +};
> > +
> > typedef struct YADIFContext {
> > const AVClass *class;
> >
> > - /**
> > - * 0: send 1 frame for each frame
> > - * 1: send 1 frame for each field
> > - * 2: like 0 but skips spatial interlacing check
> > - * 3: like 1 but skips spatial interlacing check
> > - */
> > - int mode;
> > -
> > - /**
> > - * 0: top field first
> > - * 1: bottom field first
> > - * -1: auto-detection
> > - */
> > - int parity;
> > + enum YADIFMode mode;
> > + enum YADIFParity parity;
> > + enum YADIFDeint deint;
> >
> > int frame_pending;
> >
> > - /**
> > - * 0: deinterlace all frames
> > - * 1: only deinterlace frames marked as interlaced
> > - */
> > - int deint;
> > -
> > AVFilterBufferRef *cur;
> > AVFilterBufferRef *next;
> > AVFilterBufferRef *prev;
>
> No other comment from me.
>
> Do you plan to use the macros in the rest of the code?
No, it was just a random experiment, we could add some generic macros
(FF_OPT_CONST or such) if the need arises.
--
FFmpeg = Frightening & Foolish Merciful Political Everlasting Gladiator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-lavfi-yadif-add-support-to-named-constants.patch
Type: text/x-diff
Size: 5992 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130103/4207ae3d/attachment.bin>
More information about the ffmpeg-devel
mailing list