[FFmpeg-devel] [PATCH] Add lut filter.
Mark Himsley
mark at mdsh.com
Mon Jun 6 23:37:14 CEST 2011
On 06/06/2011 20:42, Stefano Sabatini wrote:
> +#define YUV_FORMATS \
> + PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, \
> + PIX_FMT_YUV411P, PIX_FMT_YUV410P, \
> + PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P, \
> + PIX_FMT_YUV440P, PIX_FMT_YUVJ440P, \
> + PIX_FMT_YUVA420P
> +
> +#define RGB_FORMATS \
> + PIX_FMT_ARGB, PIX_FMT_RGBA, \
> + PIX_FMT_ABGR, PIX_FMT_BGRA, \
> + PIX_FMT_RGB24, PIX_FMT_BGR24
> +
[...]
> + switch (inlink->format) {
> + case PIX_FMT_YUV444P:
> + case PIX_FMT_YUV422P:
> + case PIX_FMT_YUV420P:
> + case PIX_FMT_YUV440P:
> + min[Y] = min[U] = min[V] = 16;
> + max[Y] = 235;
> + max[U] = max[V] = 240;
> + break;
> + default:
> + min[0] = min[1] = min[2] = min[3] = 0;
> + max[0] = max[1] = max[2] = max[3] = 255;
> + }
PIX_FMT_YUV411P, PIX_FMT_YUV410P & PIX_FMT_YUVA420P should also be 16-235 ?
> + lut->is_yuv = lut->is_rgb = 0;
> + if (pix_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
> + else if (pix_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
> +
> + if (lut->is_rgb) {
> + switch (inlink->format) {
> + case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break;
> + case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break;
> + case PIX_FMT_RGBA:
> + case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break;
> + case PIX_FMT_BGRA:
> + case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break;
> + }
> + lut->step = av_get_bits_per_pixel(desc)>> 3;
> + }
If only all of these attributes had been wrapped into a structure.
By the way - this filter looks like it'll be very useful, but to avoid
banding it would be good to be able to dither.
--
Mark
More information about the ffmpeg-devel
mailing list