Initial snapshot of the HEVC gstreamer plugin.
authorJacob Stiffler <j-stiffler@ti.com>
Thu, 25 Jun 2015 18:21:38 +0000 (14:21 -0400)
committerJacob Stiffler <j-stiffler@ti.com>
Thu, 25 Jun 2015 18:21:38 +0000 (14:21 -0400)
Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
27 files changed:
.gitmodules [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/gstreamer0.10-plugin-h265dec.install [new file with mode: 0644]
debian/gstreamer1.0-plugin-h265dec.install [new file with mode: 0644]
debian/rules [new file with mode: 0644]
debian/source/format [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/gsth265buf.c [new file with mode: 0644]
src/gsth265buf.h [new file with mode: 0644]
src/gsth265dec.c [new file with mode: 0644]
src/gsth265dec.h [new file with mode: 0644]
src/gsth265utils.c [new file with mode: 0644]
src/gsth265utils.h [new file with mode: 0644]
tests/.gitignore [new file with mode: 0644]
tools/.gitignore [new file with mode: 0644]
tools/make_element [new file with mode: 0644]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..a6b1eda
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "common"]
+       path = common
+       url = git://anongit.freedesktop.org/gstreamer/common
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..036283f
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..0e05f76
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,3 @@
+Pathpartner Technologies
+
+       * initial version
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..1ea48a2
--- /dev/null
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+EXTRA_DIST = autogen.sh m4 po
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..3474a99
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+Nothing much yet.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..ed75c33
--- /dev/null
+++ b/README
@@ -0,0 +1,24 @@
+WHAT IT IS
+----------
+
+gst-h265dec plugin is a GStreamer plugin for using HEVC decoder on ARM 
+
+Dependencies
+------------
+
+- gstreamer
+- gst-plugins-base
+- gst-plugins-good
+- h265vdec_pp_lib (Build using linaro toolchain)
+- lib gstdmabuf-1.0 gstdrm-1.0 gstvideo-1.0 
+
+TO BUILD:
+---------
+ Steps to be followed for execution
+ 1. Run autogen.sh script
+ 2. For cross compiling run "configure" with required flags (CC, --host, GST_LIBS, GST_CFLAGS, LD_FLAGS)
+ 3. make
+ 4. Copy libgsth265dec.so to /usr/lib/gstreamer-1.0 of platform
+ 5. gst-launch-1.0 filesrc location=IBBP_CrowdRun_p1920x1080_30fps_303fr_CUD3_4mbps.265 ! 'video/x-raw, format=(string)NV12, framerate=(fraction)30/1, width=(int)1920, height=(int)1080' ! h265dec threads=2 !  vpe ! autovideosink
+
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..340f60d
--- /dev/null
@@ -0,0 +1,121 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+DIE=0
+package=gst-h265dec
+srcfile=src/gsth265dec.c
+
+# Make sure we have common
+if test ! -f common/gst-autogen.sh;
+then
+  echo "+ Setting up common submodule"
+  git submodule init
+fi
+git submodule update
+
+# source helper functions
+if test ! -f common/gst-autogen.sh;
+then
+  echo There is something wrong with your source tree.
+  echo You are missing common/gst-autogen.sh
+  exit 1
+fi
+. common/gst-autogen.sh
+
+# install pre-commit hook for doing clean commits
+if test ! \( -x .git/hooks/pre-commit -a -L .git/hooks/pre-commit \);
+then
+    rm -f .git/hooks/pre-commit
+    ln -s ../../common/hooks/pre-commit.hook .git/hooks/pre-commit
+fi
+
+touch ChangeLog
+
+CONFIGURE_DEF_OPT='--enable-maintainer-mode'
+
+autogen_options $@
+
+printf "+ check for build tools"
+if test ! -z "$NOCHECK"; then echo " skipped"; else  echo; fi
+version_check "autoconf" "$AUTOCONF autoconf autoconf270 autoconf269 autoconf268 autoconf267 autoconf266 autoconf265 autoconf264 autoconf263 autoconf262 autoconf261 autoconf260" \
+              "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 60 || DIE=1
+version_check "automake" "$AUTOMAKE automake automake-1.11 automake-1.10" \
+              "ftp://ftp.gnu.org/pub/gnu/automake/" 1 10 || DIE=1
+version_check "autopoint" "autopoint" \
+              "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 17 || DIE=1
+version_check "libtoolize" "$LIBTOOLIZE libtoolize glibtoolize" \
+              "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 5 0 || DIE=1
+version_check "pkg-config" "" \
+              "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
+
+die_check $DIE
+
+aclocal_check || DIE=1
+autoheader_check || DIE=1
+
+die_check $DIE
+
+# if no arguments specified then this will be printed
+if test -z "$*"; then
+  echo "+ checking for autogen.sh options"
+  echo "  This autogen script will automatically run ./configure as:"
+  echo "  ./configure $CONFIGURE_DEF_OPT"
+  echo "  To pass any additional options, please specify them on the $0"
+  echo "  command line."
+fi
+
+toplevel_check $srcfile
+
+# autopoint
+#    older autopoint (< 0.12) has a tendency to complain about mkinstalldirs
+if test -x mkinstalldirs; then rm mkinstalldirs; fi
+#    first remove patch if necessary, then run autopoint, then reapply
+if test -f po/Makefile.in.in;
+then
+  patch -p0 -R < common/gettext.patch
+fi
+tool_run "$autopoint --force"
+patch -p0 < common/gettext.patch
+
+tool_run "$libtoolize" "--copy --force"
+tool_run "$aclocal" "-I m4 -I common/m4 $ACLOCAL_FLAGS"
+tool_run "$autoheader"
+
+# touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
+echo timestamp > stamp-h.in 2> /dev/null
+
+tool_run "$autoconf"
+tool_run "$automake" "-a -c"
+
+# if enable exists, add an -enable option for each of the lines in that file
+if test -f enable; then
+  for a in `cat enable`; do
+    CONFIGURE_FILE_OPT="--enable-$a"
+  done
+fi
+
+# if disable exists, add an -disable option for each of the lines in that file
+if test -f disable; then
+  for a in `cat disable`; do
+    CONFIGURE_FILE_OPT="$CONFIGURE_FILE_OPT --disable-$a"
+  done
+fi
+
+test -n "$NOCONFIGURE" && {
+  echo "+ skipping configure stage for package $package, as requested."
+  echo "+ autogen.sh done."
+  exit 0
+}
+
+echo "+ running configure ... "
+test ! -z "$CONFIGURE_DEF_OPT" && echo "  ./configure default flags: $CONFIGURE_DEF_OPT"
+test ! -z "$CONFIGURE_EXT_OPT" && echo "  ./configure external flags: $CONFIGURE_EXT_OPT"
+test ! -z "$CONFIGURE_FILE_OPT" && echo "  ./configure enable/disable flags: $CONFIGURE_FILE_OPT"
+echo
+
+./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT $CONFIGURE_FILE_OPT || {
+        echo "  configure failed"
+        exit 1
+}
+
+echo "Now type 'make' to compile $package."
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..fee3161
--- /dev/null
@@ -0,0 +1,89 @@
+dnl required version of autoconf
+AC_PREREQ([2.53])
+
+dnl TODO: fill in your package name and package version here
+AC_INIT([gst-h265dec],[1.0.0])
+
+dnl required versions of gstreamer and plugins-base
+GST_REQUIRED=1.0.0
+GSTPB_REQUIRED=1.0.0
+
+AC_CONFIG_SRCDIR([src/gsth265dec.c])
+AC_CONFIG_HEADERS([config.h])
+
+dnl required version of automake
+AM_INIT_AUTOMAKE([1.10])
+
+dnl enable mainainer mode by default
+AM_MAINTAINER_MODE
+
+dnl check for tools
+AC_PROG_CC
+
+dnl required version of libtool
+LT_PREREQ([2.2.6])
+LT_INIT
+AM_GNU_GETTEXT_VERSION([0.12.1])
+
+dnl give error and exit if we don't have pkgconfig
+AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
+  AC_MSG_ERROR([You need to have pkg-config installed!])
+])
+
+
+dnl Check for the required version of GStreamer core (and gst-plugins-base)
+dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
+dnl
+dnl If you need libraries from gst-plugins-base here, also add:
+dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= $GST_REQUIRED
+dnl for libgstvideo-1.0: gstreamer-video-1.0 >= $GST_REQUIRED
+dnl for libgsttag-1.0: gstreamer-tag-1.0 >= $GST_REQUIRED
+dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= $GST_REQUIRED
+dnl for libgstfft-1.0: gstreamer-fft-1.0 >= $GST_REQUIRED
+dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= $GST_REQUIRED
+dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= $GST_REQUIRED
+dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= $GST_REQUIRED
+dnl etc.
+PKG_CHECK_MODULES(GST, [
+  gstreamer-1.0 >= $GST_REQUIRED
+  gstreamer-base-1.0 >= $GST_REQUIRED
+  gstreamer-controller-1.0 >= $GST_REQUIRED
+], [
+  AC_SUBST(GST_CFLAGS)
+  AC_SUBST(GST_LIBS)
+], [
+  AC_MSG_ERROR([
+      You need to install or upgrade the GStreamer development
+      packages on your system. On debian-based systems these are
+      libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev.
+      on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel
+      or similar. The minimum version required is $GST_REQUIRED.
+  ])
+])
+
+dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
+AC_MSG_CHECKING([to see if compiler understands -Wall])
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wall"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
+  GST_CFLAGS="$GST_CFLAGS -Wall"
+  AC_MSG_RESULT([yes])
+], [
+  AC_MSG_RESULT([no])
+])
+
+dnl set the plugindir where plugins should be installed (for src/Makefile.am)
+if test "x${prefix}" = "x$HOME"; then
+  plugindir="$HOME/.gstreamer-1.0/plugins"
+else
+  plugindir="\$(libdir)/gstreamer-1.0"
+fi
+AC_SUBST(plugindir)
+
+dnl set proper LDFLAGS for plugins
+GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^[_]*gst_plugin_desc\$\$' $GST_ALL_LDFLAGS"
+AC_SUBST(GST_PLUGIN_LDFLAGS)
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7f8f011
--- /dev/null
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..def055b
--- /dev/null
@@ -0,0 +1,33 @@
+Source: gst-plugin-h265dec
+Section: libs
+Priority: optional
+Maintainer: TI OMAP Developers <tiomap-dev@lists.launchpad.net>
+Standards-Version: 3.9.2
+Build-Depends: debhelper (>= 7.4.20),
+       cdbs (>= 0.4.43),
+       autotools-dev,
+       libtool,
+       pkg-config,
+       dpkg-dev (>= 1.13.19),
+       pkg-config (>= 0.11.0),
+       autopoint,
+       quilt,
+       libgstreamer0.10-dev ( >= 0.10.36),
+       libgstreamer-plugins-base0.10-dev ( >= 0.10.36),
+       libgstreamer-plugins-bad0.10-dev ( >= 0.10.22),
+
+Vcs-Git:  git://git.ti.com/glsdk/gst-plugin-h265dec.git
+Homepage: http://git.ti.com/glsdk/gst-plugin-h265dec
+
+Package: gstreamer0.10-plugin-h265dec
+Architecture: armhf
+Section: libs
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: gst-plugin-h265dec is a Gstreamer plugin
+
+Package: gstreamer0.10-plugin-h265dec-dbg
+Architecture: armhf
+Section: debug
+Priority: extra
+Depends: ${misc:Depends}, gstreamer0.10-plugin-h265dec (= ${binary:Version})
+Description: Debug symbols for gst-plugin-h265dec, a Gstreamer plugin
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..46f5679
--- /dev/null
@@ -0,0 +1,37 @@
+ This package was debianized by Olivier Naudan <o-naudan@ti.com>
+ on Thu, 06 Jan 2011 17:00:00 +0100
+
+ It was downloaded from https://gitorious.org/gstreamer-omap
+
+ Upstream Author
+ ===============
+
+
+ Copyright
+ =========
+
+ Copyright (c) 2014 Texas Instruments, Incorporated. All rights reserved.
+
+
+ Licensing
+ =========
+
+
+    This package 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; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This package 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 package; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian GNU/Linux systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL'.
+
diff --git a/debian/gstreamer0.10-plugin-h265dec.install b/debian/gstreamer0.10-plugin-h265dec.install
new file mode 100644 (file)
index 0000000..a2e17fc
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/usr/lib/gstreamer-0.10/libgst*.so
diff --git a/debian/gstreamer1.0-plugin-h265dec.install b/debian/gstreamer1.0-plugin-h265dec.install
new file mode 100644 (file)
index 0000000..282e066
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/usr/lib/gstreamer-1.0/libgst*.so
diff --git a/debian/rules b/debian/rules
new file mode 100644 (file)
index 0000000..c2f7a5d
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/patchsys-quilt.mk
+include /usr/share/cdbs/1/rules/utils.mk
+
+DEB_DH_STRIP_ARGS := --dbg-package=gstreamer0.10-plugin-h265dec-dbg
+
+# Add here any variable or target overrides you need.
+
+makebuilddir/gstreamer0.10-plugin-h265dec::
+       NOCONFIGURE=1 ./autogen.sh
+
+binary-install/gstreamer0.10-plugin-h265dec::
+       rm -f debian/gstreamer0.10-plugin-h265dec/usr/lib/gstreamer-0.10/*.la
+       rm -f debian/gstreamer0.10-plugin-h265dec/usr/lib/gstreamer-0.10/*.a
+
+DEB_MAKE_INSTALL_TARGET := install DESTDIR=$(CURDIR)/debian/tmp/
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..163aaf8
--- /dev/null
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..797fb29
--- /dev/null
@@ -0,0 +1,19 @@
+plugin_LTLIBRARIES = libgsth265dec.la
+
+# headers we need but don't want installed
+noinst_HEADERS = gsth265dec.h \
+                                gsth265buf.h \
+                                gsth265utils.h
+                                 
+# sources used to compile this plug-in
+libgsth265dec_la_SOURCES = gsth265dec.c \
+                          gsth265buf.c \
+                          gsth265utils.c 
+                         
+
+# compiler and linker flags used to compile this plugin, set in configure.ac
+libgsth265dec_la_CFLAGS = $(GST_CFLAGS)
+libgsth265dec_la_LIBADD = $(GST_LIBS) -l:h265vdec_pp_lib.a -lgstdmabuf-1.0 -lgstdrm-1.0 -lgstvideo-1.0 
+libgsth265dec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsth265dec_la_LIBTOOLFLAGS = --tag=disable-static
+
diff --git a/src/gsth265buf.c b/src/gsth265buf.c
new file mode 100644 (file)
index 0000000..59feb74
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*******************************************************************************
+*   INCLUDE FILES
+*******************************************************************************/
+#include "gsth265buf.h"
+#include<stdio.h>
+#include<stdlib.h>
+/*******************************************************************************
+*   FUNCTION DEFINITIONS
+*******************************************************************************/
+
+/**
+******************************************************************************
+* @fn MEMMGR_AllocMemoryRequirements (tPPQueryMemRecords  *apQueryMemRecords,
+*                                         tPPu32 aNumMemTabEntries)
+*
+*
+* @brief This function is a utility function used to allocate memory
+*         as per the modules request
+*
+*
+* @param apQueryMemRecords [IN/OUT] Pointer to memory query records
+*
+* @param aNumMemTabEntries [OUT] Number of Mem Tab Entries
+*
+* @return Status code - SC_PP_SUCCESS       : if success
+*                       EC_PP_OUT_OF_MEMORY : insufficient memory status
+******************************************************************************
+*/
+tPPResult MEMMGR_AllocMemoryRequirements (tPPQueryMemRecords  \
+                                          *apQueryMemRecords,
+                                          tPPu32 aNumMemTabEntries)
+{
+    tPPu32 nMemTabIdx = 0;
+
+    for(nMemTabIdx = 0; nMemTabIdx < aNumMemTabEntries; nMemTabIdx++)
+    {
+        apQueryMemRecords[nMemTabIdx].allotedHandle =
+            (tPPu8 *) malloc(apQueryMemRecords[nMemTabIdx].reqSize);
+
+        if (apQueryMemRecords[nMemTabIdx].allotedHandle == NULL)
+        {
+            return EC_PP_OUT_OF_MEMORY;
+        }
+    }
+    return SC_PP_SUCCESS;
+}
+
+/**
+******************************************************************************
+* @fn MEMMGR_DeAllocMemory (tPPBaseDecoder *apBase)
+*
+* @brief This function destroys H.265 video decoder object
+*
+* @param appBase        [IN] Pointer to decoder object
+*
+* @return Status code - SC_PP_SUCCESS if success, or the following error codes
+*                       EC_PP_FAILURE : General failure
+*
+******************************************************************************
+*/
+tPPResult MEMMGR_DeAllocMemory (tPPQueryMemRecords  *apQueryMemRecords)
+{
+    tPPi32 nIndex;
+
+    if(apQueryMemRecords == NULL)
+    {
+        return EC_PP_FAILURE;
+    }
+
+    for(nIndex = PP_H265DEC_MAX_MEMTAB-1; nIndex >= 0; nIndex--)
+    {
+        if(apQueryMemRecords[nIndex].allotedHandle != NULL)
+        {
+            free(apQueryMemRecords[nIndex].allotedHandle);
+            apQueryMemRecords[nIndex].allotedHandle = NULL;
+        }
+    }
+    return SC_PP_SUCCESS;
+}/* MEMMGR_DeAllocMemory */
+
+/*****************************************************************************/
+/**
+* @fn tPPi32 BUFFMGR_GetFreeBufID(tPPInGst_Buff *GstBufOut)
+*
+* @brief  Implementation of buffer manager get free buffer module.
+*         The BUFFMGR_GetFreeBuffer function searches for a free buffer in the
+*         global buffer array and returns the address of that element. Incase
+*         if none of the elements are free then it returns NULL
+*
+*
+* @return Valid buffer element address or NULL incase if no buffers are empty
+*
+*/
+/*****************************************************************************/
+tPPi32 BUFFMGR_GetFreeBufID(tPPInGst_Buff *GstBufOut)
+{
+
+    tPPu32 tmpCnt = 0;
+    for(tmpCnt = 0; tmpCnt < MAX_BUFF_ELEMENTS; tmpCnt++)
+    {
+        if(GstBufOut[tmpCnt].bufStatus == BUFFMGR_FREE)
+        {
+            GstBufOut[tmpCnt].bufId  = tmpCnt+1;
+            GstBufOut[tmpCnt].bufStatus = BUFFMGR_USED;
+            return (tmpCnt+1) ;
+        }
+    }
+    printf("Run short of frames !!\n");
+    return 0;
+}
+
+/*****************************************************************************/
+/**
+* @fn tPPi32 BUFFMGR_ReleaseBufID(tPPi32 bufffId[], tPPInGst_Buff *GstBufOut)
+*
+* @brief  Implementation of buffer manager
+*       release module
+*
+*        The BUFFMGR_ReleaseBuffer function takes an array of buffer-ids
+*        which are released by the test-app. "0" is not a valid buffer Id
+*        hence this function keeps moving until it encounters a buffer Id
+*        as zero or it hits the MAX_BUFF_ELEMENTS
+*
+*
+* @return None
+*
+*/
+/*****************************************************************************/
+
+tPPi32 BUFFMGR_ReleaseBufID(tPPi32 bufffId[], tPPInGst_Buff *GstBufOut)
+{
+
+    tPPu32 tmpCnt, tmpId;
+
+    for(tmpCnt = 0;
+        (tmpCnt < MAX_BUFF_ELEMENTS);
+        tmpCnt++)
+    {
+        tmpId = bufffId[tmpCnt];
+
+        /*
+        * Check if the buffer Id = 0 condition has reached. zero is not a
+        * valid buffer Id hence that value is used to identify the end of
+        * buffer array
+        */
+        if(tmpId == 0)
+        {
+            break;
+        }
+        /*
+        * convert the buffer-Id to its corresponding index in the global
+        * array
+        */
+        tmpId--;
+
+        if(tmpId >= MAX_BUFF_ELEMENTS) {
+
+            /* Inidcates an invalid buffer Id passed - this buffer Id can be
+            * ignored!! alternatively we can break here.
+            */
+            continue;
+        }
+
+        if(GstBufOut[tmpId].bufStatus == BUFFMGR_FREE) {
+            /* Trying to release an already free bufffer this idicates some
+            *  mismanagement in buffer usage following printf will help
+            * application developer to identify any such problem in her
+            * algorithm
+            */
+        }
+
+        /* Set the status of the buffer to FREE */
+        GstBufOut[tmpId].bufStatus = BUFFMGR_FREE;
+        gst_buffer_unref( GstBufOut[tmpId].GstDispBuf);
+    }
+    return 0;
+}
+
diff --git a/src/gsth265buf.h b/src/gsth265buf.h
new file mode 100644 (file)
index 0000000..9174a94
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef _GSTH265DECBUF_
+#define _GSTH265DECBUF_
+
+/*******************************************************************************
+*   INCLUDE FILES
+*******************************************************************************/
+#include <gst/gst.h>
+#include "gsth265dec.h"
+#include "gsth265utils.h"
+
+/*******************************************************************************
+*   MACROS AND STRUCTURES
+*******************************************************************************/
+/** @defgroup H265_DECODER
+*/
+/** Define to indicate FALSE
+*/
+#define PP_FALSE    0
+/** Define to indicate TRUE
+*/
+#define PP_TRUE     1
+
+/** Maximum reference frames
+* Maximum reference frames this decoder configuration supports.
+* @ingroup H265_DECODER
+*/
+#define FILE_NAME_SIZE 512
+#define PP_H265DEC_MAX_MEMTAB   70
+#define PP_H265VDEC_MAX_REF_FRAMES 16
+
+/** Set status parameters macros*/
+#define PP_SET_DATASYNC             1
+#define PP_SET_DPB_FLUSH            2
+#define PP_SET_RES_INV              3
+#define PP_SET_DECODE_HDR           4
+
+/** Get status parameters macros*/
+#define PP_GET_PARAMSTATUS          1
+#define PP_GET_BUFSTATUS            2
+#define PP_GET_ERRORSTATUS          3
+
+/** Pic width and height*/
+#define PP_H265_MAX_PIC_WIDTH        4096
+#define PP_H265_MAX_PIC_HEIGHT       2176
+ /* Macro to set Error bits */
+#define PP_H265_SET_ERROR_BIT(x, m)  ((x) |= (0x1 << m))
+
+#define MAX_BUFF_ELEMENTS 17
+#define DPB_MAXLUMAPS 8912896  /*Value for level 5.2 from Table A-1*/
+
+/**
+ *  @brief      Status of the buffer elements.
+ */
+typedef enum {
+    BUFFMGR_FREE = 0,
+    BUFFMGR_USED = 1
+} BUFFMGR_BufferStatus;
+
+/**
+ *  @brief      Definition of buffer element in the buffer array.
+ *            every time a new buffer is requested buffer manager
+ *            module returns a pointer to one of the elements
+ *            defined below from the buffer array
+ */
+typedef struct BuffEle
+{
+    /** Unique Id which identifies the buffer element */
+    tPPu32 bufId;
+    /**
+     * Status of the buffer element: can be either free for allocation or
+     * held by the codec and cannot be allocated
+     */
+    BUFFMGR_BufferStatus bufStatus;
+    /** Size of buffer members held by this buffer element in bytes */
+    tPPu32 bufSize[3];
+    /** buffer members which contain the address of the actual buffers
+     * represented by this buffer element */
+    tPPu8 *buf[3];
+} BUFFMGR_buffEle;
+
+typedef struct PPInGst_Buff
+{
+ /*! Unique Id which identifies the buffer element */
+    tPPi32 bufId;
+    BUFFMGR_BufferStatus bufStatus;
+    GstBuffer *GstDispBuf;
+    GstMapInfo Out_map;
+}tPPInGst_Buff;
+
+typedef BUFFMGR_buffEle* BUFFMGR_buffEleHandle;
+
+BUFFMGR_buffEle buffArray[MAX_BUFF_ELEMENTS];
+
+
+/*******************************************************************************
+*   FUNCTION PROTOTYPES
+*******************************************************************************/
+
+/**
+ ******************************************************************************
+ * @fn gPP_H265_QueryMemoryRequirements (tPPQueryMemRecords  *apQueryMemRecords,
+ *                             tPPH265BPD_CreateParams *apCreateParams,
+ *                             tPPu32 *apNumMemTabEntries);
+ * @ingroup H265_DECODER
+ *
+ * @brief This function queries for H.265 video decoder object
+ *              memory requirements.
+ *
+ * @param apQueryMemRecords  [IN/OUT] Pointer to memory query records
+ * @param apCreateParams     [IN] Pointer to decoder create parameter structure
+ * @param apNumMemTabEntries [OUT] Number of MemTab Entries
+ *
+ * @return None
+ ******************************************************************************
+ */
+
+tPPResult gPP_H265_QueryMemoryRequirements(
+                             tPPQueryMemRecords    *apQueryMemRecords,
+                             tPP_H265_CreateParams *apCreateParams,
+                             tPPu32                *apNumMemTabEntries);
+
+/**
+******************************************************************************
+* @fn MEMMGR_AllocMemoryRequirements (tPPQueryMemRecords  *apQueryMemRecords,
+*                                         tPPu32 aNumMemTabEntries)
+*
+*
+* @brief This function is a utility function used to allocate memory
+*         as per the modules request
+*
+*
+* @param apQueryMemRecords [IN/OUT] Pointer to memory query records
+*
+* @param aNumMemTabEntries [OUT] Number of Mem Tab Entries
+*
+* @return Status code - SC_PP_SUCCESS       : if success
+*                       EC_PP_OUT_OF_MEMORY : insufficient memory status
+******************************************************************************
+*/
+
+tPPResult MEMMGR_AllocMemoryRequirements (
+  tPPQueryMemRecords  *apQueryMemRecords, tPPu32 aNumMemTabEntries);
+
+/**
+******************************************************************************
+* @fn MEMMGR_DeAllocMemory (tPPBaseDecoder *apBase)
+*
+* @brief This function destroys H.265 video decoder object
+*
+* @param appBase        [IN] Pointer to decoder object
+*
+* @return Status code - SC_PP_SUCCESS if success, or the following error codes
+*                       EC_PP_FAILURE : General failure
+*
+******************************************************************************
+*/
+tPPResult MEMMGR_DeAllocMemory (tPPQueryMemRecords  *apQueryMemRecords);
+/*****************************************************************************/
+/**
+* @fn tPPi32 BUFFMGR_GetFreeBufID(tPPInGst_Buff *GstBufOut)
+*
+* @brief  Implementation of buffer manager get free buffer module.
+*         The BUFFMGR_GetFreeBuffer function searches for a free buffer in the
+*         global buffer array and returns the address of that element. Incase
+*         if none of the elements are free then it returns NULL
+*
+*
+* @return Valid buffer element address or NULL incase if no buffers are empty
+*
+*/
+/*****************************************************************************/
+tPPi32 BUFFMGR_GetFreeBufID(tPPInGst_Buff *GstBufOut);
+/*****************************************************************************/
+/**
+* @fn tPPi32 BUFFMGR_ReleaseBufID(tPPi32 bufffId[], tPPInGst_Buff *GstBufOut)
+*
+* @brief  Implementation of buffer manager
+*       release module
+*
+*        The BUFFMGR_ReleaseBuffer function takes an array of buffer-ids
+*        which are released by the test-app. "0" is not a valid buffer Id
+*        hence this function keeps moving until it encounters a buffer Id
+*        as zero or it hits the MAX_BUFF_ELEMENTS
+*
+*
+* @return None
+*
+*/
+/*****************************************************************************/
+
+tPPi32 BUFFMGR_ReleaseBufID(tPPi32 bufffId[], tPPInGst_Buff *GstBufOut);
+
+#endif /*_GSTH265DECBUF_*/
+
+
diff --git a/src/gsth265dec.c b/src/gsth265dec.c
new file mode 100644 (file)
index 0000000..34be685
--- /dev/null
@@ -0,0 +1,944 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include <gst/video/gstvideopool.h>
+#include "gsth265dec.h"
+#include <malloc.h>
+#include "gsth265utils.h"
+#include "gsth265buf.h"
+#ifdef PROFILE
+#include <sys/time.h>
+#endif
+
+GST_DEBUG_CATEGORY_STATIC (gst_h265dec_debug);
+#define GST_CAT_DEFAULT gst_h265dec_debug
+
+#define H265_MAX_WIDTH      1920
+#define H265_MAX_HEIGHT     1080
+/* Global variables */
+volatile guint32 nDecFrmNo;
+volatile gint32 nFrameDecodeStart ;
+volatile gint32 nFrameDecodeEnd;
+volatile gint32 nTerminateStatus ;
+volatile guint32 nFrameSync ;
+volatile guint32 nFrameSyncSlave ;
+volatile guint32 nFlushCall ;
+volatile static guint8 nCnt ;
+volatile guint32 nDecodeEnd ;
+volatile static guint32 nDecodeComplete ;
+guint32  nValidBytesLeft ;
+guint32  nNumThreads ;
+guint8   nGlobalDataBuffer[((H265_MAX_WIDTH*H265_MAX_HEIGHT*3 )>>1) + 40960];
+guint32  nDispFrmNo ;
+gint32   nTOTAL_FRAME_SIZE;
+tPP_H265_DynamicParams      h265_DynamicParams;
+tPPDecParam_Status          apVal ;
+tPPBaseDecoder              *h265dec = NULL;
+BUFFMGR_buffEleHandle       H265_dec_BuffEle ;
+tPPInFrame_Buff             H265_dec_InBuff;
+tPPOutFrame_Buff            H265_dec_OutBuff;
+tPPInput_BitStream          H265InputStream ;
+tPPInput_BitStream          H265InputStreamNAL ;
+tPP_H265_CreateParams       h265_CreateParams;
+tPPQueryMemRecords          ReqMemTab[PP_H265DEC_MAX_MEMTAB];
+tPPYUVPlanarDisplayFrame    pOutBuf[PP_H265VDEC_MAX_REF_FRAMES + 1];
+tPPInGst_Buff               GstBufOut[PP_H265VDEC_MAX_REF_FRAMES + 1];
+GstMapInfo                  info_out;
+tPPGstNAL                   aGstNAL;
+/* Thread identifiers */
+pthread_t                   thread[4];
+gint32                      *pThreadRetVal[3] ;
+gint32                      taskid[4] = {0};
+guint8  pTempData[((H265_MAX_WIDTH*H265_MAX_HEIGHT*3 )>>1)];
+
+#ifdef PROFILE
+struct timeval tProcessSt, tProcessEd;
+unsigned long long process_time ;
+unsigned long long total_time ;
+float frame_rate;
+unsigned int nFrmNo;
+#endif
+
+/* Id numbers for each thread */
+/* Filter signals and args */
+enum
+{
+  /* FILL ME */
+  LAST_SIGNAL
+};
+
+enum
+{
+  PROP_0,
+  PROP_SILENT,
+  PROP_THREADS
+};
+
+/* the capabilities of the inputs and outputs.
+*
+* describe the real formats here.
+*/
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+                                                                    GST_PAD_SINK,
+                                                                    GST_PAD_ALWAYS,
+                                                                    GST_STATIC_CAPS ("ANY")
+                                                                    );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+                                                                   GST_PAD_SRC,
+                                                                   GST_PAD_ALWAYS,
+                                                                   GST_STATIC_CAPS ("ANY")
+                                                                   );                                                             
+
+#define gst_h265dec_parent_class parent_class
+G_DEFINE_TYPE (Gsth265dec, gst_h265dec, GST_TYPE_ELEMENT);
+
+static void gst_h265dec_set_property (GObject * object, guint prop_id,
+                                      const GValue * value, GParamSpec * pspec);
+
+static void gst_h265dec_get_property (GObject * object, guint prop_id,
+                                      GValue * value, GParamSpec * pspec);
+
+static gboolean gst_h265dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event);
+static GstFlowReturn gst_h265dec_chain (GstPad * pad,
+                                        GstObject * parent, GstBuffer * buf);
+static void*
+gst_h265dec_process_call(void *pInputStream);
+
+void gH265_InterleaveChroma_armv7(guint8 *Indata,
+                                  guint8 *OutData , gint32 nWidth,
+                                  gint32 nHeight);
+
+/* initialize the h265dec's class */
+static void
+gst_h265dec_class_init (Gsth265decClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
+  gobject_class->set_property = gst_h265dec_set_property;
+  gobject_class->get_property = gst_h265dec_get_property;
+
+  g_object_class_install_property (gobject_class, PROP_SILENT,
+    g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
+    FALSE, G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class, PROP_THREADS,
+    g_param_spec_int ("threads", "Threads", "Number of threads",
+    1, 4, 4, G_PARAM_READWRITE));
+  gst_element_class_set_details_simple(gstelement_class,
+    "H265 Decoder ",
+    "Codec/Decoder/Video",
+    "Decodes H265 streams",
+    "pathpartner <<pathpartner@pathpartner.org>>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+    gst_static_pad_template_get (&src_factory));
+
+  gst_element_class_add_pad_template (gstelement_class,
+    gst_static_pad_template_get (&sink_factory));
+}
+
+/* initialize the new element
+* instantiate pads and add them to element
+* set pad calback functions
+* initialize instance structure
+*/
+static void
+gst_h265dec_init (Gsth265dec * decoder)
+{
+  decoder->sinkpad
+    = gst_pad_new_from_static_template (&sink_factory, "sink");
+  gst_pad_set_event_function (decoder->sinkpad,
+    GST_DEBUG_FUNCPTR(gst_h265dec_sink_event));
+  gst_pad_set_chain_function (decoder->sinkpad,
+    GST_DEBUG_FUNCPTR(gst_h265dec_chain));
+  GST_PAD_SET_PROXY_CAPS (decoder->sinkpad);
+  gst_element_add_pad (GST_ELEMENT (decoder), decoder->sinkpad);
+  decoder->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+  GST_PAD_SET_PROXY_CAPS (decoder->srcpad);
+  gst_element_add_pad (GST_ELEMENT (decoder), decoder->srcpad);
+  decoder->nInitFlag = 0;
+  decoder->silent = FALSE;
+}
+
+static void
+gst_h265dec_set_property (GObject * object, guint prop_id,
+                          const GValue * value, GParamSpec * pspec)
+{
+  Gsth265dec *decoder = GST_H265DEC (object);
+
+  switch (prop_id)
+  {
+  case PROP_SILENT:
+    decoder->silent = g_value_get_boolean (value);
+    break;
+  case PROP_THREADS:
+    decoder->threads = g_value_get_int (value);
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+gst_h265dec_get_property (GObject * object, guint prop_id,
+                          GValue * value, GParamSpec * pspec)
+{
+  Gsth265dec *decoder = GST_H265DEC (object);
+
+  switch (prop_id) {
+case PROP_SILENT:
+  g_value_set_boolean (value, decoder->silent);
+  break;
+
+case PROP_THREADS:
+  g_value_set_int (value , decoder->threads);
+  break;
+
+default:
+  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+  break;
+  }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles sink events */
+static gboolean
+gst_h265dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  gboolean ret;
+  Gsth265dec *decoder;
+
+  decoder = GST_H265DEC (parent);
+
+  switch (GST_EVENT_TYPE (event)) {
+case GST_EVENT_CAPS:
+  {
+    GstCaps * caps;
+
+    gst_event_parse_caps (event, &caps);
+    /* do something with the caps */
+
+    /* and forward */
+    ret = gst_pad_event_default (pad, parent, event);
+    break;
+  }
+default:
+  ret = gst_pad_event_default (pad, parent, event);
+  break;
+  }
+  return ret;
+}
+/*
+******************************************************************************
+* @fn sPP_H265_MultiThreadInit(tPPi32 argc, tPPi8 *argv[])
+*
+* @brief Function to initialize multi thread parameters
+*
+* @param nMultiThreadParam [IN] Structure
+*
+* @return Number of bytes written to the file
+******************************************************************************
+*/
+static gint32 sPP_H265_MultiThreadInit(tPPMultiThreadParams *nMultiThreadParam,
+                                       guint32 nThreadID,
+                                       guint32 nNumThd)
+{
+  /*Task ID*/
+  if(nThreadID == 0)
+    nMultiThreadParam->nTaskID = kH265_TASK_MASTER ;
+  else
+    nMultiThreadParam->nTaskID = kH265_TASK_SLAVE ;
+  /*Number of threads*/
+  nMultiThreadParam->nNumThreads = nNumThd ;
+  /*Thread ID */
+  nMultiThreadParam->nThreadID = nThreadID ;
+
+  return GST_FLOW_OK ;
+}
+
+static GstCaps *
+gst_h265dec_getcaps (GstPad * pad)
+{
+  GstCaps *caps = NULL;
+  caps = gst_pad_get_current_caps (pad);
+  if (caps == NULL) {
+    GstCaps *fil = gst_pad_get_pad_template_caps (pad);
+    g_print("gst_pad_get_current_caps Failing\n");
+    return gst_caps_copy (fil);
+  } else {
+    return gst_caps_copy (caps);
+  }
+}
+
+/* chain function
+* this function does the actual processing
+*/
+static GstFlowReturn
+gst_h265dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+{
+  Gsth265dec *decoder;
+  GstMapInfo info ;
+  guint32 taskidMaster = 0;
+  gint32 nRetVal;
+  gint32 aByteConsumed = 0;
+  gint32 nOffset = 0;
+  gint32 i;
+  gint32 nFlag = 0;
+  guint32 nIndex ,nIndex1;
+  guint32 nNumMemTabEntries =0;
+  guint32 nRet;
+  guint32 nDispFlag;
+  GstQuery *query = NULL;
+  guint min = 0;
+  guint max = 0;
+  guint size = 0;
+  GstCaps *Caps;
+  GstStructure *config;
+  GstFlowReturn flow;
+  GstBuffer *pVpeBuff = NULL;
+  GstBuffer *GstOutBufTemp;
+
+  decoder = GST_H265DEC (parent);
+
+  gst_buffer_map(buf, &info , GST_MAP_READ);
+
+  H265InputStream.nBufLength    = info.size;
+  H265InputStreamNAL.nBufLength = info.size;
+
+  nOffset = nValidBytesLeft;
+  nDispFlag = 1;
+  /* Initialiazations */
+  if(!decoder->nInitFlag)
+  {
+    /* H265 decoder initialization*/
+    FUNC_MEMSET(ReqMemTab, 0,
+      sizeof(tPPQueryMemRecords)*PP_H265DEC_MAX_MEMTAB);
+
+    nRetVal = 0;
+    h265_CreateParams.nNumThreads = decoder->threads;
+    h265_CreateParams.nMaxWidth   = H265_MAX_WIDTH;
+    h265_CreateParams.nMaxHeight  = H265_MAX_HEIGHT;
+    nNumThreads = decoder->threads;
+    decoder->nTimeStamp = 0;
+
+    nRetVal = gPP_H265_QueryMemoryRequirements( &ReqMemTab[0],
+      &h265_CreateParams, &nNumMemTabEntries);
+
+    /* Increase default malloc size */
+    mallopt(M_MMAP_THRESHOLD , (1024*1024*30));
+
+    /*Allocate the memory*/
+    nRetVal = MEMMGR_AllocMemoryRequirements(&ReqMemTab[0],
+      nNumMemTabEntries);
+
+    if(nRetVal != GST_FLOW_OK)
+    {
+      g_print("Error in Allocating the memory requirements.\n");
+    }
+
+    /*Pass the memory and Initialize the decoder*/
+    nRetVal = gPP_H265_InitializeDecoder  (&h265dec,
+      &ReqMemTab[0],&h265_CreateParams);
+
+    h265_DynamicParams.nDecodeHeader = PP_H265_PARSE_HEADER;
+
+    if(nRetVal != GST_FLOW_OK)
+    {
+      g_print("Error in Initializing \n");
+    }
+
+    /* Initialise pLum pointers in output base frames to NULL.
+    * When the decoder initialises these pointers with valid values we know
+    * that its time to dump/display them
+    */
+    nIndex = 0;
+    while( nIndex < (PP_H265VDEC_MAX_REF_FRAMES+1) )
+    {
+      pOutBuf[nIndex].pLum = NULL;
+      nIndex++;
+    }
+
+    for(i = 1; i < nNumThreads; i++)
+    {
+      taskid[i] = i;
+      /* Create a thread with its argument in taskid[i] */
+      nRet = pthread_create(&thread[i], NULL,
+        &gst_h265dec_process_call, &taskid[i]);
+      if (nRet)
+      {
+        /* Check for errors */
+        printf("ERROR; return code from pthread_create() is %d\n",
+          nRet);
+      }
+    }
+    if(!gst_pad_has_current_caps(decoder->srcpad))
+      g_print("gst_pad_has_current_caps Failing\n");
+
+    Caps = gst_h265dec_getcaps (decoder->srcpad);
+    if(Caps == NULL)
+      g_print("gst_pad_get_current_caps Failing\n");
+
+
+    query =
+      gst_query_new_allocation ( Caps, TRUE);
+
+    if (gst_pad_peer_query (decoder->srcpad, query))
+    {
+      g_print("gst_pad_peer_query sucessful\n");
+    }
+    else
+    {
+      g_print("gst_pad_peer_query failed\n");
+    }
+
+    if (gst_query_get_n_allocation_pools (query) > 0) {
+      /* we got configuration from our peer, parse them */
+      gst_query_parse_nth_allocation_pool (query, 0, &decoder->externalpool, &size,
+        &min, &max);
+    }
+    else
+    {
+      decoder->externalpool = NULL;
+      size = 0;
+      min = max = 0;
+    }
+
+    if (decoder->externalpool == NULL) {
+      /* we did not get a pool, make one ourselves then */
+      decoder->externalpool = gst_video_buffer_pool_new ();
+    }
+
+    config = gst_buffer_pool_get_config (decoder->externalpool);
+    gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
+    gst_buffer_pool_config_set_params (config, Caps, size, min, max);
+    gst_buffer_pool_set_config (decoder->externalpool, config);
+
+    /* and activate */
+    gst_buffer_pool_set_active (decoder->externalpool, TRUE);
+    decoder->nInitFlag = 1;
+  }
+
+  for(i = 0 ; i < info.size ;i++)
+  {
+    nGlobalDataBuffer[i + nOffset] = info.data[i];
+  }
+
+  H265InputStream.nBitStream =
+    H265InputStreamNAL.nBitStream =  &nGlobalDataBuffer[0];
+
+  H265InputStreamNAL.nBufLength = (info.size) + nOffset;
+  /* Default buffer size*/
+  if(info.size < 4096 )
+  {
+    nFlag = 1;
+  }
+
+  do
+  {
+    aByteConsumed = 0;
+    /* Parse frame data*/
+    nRetVal = gH265_ParseNALUnitFrame(&aGstNAL,
+      H265InputStreamNAL , &aByteConsumed);
+
+    if(nRetVal == SC_PP_NEXT_FRAME_FOUND )
+    {
+      H265InputStream.nBufLength = aByteConsumed;
+      H265InputStream.nBitStream = H265InputStreamNAL.nBitStream;
+      /* if frame data decode */
+      gst_h265dec_process_call(&taskidMaster);
+
+      H265InputStreamNAL.nBitStream += aByteConsumed;
+      H265InputStreamNAL.nBufLength -= aByteConsumed;
+
+    }
+    else if(nFlag)
+    {
+      H265InputStream.nBufLength = aByteConsumed;
+      H265InputStream.nBitStream = H265InputStreamNAL.nBitStream;
+      /* if frame data decode */
+      gst_h265dec_process_call(&taskidMaster);
+
+      /* File sink */
+      nIndex = 0;
+
+      while( nIndex < (PP_H265VDEC_MAX_REF_FRAMES + 1) )
+      {
+        if (pOutBuf[nIndex].pLum)
+        {
+          nIndex1 =0;
+          while(nIndex1 < (PP_H265VDEC_MAX_REF_FRAMES + 1) )
+          {
+            if(GstBufOut[nIndex1].GstDispBuf == NULL)
+            {
+              nIndex1++;
+              continue;
+            }
+
+            if( pOutBuf[nIndex].pLum == GstBufOut[nIndex1].Out_map.data)
+            {
+              /* Conversion of YUV data to NV12 format */
+              gH265_InterleaveChroma_armv7(GstBufOut[nIndex1].\
+                Out_map.data, pTempData, apVal.nPicWidth,
+                apVal.nPicHeight);
+
+              flow = gst_buffer_pool_acquire_buffer (decoder->externalpool, &pVpeBuff, NULL);
+
+              if (flow != GST_FLOW_OK)
+              {
+                GST_INFO_OBJECT (decoder, "couldn't allocate output buffer, flow %s",
+                  gst_flow_get_name (flow));
+              }
+              gst_buffer_fill(pVpeBuff, 0, pTempData,
+                ((nTOTAL_FRAME_SIZE * 3) >> 1));
+
+              nRet = gst_pad_push (decoder->srcpad,
+                pVpeBuff);
+
+              nDispFrmNo++;
+              pOutBuf[nIndex].pLum = NULL;
+              break;
+            }
+            nIndex1++;
+          }
+        }
+        else
+        {
+          break;
+        }
+        nIndex++;
+        /*Call release buffer*/
+        BUFFMGR_ReleaseBufID(&H265_dec_OutBuff.bufId[0], GstBufOut );
+      }
+
+      nFlushCall = 1;
+      gst_h265dec_process_call(&taskidMaster);
+
+      while(nDecodeComplete != (nNumThreads - 1) );
+      /* Deallocate the memory*/
+      MEMMGR_DeAllocMemory(&ReqMemTab[0]);
+
+      for(i = 0; i < (nNumThreads - 1); i++)
+      {
+        pthread_join(thread[(i + 1)] ,
+          (void **)&pThreadRetVal[i]);
+      }
+      H265InputStreamNAL.nBitStream += aByteConsumed;
+      H265InputStreamNAL.nBufLength -= aByteConsumed;
+    }
+    else
+    {
+      for(i= 0 ; i< H265InputStreamNAL.nBufLength ;i++ )
+      {
+        nGlobalDataBuffer[i] = H265InputStreamNAL.nBitStream [i];
+      }
+      nValidBytesLeft = H265InputStreamNAL.nBufLength;
+      break;
+    }
+
+    /* File sink */
+    nIndex  = 0;
+
+    while( nIndex < (PP_H265VDEC_MAX_REF_FRAMES + 1) )
+    {
+      if (pOutBuf[nIndex].pLum)
+      {
+        nIndex1 =0;
+        while(nIndex1 < (PP_H265VDEC_MAX_REF_FRAMES + 1) )
+        {
+          if(GstBufOut[nIndex1].GstDispBuf == NULL)
+          {
+            nIndex1++;
+            continue;
+          }
+
+          if( pOutBuf[nIndex].pLum == GstBufOut[nIndex1].Out_map.data)
+          {
+            /* Conversion of YUV data to NV12 format */
+            gH265_InterleaveChroma_armv7(GstBufOut[nIndex1].\
+              Out_map.data, pTempData, apVal.nPicWidth,
+              apVal.nPicHeight);
+
+            flow = gst_buffer_pool_acquire_buffer (decoder->externalpool, &pVpeBuff, NULL);
+
+            if (flow != GST_FLOW_OK)
+            {
+              GST_INFO_OBJECT (decoder, "couldn't allocate output buffer, flow %s",
+                gst_flow_get_name (flow));
+            }
+
+            gst_buffer_fill(pVpeBuff, 0, pTempData,
+              ((nTOTAL_FRAME_SIZE * 3) >> 1));
+
+            nRet = gst_pad_push (decoder->srcpad,
+              pVpeBuff);
+
+            nDispFrmNo++;
+            pOutBuf[nIndex].pLum = NULL;
+            break;
+          }
+          nIndex1++;
+        }
+      }
+      else
+      {
+        break;
+      }
+      nIndex++;
+      /*Call release buffer*/
+      BUFFMGR_ReleaseBufID(&H265_dec_OutBuff.bufId[0], GstBufOut );
+    }
+  }while(H265InputStreamNAL.nBufLength > 3);
+
+  if(nFlag && nDispFlag)
+  {
+#ifdef PROFILE
+    g_print(" Total decode time               : %lld.%lld ms\n",
+      total_time/1000,total_time%1000);
+    frame_rate = (nDecFrmNo * (1000000))/(float)total_time;
+    g_print(" Frames per second               : %0.2f fps\n",frame_rate);
+#endif
+    nDispFlag = 0;
+  }
+  return 0;
+
+}
+
+static void*
+gst_h265dec_process_call(void* thread_args)
+{
+  gint32 nRetVal ,nRetV;
+  gint32 *thread_ptr = (gint32 *)thread_args;
+  gint32 thread_no = *thread_ptr;
+  /*MultiThread*/
+  tPPMultiThreadParams nMultiThreadParam;
+  guint32  BuffID;
+
+  nRetVal = sPP_H265_MultiThreadInit(&nMultiThreadParam ,
+    thread_no, nNumThreads);
+
+  if(nRetVal != SC_PP_SUCCESS)
+  {
+    printf("Invalid Multi thread init params\n");
+    goto EXIT_H265DEC;
+  }
+START_FRAME:
+  /* Multithread synchronization*/
+  gPP_PPL_AtomicAdd8((guint8 *)&nFrameSyncSlave, 1);
+  while((nFrameSyncSlave % nNumThreads) != 0) ;
+
+  if(!nFlushCall)
+  {
+    if (nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+      /* h265_DynamicParams.nDecodeHeader = PP_H265_PARSE_HEADER;*/
+
+      nRetV = h265dec->vSet(h265dec, PP_SET_DECODE_HDR,
+        h265_DynamicParams.nDecodeHeader, &h265_DynamicParams);
+
+      if(nRetV == EC_PP_FAILURE)
+      {
+        nTerminateStatus = 1;
+        goto EXIT_H265DEC;
+      }
+      if(h265_DynamicParams.nDecodeHeader == PP_H265_PARSE_HEADER)
+      {
+        guint8 *pBitStream ;
+        gint32 nBitLen;
+
+        pBitStream = H265InputStream.nBitStream ;
+        nBitLen    = H265InputStream.nBufLength ;
+        nRetVal = h265dec->vDecode(h265dec,
+          &(H265InputStream),  &(H265_dec_InBuff),
+          &(H265_dec_OutBuff),
+          (tPPYUVPlanarDisplayFrame *)(&pOutBuf[0]),
+          &nMultiThreadParam);
+
+        H265InputStream.nBitStream = pBitStream +
+          (nBitLen - H265InputStream.nBufLength);
+
+        nRetVal =  h265dec->vGet(h265dec,
+          PP_GET_PARAMSTATUS, (void *)(&apVal));
+      }
+
+      h265_DynamicParams.nDecodeHeader = PP_H265_DECODE_ACCESSUNIT;
+
+      nRetV = h265dec->vSet(h265dec, PP_SET_DECODE_HDR,
+        h265_DynamicParams.nDecodeHeader, &h265_DynamicParams);
+
+      if(h265_DynamicParams.nDecodeHeader ==
+        PP_H265_DECODE_ACCESSUNIT)
+      {
+        BuffID =  BUFFMGR_GetFreeBufID(GstBufOut);
+
+        nTOTAL_FRAME_SIZE =(apVal.nPicWidth * apVal.nPicHeight);
+
+        /* Assign the buffer allotted by Buffer manager to I/p frame*/
+        if(BuffID < (PP_H265VDEC_MAX_REF_FRAMES+1))
+        {
+          GstBufOut[BuffID - 1].GstDispBuf =
+            gst_buffer_new_allocate(NULL,
+            ((nTOTAL_FRAME_SIZE * 3) >>1), NULL);
+          if(GST_IS_BUFFER(GstBufOut[BuffID - 1].GstDispBuf))
+          {
+            gst_buffer_map(GstBufOut[BuffID - 1].GstDispBuf,
+              &GstBufOut[BuffID - 1].Out_map , GST_MAP_WRITE) ;
+          }
+          (H265_dec_InBuff.buf[0])=
+            GstBufOut[BuffID - 1].Out_map.data;
+          (H265_dec_InBuff.buf[1])=
+            (H265_dec_InBuff.buf[0])+ nTOTAL_FRAME_SIZE;
+          (H265_dec_InBuff.buf[2])=
+            (H265_dec_InBuff.buf[1]) + (nTOTAL_FRAME_SIZE >>2);
+          (H265_dec_InBuff.bufId) = BuffID;
+        }
+        else
+        {
+          printf("No Free Buffers available\n");
+          nTerminateStatus = 1;
+        }
+      }
+    }
+    gPP_PPL_AtomicAdd8((guint8 *)&nFrameSync, 1);
+
+    while((nFrameSync % nNumThreads) != 0)
+    {
+      if(nTerminateStatus == 1)
+      {
+        goto EXIT_H265DEC;
+      }
+    };
+    if (nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+#ifdef PROFILE
+      gettimeofday(&tProcessSt , NULL) ;
+#endif
+    }
+    nRetVal = h265dec->vDecode(h265dec,
+      &(H265InputStream),  &(H265_dec_InBuff),
+      &(H265_dec_OutBuff), (tPPYUVPlanarDisplayFrame *)(&pOutBuf[0]),
+      &nMultiThreadParam);
+
+    if (nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+#ifdef PROFILE
+      gettimeofday(&tProcessEd , NULL) ;
+      process_time = (tProcessEd.tv_sec - tProcessSt.tv_sec)*1000000 +
+        (tProcessEd.tv_usec - tProcessSt.tv_usec);
+      total_time += process_time;
+#endif
+    }
+    if(nRetVal == EC_PP_FAILURE)
+    {
+      if(nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+      {
+        goto EXIT_H265DEC;
+      }
+    }
+    if(nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+      nCnt    = 0;
+      nFrameSyncSlave = 0;
+      nFrameSync      = 0;
+
+      h265dec->vGet( h265dec,
+        PP_GET_ERRORSTATUS,(void *)(&apVal));
+
+      if(nDecFrmNo >= 0)
+      {
+        gint32 nTemp =0;
+        h265dec->vGet( h265dec, PP_GET_BUFSTATUS,
+          (void *)(&nTemp));
+        if((nTemp == BUFFMGR_FREE) || (nTemp == BUFFMGR_USED))
+        {
+          if(h265_DynamicParams.nDecodeHeader ==
+            PP_H265_DECODE_ACCESSUNIT)
+          {
+            GstBufOut->bufStatus = (BUFFMGR_BufferStatus)nTemp;
+          }
+        }
+      }
+
+      /* If the end of NAL unit(Start of the next NAL unit)
+      not found exit*/
+      if( nRetVal == EC_PP_H265_NO_NALU_END_FOUND )
+      {
+        printf("\nError : NAL unit's end not found\n");
+        goto  EXIT_H265DEC;
+      }
+
+      if ( ( nRetVal == EC_PP_FAILURE )
+        ||( nRetVal ==  EC_PP_INVALID_PARAM ) ||
+        (nRetVal == EC_PP_NOT_SUPPORTED) )
+      {
+        printf(" Invalid parameters\n");
+      }
+      /* If complete frame is decoded, write that in the output file*/
+      if( nRetVal == SC_PP_SUCCESS || nRetVal == SC_PP_RESOLUTION_CHANGED
+        ||  nRetVal == SC_PP_END_OF_PICTURE)
+      {
+        nDecFrmNo++;
+      }/*end of if( nRetVal == SC_PP_SUCCESS )*/
+    }/*end of if(nMultiThreadParam.nTaskID == kH265_TASK_MASTER)*/
+
+    if (nMultiThreadParam.nTaskID != kH265_TASK_MASTER)
+    {
+      if (( nRetVal == EC_PP_FAILURE ) ||
+        (nRetVal ==  EC_PP_INVALID_PARAM ) ||
+        (nRetVal == EC_PP_NOT_SUPPORTED) ||
+        (nRetVal == EC_PP_H265_NO_NALU_END_FOUND))
+      {
+        goto EXIT_H265DEC ;
+      }
+
+      gPP_PPL_AtomicAdd8((guint8 *)&nFrameDecodeStart,1);
+      do
+      {
+        if(nFrameDecodeStart == (nNumThreads -1))
+        {
+          gPP_PPL_AtomicAdd8((guint8 *)&nFrameDecodeEnd,1);
+          break;
+        }
+      }while(1);
+    }
+    if (nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+      do
+      {
+        if(nFrameDecodeEnd == (nNumThreads -1))
+        {
+          nFrameDecodeStart = 0;
+          nFrameDecodeEnd = 0;
+          break;
+        }
+      }
+      while(1);
+    }
+    else
+    {
+      while(nFrameDecodeStart);
+    }
+
+    if (nMultiThreadParam.nTaskID != kH265_TASK_MASTER)
+    {
+      goto START_FRAME;
+    }
+  }
+  else
+  {
+    /*Flush Call*/
+    if (nMultiThreadParam.nTaskID == kH265_TASK_MASTER)
+    {
+      /* after Decoding Last Frame Dump all the rest frame */
+      do
+      {
+        h265dec->vSet(h265dec ,
+          PP_SET_DPB_FLUSH , PP_TRUE, &h265_DynamicParams);
+
+        nRetVal = h265dec->vDecode(h265dec,
+          &(H265InputStream),
+          &(H265_dec_InBuff),
+          &(H265_dec_OutBuff),
+          (tPPYUVPlanarDisplayFrame *)(&pOutBuf[0]),
+          &nMultiThreadParam);
+
+      }while (nRetVal == SC_PP_SUCCESS);
+    }
+  }
+EXIT_H265DEC:
+  {
+    if (nMultiThreadParam.nTaskID != kH265_TASK_MASTER)
+    {
+      gPP_PPL_AtomicAdd8((guint8 *)&nDecodeComplete,1);
+      pthread_exit(&nMultiThreadParam.nThreadID);
+    }
+    /* Multithread synchronization*/
+  }
+  return GST_FLOW_OK;
+}
+
+/* entry point to initialize the plug-in
+* initialize the plug-in itself
+* register the element factories and other features
+*/
+static gboolean
+h265dec_init (GstPlugin * h265dec)
+{
+  /* debug category for fltering log messages
+  *
+  * exchange the string 'Template h265dec' with your description
+  */
+  GST_DEBUG_CATEGORY_INIT (gst_h265dec_debug, "h265dec",
+    0, "H265dec decoder");
+
+  return gst_element_register (h265dec, "h265dec", GST_RANK_PRIMARY,
+    GST_TYPE_H265DEC);
+}
+
+/* PACKAGE: this is usually set by autotools depending on some _INIT macro
+* in configure.ac and then written into and defined in config.h, but we can
+* just set it ourselves here in case someone doesn't use autotools to
+* compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
+*/
+#ifndef PACKAGE
+#define PACKAGE "myfirsth265dec"
+#endif
+
+/* gstreamer looks for this structure to register h265decs
+*
+* exchange the string 'Template h265dec' with your h265dec description
+*/
+GST_PLUGIN_DEFINE (
+                   GST_VERSION_MAJOR,
+                   GST_VERSION_MINOR,
+                   h265dec,
+                   "H265dec decoder",
+                   h265dec_init,
+                   "1.0.0",
+                   "LGPL",
+                   "GStreamer",
+                   "http://gstreamer.net/"
+                   )
diff --git a/src/gsth265dec.h b/src/gsth265dec.h
new file mode 100644 (file)
index 0000000..d9994be
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __GST_H265DEC_H__
+#define __GST_H265DEC_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+
+#define GST_TYPE_H265DEC \
+  (gst_h265dec_get_type())
+#define GST_H265DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H265DEC,Gsth265dec))
+#define GST_H265DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H265DEC,Gsth265decClass))
+#define GST_IS_H265DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H265DEC))
+#define GST_IS_H265DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H265DEC))
+#define GST_H265DEC_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_H265DEC, Gsth265decClass))  
+
+#define FUNC_MEMSET gH265D_Memset
+/* NAL UNIT TYPES */
+#define H265_TRAIL_N_NALUNIT    0
+#define H265_TRAIL_R_NALUNIT    1
+#define H265_TSA_N_NALUNIT      2
+#define H265_TLA_NALUNIT        3
+#define H265_STSA_N_NALUNIT     4
+#define H265_STSA_R_NALUNIT     5
+#define H265_RADL_N_NALUNIT     6
+#define H265_RADL_R_NALUNIT     7
+#define H265_RASL_N_NALUNIT     8
+#define H265_RASL_R_NALUNIT     9
+#define H265_BLA_W_LP_NALUNIT   16
+#define H265_BLA_W_RADL_NALUNIT 17
+#define H265_BLA_N_LP_NALUNIT   18
+#define H265_IDR_W_RADL_NALUNIT 19
+#define H265_IDR_N_LP_NALUNIT   20
+#define H265_CRA_NALUNIT        21
+#define H265_VPS_NALUNIT        32
+#define H265_SPS_NALUNIT        33
+#define H265_PPS_NALUNIT        34
+#define H265_AUDEL_NALUNIT      35
+#define H265_EOSEQ_NALUNIT      36
+#define H265_EOSTRM_NALUNIT     37
+#define H265_FILDATA_NALUNIT    38
+#define H265_SEI_NALUNIT_PREFIX 39
+#define H265_SEI_NALUNIT_SUFFIX 40
+#define H265_NEW_SLICE_FOUND    31
+#define H265_MAX_SLICES_PER_FRAME    (201)
+#define H265_BYTESTRM_PREFIX          (1)
+#define SLICE_HDR_NALU          200
+#define SC_PP_NEXT_FRAME_FOUND        (9)
+/* The below macro will be replaced by "rev" instruction by the compiler */
+#define SWAP_BYTE(word) ((word<<24) | (word>>24) | ((word&0xFF00)<<8)\
+                        | ((word&0xFF0000)>>8))
+
+
+extern gint32  gPP_PPL_AtomicAdd8(guint8 *ptr, guint8 val);
+
+extern void gH265D_Memset(void *apSrc, gint32 aValue, gint32 aNumBytes);
+
+typedef struct _Gsth265dec      Gsth265dec;
+typedef struct _Gsth265decClass Gsth265decClass;
+/**
+ *  @brief      Definition of NAL unit parameters
+ */
+typedef struct tPPGst_NALStruct
+{
+    /** For parsing NAL unit*/
+    gint32 NAlUnitType[300];
+    /** NAL ID **/
+    gint32 NALId;
+    /**  New Frame flag **/
+    gint32 NewFrameFound;
+}tPPGstNAL;
+
+struct _Gsth265dec
+{
+    GstElement element;
+    GstPad *sinkpad, *srcpad;
+    gboolean silent;
+    guint32 framerate ;
+    guint32 duration;
+    gint64  nTimeStamp;
+    guint32 nFileRead;
+    guint32 nNoBytes;
+    guint32 nByteRead ;
+    guint32 nByteLeft;
+    guint32 nIndex;
+    guint32 nBytesDec;
+    guint32 nBufFilled ;
+    guint32 nBytesConsumed ;
+    guint32 nTOTAL_FRAME_SIZE;
+    guint32 nLumSize;
+    guint32 nCbSize;
+    guint32 nCrSize;
+    gint32  nRetVal  ;
+    gint32  nInitDone;
+    gint32  nAllocDone ;
+    guint32 nCurrThreadID ;
+    gint32  nRetV;
+    guint32 nNumMemTabEntries ;
+    gint32  nResult ;
+    guint32 taskid;
+    gint width;
+    gint height;
+    gint threads;
+    guint nInitFlag;
+    GstBufferPool *externalpool;
+ };
+
+struct _Gsth265decClass 
+{
+  GstElementClass parent_class;
+};
+
+GType gst_h265dec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_H265DEC_H__ */
diff --git a/src/gsth265utils.c b/src/gsth265utils.c
new file mode 100644 (file)
index 0000000..bb2b79d
--- /dev/null
@@ -0,0 +1,404 @@
+
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*******************************************************************************
+*   INCLUDE FILES
+*******************************************************************************/
+#include "gsth265utils.h"
+#include<stdio.h>
+#include<stdlib.h>
+/*******************************************************************************
+*   FUNCTION DEFINITIONS
+*******************************************************************************/
+
+/**
+******************************************************************************
+* @fn tPPResult sH265_FindSyncMarker (tPPGstNAL *aGstNAL,
+*                                     tPPu8  *apBitStream,
+*                                     tPPu32 aBitStreamLen,
+*                                     tPPu32 *apSyncIndex,
+*                                     tPPu32 nPrefixFlag)
+*
+* @brief This function is used to set find the byte-aligned sync marker in
+*        the bit-stream, from the given point.
+*
+* @param aGstNAL         [IN] Structure holding NAL unit details
+* @param apBitStream     [IN] Bit stream data which is to be decoded.
+* @param apBitStreamLen  [IN/OUT] Length of the bitstream.
+* @param apSyncIndex     [IN/OUT] Length at which the bitstream prefix is
+*                                 found from the begining of the stream
+* @param nPrefixFlag     [IN] Prefix Flag
+* @return Status code
+*      SC_PP_SUCCESS  : Sync found and its position is given back
+*      EC_PP_FAILURE        : Sync not found
+*      EC_PP_INVALID_PARAM  : NULL params
+******************************************************************************
+*/
+tPPResult sH265_FindSyncMarkerFrame(tPPGstNAL *aGstNAL,
+                                    tPPu8  *apBitStream,
+                                    tPPu32 aBitStreamLen,
+                                    tPPu32 *apSyncIndex,
+                                    tPPu32 nPrefixFlag)
+{
+    tPPu32 nWord;
+    tPPu8 *pLocalBitStrmPtr = apBitStream;
+    tPPu8 *pLocalMaxBitStrmPtr = apBitStream + aBitStreamLen;
+    tPPu32 nIndex;
+    tPPi32 nTemp;
+    tPPi32 nTemp1;
+    tPPi32 nNalUnitType;
+    tPPi32 nFirstSliceInPicFlag;
+
+    nWord = ((*pLocalBitStrmPtr++) << 16);
+    nWord += ((*pLocalBitStrmPtr++) << 8);
+    nWord += (*pLocalBitStrmPtr++);
+
+    nIndex = 3;
+    /*
+    * Check if the formed word is nothing but the sync word  -
+    * else check if end-of bit-stream has been reached
+    */
+    while((nWord != H265_BYTESTRM_PREFIX) &&
+        (pLocalBitStrmPtr < pLocalMaxBitStrmPtr))
+    {
+        /*
+        * The word is checked for 0x00000003, This is Emulation Prevention
+        * Byte removal
+        */
+        if(nWord == 0x000003)
+        {
+            apBitStream++;
+            apBitStream++;
+            nWord = ((*pLocalBitStrmPtr++) << 16);
+            nWord += ((*pLocalBitStrmPtr++) << 8);
+            nWord += (*pLocalBitStrmPtr++);
+            nIndex = nIndex + 3;
+        }
+
+        else
+        {
+            nWord <<= 8;
+            apBitStream++;
+            nWord &= 0x00FFFFFF;
+            nWord += (*pLocalBitStrmPtr++);
+            nIndex++;
+        }
+    }
+
+    if((nWord == H265_BYTESTRM_PREFIX) && nPrefixFlag)
+    {
+        /* if((nWord & 0x00ffffff) == 0x00010000)*/
+        nTemp = SWAP_BYTE((*(tPPu32 *)pLocalBitStrmPtr));
+        nTemp1 = (nTemp >> 16);
+        /* forbidden zero bit is always zero */
+        if(nTemp1 & 0x8000)
+        {
+            /* This bit is supposed to be zero incase if it is not
+            *   then log a debug message accordingly
+            */
+            nTemp1 = nTemp1 & 0x7FFF;
+        }
+
+        /* NAL unit type, nal_unit_type*/
+        nNalUnitType = (nTemp1 >> 9) & 0x3F;
+
+        aGstNAL->NAlUnitType[aGstNAL->NALId] = nNalUnitType;
+
+        switch(nNalUnitType)
+        {
+        case H265_IDR_W_RADL_NALUNIT:
+        case H265_IDR_N_LP_NALUNIT:
+        case H265_TRAIL_N_NALUNIT:
+        case H265_TRAIL_R_NALUNIT:
+        case H265_TSA_N_NALUNIT:
+        case H265_TLA_NALUNIT:
+        case H265_STSA_N_NALUNIT:
+        case H265_STSA_R_NALUNIT:
+        case H265_RADL_N_NALUNIT:
+        case H265_RADL_R_NALUNIT:
+        case H265_RASL_N_NALUNIT:
+        case H265_RASL_R_NALUNIT:
+        case H265_BLA_W_LP_NALUNIT:
+        case H265_BLA_W_RADL_NALUNIT:
+        case H265_BLA_N_LP_NALUNIT:
+        case H265_CRA_NALUNIT:
+
+            {
+                nFirstSliceInPicFlag = (nTemp >> 15) & 0x1;
+
+                aGstNAL->NAlUnitType[aGstNAL->NALId] = SLICE_HDR_NALU;
+
+                if(aGstNAL->NALId > 0)
+                {
+                    if((aGstNAL->NAlUnitType[aGstNAL->NALId -1]\
+                        ==  SLICE_HDR_NALU) && nFirstSliceInPicFlag)
+                    {
+                        aGstNAL->NewFrameFound = 1;
+                        return SC_PP_NEXT_FRAME_FOUND;
+                    }
+
+                    if((aGstNAL->NAlUnitType[aGstNAL->NALId -1]\
+                        ==  H265_SEI_NALUNIT_SUFFIX) && nFirstSliceInPicFlag)
+                    {
+                        aGstNAL->NewFrameFound = 1;
+                        return SC_PP_NEXT_FRAME_FOUND;
+                    }
+                }
+                break;
+            }
+        default:
+            {
+                if(aGstNAL->NALId > 0)
+                {
+                    if(aGstNAL->NAlUnitType[aGstNAL->NALId - 1]
+                    == SLICE_HDR_NALU)
+                    {
+                        if(aGstNAL->NAlUnitType[aGstNAL->NALId]
+                        != H265_SEI_NALUNIT_SUFFIX)
+                        {
+                            aGstNAL->NewFrameFound = 1;
+                            return SC_PP_NEXT_FRAME_FOUND;
+                        }
+                    }
+                    if(aGstNAL->NAlUnitType[aGstNAL->NALId - 1]
+                    == H265_SEI_NALUNIT_SUFFIX)
+                    {
+                        if(aGstNAL->NAlUnitType[aGstNAL->NALId]
+                        != H265_SEI_NALUNIT_SUFFIX)
+                        {
+                            aGstNAL->NewFrameFound = 1;
+                            return SC_PP_NEXT_FRAME_FOUND;
+                        }
+                    }
+                }
+                break;
+            }
+        }/*switch(nNalUnitType)*/
+    }/*if((nWord == H265_BYTESTRM_PREFIX) && nPrefixFlag)*/
+
+    if(nIndex>aBitStreamLen)
+    {
+        nIndex = aBitStreamLen;
+    }
+
+    if(nWord == H265_BYTESTRM_PREFIX)
+    {
+        *apSyncIndex = nIndex - 3;
+        return SC_PP_SUCCESS;
+    }
+
+    if(pLocalBitStrmPtr == pLocalMaxBitStrmPtr)
+    {
+        apBitStream++ ;
+        apBitStream++ ;
+        apBitStream++ ;
+    }
+
+    if(nIndex == aBitStreamLen)
+    {
+        *apSyncIndex = nIndex;
+        return SC_PP_SUCCESS;
+    }
+
+    /*
+    * Since no sync was not found - to re-search with more bytes user
+    * would requires to re-provide last two bytes again - to facilitate
+    * this operation last two bytes is not consumed here.
+    */
+    *apSyncIndex = (aBitStreamLen - 2);
+    return EC_PP_H265_NO_SYNC_FOUND;
+}
+/**
+******************************************************************************
+* @fn tPPResult sH265_FindNalUFrame (tPPGstNAL *aGstNAL,
+*                              tPPu8  *apBitStream,
+*                              tPPi32 *apBitStreamLen,
+*                              tPPu32 *apPrefix,
+*                              tPPu32 *apSuffix)
+*
+* @brief This function detects the boundaries of a NAL unit and gives
+*        the starting and ending indices in the bitstream, if complete NAL
+*        unit is not found either due to no sync-mark at the end or at the
+*        begining it returns error.
+* @param   aGstNAL        [IN] NAL unit structure
+* @param  apBitStream     [IN] Bit stream data which is to be decoded.
+* @param  apBitStreamLen  [IN/OUT] Length of the bitstream.
+* @param  apPrefix        [IN] Prefix
+* @param  apSuffix        [IN] Suffix
+* @return Status code
+*
+*      SC_PP_SUCCESS  : Both the Sync found and its position is given back
+*      EC_PP_H265_NO_SYNC_FOUND: Sync not found
+*      EC_PP_INSUFFICIENT_BUFFER  : Buffer length is not sufficient to detect
+*                          Sync points. If the first sync marker is found but
+*                          second sync marker is not found then this
+******************************************************************************
+*/
+tPPResult sH265_FindNalUFrame (tPPGstNAL *aGstNAL,
+                               tPPu8  *apBitStream,
+                               tPPi32 *apBitStreamLen,
+                               tPPu32 *apPrefix,
+                               tPPu32 *apSuffix)
+{
+
+    tPPi32 nRetVal = SC_PP_SUCCESS;
+
+    /*---------------------------------------------------------------*/
+    /* Find Prefix length before the sync marker of present NAL unit */
+    /* Atleast 4 bytes is necessary 3 - for sync and 1 for NAL-header*/
+    /*---------------------------------------------------------------*/
+    if(*apBitStreamLen  > 4)
+    {
+        /* Get Prefix - this excludes the sync-marker bytes in the return
+        values */
+        nRetVal = sH265_FindSyncMarkerFrame(aGstNAL, apBitStream,
+            *apBitStreamLen, apPrefix, 1);
+
+        if(nRetVal == SC_PP_NEXT_FRAME_FOUND)
+        {
+            return nRetVal;
+        }
+        if(nRetVal != SC_PP_SUCCESS)
+        {
+            /*
+            * Note that FindSync marker gives number of bytes consumed till
+            * now - to facilitate re-searching of sync marker with more number
+            * of bytes in the next call
+            */
+            (*apBitStreamLen) = (*apBitStreamLen) - *apPrefix;
+            return EC_PP_H265_NO_NALU_START_FOUND;
+        }
+
+    }
+    else
+    {
+        return EC_PP_INSUFFICIENT_BUFFER;
+    }
+    /*
+    * Find length of the present NAl-unit which extends till the
+    * Sync marker of next NAL unit
+    */
+    if(*apBitStreamLen - (*apPrefix + 3) > 1)
+    {
+        /* Start search for next sync marker */
+
+        nRetVal = sH265_FindSyncMarkerFrame(aGstNAL ,
+            apBitStream + *apPrefix + 3, (*apBitStreamLen) - (*apPrefix + 3),
+            apSuffix, 0);
+
+        /* Compensate 3-byte offset introduced in the search by adding 3 */
+        *apSuffix += 3;
+
+        if(nRetVal != SC_PP_SUCCESS)
+        {
+            /*
+            * Note that FindSync marker gives number of bytes consumed till
+            * now - to facilitate re-searching of sync marker with more number
+            * of bytes in the next call
+            */
+            (*apBitStreamLen) = (*apBitStreamLen) - (*apSuffix + *apPrefix);
+            /*
+            * EXPLAIN: here return value of FindSyncMarker function is discarded
+            * and No NALU end in sight is reported - this indicates to the user
+            * that starting sync marker was found but end could not be
+            * determined with confidence.
+            */
+            return EC_PP_H265_NO_NALU_END_FOUND;
+        }
+    }
+    else
+    {
+        *apBitStreamLen = (*apBitStreamLen - *apPrefix);
+        return EC_PP_INSUFFICIENT_BUFFER;
+    }
+    return nRetVal;
+}
+/**
+******************************************************************************
+* @fn tPPResult gH265_ParseNALUnitFrame( tPPGstNAL *pGstNAL,
+*                                        tPPInput_BitStream  H265InputStreamNAL,
+*                                        tPPi32 *aByteConsumed)
+*
+* @brief This function parses NAL unit and returns corresponding status code
+*
+* @param  aGstNAL            [IN] NAL unit structure
+* @param  H265InputStreamNAL [IN] Bit stream data which is to be decoded.
+* @param  aByteConsumed      [IN] bytes consumed
+* @return Status code
+*
+*      SC_PP_SUCCESS
+******************************************************************************
+*/
+
+tPPResult gH265_ParseNALUnitFrame( tPPGstNAL *pGstNAL,
+                                  tPPInput_BitStream  H265InputStreamNAL,
+                                  tPPi32 *aByteConsumed)
+{
+    tPPi32 nPrefix;
+    tPPi32 nNaluLen;
+    tPPu8  *apBitStream;
+    tPPi32 *apBitStreamLen;
+    tPPi32 nBytesConsumed = 0;
+    tPPResult nRetVal;
+
+    apBitStream    = H265InputStreamNAL.nBitStream;
+    apBitStreamLen = &(H265InputStreamNAL.nBufLength);
+    pGstNAL->NALId = 0;
+
+    do
+    {
+        /* Determine the boundaries of one complete NAL unit */
+        nRetVal = sH265_FindNalUFrame(pGstNAL ,apBitStream, apBitStreamLen,
+            (tPPu32*)&nPrefix, (tPPu32*)&nNaluLen);
+
+        if(nRetVal == SC_PP_NEXT_FRAME_FOUND)
+        {
+            *aByteConsumed = nBytesConsumed;
+            break;
+        }
+        else if(nRetVal != SC_PP_SUCCESS)
+        {
+            *aByteConsumed = nBytesConsumed;
+            break;
+        }
+        nBytesConsumed += (nPrefix + nNaluLen);
+        pGstNAL->NALId ++;
+
+        (*apBitStreamLen) -= (nPrefix + nNaluLen);
+        apBitStream += (nPrefix + nNaluLen);
+    } while(1);
+
+    return nRetVal;
+}
diff --git a/src/gsth265utils.h b/src/gsth265utils.h
new file mode 100644 (file)
index 0000000..33d59a6
--- /dev/null
@@ -0,0 +1,1668 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the  
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef _GSTH265DECUTILS_
+#define _GSTH265DECUTILS_
+
+/*******************************************************************************
+*   INCLUDE FILES
+*******************************************************************************/
+#include <gst/gst.h>
+#include "gsth265dec.h"
+
+/*******************************************************************************
+*   MACROS AND STRUCTURES
+*******************************************************************************/
+/** @defgroup H265_DECODER
+*/
+/** Define to indicate FALSE
+*/
+#define PP_FALSE    0
+/** Define to indicate TRUE
+*/
+#define PP_TRUE     1
+
+/** Basic data type to store unsigned integer of 8 bits
+*/
+typedef unsigned char    tPPu8;
+/** Basic data type to store unsigned integer of 16 bits
+*/
+typedef unsigned short   tPPu16;
+/** Basic data type to store unsigned integer of 32 bits
+*/
+typedef unsigned int     tPPu32;
+
+/** Basic data type to store signed integer of 8 bits
+*/
+typedef signed char      tPPi8;
+/** Basic data type to store signed integer of 16 bits
+*/
+typedef signed short    tPPi16;
+/** Basic data type to store signed integer of 32 bits
+*/
+typedef signed int      tPPi32;
+/** Basic data type to store unsigned integer of 64 bits
+*/
+typedef unsigned long long  tPPu64;
+
+/** Basic data type to store signed integer of 64 bits
+*/
+typedef signed long long  tPPi64;
+
+/** Basic data type to store 32 bit fractional values
+*/
+typedef float           tPPf32;
+/** Basic data type to store 64 bits fractional values
+*/
+typedef double          tPPf64;
+
+/** Data type of return value of functions
+All the funtions must return this data type for consistency across all modules
+*/
+typedef signed int      tPPResult;
+/** Bool data type
+Any of PP_TRUE or PP_FALSE values
+*/
+typedef unsigned char   tPPBool;
+/** Flag data type
+Any of PP_ON or PP_PFF values
+*/
+typedef unsigned char   tPPFlag;
+
+/*Status codes*/
+
+/** Success
+*/
+#define SC_PP_SUCCESS                 (0)
+
+/** API has successfully accepted the request , however its action asyhchornous
+*/
+#define SC_PP_PENDING                 (1)
+
+/** End Of Picture
+*/
+#define SC_PP_END_OF_PICTURE          (2)
+
+/** Error Occured while parsing
+*/
+#define SC_PP_PARSING_ERROR           (3)
+
+/** Slice of different Access Unit found before completion of current AU
+*/
+#define SC_PP_NEW_AU_FOUND            (4)
+/** slice data error
+*/
+#define SC_PP_SLICE_DATA_ERR          (5)
+/** Reference not found
+*/
+#define SC_PP_REFPIC_NOT_FOUND        (6)
+
+/** Picture resolution changed
+*/
+#define SC_PP_RESOLUTION_CHANGED      (7)
+/** Decoding successful but complete frame is not yet decoded
+*  Successfully decoded a packet data
+*  but more packets required for complete frame decoding.
+*/
+#define SC_PP_DECODE_INCOMPLETE       (8)
+/** New frame found */
+#define SC_PP_NEXT_FRAME_FOUND        (9)
+
+/***************************************************************
+                        General Error codes
+***************************************************************/
+#define _EC_PP_GENERAL_ERROR_BASE_    (0)
+/** General Failure
+Cause is unknown.
+*/
+#define EC_PP_FAILURE               (_EC_PP_GENERAL_ERROR_BASE_-1)
+/** Failure due to low memory condition.
+System might be running on low memory hence allocation failed.
+*/
+#define EC_PP_OUT_OF_MEMORY         (_EC_PP_GENERAL_ERROR_BASE_-2)
+/** Failure due to invalid parameter passed.
+*/
+#define EC_PP_INVALID_PARAM         (_EC_PP_GENERAL_ERROR_BASE_-3)
+/** Operation is Not supported
+*/
+#define EC_PP_NOT_SUPPORTED         (_EC_PP_GENERAL_ERROR_BASE_-4)
+/** Buffer passed is insufficient to complete the operation.
+*/
+#define EC_PP_INSUFFICIENT_BUFFER   (_EC_PP_GENERAL_ERROR_BASE_-5)
+/** Operation failed due memory corruption
+*/
+#define EC_PP_CORRUPT_DATA          (_EC_PP_GENERAL_ERROR_BASE_-6)
+
+/***************************************************************
+File/directory operations related return codes.
+***************************************************************/
+#define _EC_PP_FILE_OPERATION_ERROR_BASE_ (-100)
+/** File open failed.
+Either the file is not present or
+the file is locked by other application in exclusive mode.
+*/
+#define EC_PP_FILE_OPEN_FAIL      (_EC_PP_FILE_OPERATION_ERROR_BASE_ - 1)
+/** File close failed.
+*/
+#define EC_PP_FILE_CLOSE_FAIL     (_EC_PP_FILE_OPERATION_ERROR_BASE_ - 2)
+/** File read failed.
+File pointer might be at the end of the file.
+*/
+#define EC_PP_FILE_READ_FAIL      (_EC_PP_FILE_OPERATION_ERROR_BASE_ - 3)
+/** File write operation failed.
+*/
+#define EC_PP_FILE_WRITE_FAIL     (_EC_PP_FILE_OPERATION_ERROR_BASE_ - 4)
+/** File seek operation failed.
+*/
+
+/** End of file reached
+*/
+#define EC_PP_END_OF_FILE         (_EC_PP_FILE_OPERATION_ERROR_BASE_ - 5)
+
+#define EC_PP_H265_STATUSCODE_BASE (-1000)
+
+/** No Sync word found in the given stream
+*/
+#define EC_PP_H265_NO_SYNC_FOUND (EC_PP_H265_STATUSCODE_BASE - 1)
+/** No end Sync word found in the given stream - indicating insuffucient
+    buffer to detect second sync word => end of present NALU
+*/
+#define EC_PP_H265_NO_NALU_END_FOUND (EC_PP_H265_STATUSCODE_BASE - 2)
+
+/** Forbidden bit should be zero for all Nal unit - if its non-zero
+    it indicates corruption of bit-stream
+*/
+#define EC_PP_H265_FORBIDDEN_BIT_NON_ZERO (EC_PP_H265_STATUSCODE_BASE - 3)
+
+/** If NAL unit type is not identified.
+*/
+#define EC_PP_H265_INVALID_NAL_UNIT_TYPE (EC_PP_H265_STATUSCODE_BASE - 4)
+
+/** Invalid combination of NAL Unit type and reference IDC
+*/
+#define EC_PP_H265_INVALID_NAL_UNIT_TYPE_AND_REF_IDC \
+                                       (EC_PP_H265_STATUSCODE_BASE - 5)
+/** No start Sync word found in the given stream - indicating insuffucient
+    buffer to detect start sync word => start of present NALU
+*/
+#define EC_PP_H265_NO_NALU_START_FOUND   (EC_PP_H265_STATUSCODE_BASE - 6)
+
+/** Maximum reference frames
+* Maximum reference frames this decoder configuration supports.
+* @ingroup H265_DECODER
+*/
+#define FILE_NAME_SIZE 512
+#define PP_H265DEC_MAX_MEMTAB   70
+#define PP_H265VDEC_MAX_REF_FRAMES 16
+
+/** Set status parameters macros*/
+#define PP_SET_DATASYNC             1
+#define PP_SET_DPB_FLUSH            2
+#define PP_SET_RES_INV              3
+#define PP_SET_DECODE_HDR           4
+
+/** Get status parameters macros*/
+#define PP_GET_PARAMSTATUS          1
+#define PP_GET_BUFSTATUS            2
+#define PP_GET_ERRORSTATUS          3
+
+/** Pic width and height*/
+#define PP_H265_MAX_PIC_WIDTH        4096
+#define PP_H265_MAX_PIC_HEIGHT       2176
+ /* Macro to set Error bits */
+#define PP_H265_SET_ERROR_BIT(x, m)  ((x) |= (0x1 << m))
+
+#define MAX_BUFF_ELEMENTS 17
+#define DPB_MAXLUMAPS 8912896  /*Value for level 5.2 from Table A-1*/
+/**************      SEI & VUI Related Macros and Structures     **************/
+
+
+/* SEI PayLoad Types */
+#define H265_SEI_PICTURE_DIGEST            256
+#define H265_MAX_SEI_USERDATA              256
+
+/* Max value of (cpb_cnt_minus1 + 1) */
+#define H265_MAX_CPB_CNT                   32
+#define H265_MAX_PAN_SCAN_RECT             3
+
+#define     H265_MAX_NUM_PIVOTS       65535  /* (1 << bitdepth) */
+/* Max Video PLane Buffer 3 (Y,Cb,Cr) */
+#define     H265_MAX_NUM_VIDEOPLANE_BUF  3
+/* Max Meta Data Buffer currently 2 (SEI & VUI) */
+#define     H265_MAX_NUM_METADATA_BUF  2
+/* SEI & VUI Related MACROS */
+#define     H265_SEI_TOTAL_COL_COMP             3
+#define     H265_SEI_EXTENDED_ISO               255
+#define     H265_SEI_EXTENDED_SAR               255
+#define     H265_SEI_UUID_ISO_IEC_128           16
+#define     H265_SEI_INTENSITY_LEVEL_INTERVAL   256
+#define     H265_SEI_MAX_NUM_NESTING_OPS        1024
+#define     H265_SEI_MAX_NUM_NESTING_LAYER      64
+#define     H265_SEI_COL_COMP_MAX_MODEL_ID      8
+#define     H265_SEI_COL_FILTER_HINT_X          15
+#define     H265_SEI_COL_FILTER_HINT_Y          15
+#define     H265_SEI_MAX_NUM_SOP                1024
+#define     H265_SEI_MAX_MD5_DATA_LEN           16
+#define     H265_SEI_BIT_DEPTH                  16 /* upto 16 supported */
+#define     H265_HRD_MAX_CPB_COUNT              32
+/* need to check ,changed from 6 to 8 */
+#define     H265_HRD_MAX_NUM_SUB_LAYER          8
+
+/* supported Macros required */
+#define     PP_H265_MIN_LCU_SIZE    16
+#define     PP_H265_MAX_NUM_LCU_COLUMNS  \
+    (PP_H265_MAX_PIC_WIDTH/PP_H265_MIN_LCU_SIZE)
+#define     PP_H265_MAX_NUM_LCU_ROWS     \
+    (PP_H265_MAX_PIC_HEIGHT/PP_H265_MIN_LCU_SIZE)
+#define     PP_H265_MAX_NUM_LCU          \
+                         (PP_H265_MAX_NUM_LCU_COLUMNS * \
+                         PP_H265_MAX_NUM_LCU_ROWS)
+
+/** Metadata macros*/
+#define PP_METADATAPLANE_NONE                -1
+#define PP_MAX_NUM_METADATA_PLANES            3
+/** Reference frame macros */
+#define PP_MAX_REF_FRAME_COUNT               18
+#define PP_MAX_INBUF_COUNT                    5
+
+
+/** bitstream structure
+* @ingroup BASE_CODEC
+* Structure to contain encoded bitstream.
+*/
+typedef struct PPInput_BitStream
+{
+    tPPu8 *nBitStream; /* Buffer to hold the encoded bit stream */
+    tPPi32 nBufLength; /* Contains the length of bit Stream buffer in bytes */
+}tPPInput_BitStream;
+
+/** Frame object identifying the input buffer element
+* @ingroup BASE_CODEC
+* Contains identification information to tag the input buffer submitted to the
+* decode function. This identification tag will be used by the decoder to mark
+* buffers for display and or freeing.
+*/
+typedef struct PPInFrame_Buff
+{
+ /*! Unique Id which identifies the buffer element */
+    tPPi32 bufId;
+    tPPu8 *buf[PP_MAX_INBUF_COUNT];
+}tPPInFrame_Buff;
+
+/** list of buffer elements to be freed up.
+* @ingroup BASE_CODEC
+* Contains list of identification tags of buffers which the decoder intends to
+* free-up and there by returning them back to buffer managers pool.
+*/
+typedef struct PPOutFrame_Buff
+{
+ /* Unique Id which identifies the buffer element */
+ /* the elements in the list are to be freed as its freed by decoder*/
+    tPPi32 bufId[PP_MAX_REF_FRAME_COUNT];
+}tPPOutFrame_Buff;
+
+/** Memory requirement Query
+* Structure used to query for memory requirements of the codec object
+* codec create function calculates exact
+* @ingroup BASE_CODEC
+*/
+typedef struct PPQueryMemRecords
+{
+    tPPu8 *allotedHandle; /* contains allotted handle to be given to
+                          initialise handle */
+    tPPi32 reqSize;       /* Size requested in bytes */
+    tPPi32 memType;      /* Type of memory(Scratch or Persistence)*/
+}tPPQueryMemRecords;
+
+typedef enum {
+  kH265_TASK_MASTER         = 0,   /** Global master       */
+  kH265_TASK_SLAVE          = 1    /** Slave cores         */
+} eH265_multiThreadTask;
+
+/** Multi-thread
+* Structure used to hold all multi-thread parameteres
+* @ingroup BASE_CODEC
+*/
+typedef struct PPMultiThreadParams
+{
+    tPPi32 nThreadID;       /* Thread ID */
+    eH265_multiThreadTask nTaskID;  /* Core task Identification:
+                                    Reserved MASTER_CORE */
+    tPPi32 nNumThreads;   /* Num of Threads */
+}tPPMultiThreadParams;
+
+
+typedef struct ppH265Dec_CreateParams tPP_H265_CreateParams;
+/** Create parameter structure for decoder
+ *  @brief Structure containing attributes of the decoder object to be instanced
+ *  @ingroup H265_DECODER
+ */
+struct ppH265Dec_CreateParams
+{
+    /* Max width*/
+    tPPi32  nMaxWidth;
+    /* Max height */
+    tPPi32  nMaxHeight;
+    /* Number of CPUs */
+    tPPu32  nNumThreads;
+    /* Inputdata sync enable flag */
+    tPPi32 nInputLowDelayMode;
+    /* Output data sync enable flag */
+    tPPi32 nOutputLowDelayMode;
+    /* number of CTU rows */
+    tPPi32 nNumCTURows;
+    /* Metadata type - SEI , VUI*/
+    tPPi32 nMetadataType;
+};
+/**
+ *  @brief          Descriptor for the chunk of data being
+ *                  transferred in one call to putData/Get data
+ */
+typedef struct H265DataSyncDesc tPP_H265_DataSyncDesc;
+
+struct H265DataSyncDesc
+{
+    tPPi32 nNumBlocks;           /**< Number of blocks available */
+    tPPi32 nSize;                /**< sizeField */
+};
+
+/**
+ *  @brief      Non-blocking API to signal "data ready" to one or more
+ *              consumers.
+ *  @param[out] pDataSyncDesc    Full data sync descriptor.  This includes one
+ *                              or more filled data buffers.
+ *
+ */
+typedef void (*gH265_DataSyncPutFxn)(tPP_H265_DataSyncDesc *pDataSyncDesc);
+/**
+ *  @brief      Non-blocking API to signal "data ready" to one or more
+ *              consumers.
+ *  @param[out] pDataSyncDesc    Full data sync descriptor.  This includes one
+ *                              or more filled data buffers.
+ *
+ */
+typedef void (*gH265_DataSyncGetFxn)(tPP_H265_DataSyncDesc *pDataSyncDesc);
+
+typedef struct  ppH265Dec_DynamicParams tPP_H265_DynamicParams;
+/** Dynamic parameter structure for decoder
+ *  @brief Structure containing attributes of the decoder that
+ *  can change dynamically
+ *  @ingroup H265_DECODER
+ */
+struct ppH265Dec_DynamicParams
+{
+     tPPi32 nDecodeHeader; /*parameter for header decoder */
+     gH265_DataSyncPutFxn     fOutputLowDelayFxn;
+                        /**< Optional datasync "put data" function.
+                         *
+                         *   @remarks   Apps/frameworks that don't
+                         *              support datasync should set
+                         *              this to NULL.
+                         *
+                         *   @remarks   This function is provided
+                         *              by the app/framework to the
+                         *              video decoder.  The decoder
+                         *              calls this function when
+                         *              sub-frame data has been put
+                         *              into an output buffer and is
+                         *              available.
+                         */
+     gH265_DataSyncGetFxn   fInputLowDelayFxn;
+                        /**< Optional datasync "get data" function.
+                         *
+                         *   @remarks   Apps/frameworks that don't
+                         *              support datasync should set
+                         *              this to NULL.
+                         *   @remarks   This function is provided
+                         *              by the app/framework to the
+                         *              video decoder.  The decoder
+                         *              calls this function to get
+                         *              partial compressed bit-stream
+                         *              data from the app/framework.
+                         */
+};
+/** Status parameter structure from/for decoder
+ *  @brief Structure containing attributes of the decoder object instanced.
+ *  this structure is also used to change the attributes of the decoder.
+ *  @ingroup H265_DECODER
+ */
+typedef struct ppH265Dec_StatusParams
+{
+  /** Frame size */
+  tPPi32 nTotalFrameSize;
+  /** Pic width */
+  tPPi32 nPicWidth;
+  /** Pic height */
+  tPPi32 nPicHeight;
+  /** Bitstream profile*/
+  tPPi32  nProfile;
+  /* Input Low delay mode */
+  tPPi32 nInputLowDelayMode;
+  /* Output Low delay mode */
+  tPPi32 nOutputLowDelayMode;
+  /* Function pointer for input low delay*/
+  gH265_DataSyncGetFxn     fInputLowDelayFxn;
+  /* Function pointer for output low delay*/
+  gH265_DataSyncPutFxn     fOutputLowDelayFxn;
+  /* number of CTU rows */
+  tPPi32 nNumCTURows;
+  /* Metadata type - SEI , VUI*/
+  tPPi32 nMetadataType;
+  /*  Header decode status*/
+  tPPi32 nDecodeHeader;
+  /* Error status */
+  tPPi32  nError;
+
+}tPPDecParam_Status;
+
+/** Base video frame structure
+This structure defines the base video frame.
+It contains the frame size information and also
+padding information
+*/
+typedef struct ppBaseVideoFrame
+{
+    tPPi32              nWidth;     /**< Actual width of the frame */
+    tPPi32              nHeight;    /**< Actual height of the frame */
+    tPPBool             bIsPadded;  /**< Flag to indicate if the frame is
+                                    padded*/
+    tPPi32              nExWidth;   /**< Extended width of the frame due to
+                                    padding*/
+}tPPBaseVideoFrame;
+
+
+/** YUV Planar video frame
+YUV planar frame shall have seperate lum, cb and cr data.
+*/
+typedef struct
+{
+    tPPBaseVideoFrame nBaseFrame;   /**< Derived from base video frame */
+    tPPu8       *pLum;              /**< Lum data pointer   */
+    tPPu8       *pCb;               /**< Cb data pointer    */
+    tPPu8       *pCr;               /**< Cr data pointer    */
+}tPPYUVPlanarDisplayFrame;
+
+/** Base Decoder definition
+* @ingroup BASE_DECODER
+*/
+typedef struct ppBaseDecoder tPPBaseDecoder;
+/** Base Decoder definition
+* @ingroup BASE_DECODER
+*/
+struct ppBaseDecoder
+{
+/**
+******************************************************************************
+* tPPResult (*vDecode) (tPPBaseDecoder    *apBase,
+*                       tPPInput_BitStream *apInBitStream,
+*                       tPPInFrame_Buff     *apH265_dec_InBuff,
+*                       tPPOutFrame_Buff    *apH265_dec_OutBuff,
+*                       tPPYUVPlanarDisplayFrame *apFrame,
+*                       tPPMultiThreadParams *nMTParam)
+*
+*
+* @brief This virtual interface decodes a bitstream to produce a output raw
+* frame. The input bitstream can be packet mode or frame mode. Handling of
+* both modes is done differently as follows:
+* Frame Mode:
+*   In this mode, when the API is able to decode the frame successfully, it
+*   returns SC_PP_SUCCESS and returns the output frame in apFrame ( if not
+*   NULL).
+*
+* Packet Mode:
+*
+*   if the packets are decoded in the order,and if the decoder is able to
+*   detect the last packet of the frame by any means, then this API shall
+*   return SC_PP_SUCCESS and returns the output frame in apFrame (if not NULL)
+*   when it successfully decodes the last packet of the frame.
+*
+*   If the packets are not decoded in correct order, the decoder shall detect
+*   the end of frame decoding only when it receives the packet belonging to
+*   the next frame. In this scenario, when the packet belonging to next frame
+*   is passed for decoding , the decoder must not consume the input bitstream,
+*   but must return SC_PP_SUCCESS to indicate the successful decode of the
+*   last frame and return the output of the last frame in apFrame parameter
+*   (if not NULL). The caller must call the decode API again with the previous
+*   unconsumed bitstream (containing packet of the next frame).
+*
+* @param apBase              [IN] Pointer to base decoder interface
+* @param apBitStream         [IN] Bit stream structure whicha has data to be
+*                                 decoded.
+* @param apH265_dec_InBuff   [IN] This holds the pointer to the buffer
+*                                 allocated by the buffer manager to the
+*                                 decoder.The decoder stores the current
+*                                 decoded frame in this location.
+*                                 Length of the bitstream.
+* @param apH265_dec_OutBuff  [OUT] This holds the pointer to the buffer to be
+*                                   freed by the decoder. The application sets
+*                                   "0" in these locations as BuffID's. The
+*                                   decoder sets the BuffID of the buffer which
+*                                   needs to be freeds
+* @param apFrame             [IN/OUT] The decoded frame output only if the
+*                                      return value is SC_PP_SUCCESS . The
+*                                      structure that holds the array of frames
+*                                      to be displayed.If this parameter is
+*                                      NULL, the output frame MAY be queried
+*                                      through the vGet interface.
+*
+* @param nMTParam            [IN]      Multi thread parameters
+* @return Status code
+*
+*      SC_PP_SUCCESS             : Successfully decoded the complete frame
+*                                  (in frame mode) the apFrame shall contain
+*                                   the decoded frame data OR successfully
+*                                  decoded the last packet of the frame
+*                                  (in packet mode) OR detected successfull
+*                                  decoding of frame data when received packet
+*                                  of next frame ( in packet mode). The
+*                                  apFrame shall contain the decoded frame data
+*      SC_PP_DECODE_INCOMPLETE   : Only applicable in packet mode. Successfully
+*                                  decoded a packet data but more packets
+*                                  required for complete frame decoding. The
+*                                  apFrame shall not contain any valid frame
+*                                  data.
+*      EC_PP_FAILURE             : General failure
+*
+*      EC_PP_INVALID_PARAM       : Failed due to incorrect params.
+*                                  (or NULL params/handle)
+*      EC_PP_CORRUPT_DATA        : Error encountered during decoding due to
+*                                  corrupt data
+*      EC_PP_H265_NO_NALU_END_FOUND : Finds no NAL unit end
+*
+*      SC_PP_RESOLUTION_CHANGED  :  Resolution got Changed.
+*
+*     EC_PP_INSUFFICIENT_BUFFER  :  Bit Stream End Found.
+*
+******************************************************************************
+*/
+tPPResult (*vDecode)(tPPBaseDecoder            *apBase,
+                     tPPInput_BitStream        *apInBitStream,
+                     tPPInFrame_Buff           *apH265_dec_InBuff,
+                     tPPOutFrame_Buff          *apH265_dec_OutBuff,
+                     tPPYUVPlanarDisplayFrame  *apFrame,
+                     tPPMultiThreadParams *nMTParam);
+
+/**
+ ******************************************************************************
+ * @fn tPPResult vReset( tPPBaseDecoder *apBase);
+ *
+ * @brief This virtual interface resets the decoder.
+ *
+ * @param apBase  [IN] Pointer to base decoder interface
+
+ *
+ * @return Status code SC_PP_SUCCESS if success, or the following error codes
+ *  EC_PP_FAILURE : General failure
+ *
+ * @ingroup BASE_DECODER
+ ******************************************************************************
+ */
+       tPPResult (*vReset)( tPPBaseDecoder *apBase);
+
+/**
+ ******************************************************************************
+ * @fn  tPPResult vSet( tPPBaseDecoder *apBase, tPPu32 anFlag, tPPi32 anVal);
+ *
+ * @brief This virtual interface to set some parameters to the decoder.
+ *
+ * @param apBase  [IN] Pointer to base decoder interface
+ * @param anFlag  [IN] Flag to specify the parameter which needs to be set
+ * @param anVal   [IN] Value of the parameter
+ * @param apDynamicParams [IN] Dynamic parameter handle
+ *
+ * @return Status code SC_PP_SUCCESS if success, or the following error codes
+ *  EC_PP_FAILURE : General failure
+ *
+ * @ingroup BASE_DECODER
+ ******************************************************************************
+ */
+       tPPResult (*vSet)( tPPBaseDecoder *apBase, tPPu32 anFlag, tPPi32 anVal,
+           tPP_H265_DynamicParams *apDynamicParams);
+
+
+
+/**
+ ******************************************************************************
+ * @fn  tPPResult vGet( tPPBaseDecoder *apBase, tPPu32 anFlag, void* apVal);
+ *
+ * @brief This virtual interface to get some parameters of the decoder.
+ *
+ * @param apBase    [IN] Pointer to base decoder interface
+ * @param anFlag    [IN] Flag to specify the parameter which needs to be get
+ * @param anVal     [IN/OUT] Pointer to hold the value of the parameter
+
+ *
+ * @return Status code SC_PP_SUCCESS if success, or the following error codes
+ *  EC_PP_FAILURE : General failure
+ *
+ * @ingroup BASE_DECODER
+ ******************************************************************************
+ */
+ tPPResult (*vGet)( tPPBaseDecoder *apBase, tPPu32 anFlag, void *apVal);
+
+};
+
+/*enum for Memory type*/
+typedef enum
+{
+    PP_H265_PERSIST = 0,
+    PP_H265_SCRATCH ,
+} tPP_MemType;
+
+/*enum for decode mode*/
+typedef enum
+{
+  PP_H265_DECODE_ACCESSUNIT = 0,
+  PP_H265_PARSE_HEADER,
+} tPP_DecodeMode;
+/* enum for input low delay mode*/
+typedef enum
+{
+  PP_H265_ENTIREINPUTFRAME = 0,
+  PP_H265_SLICEMODE
+} tPP_InputLowDelayMode;
+
+/* enum for input low delay mode*/
+typedef enum
+{
+  PP_H265_ENTIREOUTPUTFRAME = 0,
+  PP_H265_NUMCTUROWS
+} tPP_OutputLowDelayMode;
+
+typedef enum
+{
+  PP_H265_METADATAPLANE_NONE = 0,
+  PP_H265_METADATA_SEI_DATA,
+  PP_H265_METADATA_VUI_DATA
+} tPP_MetadataType;
+/* SEI related definition */
+/**
+ *  @brief SEI types
+ */
+typedef enum
+{
+  H265_SEI_BUFFERING_PERIOD,
+  H265_SEI_PIC_TIMING,
+  H265_SEI_PAN_SCAN_RECT,
+  H265_SEI_FILLER_PAYLOAD,
+  H265_SEI_USERDATA_REGISTERED_ITU_T_T_35,
+  H265_SEI_USERDATA_UNREGISTERED,
+  H265_SEI_RECOVERY_POINT,
+  H265_SEI_SCENE_INFO = 9,
+  H265_SEI_PICTURE_SNAPSHOT = 15,
+  H265_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START,
+  H265_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END,
+  H265_SEI_FILM_GRAIN_CHARACTERISTICS = 19,
+  H265_SEI_POST_FILTER_HINT = 22,
+  H265_SEI_TONE_MAPPING_INFO,
+  H265_SEI_FRAME_PACKING_ARRANGEMENT = 45,
+  H265_SEI_DISPLAY_ORIENTATION = 47,
+  H265_SEI_STRUCTURE_OF_PICTURES_INFO = 128,
+  H265_SEI_ACTIVE_PARAMETER_SETS,
+  H265_SEI_DECODING_UNIT_INFO,
+  H265_SEI_TEMPORAL_SUB_LAYER_ZERO_INDEX,
+  H265_SEI_DECODED_PICTURE_HASH,
+  H265_SEI_SCALABLE_NESTING,
+  H265_SEI_REGION_REFRESH_INFO,
+  H265_SEI_RESERVED
+}H265_SEIType;
+
+/* SEI Scene Transition Type definition */
+/**
+ *  @brief SEI SceneTransitionType types
+ */
+typedef enum
+{
+  H265_SEI_STT_NO_TRASITION = 0,
+  H265_SEI_STT_FADE_TO_BLACK,
+  H265_SEI_STT_FADE_FROM_BLACK,
+  H265_SEI_STT_UNSPECIFIED_TRASITION,
+  H265_SEI_STT_DISSOLVE,
+  H265_SEI_STT_WIPE,
+  H265_SEI_STT_UNSPECIFIED_MIXTURE
+} H265_SEI_SceneTransitionType;
+
+/* SEI Tone Mapping Info Model Id related definition */
+/**
+ *  @brief SEI Tone Mapping Info Model Id types
+ */
+typedef enum
+{
+  H265_SEI_TMI_LINEAR_MAPPING = 0,
+  H265_SEI_TMI_SIGMOIDAL_MAPPING,
+  H265_SEI_TMI_USER_DEFINED_TABLE_MAPPING,
+  H265_SEI_TMI_PIECE_WISE_LINEAR_MAPPING,
+  H265_SEI_TMI_LUMINANCE_DYNAMIC_RANGE_INFO,
+  H265_SEI_TMI_RESERVED
+}H265_SEI_ToneMappingInfo_ModelId;
+
+/* SEI Frame Packing Arrangement Type related definition */
+/**
+ *  @brief SEI Frame Packing Arrangement Type
+ */
+typedef enum
+{
+  H265_SEI_FPA_SIDE_BYSIDE = 3,
+  H265_SEI_FPA_TOP_BOTTOM,
+  H265_SEI_FPA_TEMPORAL_INTERLEAVING
+}H265_SEI_FramePackingArrangementType;
+
+/* SEI Decode Picture Hash Type related definition */
+/**
+ *  @brief SEI Decode Picture Hash Type
+ */
+typedef enum
+{
+  H265_SEI_DPHT_MD5 = 0,
+  H265_SEI_DPHT_CRC,
+  H265_SEI_DPHT_CHECKSUM
+}H265_SEI_DecodePicHashType;
+
+/**
+ *  @brief Structure for H265_SeiBufferingPeriod parameters
+ *
+ */
+typedef struct H265_SeiBufferingPeriod tH265_SeiBufferingPeriod;
+struct H265_SeiBufferingPeriod
+{
+  /* SeiBufferingPeriod Present Flag*/
+  tPPBool        nSeiBufferingPeriodPresentFlag;
+  /* bp_seq_parameter_set_id */
+  tPPu32      nBpSeqParamSetId;
+  /* irap_cpb_params_present_flag */
+  tPPu32      nIrapCpbParamsPresentFlag;
+  /* cpb_delay_offset */
+  tPPu32      nCpbDelayOffset;
+  /* dpb_delay_offset */
+  tPPu32      nDpbDelayOffset;
+  /* concatenation_flag */
+  tPPu32      nConcatenationFlag;
+  /* au_cpb_removal_delay_delta_minus1 */
+  tPPu32      nAuCpbRemovalDelayDeltaMinus1;
+  /* nal_initial_cpb_removal_delay[]*/
+  tPPu32      nNalInitialCpbRemovalDelay[H265_MAX_CPB_CNT];
+  /*nal_initial_alt_cpb_removal_delay[]*/
+  tPPu32      nNalInitialAltCpbRemovalDelay[H265_MAX_CPB_CNT];
+  /* nal_initial_cpb_removal_offset[] */
+  tPPu32      nNalInitialCpbRemovalOffset[H265_MAX_CPB_CNT];
+  /*nal_initial_alt_cpb_removal_offset[]*/
+  tPPu32      nNalInitialAltCpbRemovalOffset[H265_MAX_CPB_CNT];
+  /*vcl_initial_cpb_removal_delay[]*/
+  tPPu32      nVclInitialCpbRemovalDelay[H265_MAX_CPB_CNT];
+  /*vcl_initial_alt_cpb_removal_delay[]*/
+  tPPu32      nVclInitialAltCpbRemovalDelay[H265_MAX_CPB_CNT];
+  /*vcl_initial_cpb_removal_offset[]*/
+  tPPu32      nVclInitialCpbRemovalOffset[H265_MAX_CPB_CNT];
+  /* vcl_initial_alt_cpb_removal_offset[]*/
+  tPPu32      nVclInitialAltCpbRemovalOffset[H265_MAX_CPB_CNT];
+};
+
+/**
+ *  @brief Structure for H265_SeiPanScanRect parameters
+ *
+ */
+typedef struct H265_SeiPanScanRect tH265_SeiPanScanRect;
+struct H265_SeiPanScanRect
+{
+  /* SeiPanScanRect Present Flag*/
+  tPPBool        nSeiPanScanRectPresentFlag;
+   /* pan_scan_rect_id */
+  tPPu32      nPanScanRectId;
+   /* pan_scan_rect_cancel_flag */
+  tPPu32      nPanScanRectCancelFlag ;
+  /* pan_scan_cnt_minus1 */
+  tPPu32      nPanScanCntMinus1;
+  /* pan_scan_rect_left_offset[ index ] */
+  tPPi32      nPanScanRectLeftOffset[H265_MAX_PAN_SCAN_RECT];
+   /* pan_scan_rect_right_offset[ index ] */
+  tPPi32      nPanScanRectRightOffset[H265_MAX_PAN_SCAN_RECT];
+  /* pan_scan_rect_top_offset[ index ] */
+  tPPi32      nPanScanRectTopOffset[H265_MAX_PAN_SCAN_RECT];
+   /* pan_scan_rect_bottom_offset[ index ] */
+  tPPi32      nPanScanRectBottomOffset[H265_MAX_PAN_SCAN_RECT];
+  /* added pan_scan_rect_persistence_flag */
+  tPPu32      nPanScanRectPersistenceFlag;
+};
+/**
+ *  @brief Structure for H265_SeiPictureTiming parameters
+ *
+ */
+typedef struct H265_SeiPictureTiming tH265_SeiPictureTiming;
+struct H265_SeiPictureTiming
+{
+  /* SeiPictureTiming Present Flag */
+  tPPBool        nSeiPictureTimingPresentFlag;
+  /* pic_struct */
+  tPPu8      nPicStruct;
+  /* source_scan_type */
+  tPPu8      nSourceScanType;
+  /*duplicate_flag*/
+  tPPu8      nDuplicateFlag;
+  /* au_cpb_removal_delay_minus1 */
+  tPPu32     nAuCpbRemovalDelayMinus1;
+  /* pic_dpb_output_delay */
+  tPPu32     nPicDpbOutputDelay;
+  /* pic_dpb_output_du_delay */
+  tPPu32     nPicDpbOutputDuDelay;
+  /* num_decoding_units_minus1 */
+  tPPu32     nNumDecodingUnitsMinus1;
+  /* du_common_cpb_removal_delay_flag */
+  tPPu32     nDuCommonCpbRemovalDelayFlag;
+  /* du_common_cpb_removal_delay_increment_minus1 */
+  tPPu32     nDuCommonCpbRemovalDelayIncrementMinus1;
+  /* num_nalus_in_du_minus1[ i ] */
+  tPPu32      nNumNalusInDuMinus1[PP_H265_MAX_NUM_LCU] ;
+  /* du_cpb_removal_delay_increment_minus1[ i ] */
+  tPPu32      nDuCpbRemovalDelayIncrementMinus1[PP_H265_MAX_NUM_LCU];
+};
+/**
+ *  @brief Structure for H265_SeiFillerPayload parameters
+ *
+ */
+typedef struct H265_SeiFillerPayload  tH265_SeiFillerPayload;
+struct H265_SeiFillerPayload
+{
+  /* SeiFillerPayload Present Flag */
+  tPPBool        nSeiFillerPayloadPresentFlag;
+  tPPu8       nFillerPayload;
+};
+/**
+ *  @brief Structure for H265_SeiUserDataRegistered parameters
+ *
+ */
+typedef struct H265_SeiUserDataRegistered tH265_SeiUserDataRegistered;
+struct H265_SeiUserDataRegistered
+{
+   /* SeiUserDataRegistered Present Flag*/
+  tPPBool        nSeiUserDataRegisteredPresentFlag;
+  /* itu_t_t35_country_code */
+  tPPu32      nItuTt35CountryCode;
+   /* itu_t_t35_country_code_extension_byte */
+  tPPu32      nItuTt35CountryCodeExtensionByte ;
+  /* itu_t_t35_payload_byte */
+  tPPu32      nItuTt35PayloadByte;
+};
+
+/**
+ *  @brief Structure for H265_SeiUserDataUnregistered parameters
+ *
+ */
+typedef struct H265_SeiUserDataUnregistered tH265_SeiUserDataUnregistered;
+struct H265_SeiUserDataUnregistered
+{
+  /* SeiUserDataUnregistered Present Flag */
+  tPPBool        nSeiUserDataUnregisteredPresentFlag;
+  /* uuid_iso_iec_11578 */
+  tPPu8       nUuid_iso_iec_11578[H265_SEI_UUID_ISO_IEC_128];
+  /* user_data_payload_byte */
+  tPPu8       nUserDataPayloadbyte[H265_MAX_SEI_USERDATA];
+};
+
+/**
+ *  @brief Structure for H265_SeiRecoveryPoint parameters
+ *
+ */
+typedef struct H265_SeiRecoveryPoint tH265_SeiRecoveryPoint;
+struct H265_SeiRecoveryPoint
+{
+  /* SeiRecoveryPoint Present Flag */
+  tPPBool        nSeiRecoveryPointPresentFlag;
+  /* recovery_poc_cnt */
+  tPPi32       nRecoveryPocCnt;
+  /* exact_match_flag */
+  tPPu32       nExactMatchFlag;
+  /* broken_link_flag */
+  tPPu32       nBrokenLinkFlag;
+};
+
+/**
+ *  @brief Structure for H265_SeiSceneInfo parameters
+ *
+ */
+typedef struct H265_SeiSceneInfo tH265_SeiSceneInfo;
+struct H265_SeiSceneInfo
+{
+  /* SeiSceneInfo Present Flag */
+  tPPBool        nSeiSceneInfoPresentFlag;
+   /* scene_info_present_flag */
+  tPPu32       nSceneInfoPresentFlag;
+  /* prev_scene_id_valid_flag */
+  tPPu32       nPrevSceneIdValidFlag;
+  /* scene_id */
+  tPPu32       nSceneId;
+  /* scene_transition_type */
+  tPPu32       nSceneTransitionType;
+  /* second_scene_id */
+  tPPu32       nSecondSceneId;
+};
+
+/**
+ *  @brief Structure for H265_SeiPictureSnapShot parameters
+ *
+ */
+typedef struct H265_SeiPictureSnapShot tH265_SeiPictureSnapShot;
+struct H265_SeiPictureSnapShot
+{
+  /* SeiPictureSnapShot Present Flag */
+  tPPBool        nSeiPictureSnapShotPresentFlag;
+  /* snapshot_id */
+  tPPu32      nSnapshotId;
+};
+
+/**
+ *  @brief Structure for H265_SeiProgRefinementStart parameters
+ *
+ */
+typedef struct H265_SeiProgRefinementStart\
+               tH265_SeiProgRefinementStart;
+struct H265_SeiProgRefinementStart
+{
+  /* SeiProgRefinementStart Present Flag */
+  tPPBool        nSeiProgRefinementStartPresentFlag;
+  /* progressive_refinement_id */
+  tPPu32       nProgressiveRefinementId;
+   /* pic_order_cnt_delta */
+  tPPu32       nPicOrderCntDelta;
+};
+
+/**
+ *  @brief Structure for H265_SeiProgRefinementEnd parameters
+ *
+ */
+typedef struct H265_SeiProgRefinementEnd tH265_SeiProgRefinementEnd;
+struct H265_SeiProgRefinementEnd
+{
+  /* SeiProgRefinementEnd Present Flag */
+  tPPBool         nSeiProgRefinementEndPresentFlag;
+   /* progressive_refinement_id */
+  tPPu32       nProgressiveRefinementId;
+};
+
+/**
+ *  @brief Structure for H265_SeiFilmGrainChar parameters
+ *
+ */
+typedef struct H265_SeiFilmGrainChar tH265_SeiFilmGrainChar;
+struct H265_SeiFilmGrainChar
+{
+  /* SeiFilmGrainChar Present Flag */
+  tPPBool        nSeiFilmGrainCharPresentFlag;
+  /* film_grain_characteristics_cancel_flag */
+  tPPu32       nFilmGrainCharacteristicsCancelFlag;
+  /* model_id */
+  tPPu32       nModelId;
+  /* separate_colour_description_present_flag */
+  tPPu32       nSeparateColourDescriptionPresentFlag;
+  /* film_grain_bit_depth_luma_minus8 */
+  tPPu32       nFilmGrainBitDepthLumaMinus8;
+  /* film_grain_bit_depth_chroma_minus8 */
+  tPPu32       nFilmGrainBitDepthChromaMinus8;
+  /* film_grain_full_range_flag */
+  tPPu32       nFilmGrainFullRangeFlag;
+   /* film_grain_colour_primaries */
+  tPPu32       nFilmGrainColourPrimaries;
+  /* film_grain_transfer_characteristics */
+  tPPu32       nFilmGrainTransferCharacteristics;
+  /* film_grain_matrix_coeffs */
+  tPPu32       nFilmGrainMatrixCoefficients;
+  /* blending_mode_id added */
+  tPPu32       nBlendingModeId;
+  /* log2_scale_factor */
+  tPPu32       nLog2ScaleFactor;
+  /* comp_model_present_flag[ nIndex ] */
+  tPPu32       nCompModelPresentFlag[H265_SEI_TOTAL_COL_COMP];
+   /* num_intensity_intervals_minus1[ nIndex ] */
+  tPPu32       nNumIntensityIntervalsMinus1[H265_SEI_TOTAL_COL_COMP];
+  /* num_model_values_minus1[ nIndex ] */
+  tPPu32       nNumModelValuesMinus1[H265_SEI_TOTAL_COL_COMP];
+  /* intensity_interval_lower_bound[ nIndex ][ nIndex1 ] */
+  tPPu32       nIntensityIntervallowerBound[H265_SEI_TOTAL_COL_COMP]\
+                      [H265_SEI_INTENSITY_LEVEL_INTERVAL];
+   /* intensity_interval_upper_bound[ nIndex ][ nIndex1 ] */
+  tPPu32       nIntensityIntervalUpperBound[H265_SEI_TOTAL_COL_COMP]\
+                      [H265_SEI_INTENSITY_LEVEL_INTERVAL];
+  /* comp_model_value[ nIndex ][ nIndex1 ][ nIndex2 ] */
+  tPPu32       nCompModelValue[H265_SEI_TOTAL_COL_COMP]\
+                      [H265_SEI_INTENSITY_LEVEL_INTERVAL]\
+                      [H265_SEI_COL_COMP_MAX_MODEL_ID];
+  /* film_grain_characteristics_persistence_flag added */
+  tPPi32        nFilmGrainCharacteristicsPersistenceFlag;
+};
+
+/**
+ *  @brief Structure for H265_SeiPostFilterHint parameters
+ *
+ */
+typedef struct H265_SeiPostFilterHint tH265_SeiPostFilterHint;
+struct H265_SeiPostFilterHint
+{
+  /* SeiPostFilterHin Present Flag */
+  tPPBool         nSeiPostFilterHinPresentFlag;
+  /* filter_hint_size_y */
+  tPPu32       nFilterHintSizeY;
+  /* filter_hint_size_x */
+  tPPu32       nFilterHintSizeX;
+   /* filter_hint_type */
+  tPPu32       nFilterHintType;
+  /* filter_hint[ nIndex ][ nIndex1 ][ nIndex2 ] */
+  tPPi32        nFilterHint[H265_SEI_TOTAL_COL_COMP]\
+                     [H265_SEI_COL_FILTER_HINT_Y][H265_SEI_COL_FILTER_HINT_X];
+};
+
+/**
+ *  @brief Structure for H265_SeiToneMappingInfo parameters
+ *
+ */
+typedef struct H265_SeiToneMappingInfo tH265_SeiToneMappingInfo;
+struct H265_SeiToneMappingInfo
+{
+  /* SeiToneMappingInfo Present Flag */
+  tPPBool         nSeiToneMappingInfoPresentFlag;
+  /* tone_map_id */
+  tPPu32       nToneMapId ;
+  /* tone_map_cancel_flag */
+  tPPBool         nToneMapCancelFlag;
+  /* tone_map_persistence_flag */
+  tPPBool         nToneMapPersistenceFlag;
+  /* coded_data_bit_depth */
+  tPPu8        nCodedDataBitDepth;
+  /* target_bit_depth */
+  tPPu8        nTargetBitDepth;
+  /* tone_map_model_id */
+  tPPu32        nToneMapModelId;
+  /* min_value */
+  tPPu32       nMinValue;
+  /* max_value */
+  tPPu32       nMaxValue;
+  /* sigmoid_midpoint */
+  tPPu32       nSigmoidMidpoint;
+  /* sigmoid_width */
+  tPPu32       nSigmoidWidth;
+  /* start_of_coded_interval[ i ] */
+  tPPu32       nStartOfCodedInterval[ 1 << H265_SEI_BIT_DEPTH];
+  /* num_pivots */
+  tPPu16       nNumPivots;
+  /* coded_pivot_value[ i ]  */
+  tPPu32       nCodedPivotValue[H265_MAX_NUM_PIVOTS];
+  /* target_pivot_value[ i ] */
+  tPPu32       nTargetPivotValue[H265_MAX_NUM_PIVOTS];
+   /* camera_iso_speed_idc */
+  tPPu8        nCameraIsoSpeedIdc;
+   /* camera_iso_speed_value */
+  tPPu32       nCameraIsoSpeedValue;
+   /* exposure_index_idc */
+  tPPu8        nExposureIndexIdc;
+   /* exposure_index_value */
+  tPPu32       nExposureIndexValue;
+   /* exposure_compensation_value_sign_flag */
+  tPPBool         nExposureCompensationValueSignFlag;
+   /* exposure_compensation_value_numerator */
+  tPPu16       nExposureCompensationValueNumerator;
+   /* exposure_compensation_value_denom_idc */
+  tPPu16       nExposureCompensationValueDenomIdc;
+   /* ref_screen_luminance_white */
+  tPPu32       nRefScreenLuminanceWhite;
+   /* extended_range_white_level */
+  tPPu32       nExtendedRangeWhiteLevel;
+   /* nominal_black_level_code_value */
+  tPPu16       nNominalBlackLevelCodeValue;
+   /* nominal_white_level_code_value */
+  tPPu16       nNominalWhiteLevelCodeValue;
+  /* extended_white_level_code_value u(16) */
+  tPPu16       nExtendedWhiteLevelCodeValue;
+};
+
+/**
+ *  @brief Structure for H265_SeiFramePackingArrange parameters
+ *
+ */
+typedef struct H265_SeiFramePackingArrange\
+               tH265_SeiFramePackingArrange;
+struct H265_SeiFramePackingArrange
+{
+  /* Sei Frame Packing Arrange Present Flag*/
+  tPPBool         nSeiFramePackingArrangePresentFlag;
+  /* frame_packing_arrangement_id */
+  tPPu32       nFramePackingArrangementId;
+  /* frame_packing_arrangement_cancel_flag */
+  tPPu32       nFramePackingArrangementCancelFlag;
+  /* frame_packing_arrangement_type */
+  tPPu32       nFramePackingArrangementType;
+  /* quincunx_sampling_flag */
+  tPPu32       nQuincunxSamplingFlag;
+  /* content_interpretation_type */
+  tPPu32       nContentInterpretationType;
+  /* spatial_flipping_flag */
+  tPPu32       nSpatialFlippingFlag;
+  /* frame0_flipped_flag */
+  tPPu32       nFrame0FlippedFlag;
+  /* field_views_flag */
+  tPPu32       nFieldViewsFlag;
+   /* current_frame_is_frame0_flag */
+  tPPu32       nCurrentFrameIsFrame0Flag;
+  /* frame0_self_contained_flag */
+  tPPu32       nFrame0SelfContainedFlag;
+  /* frame1_self_contained_flag */
+  tPPu32       nFrame1SelfContainedFlag;
+  /* frame0_grid_position_x */
+  tPPu32       nFrame0GridPositionX;
+  /* frame0_grid_position_y */
+  tPPu32       nFrame0GridPositionY;
+  /* frame1_grid_position_x */
+  tPPu32       nFrame1GridPositionX;
+   /* frame1_grid_position_y */
+  tPPu32       nFrame1GridPositionY;
+  /* frame_packing_arrangement_reserved_byte */
+  tPPu32       nFramePackingArrangementReservedByte;
+  /* frame_packing_arrangement_persistence_flag */
+  tPPu32       nFramePackingArrangementRepetitionPeriod;
+  /* upsampled_aspect_ratio_flag */
+  tPPu32       nFramePackingArrangementExtensionFlag;
+};
+
+/**
+ *  @brief Structure for H265_SeiDisplayOrientaiton parameters
+ *
+ */
+typedef struct H265_SeiDisplayOrientaiton tH265_SeiDisplayOrientaiton;
+struct H265_SeiDisplayOrientaiton
+{
+  /* Sei Display Orientaiton Present Flag */
+  tPPBool        nSeiDisplayOrientaitonPresentFlag;
+  /* display_orientation_cancel_flag */
+  tPPu32       nDisplayOrientationCancelFlag ;
+   /* hor_flip */
+  tPPu32       nHorFlip;
+   /* ver_flip */
+  tPPu32       nVerFlip;
+  /* anticlockwise_rotation */
+  tPPu32       nAnticlockwiseRotation;
+  /* display_orientation_persistence_flag */
+  tPPu32       nDisplayOrientationRepetitionPeriod;
+};
+
+/**
+ *  @brief Structure for H265_SeiStructureOfPictureInfo parameters
+ *
+ */
+typedef struct H265_SeiStructureOfPictureInfo\
+               tH265_SeiStructureOfPictureInfo;
+struct H265_SeiStructureOfPictureInfo
+{
+  /* Sei Structure Of Picture Info Present Flag */
+  tPPBool         nSeiStructureOfPictureInfoPresentFlag;
+  /* sop_seq_parameter_set_id */
+  tPPu32       nSpsId;
+  /* num_entries_in_sop_minus1 */
+  tPPu32       nNumPicsInSopMinus1;
+  /* Not sure about the max_value. Now set to number of short term refs(65) */
+  /* sop_vcl_nut[ index ] */
+  tPPu32       nSopDescNalRefFlag[H265_SEI_MAX_NUM_SOP] ;
+  /* sop_temporal_id[ index ] */
+  tPPu32       nSopDescTemporalId[H265_SEI_MAX_NUM_SOP] ;
+  /* sop_short_term_rps_idx[ index ] */
+  tPPu32       nStRpsIdx[H265_SEI_MAX_NUM_SOP] ;
+  /* sop_poc_delta[ index ] */
+  tPPi32        nPocDelta[H265_SEI_MAX_NUM_SOP] ;
+};
+
+/**
+ *  @brief Structure for H265_SeiDecodedPictureHash parameters
+ *
+ */
+typedef struct H265_SeiDecodedPictureHash \
+               tH265_SeiDecodedPictureHash;
+struct H265_SeiDecodedPictureHash
+{
+  /* Sei Decoded Picture Hash Present Flag */
+  tPPBool         nSeiDecodedPictureHashPresentFlag;
+  /* hash_type */
+  tPPu32       nHashType ;
+  /* picture_md5[ index ][ index1 ] */
+  tPPu32       nPictureMd5[H265_SEI_TOTAL_COL_COMP]\
+                      [H265_SEI_MAX_MD5_DATA_LEN] ;
+  /* picture_crc[ index ] */
+  tPPu32       nPictureCrc[H265_SEI_TOTAL_COL_COMP];
+  /* picture_checksum[ index ] */
+  tPPu32       nPictureChecksum[H265_SEI_TOTAL_COL_COMP];
+};
+
+/**
+ *  @brief Structure for H265_SeiActiveParameterSets parameters
+ *
+ */
+typedef struct H265_SeiActiveParameterSets\
+               tH265_SeiActiveParameterSets;
+struct H265_SeiActiveParameterSets
+{
+  /* Sei Active Parameter Sets Present Flag */
+  tPPBool         nSeiActiveParameterSetsPresentFlag;
+  /* active_video_parameter_set_id */
+  tPPu32       nActiveVpsId;
+  /* self_contained_cvs_flag */
+  tPPu32       nSelfContainedCSVFlag;
+  /* no_parameter_set_update_flag */
+  tPPu32       nNumParameterSetUpdateFlag;
+   /* num_sps_ids_minus1 */
+  tPPu32       nNumSpsIdsMinus1;
+  /* active_seq_parameter_set_id[ i ] */
+  tPPu32       nActiveSeqParameterSetId[PP_H265VDEC_MAX_REF_FRAMES];
+};
+
+/**
+ *  @brief Structure for H265_SeiTemporalSubLayerZeroIndex parameters
+ *
+ */
+typedef struct H265_SeiTemporalSubLayerZeroIndex
+                 tH265_SeiTemporalSubLayerZeroIndex;
+struct H265_SeiTemporalSubLayerZeroIndex
+{
+  /* Sei Temporal Sub-Layer Zero Index Present Flag */
+  tPPBool        nSeiTemporalSubLayerZeroIndexPresentFlag;
+   /* temporal_sub_layer_zero_idx */
+  tPPu8       nTemporalSubLayerZeroIdx;
+  /* irap_pic_id */
+  tPPu8       nIrapPicId;
+};
+
+/**
+ *  @brief Structure for H265_SEIDecodingUnitInfo parameters
+ *
+ */
+typedef struct H265_SEIDecodingUnitInfo tH265_SEIDecodingUnitInfo;
+struct H265_SEIDecodingUnitInfo
+{
+  /* Sei Decoding Unit Info Present Flag */
+  tPPBool        nSEIDecodingUnitInfoPresentFlag;
+  /* decoding_unit_idx */
+  tPPu32       nDecodingUnitIdx;
+  /* du_spt_cpb_removal_delay_increment */
+  tPPu32       nDuSptCpbRemovalDelayIncrement;
+  /* dpb_output_du_delay_present_flag */
+  tPPu32       nDpbOutputDuDelayPresentFlag;
+  /* pic_spt_dpb_output_du_delay_flag */
+  tPPu32       nPicSptDpbOutputDuDelayFlag;
+};
+
+/**
+ *  @brief Structure for H265_SEIScalableNesting parameters
+ *
+ */
+typedef struct H265_SEIScalableNesting tH265_SEIScalableNesting;
+struct H265_SEIScalableNesting
+{
+  /* Sei Scalable Nesting Present Flag */
+  tPPBool        nSEIScalableNestingPresentFlag;
+  /* bitstream_subset_flag */
+  tPPu8       nBitstreamSubsetFlag;
+  /* nesting_op_flag */
+  tPPu8       nNestingOpFlag;
+  /* default_op_flag */
+  tPPu8       nDefaultOpFlag;
+  /* nesting_num_ops_minus1 */
+  tPPu32       nNestingNumOpsMinus1;
+  /* nesting_max_temporal_id_plus1[ i ] */
+  tPPu8       nNestingMaxTemporalIdPlus1[ H265_SEI_MAX_NUM_NESTING_OPS ];
+  /* nesting_op_idx[ i ] */
+  tPPu32       nNestingOpIdx[ H265_SEI_MAX_NUM_NESTING_OPS ];
+  /* all_layers_flag */
+  tPPu8       nAllLayersFlag;
+  /* nesting_no_op_max_temporal_id_plus1 */
+  tPPu8       nNestingNoOpMaxTemporalIdPlus1;
+  /* nesting_num_layers_minus1 */
+  tPPu8       nNestingNumLayersMinus1;
+  /* nesting_layer_id[ i ] */
+  tPPu8       nNestingLayerId[ H265_SEI_MAX_NUM_NESTING_LAYER ];
+  /* nesting_zero_bit */
+  tPPu8       nNestingZeroBit;
+};
+
+/**
+ *  @brief Structure for H265_SEIRegionRefreshInfo parameters
+ *
+ */
+typedef struct H265_SEIRegionRefreshInfo tH265_SEIRegionRefreshInfo;
+struct H265_SEIRegionRefreshInfo
+{
+   /* Sei Region Refresh Info Present Flag */
+  tPPBool        nSEIRegionRefreshInfoPresentFlag;
+  /* refreshed_region_flag */
+  tPPu8       nRefreshedRegionFlag;
+};
+
+/**
+ *  @brief Structure for H265_SEISeiReserved parameters
+ *
+ */
+typedef struct H265_SEISeiReserved tH265_SEISeiReserved;
+struct H265_SEISeiReserved
+{
+  /*
+   * reserved for future backward-compatible
+   * parameter mentoind below is not the actual one
+   */
+   /* Sei SEI Reserved Present Flag */
+  tPPBool        nSeiReservedPresentFlag;
+  /* reserved_sei_message_payload_byte */
+  tPPu8       nReservedSeiMessagePayloadByte;
+};
+/**
+ *  @brief Structure for H265_SubLayerHRD Parameters
+ *
+ */
+typedef struct H265_SubLayerHRDParameters\
+               tH265_SubLayerHRDParameters;
+struct H265_SubLayerHRDParameters
+{
+  /* bit_rate_value_minus1[ 32 ] */
+  tPPu32   nBitRateValueMinus1[ H265_HRD_MAX_CPB_COUNT ];
+  /* cpb_size_value_minus1[ 32 ] */
+  tPPu32   nCpbSizeValueMinus1[ H265_HRD_MAX_CPB_COUNT ];
+  /* cpb_size_du_value_minus1[ 32 ] */
+  tPPu32   nCpbSizeDuValueMinus1[ H265_HRD_MAX_CPB_COUNT ];
+  /** bit_rate_du_value_minus1[ 32 ] */
+  tPPu32   nBitRateDuValueMinus1[ H265_HRD_MAX_CPB_COUNT ];
+  /* cbr_flag[ i ] */
+  tPPBool     nCbrFlag[ H265_HRD_MAX_CPB_COUNT ];
+};
+/**
+ *  @brief Structure for H265_HRD Parameters
+ *
+ */
+typedef struct H265_HRDParameters tH265_HRDParameters;
+struct H265_HRDParameters
+{
+  /* HRD param valid flag */
+  tPPBool     nHrdParametersValidFlag;
+  /* nal_hrd_parameters_present_flag */
+  tPPBool     nNalHrdParametersPresentFlag;
+  /* vcl_hrd_parameters_present_flag */
+  tPPBool     nVclHrdParametersPresentFlag;
+  /* sub_pic_cpb_params_present_flag */
+  tPPBool     nSubPicCpbParamsPresentFlag;
+  /* tick_divisor_minus2 */
+  tPPu8    nTickDivisorMinus2;
+  /* du_cpb_removal_delay_increment_length_minus1 */
+  tPPu8    nDuCpbRemovalDelayIncrementLengthMinus1;
+  /* sub_pic_cpb_params_in_pic_timing_sei_flag */
+  tPPu8    nSubPicCpbParamsInPicTimingSeiFlag;
+  /* dpb_output_delay_du_length_minus1 */
+  tPPu8    nDpbOutputDelayDuLengthMinus1;
+  /* bit_rate_scale */
+  tPPu8    nBitRateScale;
+  /* cpb_size_scale */
+  tPPu8    nCpbSizeScale;
+  /* cpb_size_du_scale */
+  tPPu8    nCpbSizeDuScale;
+  /* initial_cpb_removal_delay_length_minus1 */
+  tPPu8    nInitialCpbRemovalDelayLengthMinus1;
+  /* au_cpb_removal_delay_length_minus1 */
+  tPPu8    nAuCpbRemovalDelayLengthMinus1;
+  /* dpb_output_delay_length_minus1 */
+  tPPu8    nDpbOutputDelayLengthMinus1;
+  /* fixed_pic_rate_general_flag[ 6 ] */
+  tPPBool     nFixedPicRateGeneralFlag[ H265_HRD_MAX_NUM_SUB_LAYER ];
+  /* fixed_pic_rate_within_cvs_flag[ 6 ] */
+  tPPBool     nFixedPicRateWithinCvsFlag[ H265_HRD_MAX_NUM_SUB_LAYER ];
+  /* elemental_duration_in_tc_minus1[ 6 ] */
+  tPPu16   nElementalDurationInTcMinus1[ H265_HRD_MAX_NUM_SUB_LAYER ];
+  /* low_delay_hrd_flag[ 6 ] */
+  tPPBool     nLowDelayHrdFlag[ H265_HRD_MAX_NUM_SUB_LAYER ];
+  /* cpb_cnt_minus1[ 6 ] */
+  tPPu8    nCpbCntMinus1[ H265_HRD_MAX_NUM_SUB_LAYER ];
+   /* structure of H265_SubLayerHRDParameters */
+  tH265_SubLayerHRDParameters nSubLayerHRDParameters\
+    [H265_HRD_MAX_NUM_SUB_LAYER];
+};
+
+/**
+ *  @brief Structure for IH265_VUI Parameters
+ *
+ */
+typedef struct H265_VUIParameters tH265_VUIParameters;
+struct H265_VUIParameters
+{
+  /* VUI param valid flag */
+  tPPBool     nVUIParamsValidFlag;
+  /* aspect_ratio_info_present_flag */
+  tPPBool     nAspectRatioInfoPresentFlag;
+  /* aspect_ratio_idc */
+  tPPu8    nAspectRatioIdc;
+  /* sar_widtht */
+  tPPu16   nSarWidth;
+  /* sar_height */
+  tPPu16    nSarHeight;
+  /* overscan_info_present_flag */
+  tPPBool     nOverscanInfoPresentFlag;
+  /* overscan_appropriate_flag */
+  tPPBool     nOverScanAppropriateFlag;
+  /* video_signal_type_present_flag */
+  tPPBool     nVideoSignalTypePresentFlag;
+  /* video_format */
+  tPPu8    nVideoFormat;
+  /* video_full_range_flag */
+  tPPBool     nVideoFullRangeFlag;
+  /* colour_description_present_flag */
+  tPPBool     nColourDescriptionPresentFlag;
+  /* colour_primaries */
+  tPPu8    nColourPrimaries;
+  /* transfer_characteristics */
+  tPPu8    nTransferCharacteristics;
+  /* matrix_coeffs */
+  tPPu8    nMatrixCoeffs;
+  /* chroma_loc_info_present_flag */
+  tPPBool     nChromaLocInfoPresentFlag;
+  /* chroma_sample_loc_type_top_field */
+  tPPu8    nChromaSampleLocTypeTopField;
+  /* chroma_sample_loc_type_bottom_field */
+  tPPu8    nChromaSampleLocTypeBottomField;
+  /* neutral_chroma_indication_flagld */
+  tPPBool     nNeutralChromaIndicationFlagId;
+  /* field_seq_flag */
+  tPPBool     nFieldSeqFlag;
+  /* frame_field_info_present_flag*/
+  tPPBool     nFrameFieldInfoPresentFlag;
+  /* default_display_window_flag */
+  tPPBool     nDefaultDisplayWindowFlag;
+  /* def_disp_win_left_offset */
+  tPPu16   nDefDispWinLeftOffset;
+  /* def_disp_win_right_offset */
+  tPPu16   nDefDispWinRightOffset;
+  /* def_disp_win_top_offset */
+  tPPu16   nDefDispWinTopOffset;
+  /* def_disp_win_bottom_offset */
+  tPPu16   nDefDispWinBottomOffset;
+  /* vui_timing_info_present_flag */
+  tPPBool     nVUITimingInfoPresentFlag;
+  /* vui_num_units_in_tick */
+  tPPu32   nVUINumUnitsInTick;
+  /* vui_time_scale */
+  tPPu32   nVUITimeScale;
+  /* vui_poc_proportional_to_timing_flag */
+  tPPBool     nVUIpocProportionalToTimingFlag;
+  /* vui_num_ticks_poc_diff_one_minus1 */
+  tPPu32   nVUINumTicksPOCDiffOneMinus1;
+  /* vui_hrd_parameters_present_flags */
+  tPPBool     nVUIHrdParametersPresentFlags;
+  /* bitstream_restriction_flag */
+  tPPBool     nBitStreamRestrictionFlag;
+  /* tiles_fixed_structure_flag */
+  tPPBool     nTilesFixedStructureFlag;
+  /* motion_vectors_over_pic_boundaries_flag*/
+  tPPBool     nMotionVectorsOverPicBoundariesFlag;
+  /* restricted_ref_pic_lists_flag*/
+  tPPBool     nRestrictedRefPicListsFlag;
+  /* min_spatial_segmentation_idc */
+  tPPu16   nMinSpatialSegmentationIdc;
+  /* max_bytes_per_pic_denom */
+  tPPu8    nMaxBytesPerPicDenom;
+  /* max_bits_per_min_cu_denom */
+  tPPu8    nMaxBitsPerMinCuDenom;
+  /* log2_max_mv_length_horizontal */
+  tPPu8    nLog2MaxMvLengthHorizontal;
+  /* log2_max_mv_length_vertical*/
+  tPPu8    nLog2MaxMvLengthVertical;
+  /* structure of H265_HRDParameters */
+  tH265_HRDParameters nHrdParameters;
+};
+/**
+ *  @brief Structure for H265_SeiMesseges parameters
+ *
+ */
+typedef struct H265_SeiMesseges tH265_SeiMesseges;
+struct H265_SeiMesseges
+{
+  /* structure of H265_SeiBufferingPeriod */
+  tH265_SeiBufferingPeriod             nSeiBufferingPeriod;
+   /* structure of */
+  tH265_SeiPictureTiming               nSeiPictureTiming;
+   /* structure of H265_SeiPictureTiming */
+  tH265_SeiPanScanRect                 nSeiPanScanRect;
+   /* structure of H265_SeiFillerPayload */
+  tH265_SeiFillerPayload               nSeiFillerPayload;
+   /* structure of H265_SeiUserDataRegistered */
+  tH265_SeiUserDataRegistered          nSeiUserDataRegistered;
+  /* structure of H265_SeiUserDataUnregistered */
+  tH265_SeiUserDataUnregistered        nSeiUserDataUnregistered;
+   /* structure of H265_SeiRecoveryPoint */
+  tH265_SeiRecoveryPoint               nSeiRecoveryPoint;
+   /* structure of H265_SeiSceneInfo */
+  tH265_SeiSceneInfo                   nSeiSceneInfo;
+   /* structure of H265_SeiPictureSnapShot */
+  tH265_SeiPictureSnapShot             nSeiPictureSnapShot;
+   /* structure of H265_SeiProgRefinementStart */
+  tH265_SeiProgRefinementStart         nSeiProgRefinementStart;
+   /* structure of H265_SeiProgRefinementEnd */
+  tH265_SeiProgRefinementEnd           nSeiProgRefinementEnd;
+   /* structure of H265_SeiFilmGrainChar */
+  tH265_SeiFilmGrainChar               nSeiFilmGrainChar;
+   /* structure of H265_SeiPostFilterHint */
+  tH265_SeiPostFilterHint              nSeiPostFilterHint;
+   /* structure of H265_SeiToneMappingInfo */
+  tH265_SeiToneMappingInfo             nSeiToneMappingInfo;
+   /* structure of H265_SeiFramePackingArrange */
+  tH265_SeiFramePackingArrange         nSeiFramePackingArrange;
+   /* structure of H265_SeiDisplayOrientaiton */
+  tH265_SeiDisplayOrientaiton          nSeiDisplayOrientaiton;
+   /* structure of H265_SeiStructureOfPictureInfo */
+  tH265_SeiStructureOfPictureInfo      nSeiStructureOfPictureInfo;
+   /* structure of H265_SeiActiveParameterSets */
+  tH265_SeiActiveParameterSets         nSeiActiveParameterSets;
+   /* structure of H265_SEIDecodingUnitInfo */
+  tH265_SEIDecodingUnitInfo             nSeiDecodingUnitInfo;
+   /* structure of H265_SeiTemporalSubLayerZeroIndex */
+  tH265_SeiTemporalSubLayerZeroIndex   nSeiTemporalSubLayerZeroIndex;
+   /* structure of H265_SeiDecodedPictureHash */
+  tH265_SeiDecodedPictureHash          nSeiDecodedPictureHash;
+   /* structure of H265_SEIScalableNesting */
+  tH265_SEIScalableNesting              nSeiScalableNesting;
+   /* structure of H265_SEIRegionRefreshInfo */
+  tH265_SEIRegionRefreshInfo            nSeiRegionRefreshInfo;
+   /* structure of H265_SEISeiReserved */
+  tH265_SEISeiReserved                  nSeiReserved;
+};
+
+/* ER codes */
+/* enum for extended error used for bit-setting */
+typedef enum
+{
+  PP_H265_ERR_UNSUPPORTED = 1,
+  PP_H265_ERR_NO_NALU_BEGIN_FOUND,
+  PP_H265_ERR_NO_NALU_END_FOUND,
+  PP_H265_ERR_INVALID_NAL_UNIT_TYPE,
+  PP_H265_ERR_INSUFFICIENT_BUFFER,
+  PP_H265_ERR_DATA_SYNC,
+  PP_H265_ERR_CRITICAL,
+  PP_H265_ERR_NO_VPS,
+  PP_H265_ERR_VPS,
+  PP_H265_ERR_NO_SPS,
+  PP_H265_ERR_SPS,
+  PP_H265_ERR_NO_PPS,
+  PP_H265_ERR_PPS,
+  PP_H265_ERR_SLICELOSS,
+  PP_H265_ERR_SLICEHDR,
+  PP_H265_ERR_SLICEDATA,
+  PP_H265_ERR_RANDOM_ACCESS_SKIP,
+  PP_H265_ERR_REFPIC_NOT_FOUND,
+  PP_H265_ERR_META_DATA
+}PP_H265VDEC_Errors;
+
+/*******************************************************************************
+*   FUNCTION PROTOTYPES
+*******************************************************************************/
+
+/**
+ ******************************************************************************
+ * @fn tPPResult gPP_H265_InitializeDecoder  (tPPBaseDecoder    **appBase,
+ *                                       tPPQueryMemRecords  *apQueryMemRecords,
+ *                                       tPP_H265_CreateParams *apCreateParams);
+ * @ingroup H265_DECODER
+ *
+ * @brief This function initialises H.265 video decoder object
+ *
+ * @param appBase           [IN/OUT] Pointer to hold decoder object handle
+ * @param apQueryMemRecords [IN] Structure holding allocated memory records
+ * @param apCreateParams    [IN] Pointer to decoder create parameter structure
+ *
+ * @return None
+ ******************************************************************************
+ */
+tPPResult gPP_H265_InitializeDecoder  (tPPBaseDecoder       **appBase,
+                                  tPPQueryMemRecords  *apQueryMemRecords,
+                                  tPP_H265_CreateParams *apCreateParams);
+
+/**
+******************************************************************************
+* @fn tPPResult gH265_ParseNALUnitFrame( tPPGstNAL *pGstNAL,
+*                                        tPPInput_BitStream  H265InputStreamNAL,
+*                                        tPPi32 *aByteConsumed)
+*
+* @brief This function parses NAL unit and returns corresponding status code
+*
+* @param  aGstNAL            [IN] NAL unit structure
+* @param  H265InputStreamNAL [IN] Bit stream data which is to be decoded.
+* @param  aByteConsumed      [IN] bytes consumed
+* @return Status code
+*
+*      SC_PP_SUCCESS
+******************************************************************************
+*/
+
+tPPResult gH265_ParseNALUnitFrame( tPPGstNAL *pGstNAL,
+                                  tPPInput_BitStream  H265InputStreamNAL,
+                                  tPPi32 *aByteConsumed);
+
+#endif /*_GSTH265DECUTILS_*/
+
+
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644 (file)
index 0000000..0e6035b
--- /dev/null
@@ -0,0 +1,7 @@
+aclocal.m4
+autom4te.cache
+autoregen.sh
+config.log
+config.status
+configure
+libtool
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644 (file)
index 0000000..0e6035b
--- /dev/null
@@ -0,0 +1,7 @@
+aclocal.m4
+autom4te.cache
+autoregen.sh
+config.log
+config.status
+configure
+libtool
diff --git a/tools/make_element b/tools/make_element
new file mode 100644 (file)
index 0000000..3ae7d18
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+Template=$1;
+srcfile=$2.c;
+srcfile_h=$2.h;
+
+if test x"$1" = x ; then
+       echo "$0 Objectname [srcfile]\n";
+       echo "  creates gstobjectname.{c,h} implementing GstObjectname\n";
+       exit 1;
+fi
+
+if test x"$2" = x ; then
+       srcfile="gstplugin.c"
+       srcfile_h="gstplugin.h"
+fi
+
+id=$(echo '$Id$' | sed \
+       -e 's/\$I[d]: \([^$]*\)\$/\1/g' \
+       )
+
+TEMPLATE=$(echo $Template | tr a-z A-Z)
+template=$(echo $Template | tr A-Z a-z)
+filename=$(echo $template | tr -d _)
+Template=$(echo $Template | tr -d _)
+template_=$(echo $Template | sed "s/\([a-z]\)\([A-Z]\)/\1_\2/g" | tr A-Z a-z)
+
+YEAR=`date "+%Y"`
+if [ -z "$REAL_NAME" ]; then
+  user=`id -u`
+  if [ `which 2>/dev/null getent` ]; then
+    entry=`getent passwd $user`
+  else
+    entry=`grep $user /etc/passwd`
+  fi
+  REAL_NAME=`echo $entry | awk -F":" '{ print $5 }' | awk -F"," '{ print $1 }'`
+fi
+if [ -z "$EMAIL_ADDRESS" ]; then
+  EMAIL_ADDRESS="<user@hostname.org>"
+fi
+
+# remember to break up the Id: in the line below
+sed \
+       -e 's/gstplugin\.c/SOURCEFILE/g' \
+       -e "s/gstplugin\.h/gst$filename.h/g" \
+        -e "s/gsttransform\.h/gst$filename.h/g" \
+       -e "s/GstPluginTemplate/Gst$Template/g" \
+       -e "s/gst_plugin_template/gst_$template_/g" \
+       -e "s/gst_type_plugin_template/gst_$template_/g" \
+       -e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
+       -e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
+       -e 's/\$I[d]: \([^$]*\)\$/\1/g' \
+       -e 's/SOURCEFILE/gstobject\.c/g' \
+       -e "s%MAKEFILTERVERSION%$id%g" \
+       -e "s/plugin/$template/g" \
+       -e "s/\([^G][^s][^t]\)Plugin/\1$Template/g" \
+       -e "s/YEAR/$YEAR/g" \
+       -e "s/AUTHOR_NAME/$REAL_NAME/g" \
+       -e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
+       $srcfile >gst$filename.c.tmp && mv gst$filename.c.tmp gst$filename.c
+
+if [ -e $srcfile_h ]; then
+  sed \
+       -e 's/gstplugin\.c/SOURCEFILE/g' \
+       -e "s/GstPluginTemplate/Gst$Template/g" \
+       -e "s/gst_plugin_template/gst_$template_/g" \
+       -e "s/gst_type_plugin_template/gst_$template_/g" \
+       -e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
+       -e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
+       -e "s/GST_IS_PLUGIN_TEMPLATE/GST_IS_$TEMPLATE/g" \
+       -e 's/\$I[d]: \([^$]*\)\$/\1/g' \
+       -e 's/SOURCEFILE/gstobject\.c/g' \
+       -e "s%MAKEFILTERVERSION%$id%g" \
+       -e "s/plugin/$template/g" \
+       -e "s/\([^G][^s][^t]\)Plugin/\1$Template/g" \
+       -e "s/YEAR/$YEAR/g" \
+       -e "s/AUTHOR_NAME/$REAL_NAME/g" \
+       -e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
+       $srcfile_h >gst$filename.h.tmp && mv gst$filename.h.tmp gst$filename.h
+fi
+