[FFmpeg-cvslog] vf_lut: Add support for RGB48 and RGBA64.

Steven Robertson git at videolan.org
Fri Oct 30 04:04:28 CET 2015


ffmpeg | branch: master | Steven Robertson <steven at strobe.cc> | Sat Oct 10 18:27:17 2015 -0700| [b38e685c053786bc20743cc6b3e54e6ae1fe957b] | committer: Michael Niedermayer

vf_lut: Add support for RGB48 and RGBA64.

Signed-off-by: Steven Robertson <steven at strobe.cc>
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b38e685c053786bc20743cc6b3e54e6ae1fe957b
---

 libavfilter/vf_lut.c              |   50 +++++++++++++++++++++++++++++++++++--
 tests/ref/fate/filter-pixfmts-lut |    2 ++
 2 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index f0a2aba..38a25fe 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -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;
diff --git a/tests/ref/fate/filter-pixfmts-lut b/tests/ref/fate/filter-pixfmts-lut
index 150157c..8d50f3e 100644
--- a/tests/ref/fate/filter-pixfmts-lut
+++ b/tests/ref/fate/filter-pixfmts-lut
@@ -3,7 +3,9 @@ argb                4f575be3cd02799389f581df99c4de38
 bgr24               fa43e3b2abfde8d9e60e157a9acc553d
 bgra                4e2e689897ee7a8e42b16234597bab35
 rgb24               a356171207723a580e7d277078072005
+rgb48le             5c7dd8575836d18c91e09f1915cf9aa9
 rgba                7bc854c2698b78af3e9159a19c2d9d21
+rgba64le            3a087ecab583d1930220592731f282b4
 yuv410p             51b39a0e33f108e652457a26667319ea
 yuv411p             9204c5af92aef4922a05f58c1f6c095e
 yuv420p             7c43bb0cae8dee633375c89295598508



More information about the ffmpeg-cvslog mailing list