[FFmpeg-devel] [PATCH] Implement avfilter_add_colorspaces()

Michael Niedermayer michaelni
Thu Dec 31 01:18:27 CET 2009


On Wed, Dec 30, 2009 at 01:32:36AM +0100, Stefano Sabatini wrote:
> On date Tuesday 2009-12-29 14:58:49 +0100, Michael Niedermayer encoded:
> > On Sat, Nov 07, 2009 at 02:28:38AM +0100, Stefano Sabatini wrote:
> > > Hi all,
> > > 
> > > this patch has a long story:
> > > http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/83733
> > > 
> > > Now that pixdescs are finally completed then this function can finally
> > > be implemented.
> > > 
> > > In attachment an example of how this function can be used to simplify
> > > filters code.
> > [...]
> > > @@ -35,38 +36,18 @@
> > >      int hsub, vsub;     ///< chroma subsampling
> > >  } CropContext;
> > >  
> > > +static int select_colorspace(AVFilterContext *ctx, enum PixelFormat pix_fmt)
> > > +{
> > > +    int ret = !(av_pix_fmt_descriptors[pix_fmt].flags & (PIX_FMT_BITSTREAM|PIX_FMT_HWACCEL));
> > > +    if (ret)
> > > +        av_log(ctx, AV_LOG_INFO, "%s: Selected format: %s\n", __func__, av_pix_fmt_descriptors[pix_fmt].name);
> > > +    return ret;
> > > +}
> > > +
> > >  static int query_formats(AVFilterContext *ctx)
> > >  {
> > > -    static const enum PixelFormat pix_fmts[] = {
> > > -        PIX_FMT_RGB48BE,      PIX_FMT_RGB48LE,
> > > -        PIX_FMT_ARGB,         PIX_FMT_RGBA,
> > > -        PIX_FMT_ABGR,         PIX_FMT_BGRA,
> > > -        PIX_FMT_RGB24,        PIX_FMT_BGR24,
> > > -        PIX_FMT_RGB565BE,     PIX_FMT_RGB565LE,
> > > -        PIX_FMT_RGB555BE,     PIX_FMT_RGB555LE,
> > > -        PIX_FMT_BGR565BE,     PIX_FMT_BGR565LE,
> > > -        PIX_FMT_BGR555BE,     PIX_FMT_BGR555LE,
> > > -        PIX_FMT_GRAY16BE,     PIX_FMT_GRAY16LE,
> > > -        PIX_FMT_YUV420P16LE,  PIX_FMT_YUV420P16BE,
> > > -        PIX_FMT_YUV422P16LE,  PIX_FMT_YUV422P16BE,
> > > -        PIX_FMT_YUV444P16LE,  PIX_FMT_YUV444P16BE,
> > > -        PIX_FMT_YUV444P,      PIX_FMT_YUV422P,
> > > -        PIX_FMT_YUV420P,      PIX_FMT_YUV411P,
> > > -        PIX_FMT_YUV410P,      PIX_FMT_YUV440P,
> > > -        PIX_FMT_YUVJ444P,     PIX_FMT_YUVJ422P,
> > > -        PIX_FMT_YUVJ420P,     PIX_FMT_YUVJ440P,
> > > -        PIX_FMT_YUVA420P,
> > > -        PIX_FMT_NV12,         PIX_FMT_NV21,
> > > -        PIX_FMT_YUYV422,      PIX_FMT_UYVY422,
> > > -        PIX_FMT_UYYVYY411,
> > > -        PIX_FMT_RGB8,         PIX_FMT_BGR8,
> > > -        PIX_FMT_RGB4_BYTE,    PIX_FMT_BGR4_BYTE,
> > > -        PIX_FMT_PAL8,         PIX_FMT_GRAY8,
> > > -        PIX_FMT_NONE
> > > -    };
> > > +    avfilter_set_common_formats(ctx, avfilter_colorspaces(ctx, select_colorspace));
> > 
> > 
> > for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> >     if (!(av_pix_fmt_descriptors[pix_fmt].flags & (PIX_FMT_BITSTREAM|PIX_FMT_HWACCEL)))
> >         avfilter_add_colorspace(formats, pix_fmt);
> > 
> > no function pointers, fewer lines of code
> 
> Yes, nice idea thanks.
> 
> Is also OK to change avfilter_all_colorspace() like in attached?
> 
> Regards.
> -- 
> FFmpeg = Faboulous and Frenzy Merciless Plastic Epic Genius

>  avfilter.h |    6 ++++++
>  formats.c  |    7 +++++++
>  2 files changed, 13 insertions(+)
> a2a6f69b454a46aa56c55b6155b5d7234b64f4d7  implement-add-colorspace.patch
> Index: libavfilter-soc/ffmpeg/libavfilter/avfilter.h
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/libavfilter/avfilter.h	2009-12-30 01:24:53.000000000 +0100
> +++ libavfilter-soc/ffmpeg/libavfilter/avfilter.h	2009-12-30 01:25:01.000000000 +0100
> @@ -192,6 +192,12 @@
>  AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts);
>  
>  /**
> + * Adds pix_fmt to the list of formats pointed by formats, and updates
> + * formats to point to the new updated list.
> + */
> +void avfilter_add_colorspace(AVFilterFormats **formats, enum PixelFormat pix_fmt);

why **formats and not *formats ?


[...]

>  formats.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 759e5c6517a89b1d60cfefe18e1a8848554768ed  make-all-colorspace-skip-hw-fmts.patch

ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091231/6a7c13b3/attachment.pgp>



More information about the ffmpeg-devel mailing list