vf_lut: Add support for RGB48 and RGBA64.
authorSteven Robertson <steven@strobe.cc>
Sun, 11 Oct 2015 01:27:17 +0000 (18:27 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 30 Oct 2015 02:55:12 +0000 (03:55 +0100)
Signed-off-by: Steven Robertson <steven@strobe.cc>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavfilter/vf_lut.c
tests/ref/fate/filter-pixfmts-lut

index f0a2aba..38a25fe 100644 (file)
@@ -125,7 +125,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 #define RGB_FORMATS                             \
     AV_PIX_FMT_ARGB,         AV_PIX_FMT_RGBA,         \
     AV_PIX_FMT_ABGR,         AV_PIX_FMT_BGRA,         \
-    AV_PIX_FMT_RGB24,        AV_PIX_FMT_BGR24
+    AV_PIX_FMT_RGB24,        AV_PIX_FMT_BGR24,        \
+    AV_PIX_FMT_RGB48LE,      AV_PIX_FMT_RGBA64LE
 
 static const enum AVPixelFormat yuv_pix_fmts[] = { YUV_FORMATS, AV_PIX_FMT_NONE };
 static const enum AVPixelFormat rgb_pix_fmts[] = { RGB_FORMATS, AV_PIX_FMT_NONE };
@@ -260,6 +261,11 @@ static int config_props(AVFilterLink *inlink)
         max[V] = 240 * (1 << (desc->comp[2].depth - 8));
         max[A] = (1 << desc->comp[3].depth) - 1;
         break;
+    case AV_PIX_FMT_RGB48LE:
+    case AV_PIX_FMT_RGBA64LE:
+        min[0] = min[1] = min[2] = min[3] = 0;
+        max[0] = max[1] = max[2] = max[3] = 65535;
+        break;
     default:
         min[0] = min[1] = min[2] = min[3] = 0;
         max[0] = max[1] = max[2] = max[3] = 255;
@@ -272,6 +278,9 @@ static int config_props(AVFilterLink *inlink)
     if (s->is_rgb) {
         ff_fill_rgba_map(rgba_map, inlink->format);
         s->step = av_get_bits_per_pixel(desc) >> 3;
+        if (s->is_16bit) {
+            s->step = s->step >> 1;
+        }
     }
 
     for (color = 0; color < desc->nb_components; color++) {
@@ -336,7 +345,44 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         av_frame_copy_props(out, in);
     }
 
-    if (s->is_rgb) {
+    if (s->is_rgb && s->is_16bit) {
+        /* packed, 16-bit */
+        uint16_t *inrow, *outrow, *inrow0, *outrow0;
+        const int w = inlink->w;
+        const int h = in->height;
+        const uint16_t (*tab)[256*256] = (const uint16_t (*)[256*256])s->lut;
+        const int in_linesize  =  in->linesize[0] / 2;
+        const int out_linesize = out->linesize[0] / 2;
+        const int step = s->step;
+
+        inrow0  = (uint16_t*) in ->data[0];
+        outrow0 = (uint16_t*) out->data[0];
+
+        for (i = 0; i < h; i ++) {
+            inrow  = inrow0;
+            outrow = outrow0;
+            for (j = 0; j < w; j++) {
+
+                switch (step) {
+#if HAVE_BIGENDIAN
+                case 4:  outrow[3] = av_bswap16(tab[3][av_bswap16(inrow[3])]); // Fall-through
+                case 3:  outrow[2] = av_bswap16(tab[2][av_bswap16(inrow[2])]); // Fall-through
+                case 2:  outrow[1] = av_bswap16(tab[1][av_bswap16(inrow[1])]); // Fall-through
+                default: outrow[0] = av_bswap16(tab[0][av_bswap16(inrow[0])]);
+#else
+                case 4:  outrow[3] = tab[3][inrow[3]]; // Fall-through
+                case 3:  outrow[2] = tab[2][inrow[2]]; // Fall-through
+                case 2:  outrow[1] = tab[1][inrow[1]]; // Fall-through
+                default: outrow[0] = tab[0][inrow[0]];
+#endif
+                }
+                outrow += step;
+                inrow  += step;
+            }
+            inrow0  += in_linesize;
+            outrow0 += out_linesize;
+        }
+    } else if (s->is_rgb) {
         /* packed */
         uint8_t *inrow, *outrow, *inrow0, *outrow0;
         const int w = inlink->w;
index 150157c..8d50f3e 100644 (file)
@@ -3,7 +3,9 @@ argb                4f575be3cd02799389f581df99c4de38
 bgr24               fa43e3b2abfde8d9e60e157a9acc553d
 bgra                4e2e689897ee7a8e42b16234597bab35
 rgb24               a356171207723a580e7d277078072005
+rgb48le             5c7dd8575836d18c91e09f1915cf9aa9
 rgba                7bc854c2698b78af3e9159a19c2d9d21
+rgba64le            3a087ecab583d1930220592731f282b4
 yuv410p             51b39a0e33f108e652457a26667319ea
 yuv411p             9204c5af92aef4922a05f58c1f6c095e
 yuv420p             7c43bb0cae8dee633375c89295598508