Mesa (master): frontends/omx/bellagio: add AV1 initial support to omx dec
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 17 19:38:28 UTC 2020
Module: Mesa
Branch: master
Commit: 6ab3030f925e183a218d49b878b1841954950a63
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ab3030f925e183a218d49b878b1841954950a63
Author: Leo Liu <leo.liu at amd.com>
Date: Sun Oct 18 10:45:05 2020 -0400
frontends/omx/bellagio: add AV1 initial support to omx dec
Also add bitstream base parser based on AV1 spec
Signed-off-by: Leo Liu <leo.liu at amd.com>
Reviewed-by: Boyuan Zhang <boyuan.zhang at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7596>
---
.../frontends/omx/bellagio/Makefile.sources | 1 +
src/gallium/frontends/omx/bellagio/vid_dec_av1.c | 133 +++++++++++++++++++++
src/gallium/frontends/omx/bellagio/vid_dec_av1.h | 31 +++++
src/gallium/frontends/omx/meson.build | 1 +
4 files changed, 166 insertions(+)
diff --git a/src/gallium/frontends/omx/bellagio/Makefile.sources b/src/gallium/frontends/omx/bellagio/Makefile.sources
index ab60ce803cb..94393597292 100644
--- a/src/gallium/frontends/omx/bellagio/Makefile.sources
+++ b/src/gallium/frontends/omx/bellagio/Makefile.sources
@@ -6,5 +6,6 @@ C_SOURCES := \
vid_dec_mpeg12.c \
vid_dec_h264.c \
vid_dec_h265.c \
+ vid_dec_av1.c \
vid_enc.c \
vid_enc.h
diff --git a/src/gallium/frontends/omx/bellagio/vid_dec_av1.c b/src/gallium/frontends/omx/bellagio/vid_dec_av1.c
new file mode 100644
index 00000000000..2af35a0e461
--- /dev/null
+++ b/src/gallium/frontends/omx/bellagio/vid_dec_av1.c
@@ -0,0 +1,133 @@
+/**************************************************************************
+ *
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vid_dec.h"
+
+static unsigned av1_f(struct vl_vlc *vlc, unsigned n)
+{
+ unsigned valid = vl_vlc_valid_bits(vlc);
+
+ if (n == 0)
+ return 0;
+
+ if (valid < 32)
+ vl_vlc_fillbits(vlc);
+
+ return vl_vlc_get_uimsbf(vlc, n);
+}
+
+static unsigned av1_uvlc(struct vl_vlc *vlc)
+{
+ unsigned value;
+ unsigned leadingZeros = 0;
+
+ while (1) {
+ bool done = av1_f(vlc, 1);
+ if (done)
+ break;
+ leadingZeros++;
+ }
+
+ if (leadingZeros >= 32)
+ return 0xffffffff;
+
+ value = av1_f(vlc, leadingZeros);
+
+ return value + (1 << leadingZeros) - 1;
+}
+
+static int av1_le(struct vl_vlc *vlc, const unsigned n)
+{
+ unsigned byte, t = 0;
+ unsigned i;
+
+ for (i = 0; i < n; ++i) {
+ byte = av1_f(vlc, 8);
+ t += (byte << (i * 8));
+ }
+
+ return t;
+}
+
+static unsigned av1_uleb128(struct vl_vlc *vlc)
+{
+ unsigned value = 0;
+ unsigned leb128Bytes = 0;
+ unsigned i;
+
+ for (i = 0; i < 8; ++i) {
+ leb128Bytes = av1_f(vlc, 8);
+ value |= ((leb128Bytes & 0x7f) << (i * 7));
+ if (!(leb128Bytes & 0x80))
+ break;
+ }
+
+ return value;
+}
+
+static int av1_su(struct vl_vlc *vlc, const unsigned n)
+{
+ unsigned value = av1_f(vlc, n);
+ unsigned signMask = 1 << (n - 1);
+
+ if (value && signMask)
+ value = value - 2 * signMask;
+
+ return value;
+}
+
+static unsigned FloorLog2(unsigned x)
+{
+ unsigned s = 0;
+ unsigned x1 = x;
+
+ while (x1 != 0) {
+ x1 = x1 >> 1;
+ s++;
+ }
+
+ return s - 1;
+}
+
+static unsigned av1_ns(struct vl_vlc *vlc, unsigned n)
+{
+ unsigned w = FloorLog2(n) + 1;
+ unsigned m = (1 << w) - n;
+ unsigned v = av1_f(vlc, w - 1);
+
+ if (v < m)
+ return v;
+
+ bool extra_bit = av1_f(vlc, 1);
+
+ return (v << 1) - m + extra_bit;
+}
+
+static void av1_byte_alignment(struct vl_vlc *vlc)
+{
+ vl_vlc_eatbits(vlc, vl_vlc_valid_bits(vlc) % 8);
+}
diff --git a/src/gallium/frontends/omx/bellagio/vid_dec_av1.h b/src/gallium/frontends/omx/bellagio/vid_dec_av1.h
new file mode 100644
index 00000000000..52f43b424c5
--- /dev/null
+++ b/src/gallium/frontends/omx/bellagio/vid_dec_av1.h
@@ -0,0 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef VID_DEC_AV1_H
+#define VID_DEC_AV1_H
+
+#endif
diff --git a/src/gallium/frontends/omx/meson.build b/src/gallium/frontends/omx/meson.build
index 650d87c625e..ee19145b2a9 100644
--- a/src/gallium/frontends/omx/meson.build
+++ b/src/gallium/frontends/omx/meson.build
@@ -37,6 +37,7 @@ if with_gallium_omx == 'bellagio'
'bellagio/vid_dec_mpeg12.c',
'bellagio/vid_dec_h264.c',
'bellagio/vid_dec_h265.c',
+ 'bellagio/vid_dec_av1.c',
'bellagio/vid_enc.c'
)
elif with_gallium_omx == 'tizonia'
More information about the mesa-commit
mailing list