[FFmpeg-devel] [PATCH 1/2] libavfilter: add vf_hue.c

Stefano Sabatini stefasab at gmail.com
Sun Aug 12 21:38:41 CEST 2012


On date Sunday 2012-08-12 19:10:38 +0200, Stefano Sabatini encoded:
> On date Sunday 2012-08-12 13:26:17 +0200, Jérémy Tran encoded:
> > This is a port of the MPlayer hue filter (libmpcodecs/vf_hue.c)
> > 
> > Signed-off-by: Jérémy Tran <tran.jeremy.av at gmail.com>
> > ---
> >  doc/filters.texi         |  20 +++++
> >  libavfilter/Makefile     |   1 +
> >  libavfilter/allfilters.c |   1 +
> >  libavfilter/vf_hue.c     | 194 +++++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 216 insertions(+)
> >  create mode 100644 libavfilter/vf_hue.c
> > 
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 18be723..71f6670 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -2187,6 +2187,26 @@ a float number which specifies chroma temporal strength, defaults to
> >  @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
> >  @end table
> >  
> > + at section hue
> > +
> > +Modify the hue and/or the saturation of the input.
> > +
> 
> > +The filter supports the following syntaxes:
> > + at example
> > +# hue = 100 ; saturation = 1
> > +ffmpeg -i in.avi -vf hue=100:1
> > +
> > +# same command but using named options
> > +ffmpeg -i in.avi -vf hue=h=100:s=1
> > + at end example
> > +
> > + at table @option
> > + at item hue
> > +A float number that specifies the hue in the [-360;360] range, defaults to 0.0.
> > + at item saturation
> > +A float number that specifies the saturation in the [0;2] range, defaults to 1.0.
> > + at end table
> > +
> 
> Simpler:
> 
> This filter accepts the optional parameters: @var{hue}:@var{saturation}.
> 
> @var{hue} must be a float number that specifies the hue in the
> [-360,360] range, and defaults to 0.0.
> @var{saturation} must be a float number that specifies the saturation
> in the [0,2] range, and defaults to 1.0.
[...] 
> > +#include "libavutil/pixdesc.h"
> > +
> > +#include "avfilter.h"
> > +#include "formats.h"
> > +#include "internal.h"
> > +#include "video.h"
> > +
> > +typedef struct {
> > +    float    hue;
> > +    float    saturation;
> > +    int      hsub;
> > +    int      vsub;
> 
> > +    uint32_t hue_sin;
> > +    uint32_t hue_cos;
> 
> int32_t?
> 
> > +} HueContext;
> > +
> > +static av_cold int init(AVFilterContext *ctx, const char *args)
> > +{
> > +    HueContext *hue = ctx->priv;
> > +    float h = 0, s = 1;
> > +    int32_t ret;
> > +    char c1 = 0, c2 = 0;
> > +
> > +    if (args) {
> > +        ret = sscanf(args, "%f%c%f%c", &h, &c1, &s, &c2);

> > +        if (!ret || c1 != ':' || c2) {

This won't accept the syntax "hue=90".

[...] 
> Should be OK otherwise (no need to send another patch), assuming that
> the output is equivalent to mp=hue.

Changed saturation range to the one supported by the MPlayer hue
filter [-10, +10], fixed argument parsing, and applied minor
cosmetics.

I'll push this tomorrow if I read no more comments.
-- 
FFmpeg = Fundamental and Forgiving Mastering Pure Evil Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavfi-add-hue-filter.patch
Type: text/x-diff
Size: 9469 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120812/3e3f1206/attachment.bin>


More information about the ffmpeg-devel mailing list