[FFmpeg-devel] [PATCH] Add lut filter.

Stefano Sabatini stefano.sabatini-lala at poste.it
Tue Jun 7 02:22:07 CEST 2011


On date Monday 2011-06-06 22:37:14 +0100, Mark Himsley encoded:
> 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 ?

Fixed.

> >+    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.

Maybe a separate filter?
-- 
FFmpeg = Foolish and Freak Meaningful Proud Extended Gymnast
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavfi-add-LUT-LookUp-Table-generic-filters.patch
Type: text/x-diff
Size: 18056 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110607/3871e503/attachment.bin>


More information about the ffmpeg-devel mailing list