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

Michael Niedermayer michaelni at gmx.at
Tue Jun 7 03:55:48 CEST 2011


On Mon, Jun 06, 2011 at 10:37:14PM +0100, Mark Himsley wrote:
> 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.

running the filter on 10+bits data which is then converted back to
8bit would do dither automatically

also the input might need debanding
any good denoise filter should remove banding (overcomplete wavelets
come to mind) or gradfun could be used

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110607/25736d48/attachment.asc>


More information about the ffmpeg-devel mailing list