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

Michael Niedermayer michaelni
Tue Dec 29 14:58:49 CET 2009


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

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- 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/20091229/eca707ac/attachment.pgp>



More information about the ffmpeg-devel mailing list