Added hevc decoder support 53/124453/2
authorSejun Park <sejun79.park@samsung.com>
Tue, 11 Apr 2017 09:40:50 +0000 (18:40 +0900)
committerSejun Park <sejun79.park@samsung.com>
Tue, 11 Apr 2017 09:45:34 +0000 (18:45 +0900)
Change-Id: If6a873ad42db52ba3b90bfbdf0a0d7fb8b8e52c0

config/exynos/gstomx.conf [changed mode: 0755->0644]
configure.ac
omx/Makefile.am
omx/gstomx.c
omx/gstomxh265dec.c [new file with mode: 0644]
omx/gstomxh265dec.h [new file with mode: 0644]
omx/openmax/OMX_VideoExt.h [changed mode: 0755->0644]
packaging/gst-omx.spec

old mode 100755 (executable)
new mode 100644 (file)
index 5fb1b94..7b8f522
@@ -42,6 +42,17 @@ in-port-usebuffer=0
 out-port-usebuffer=1
 hacks=no-component-role;no-disable-outport;no-component-reconfigure
 
+[omxdec_h265]
+type-name=GstOMXH265Dec
+core-name=/usr/lib/libExynosOMX_Core.so
+component-name=OMX.Exynos.HEVC.Decoder
+rank=258
+in-port-index=0
+out-port-index=1
+in-port-usebuffer=0
+out-port-usebuffer=1
+hacks=no-component-role;no-disable-outport;no-component-reconfigure
+
 [omxdec_vp8]
 type-name=GstOMXVP8Dec
 core-name=/usr/lib/libExynosOMX_Core.so
index bb6d6c0..d40f035 100644 (file)
@@ -221,6 +221,23 @@ if test "x$HAVE_THEORA" = "xyes"; then
   AC_DEFINE(HAVE_THEORA, 1, [OpenMAX IL has Theora support])
 fi
 
+dnl check for supporting hevc
+AC_MSG_CHECKING([for supporting hevc])
+AC_ARG_ENABLE(hevc, AC_HELP_STRING([--enable-hevc], [OpenMAX IL has HEVC support]),
+  [
+    case "${enableval}" in
+      yes) HAVE_HEVC=yes ;;
+      no)  HAVE_HEVC=no ;;
+      *)   AC_MSG_ERROR(bad value ${enableval} for --enable-hevc) ;;
+    esac
+  ],
+  [HAVE_HEVC=no])
+AM_CONDITIONAL(HAVE_HEVC, test "x$HAVE_HEVC" = "xyes")
+AC_MSG_RESULT([$HAVE_HEVC])
+if test "x$HAVE_HEVC" = "xyes"; then
+  AC_DEFINE(HAVE_HEVC, 1, [OpenMAX IL has HEVC support])
+fi
+
 dnl Check for -Bsymbolic-functions linker flag used to avoid
 dnl intra-library PLT jumps, if available.
 AC_ARG_ENABLE(Bsymbolic,
index e389f72..c2857f4 100644 (file)
@@ -10,6 +10,11 @@ THEORA_C_FILES=gstomxtheoradec.c
 THEORA_H_FILES=gstomxtheoradec.h
 endif
 
+if HAVE_HEVC
+HEVC_C_FILES=gstomxh265dec.c
+HEVC_H_FILES=gstomxh265dec.h
+endif
+
 libgstomx_la_SOURCES = \
        gstomx.c \
        gstomxbufferpool.c \
@@ -26,6 +31,7 @@ libgstomx_la_SOURCES = \
        gstomxwmvdec.c \
        $(VP8_C_FILES) \
        $(THEORA_C_FILES) \
+       $(HEVC_C_FILES) \
        gstomxmpeg4videoenc.c \
        gstomxh264enc.c \
        gstomxh263enc.c \
@@ -35,7 +41,7 @@ libgstomx_la_SOURCES = \
        gstomxamrdec.c \
        gstomxaudiosink.c \
        gstomxanalogaudiosink.c \
-       gstomxhdmiaudiosink.c   
+       gstomxhdmiaudiosink.c
 
 noinst_HEADERS = \
        gstomx.h \
@@ -53,6 +59,7 @@ noinst_HEADERS = \
        gstomxwmvdec.h \
        $(VP8_H_FILES) \
        $(THEORA_H_FILES) \
+       $(HEVC_H_FILES) \
        gstomxmpeg4videoenc.h \
        gstomxh264enc.h \
        gstomxh263enc.h \
@@ -62,7 +69,7 @@ noinst_HEADERS = \
        gstomxamrdec.h \
        gstomxaudiosink.h \
        gstomxanalogaudiosink.h \
-       gstomxhdmiaudiosink.h   
+       gstomxhdmiaudiosink.h
 
 if !HAVE_EXTERNAL_OMX
 OMX_INCLUDEPATH = -I$(abs_srcdir)/openmax
index 19b533a..09bbd1b 100644 (file)
@@ -31,6 +31,7 @@
 #include "gstomxmjpegdec.h"
 #include "gstomxmpeg2videodec.h"
 #include "gstomxmpeg4videodec.h"
+#include "gstomxh265dec.h"
 #include "gstomxh264dec.h"
 #include "gstomxh263dec.h"
 #include "gstomxvp8dec.h"
@@ -2428,6 +2429,9 @@ static const GGetTypeFunction types[] = {
 #ifdef HAVE_VP8
       , gst_omx_vp8_dec_get_type
 #endif
+#ifdef HAVE_HEVC
+      , gst_omx_h265_dec_get_type
+#endif
 #ifdef HAVE_THEORA
       , gst_omx_theora_dec_get_type
 #endif
diff --git a/omx/gstomxh265dec.c b/omx/gstomxh265dec.c
new file mode 100644 (file)
index 0000000..e822cd9
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *   Author: Sejun Park <sejun79.park@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+#include "gstomxh265dec.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_omx_h265_dec_debug_category);
+#define GST_CAT_DEFAULT gst_omx_h265_dec_debug_category
+
+/* prototypes */
+static gboolean gst_omx_h265_dec_is_format_change (GstOMXVideoDec * dec,
+    GstOMXPort * port, GstVideoCodecState * state);
+static gboolean gst_omx_h265_dec_set_format (GstOMXVideoDec * dec,
+    GstOMXPort * port, GstVideoCodecState * state);
+
+enum
+{
+  PROP_0
+};
+
+/* class initialization */
+
+#define DEBUG_INIT \
+  GST_DEBUG_CATEGORY_INIT (gst_omx_h265_dec_debug_category, "omxh265dec", 0, \
+      "debug category for gst-omx video decoder base class");
+
+G_DEFINE_TYPE_WITH_CODE (GstOMXH265Dec, gst_omx_h265_dec,
+    GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT);
+
+static void
+gst_omx_h265_dec_class_init (GstOMXH265DecClass * klass)
+{
+  GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+  videodec_class->is_format_change =
+      GST_DEBUG_FUNCPTR (gst_omx_h265_dec_is_format_change);
+  videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h265_dec_set_format);
+
+  videodec_class->cdata.default_sink_template_caps = "video/x-h265, "
+      "alignment=(string) { au }, "
+      "stream-format=(string) byte-stream, "
+      "width=(int) [1,MAX], " "height=(int) [1,MAX],"
+      "framerate = (fraction) [0/1, MAX]";
+
+  gst_element_class_set_static_metadata (element_class,
+      "OpenMAX HEVC Video Decoder",
+      "Codec/Decoder/Video",
+      "Decode HEVC video streams",
+      "Sejun Park <sejun79.park@samsung.com>");
+
+  gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.hevc");
+}
+
+static void
+gst_omx_h265_dec_init (GstOMXH265Dec * self)
+{
+}
+
+static gboolean
+gst_omx_h265_dec_is_format_change (GstOMXVideoDec * dec,
+    GstOMXPort * port, GstVideoCodecState * state)
+{
+  GstCaps *old_caps = NULL;
+  GstCaps *new_caps = state->caps;
+  GstStructure *old_structure, *new_structure;
+  const gchar *old_profile, *old_level, *new_profile, *new_level;
+
+  if (dec->input_state) {
+    old_caps = dec->input_state->caps;
+  }
+
+  if (!old_caps) {
+    return FALSE;
+  }
+
+  old_structure = gst_caps_get_structure (old_caps, 0);
+  new_structure = gst_caps_get_structure (new_caps, 0);
+  old_profile = gst_structure_get_string (old_structure, "profile");
+  old_level = gst_structure_get_string (old_structure, "level");
+  new_profile = gst_structure_get_string (new_structure, "profile");
+  new_level = gst_structure_get_string (new_structure, "level");
+
+  if (g_strcmp0 (old_profile, new_profile) != 0
+      || g_strcmp0 (old_level, new_level) != 0) {
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static gboolean
+gst_omx_h265_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port,
+    GstVideoCodecState * state)
+{
+  gboolean ret;
+  OMX_PARAM_PORTDEFINITIONTYPE port_def;
+
+  gst_omx_port_get_port_definition (port, &port_def);
+  port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC;
+  ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone;
+
+  return ret;
+}
diff --git a/omx/gstomxh265dec.h b/omx/gstomxh265dec.h
new file mode 100644 (file)
index 0000000..9c74474
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *   Author: Sejun Park <sejun79.park@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ */
+
+#ifndef __GST_OMX_H265_DEC_H__
+#define __GST_OMX_H265_DEC_H__
+
+#include <gst/gst.h>
+#include "gstomxvideodec.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_OMX_H265_DEC \
+  (gst_omx_h265_dec_get_type())
+#define GST_OMX_H265_DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H265_DEC,GstOMXH265Dec))
+#define GST_OMX_H265_DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H265_DEC,GstOMXH265DecClass))
+#define GST_OMX_H265_DEC_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H265_DEC,GstOMXH265DecClass))
+#define GST_IS_OMX_H265_DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H265_DEC))
+#define GST_IS_OMX_H265_DEC_CLASS(obj) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H265_DEC))
+
+typedef struct _GstOMXH265Dec GstOMXH265Dec;
+typedef struct _GstOMXH265DecClass GstOMXH265DecClass;
+
+struct _GstOMXH265Dec
+{
+  GstOMXVideoDec parent;
+};
+
+struct _GstOMXH265DecClass
+{
+  GstOMXVideoDecClass parent_class;
+};
+
+GType gst_omx_h265_dec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_OMX_H265_DEC_H__ */
+
old mode 100755 (executable)
new mode 100644 (file)
index 4983dc4..30ea88e
@@ -62,6 +62,7 @@ typedef struct OMX_NALSTREAMFORMATTYPE{
 typedef enum OMX_VIDEO_CODINGEXTTYPE {\r
     OMX_VIDEO_ExtCodingUnused = OMX_VIDEO_CodingKhronosExtensions,\r
     OMX_VIDEO_CodingVP8,        /**< VP8/WebM */\r
+    OMX_VIDEO_CodingHEVC,       /**< ITU H.265/HEVC */\r
 } OMX_VIDEO_CODINGEXTTYPE;\r
 \r
 /** VP8 profiles */\r
@@ -114,6 +115,63 @@ typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE {
     OMX_BOOL bIsGoldenOrAlternateFrame;\r
 } OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE;\r
 \r
+/** HEVC Profile enum type */\r
+typedef enum OMX_VIDEO_HEVCPROFILETYPE {\r
+    OMX_VIDEO_HEVCProfileUnknown = 0x0,\r
+    OMX_VIDEO_HEVCProfileMain    = 0x1,\r
+    OMX_VIDEO_HEVCProfileMain10  = 0x2,\r
+    OMX_VIDEO_HEVCProfileMax     = 0x7FFFFFFF\r
+} OMX_VIDEO_HEVCPROFILETYPE;\r
+\r
+/** HEVC Level enum type */\r
+typedef enum OMX_VIDEO_HEVCLEVELTYPE {\r
+    OMX_VIDEO_HEVCLevelUnknown    = 0x0,\r
+    OMX_VIDEO_HEVCMainTierLevel1  = 0x1,\r
+    OMX_VIDEO_HEVCHighTierLevel1  = 0x2,\r
+    OMX_VIDEO_HEVCMainTierLevel2  = 0x4,\r
+    OMX_VIDEO_HEVCHighTierLevel2  = 0x8,\r
+    OMX_VIDEO_HEVCMainTierLevel21 = 0x10,\r
+    OMX_VIDEO_HEVCHighTierLevel21 = 0x20,\r
+    OMX_VIDEO_HEVCMainTierLevel3  = 0x40,\r
+    OMX_VIDEO_HEVCHighTierLevel3  = 0x80,\r
+    OMX_VIDEO_HEVCMainTierLevel31 = 0x100,\r
+    OMX_VIDEO_HEVCHighTierLevel31 = 0x200,\r
+    OMX_VIDEO_HEVCMainTierLevel4  = 0x400,\r
+    OMX_VIDEO_HEVCHighTierLevel4  = 0x800,\r
+    OMX_VIDEO_HEVCMainTierLevel41 = 0x1000,\r
+    OMX_VIDEO_HEVCHighTierLevel41 = 0x2000,\r
+    OMX_VIDEO_HEVCMainTierLevel5  = 0x4000,\r
+    OMX_VIDEO_HEVCHighTierLevel5  = 0x8000,\r
+    OMX_VIDEO_HEVCMainTierLevel51 = 0x10000,\r
+    OMX_VIDEO_HEVCHighTierLevel51 = 0x20000,\r
+    OMX_VIDEO_HEVCMainTierLevel52 = 0x40000,\r
+    OMX_VIDEO_HEVCHighTierLevel52 = 0x80000,\r
+    OMX_VIDEO_HEVCMainTierLevel6  = 0x100000,\r
+    OMX_VIDEO_HEVCHighTierLevel6  = 0x200000,\r
+    OMX_VIDEO_HEVCMainTierLevel61 = 0x400000,\r
+    OMX_VIDEO_HEVCHighTierLevel61 = 0x800000,\r
+    OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000,\r
+    OMX_VIDEO_HEVCHighTierLevel62 = 0x2000000,\r
+    OMX_VIDEO_HEVCHighTiermax     = 0x7FFFFFFF\r
+} OMX_VIDEO_HEVCLEVELTYPE;\r
+\r
+/** Structure for controlling HEVC video encoding and decoding */\r
+typedef struct OMX_VIDEO_PARAM_HEVCTYPE {\r
+    OMX_U32 nSize;\r
+    OMX_VERSIONTYPE nVersion;\r
+    OMX_U32 nPortIndex;\r
+    OMX_VIDEO_HEVCPROFILETYPE eProfile;\r
+    OMX_VIDEO_HEVCLEVELTYPE eLevel;\r
+} OMX_VIDEO_PARAM_HEVCTYPE;\r
+\r
+/** Structure to define if dependent slice segments should be used */\r
+typedef struct OMX_VIDEO_SLICESEGMENTSTYPE {\r
+    OMX_U32 nSize;\r
+    OMX_VERSIONTYPE nVersion;\r
+    OMX_U32 nPortIndex;\r
+    OMX_BOOL bDepedentSegments;\r
+    OMX_BOOL bEnableLoopFilterAcrossSlices;\r
+} OMX_VIDEO_SLICESEGMENTSTYPE;\r
 \r
 #ifdef __cplusplus\r
 }\r
index 5e431f3..aa3afb8 100755 (executable)
@@ -31,7 +31,7 @@ export CFLAGS+=" -DTIZEN_FEATURE_OMX"
 %ifarch aarch64
 %configure --disable-static --prefix=/usr --with-omx-target=exynos64
 %else
-%configure --disable-static --prefix=/usr --with-omx-target=exynos --enable-vp8
+%configure --disable-static --prefix=/usr --with-omx-target=exynos --enable-vp8 --enable-hevc
 %endif
 
 make %{?jobs:-j%jobs}