[FFmpeg-devel,v2,4/5] avfilter/vf_lut: support native-endian instead of little-endian

Submitted by Muhammad Faiz on Jan. 28, 2019, 10:07 a.m.

Details

Message ID 20190128100741.22923-4-mfcc64@gmail.com
State New
Headers show

Commit Message

Muhammad Faiz Jan. 28, 2019, 10:07 a.m.
This should make code run faster on big-endian platform.
Change fate to use native-endian mode.

Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
---
 libavfilter/vf_lut.c              | 123 ++++++++++++++----------------
 tests/fate/filter-video.mak       |   2 +-
 tests/ref/fate/filter-pixfmts-lut | 105 ++++++++++++++++---------
 3 files changed, 127 insertions(+), 103 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index c815ddc194..c2bddfaaab 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -110,34 +110,34 @@  static av_cold void uninit(AVFilterContext *ctx)
     }
 }
 
-#define YUV_FORMATS                                         \
-    AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,    \
-    AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P,  AV_PIX_FMT_YUV440P,    \
-    AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,   \
-    AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,   \
-    AV_PIX_FMT_YUVJ440P,                                             \
-    AV_PIX_FMT_YUV444P9LE, AV_PIX_FMT_YUV422P9LE, AV_PIX_FMT_YUV420P9LE, \
-    AV_PIX_FMT_YUV444P10LE, AV_PIX_FMT_YUV422P10LE, AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUV440P10LE, \
-    AV_PIX_FMT_YUV444P12LE, AV_PIX_FMT_YUV422P12LE, AV_PIX_FMT_YUV420P12LE, AV_PIX_FMT_YUV440P12LE, \
-    AV_PIX_FMT_YUV444P14LE, AV_PIX_FMT_YUV422P14LE, AV_PIX_FMT_YUV420P14LE, \
-    AV_PIX_FMT_YUV444P16LE, AV_PIX_FMT_YUV422P16LE, AV_PIX_FMT_YUV420P16LE, \
-    AV_PIX_FMT_YUVA444P16LE, AV_PIX_FMT_YUVA422P16LE, AV_PIX_FMT_YUVA420P16LE
-
-#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_RGB48LE,      AV_PIX_FMT_RGBA64LE,     \
-    AV_PIX_FMT_GBRP,         AV_PIX_FMT_GBRAP,        \
-    AV_PIX_FMT_GBRP9LE,      AV_PIX_FMT_GBRP10LE,     \
-    AV_PIX_FMT_GBRAP10LE,                             \
-    AV_PIX_FMT_GBRP12LE,     AV_PIX_FMT_GBRP14LE,     \
-    AV_PIX_FMT_GBRP16LE,     AV_PIX_FMT_GBRAP12LE,    \
-    AV_PIX_FMT_GBRAP16LE
-
-#define GRAY_FORMATS                            \
-    AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9LE, AV_PIX_FMT_GRAY10LE, \
-    AV_PIX_FMT_GRAY12LE, AV_PIX_FMT_GRAY14LE, AV_PIX_FMT_GRAY16LE
+#define YUV_FORMATS                                                             \
+    AV_PIX_FMT_YUV444P,    AV_PIX_FMT_YUV422P,    AV_PIX_FMT_YUV420P,           \
+    AV_PIX_FMT_YUV411P,    AV_PIX_FMT_YUV410P,    AV_PIX_FMT_YUV440P,           \
+    AV_PIX_FMT_YUVA420P,   AV_PIX_FMT_YUVA422P,   AV_PIX_FMT_YUVA444P,          \
+    AV_PIX_FMT_YUVJ444P,   AV_PIX_FMT_YUVJ422P,   AV_PIX_FMT_YUVJ420P,          \
+    AV_PIX_FMT_YUVJ440P,                                                        \
+    AV_PIX_FMT_YUV444P9,   AV_PIX_FMT_YUV422P9,   AV_PIX_FMT_YUV420P9,          \
+    AV_PIX_FMT_YUV444P10,  AV_PIX_FMT_YUV422P10,  AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV440P10, \
+    AV_PIX_FMT_YUV444P12,  AV_PIX_FMT_YUV422P12,  AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV440P12, \
+    AV_PIX_FMT_YUV444P14,  AV_PIX_FMT_YUV422P14,  AV_PIX_FMT_YUV420P14,         \
+    AV_PIX_FMT_YUV444P16,  AV_PIX_FMT_YUV422P16,  AV_PIX_FMT_YUV420P16,         \
+    AV_PIX_FMT_YUVA444P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA420P16
+
+#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_RGB48,   AV_PIX_FMT_RGBA64,  \
+    AV_PIX_FMT_GBRP,    AV_PIX_FMT_GBRAP,   \
+    AV_PIX_FMT_GBRP9,   AV_PIX_FMT_GBRP10,  \
+    AV_PIX_FMT_GBRAP10,                     \
+    AV_PIX_FMT_GBRP12,  AV_PIX_FMT_GBRP14,  \
+    AV_PIX_FMT_GBRP16,  AV_PIX_FMT_GBRAP12, \
+    AV_PIX_FMT_GBRAP16
+
+#define GRAY_FORMATS                                         \
+    AV_PIX_FMT_GRAY8,  AV_PIX_FMT_GRAY9,  AV_PIX_FMT_GRAY10, \
+    AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16
 
 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 };
@@ -237,32 +237,32 @@  static int config_props(AVFilterLink *inlink)
     case AV_PIX_FMT_YUVA420P:
     case AV_PIX_FMT_YUVA422P:
     case AV_PIX_FMT_YUVA444P:
-    case AV_PIX_FMT_YUV420P9LE:
-    case AV_PIX_FMT_YUV422P9LE:
-    case AV_PIX_FMT_YUV444P9LE:
-    case AV_PIX_FMT_YUVA420P9LE:
-    case AV_PIX_FMT_YUVA422P9LE:
-    case AV_PIX_FMT_YUVA444P9LE:
-    case AV_PIX_FMT_YUV420P10LE:
-    case AV_PIX_FMT_YUV422P10LE:
-    case AV_PIX_FMT_YUV440P10LE:
-    case AV_PIX_FMT_YUV444P10LE:
-    case AV_PIX_FMT_YUVA420P10LE:
-    case AV_PIX_FMT_YUVA422P10LE:
-    case AV_PIX_FMT_YUVA444P10LE:
-    case AV_PIX_FMT_YUV420P12LE:
-    case AV_PIX_FMT_YUV422P12LE:
-    case AV_PIX_FMT_YUV440P12LE:
-    case AV_PIX_FMT_YUV444P12LE:
-    case AV_PIX_FMT_YUV420P14LE:
-    case AV_PIX_FMT_YUV422P14LE:
-    case AV_PIX_FMT_YUV444P14LE:
-    case AV_PIX_FMT_YUV420P16LE:
-    case AV_PIX_FMT_YUV422P16LE:
-    case AV_PIX_FMT_YUV444P16LE:
-    case AV_PIX_FMT_YUVA420P16LE:
-    case AV_PIX_FMT_YUVA422P16LE:
-    case AV_PIX_FMT_YUVA444P16LE:
+    case AV_PIX_FMT_YUV420P9:
+    case AV_PIX_FMT_YUV422P9:
+    case AV_PIX_FMT_YUV444P9:
+    case AV_PIX_FMT_YUVA420P9:
+    case AV_PIX_FMT_YUVA422P9:
+    case AV_PIX_FMT_YUVA444P9:
+    case AV_PIX_FMT_YUV420P10:
+    case AV_PIX_FMT_YUV422P10:
+    case AV_PIX_FMT_YUV440P10:
+    case AV_PIX_FMT_YUV444P10:
+    case AV_PIX_FMT_YUVA420P10:
+    case AV_PIX_FMT_YUVA422P10:
+    case AV_PIX_FMT_YUVA444P10:
+    case AV_PIX_FMT_YUV420P12:
+    case AV_PIX_FMT_YUV422P12:
+    case AV_PIX_FMT_YUV440P12:
+    case AV_PIX_FMT_YUV444P12:
+    case AV_PIX_FMT_YUV420P14:
+    case AV_PIX_FMT_YUV422P14:
+    case AV_PIX_FMT_YUV444P14:
+    case AV_PIX_FMT_YUV420P16:
+    case AV_PIX_FMT_YUV422P16:
+    case AV_PIX_FMT_YUV444P16:
+    case AV_PIX_FMT_YUVA420P16:
+    case AV_PIX_FMT_YUVA422P16:
+    case AV_PIX_FMT_YUVA444P16:
         min[Y] = 16 * (1 << (desc->comp[0].depth - 8));
         min[U] = 16 * (1 << (desc->comp[1].depth - 8));
         min[V] = 16 * (1 << (desc->comp[2].depth - 8));
@@ -272,8 +272,8 @@  static int config_props(AVFilterLink *inlink)
         max[V] = 240 * (1 << (desc->comp[2].depth - 8));
         max[A] = (1 << desc->comp[0].depth) - 1;
         break;
-    case AV_PIX_FMT_RGB48LE:
-    case AV_PIX_FMT_RGBA64LE:
+    case AV_PIX_FMT_RGB48:
+    case AV_PIX_FMT_RGBA64:
         min[0] = min[1] = min[2] = min[3] = 0;
         max[0] = max[1] = max[2] = max[3] = 65535;
         break;
@@ -376,17 +376,10 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             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;
@@ -441,11 +434,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
             for (i = 0; i < h; i++) {
                 for (j = 0; j < w; j++) {
-#if HAVE_BIGENDIAN
-                    outrow[j] = av_bswap16(tab[av_bswap16(inrow[j])]);
-#else
                     outrow[j] = tab[inrow[j]];
-#endif
                 }
                 inrow  += in_linesize;
                 outrow += out_linesize;
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 1042e96e54..699c9c6ae1 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -674,7 +674,7 @@  FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += fate-filter-pixfmts-kerndeint
 fate-filter-pixfmts-kerndeint: CMD = pixfmts "" "tinterlace=interleave_top,"
 
 FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut
-fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40"
+fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" "" "" ne
 
 FATE_FILTER_PIXFMTS-$(CONFIG_NULL_FILTER) += fate-filter-pixfmts-null
 fate-filter-pixfmts-null:  CMD = pixfmts
diff --git a/tests/ref/fate/filter-pixfmts-lut b/tests/ref/fate/filter-pixfmts-lut
index 41c66e2bfc..972184ffd2 100644
--- a/tests/ref/fate/filter-pixfmts-lut
+++ b/tests/ref/fate/filter-pixfmts-lut
@@ -3,54 +3,89 @@  argb                4f575be3cd02799389f581df99c4de38
 bgr24               fa43e3b2abfde8d9e60e157a9acc553d
 bgra                4e2e689897ee7a8e42b16234597bab35
 gbrap               0d1eb2c39e291c53c57302cdc653c2fc
-gbrap10le           fed58af6d557a7069a4a39e6d8f5f4e0
-gbrap12le           43fec231bd1d3dd957cdd8478cab9259
-gbrap16le           22ca3644658ae306541116c31e135074
+gbrap10(be)         b7129c9a5ba723a8b410d4b5917ff1d6
+gbrap10(le)         fed58af6d557a7069a4a39e6d8f5f4e0
+gbrap12(be)         5afe2567a5c21337a66c57ab4393e875
+gbrap12(le)         43fec231bd1d3dd957cdd8478cab9259
+gbrap16(be)         16c9eb4f40ea3a8cee3b18c96b56a02f
+gbrap16(le)         22ca3644658ae306541116c31e135074
 gbrp                e572d53183f3f2ed3951aa9940d440a1
-gbrp10le            a8fd1ebbc36a477e2b134241fed91687
-gbrp12le            c5a4b89571f7095eb737ad9fd6b1ee08
-gbrp14le            bdfdfd6f36c60497d1cdae791f3cc117
-gbrp16le            df095ef3a20995935cfcaf144afc68b6
-gbrp9le             a8c4e29f4cb627db81ba053e0853e702
+gbrp10(be)          8fb3986ee44ea3e9c962c92601f6be33
+gbrp10(le)          a8fd1ebbc36a477e2b134241fed91687
+gbrp12(be)          f3b2e707594075cd0ec795b327a18499
+gbrp12(le)          c5a4b89571f7095eb737ad9fd6b1ee08
+gbrp14(be)          1b151fbe61292f2235ee0c20899e1c36
+gbrp14(le)          bdfdfd6f36c60497d1cdae791f3cc117
+gbrp16(be)          e840b29236eaff85ec7a8c040f1d3869
+gbrp16(le)          df095ef3a20995935cfcaf144afc68b6
+gbrp9(be)           1b5feab9ebf23ac93e59a4109b18c49d
+gbrp9(le)           a8c4e29f4cb627db81ba053e0853e702
 gray                20b14b5e26cd11300ed1249e04082170
-gray10le            8f4140b55e847cc423002b89666db5ea
-gray12le            ea89c02f6b3af49ddaf13364ed33d86d
-gray14le            12bebea325a7822e890675bfc5111f0c
-gray16le            aa10599924fb2440fa12b76e90f57dcb
-gray9le             7d9cc9ad6118674c547a54281d10cf05
+gray10(be)          19ed2642bb83c5d31979fb9d6401b421
+gray10(le)          8f4140b55e847cc423002b89666db5ea
+gray12(be)          3dac00fdf013fad4e725329241867b3c
+gray12(le)          ea89c02f6b3af49ddaf13364ed33d86d
+gray14(be)          c8acac8c0cd2f49465a34c259dfeb391
+gray14(le)          12bebea325a7822e890675bfc5111f0c
+gray16(be)          a863db00ada40e6aea051d57fd0ecea1
+gray16(le)          aa10599924fb2440fa12b76e90f57dcb
+gray9(be)           572a7de038acffe5bcb8295804444a78
+gray9(le)           7d9cc9ad6118674c547a54281d10cf05
 rgb24               a356171207723a580e7d277078072005
-rgb48le             5c7dd8575836d18c91e09f1915cf9aa9
+rgb48(be)           d9a7669cab9159c7f28dc92387fab304
+rgb48(le)           5c7dd8575836d18c91e09f1915cf9aa9
 rgba                7bc854c2698b78af3e9159a19c2d9d21
-rgba64le            3a087ecab583d1930220592731f282b4
+rgba64(be)          612546f91b274bcc8c314386ba410c3d
+rgba64(le)          3a087ecab583d1930220592731f282b4
 yuv410p             10cf5dbbccb858a9ab51e0b8bf278f6d
 yuv411p             3f0bfa543ba513c6b6d7fff785fbe150
 yuv420p             ad99204ace669a383f8ae03a1ea5b98f
-yuv420p10le         f1e6cc4c2a5e9665dedd7ac0f2a4d551
-yuv420p12le         d9dfe871483b6a26512d427cb048ff65
-yuv420p14le         cd8bb4803f8e99c6cd31149bf848c30c
-yuv420p16le         4bb13820cf2de9b40ca47adeb7fea356
-yuv420p9le          f12c98b599e667fc45126d6dea7f0fd9
+yuv420p10(be)       c5a88defde62a6e3494fa6df1637e1de
+yuv420p10(le)       f1e6cc4c2a5e9665dedd7ac0f2a4d551
+yuv420p12(be)       9b1dab8ec496e143ba95804228ead76d
+yuv420p12(le)       d9dfe871483b6a26512d427cb048ff65
+yuv420p14(be)       bd82bbc319ce5acc974173b9f56bd3ef
+yuv420p14(le)       cd8bb4803f8e99c6cd31149bf848c30c
+yuv420p16(be)       dfa3b49d7f31fc992b44cef454e81f5d
+yuv420p16(le)       4bb13820cf2de9b40ca47adeb7fea356
+yuv420p9(be)        0148732632c3399d91edd76bb20bfa7e
+yuv420p9(le)        f12c98b599e667fc45126d6dea7f0fd9
 yuv422p             c57e304bb3f4a1d30bf4ced5e829cdc6
-yuv422p10le         9d95b03f75ae5778804279f3c3135837
-yuv422p12le         08e73e233793740ad68a939b9886dd32
-yuv422p14le         bea6b54ec3e33eadfbd317a175b96288
-yuv422p16le         5438e5738ab3e1e5f7fce5faaac036c4
-yuv422p9le          222a699b69ba8d511518a61d77a10c25
+yuv422p10(be)       5bcdb1906b98519ecbc584809d05b44f
+yuv422p10(le)       9d95b03f75ae5778804279f3c3135837
+yuv422p12(be)       b7303b22554cd91a564e750d331c1192
+yuv422p12(le)       08e73e233793740ad68a939b9886dd32
+yuv422p14(be)       548b16de9c20cba805b3412f9fc968b1
+yuv422p14(le)       bea6b54ec3e33eadfbd317a175b96288
+yuv422p16(be)       ac9440af461aa97225d0f0e81679dc6c
+yuv422p16(le)       5438e5738ab3e1e5f7fce5faaac036c4
+yuv422p9(be)        d1f9dccb9e5a2061944ca75847135ca7
+yuv422p9(le)        222a699b69ba8d511518a61d77a10c25
 yuv440p             f8105ff9433ecdedf2645f3370a575d8
-yuv440p10le         6e104ac6c33b00185bb6d95b371e1354
-yuv440p12le         636834efcba838d74337b2ebb9dbffb3
+yuv440p10(be)       5346c7e5f3c91989de336a2cd52e067f
+yuv440p10(le)       6e104ac6c33b00185bb6d95b371e1354
+yuv440p12(be)       6d12a58a8e5a6f83e683346b858017cb
+yuv440p12(le)       636834efcba838d74337b2ebb9dbffb3
 yuv444p             ca662e7bd7a28805650f25b1537d50a2
-yuv444p10le         c301eb2763e0f74fde94388046c437fa
-yuv444p12le         9482b13de4a9fbce176e8344c9332139
-yuv444p14le         fb558c97e59e884fe5ba407df158ebd5
-yuv444p16le         be9b3ce54168159b132746f7ac9088fe
-yuv444p9le          fa4b9bd6b8cac96e10322e613c8e7149
+yuv444p10(be)       3114b39965cc6576914921032e607773
+yuv444p10(le)       c301eb2763e0f74fde94388046c437fa
+yuv444p12(be)       deb27e505a77c1387364002826f69a10
+yuv444p12(le)       9482b13de4a9fbce176e8344c9332139
+yuv444p14(be)       71a5f6f00beec4fe7cb186cc93bb7270
+yuv444p14(le)       fb558c97e59e884fe5ba407df158ebd5
+yuv444p16(be)       cfb4e0a396d4cf3381bdcd902f3dc029
+yuv444p16(le)       be9b3ce54168159b132746f7ac9088fe
+yuv444p9(be)        2d611fa7e65db765c0a746942a7d74c5
+yuv444p9(le)        fa4b9bd6b8cac96e10322e613c8e7149
 yuva420p            7284cbf9eacf1ca5ce9e2efebcadf999
-yuva420p16le        b37d34212c2a79e91b675bc87dac6cc6
+yuva420p16(be)      327574517e52856ba98bbd75a0713561
+yuva420p16(le)      b37d34212c2a79e91b675bc87dac6cc6
 yuva422p            5938a7c7588febb069bd0cd4c447305e
-yuva422p16le        c5ccfdc1a0dc6cb130c07ea61df6f727
+yuva422p16(be)      f090e50b2172f501d850c6676ade9990
+yuva422p16(le)      c5ccfdc1a0dc6cb130c07ea61df6f727
 yuva444p            fbcbdc3521d17c702ee521b0893098e4
-yuva444p16le        b7142d28d4d069d7eb019dcaf8b323b1
+yuva444p16(be)      e7a285a216b2422c9be99082ef14ecd1
+yuva444p16(le)      b7142d28d4d069d7eb019dcaf8b323b1
 yuvj420p            65bc88887c7f06a6221155ca7f9cfca4
 yuvj422p            ff5baffefc8ffe4547653092fd7da200
 yuvj440p            ef3f27270e60ac06582e3ac7c2f3e6fa