Merge tizen patch based on 1.12.2
authorSejun Park <sejun79.park@samsung.com>
Thu, 9 Nov 2017 07:57:49 +0000 (16:57 +0900)
committerSejun Park <sejun79.park@samsung.com>
Thu, 9 Nov 2017 07:57:49 +0000 (16:57 +0900)
Change-Id: I3de5759ac30cd4932ca8a256b59d8ecc44e97ea8

23 files changed:
1  2 
.gbs.conf
.gitmodules
Makefile.am
config/bellagio/gstomx.conf
config/exynos/gstomx.conf
config/rpi/gstomx.conf
configure.ac
examples/egl/testegl.c
omx/Makefile.am
omx/gstomx.h
omx/gstomxaudiodec.c
omx/gstomxaudioenc.c
omx/gstomxbufferpool.c
omx/gstomxbufferpool.h
omx/gstomxh264enc.c
omx/gstomxh264enc.h
omx/gstomxvideo.c
omx/gstomxvideodec.c
omx/gstomxvideodec.h
omx/gstomxvideoenc.c
omx/gstomxvideoenc.h
packaging/common.tar.gz
packaging/gst-omx.spec

diff --combined .gbs.conf
+++ b/.gbs.conf
@@@ -1,3 -1,3 +1,3 @@@
  [general]
--upstream_branch = upstream
- upstream_tag = ${upstreamversion}
++upstream_branch = upstream/1.12
+ upstream_tag = upstream/${upstreamversion}
diff --combined .gitmodules
@@@ -1,3 -1,3 +1,0 @@@
--[submodule "common"]
--      path = common
--      url = git://anongit.freedesktop.org/gstreamer/common
diff --combined Makefile.am
index 82affc6,b063bc1..b063bc1
mode 100755,100644..100755
@@@ -1,4 -1,4 +1,4 @@@
- SUBDIRS = common omx tools config m4
+ SUBDIRS = common omx tools m4
  
  if BUILD_EXAMPLES
  SUBDIRS += examples
index 78f8e7d,5ca8ba6..5ca8ba6
mode 100755,100644..100755
@@@ -2,7 -2,7 +2,7 @@@
  type-name=GstOMXMPEG4VideoDec
  core-name=/usr/local/lib/libomxil-bellagio.so.0
  component-name=OMX.st.video_decoder.mpeg4
- rank=256
+ rank=257
  in-port-index=0
  out-port-index=1
  hacks=event-port-settings-changed-ndata-parameter-swap;event-port-settings-changed-port-0-to-1
@@@ -11,7 -11,7 +11,7 @@@
  type-name=GstOMXH264Dec
  core-name=/usr/local/lib/libomxil-bellagio.so.0
  component-name=OMX.st.video_decoder.avc
- rank=256
+ rank=257
  in-port-index=0
  out-port-index=1
  hacks=event-port-settings-changed-ndata-parameter-swap;event-port-settings-changed-port-0-to-1
index 0113214,e83ec55..e83ec55
mode 100755,100644..100755
@@@ -5,7 -5,9 +5,9 @@@ component-name=OMX.Exynos.MPEG2.Decode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
  
  [omxdec_mpeg4]
  type-name=GstOMXMPEG4VideoDec
@@@ -14,7 -16,9 +16,9 @@@ component-name=OMX.Exynos.MPEG4.Decode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
  
  [omxdec_h263]
  type-name=GstOMXH263Dec
@@@ -23,7 -27,9 +27,9 @@@ component-name=OMX.Exynos.H263.Decode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
  
  [omxdec_h264]
  type-name=GstOMXH264Dec
@@@ -32,7 -38,42 +38,42 @@@ component-name=OMX.Exynos.AVC.Decode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
+ [omxdec_h265]
+ type-name=GstOMXH265Dec
+ core-name=/usr/lib/libExynosOMX_Core.so
+ component-name=OMX.Exynos.HEVC.Decoder
+ rank=258
+ in-port-index=0
+ out-port-index=1
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
+ [omxdec_vp8]
+ type-name=GstOMXVP8Dec
+ core-name=/usr/lib/libExynosOMX_Core.so
+ component-name=OMX.Exynos.VP8.Decoder
+ rank=258
+ in-port-index=0
+ out-port-index=1
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
+ [omxdec_vp9]
+ type-name=GstOMXVP9Dec
+ core-name=/usr/lib/libExynosOMX_Core.so
+ component-name=OMX.Exynos.VP9.Decoder
+ rank=258
+ in-port-index=0
+ out-port-index=1
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport;no-component-reconfigure
  
  [omxdec_vc1]
  type-name=GstOMXWMVDec
@@@ -41,7 -82,9 +82,9 @@@ component-name=OMX.Exynos.WMV.Decode
  rank=256
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=0
+ out-port-usebuffer=1
+ hacks=no-component-role;no-disable-outport
  sink-template-caps=video/x-wmv,wmvversion=(int)3,format=(string){WMV3,WVC1},width=(int)[1,MAX],height=(int)[1,MAX]
  
  [omxenc_h264]
@@@ -51,7 -94,22 +94,22 @@@ component-name=OMX.Exynos.AVC.Encode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=1
+ out-port-usebuffer=0
+ hacks=no-disable-outport;no-component-role
+ sink-template-caps=video/x-raw, format=(string)SN12, width=(int) [1,1920], height=(int) [1,1080], framerate=(fraction)[0/1, MAX]
+ src-template-caps=video/x-h264, width=(int) [1,1920], height=(int) [1,1080], framerate=(fraction) [0/1, MAX], alignment=(string) au, stream-format = (string){ avc, byte-stream }
+ [omxenc_h265]
+ type-name=GstOMXH265Enc
+ core-name=/usr/lib/libExynosOMX_Core.so
+ component-name=OMX.Exynos.HEVC.Encoder
+ rank=258
+ in-port-index=0
+ out-port-index=1
+ in-port-usebuffer=1
+ out-port-usebuffer=0
+ hacks=no-disable-outport;no-component-role
  
  [omxenc_mpeg4]
  type-name=GstOMXMPEG4VideoEnc
@@@ -60,7 -118,9 +118,9 @@@ component-name=OMX.Exynos.MPEG4.Encode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=1
+ out-port-usebuffer=0
+ hacks=no-component-role;no-disable-outport
  
  [omxenc_h263]
  type-name=GstOMXH263Enc
@@@ -69,4 -129,6 +129,6 @@@ component-name=OMX.Exynos.H263.Encode
  rank=258
  in-port-index=0
  out-port-index=1
- hacks=no-component-role
+ in-port-usebuffer=1
+ out-port-usebuffer=0
+ hacks=no-component-role;no-disable-outport
diff --combined config/rpi/gstomx.conf
index 9e23d45,8b5c7d6..21ab304
mode 100755,100644..100755
@@@ -2,7 -2,7 +2,7 @@@
  type-name=GstOMXMPEG2VideoDec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -11,7 -11,7 +11,7 @@@
  type-name=GstOMXMPEG4VideoDec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -20,7 -20,7 +20,7 @@@
  type-name=GstOMXH263Dec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -29,7 -29,7 +29,7 @@@
  type-name=GstOMXH264Dec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -38,7 -38,7 +38,7 @@@
  type-name=GstOMXTheoraDec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -47,7 -47,7 +47,7 @@@
  type-name=GstOMXVP8Dec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -56,7 -56,7 +56,7 @@@
  type-name=GstOMXMJPEGDec
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_decode
- rank=256
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -64,8 -64,8 +64,8 @@@
  [omxvc1dec]
  type-name=GstOMXWMVDec
  core-name=/opt/vc/lib/libopenmaxil.so
- component-name=OMX.broadcom.video_encode
- rank=256
+ component-name=OMX.broadcom.video_decode
+ rank=257
  in-port-index=130
  out-port-index=131
  hacks=no-component-role
@@@ -75,28 -75,28 +75,48 @@@ sink-template-caps=video/x-wmv,wmvversi
  type-name=GstOMXH264Enc
  core-name=/opt/vc/lib/libopenmaxil.so
  component-name=OMX.broadcom.video_encode
- rank=256
+ rank=257
  in-port-index=200
  out-port-index=201
+ hacks=no-component-role;no-component-reconfigure
+ [omxanalogaudiosink]
+ type-name=GstOMXAnalogAudioSink
+ core-name=/opt/vc/lib/libopenmaxil.so
+ component-name=OMX.broadcom.audio_render
+ rank=257
+ in-port-index=100
+ out-port-index=101
  hacks=no-component-role
+ sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,2]
+ [omxhdmiaudiosink]
+ type-name=GstOMXHdmiAudioSink
+ core-name=/opt/vc/lib/libopenmaxil.so
+ component-name=OMX.broadcom.audio_render
+ rank=258
+ in-port-index=100
+ out-port-index=101
+ hacks=no-component-role
+ sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,8];audio/x-ac3,framed=(boolean)true;audio/x-dts,framed=(boolean)true,block-size=(int){512,1024,2048}
  
 +[omxanalogaudiosink]
 +type-name=GstOMXAnalogAudioSink
 +core-name=/opt/vc/lib/libopenmaxil.so
 +component-name=OMX.broadcom.audio_render
 +rank=257
 +in-port-index=100
 +out-port-index=101
 +hacks=no-component-role
 +sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,2]
 +
 +[omxhdmiaudiosink]
 +type-name=GstOMXHdmiAudioSink
 +core-name=/opt/vc/lib/libopenmaxil.so
 +component-name=OMX.broadcom.audio_render
 +rank=258
 +in-port-index=100
 +out-port-index=101
 +hacks=no-component-role
 +sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,8];audio/x-ac3,framed=(boolean)true;audio/x-dts,framed=(boolean)true,block-size=(int){512,1024,2048}
 +
diff --combined configure.ac
index f523e32,11108c9..11108c9
mode 100755,100644..100755
@@@ -187,23 -187,73 +187,73 @@@ if test "x$HAVE_VIDEO_EXT" = "xyes"; th
  "
  fi
  
- AC_CHECK_DECLS([OMX_VIDEO_CodingVP8],
+ dnl check for supporting vp8
+ AC_MSG_CHECKING([for supporting vp8])
+ AC_ARG_ENABLE(vp8, AC_HELP_STRING([--enable-vp8], [OpenMAX IL has VP8 support]),
    [
-     AC_DEFINE(HAVE_VP8, 1, [OpenMAX IL has VP8 support])
-     HAVE_VP8=yes
-   ], [
-     HAVE_VP8=no
-   ], [[$VIDEO_HEADERS]])
+     case "${enableval}" in
+       yes) HAVE_VP8=yes ;;
+       no)  HAVE_VP8=no ;;
+       *)   AC_MSG_ERROR(bad value ${enableval} for --enable-vp8) ;;
+     esac
+   ],
+   [HAVE_VP8=no])
  AM_CONDITIONAL(HAVE_VP8, test "x$HAVE_VP8" = "xyes")
+ AC_MSG_RESULT([$HAVE_VP8])
+ if test "x$HAVE_VP8" = "xyes"; then
+   AC_DEFINE(HAVE_VP8, 1, [OpenMAX IL has VP8 support])
+ fi
+ dnl check for supporting vp9
+ AC_MSG_CHECKING([for supporting vp9])
+ AC_ARG_ENABLE(vp9, AC_HELP_STRING([--enable-vp9], [OpenMAX IL has VP9 support]),
+   [
+     case "${enableval}" in
+       yes) HAVE_VP9=yes ;;
+       no)  HAVE_VP9=no ;;
+       *)   AC_MSG_ERROR(bad value ${enableval} for --enable-vp9) ;;
+     esac
+   ],
+   [HAVE_VP9=no])
+ AM_CONDITIONAL(HAVE_VP9, test "x$HAVE_VP9" = "xyes")
+ AC_MSG_RESULT([$HAVE_VP9])
+ if test "x$HAVE_VP9" = "xyes"; then
+   AC_DEFINE(HAVE_VP9, 1, [OpenMAX IL has VP9 support])
+ fi
  
- AC_CHECK_DECLS([OMX_VIDEO_CodingTheora],
+ dnl check for supporting theora
+ AC_MSG_CHECKING([for supporting theora])
+ AC_ARG_ENABLE(theora, AC_HELP_STRING([--enable-theora], [OpenMAX IL has Theora support]),
    [
-     AC_DEFINE(HAVE_THEORA, 1, [OpenMAX IL has Theora support])
-     HAVE_THEORA=yes
-   ], [
-     HAVE_THEORA=no
-   ], [[$VIDEO_HEADERS]])
+     case "${enableval}" in
+       yes) HAVE_THEORA=yes ;;
+       no)  HAVE_THEORA=no ;;
+       *)   AC_MSG_ERROR(bad value ${enableval} for --enable-theora) ;;
+     esac
+   ],
+   [HAVE_THEORA=no])
  AM_CONDITIONAL(HAVE_THEORA, test "x$HAVE_THEORA" = "xyes")
+ AC_MSG_RESULT([$HAVE_THEORA])
+ if test "x$HAVE_THEORA" = "xyes"; then
+   AC_DEFINE(HAVE_THEORA, 1, [OpenMAX IL has Theora support])
+ fi
+ dnl check for supporting hevc
+ AC_MSG_CHECKING([for supporting hevc])
+ AC_ARG_ENABLE(hevc, AC_HELP_STRING([--enable-hevc], [OpenMAX IL has HEVC support]),
+   [
+     case "${enableval}" in
+       yes) HAVE_HEVC=yes ;;
+       no)  HAVE_HEVC=no ;;
+       *)   AC_MSG_ERROR(bad value ${enableval} for --enable-hevc) ;;
+     esac
+   ],
+   [HAVE_HEVC=no])
+ AM_CONDITIONAL(HAVE_HEVC, test "x$HAVE_HEVC" = "xyes")
+ AC_MSG_RESULT([$HAVE_HEVC])
+ if test "x$HAVE_HEVC" = "xyes"; then
+   AC_DEFINE(HAVE_HEVC, 1, [OpenMAX IL has HEVC support])
+ fi
  
  dnl Check for -Bsymbolic-functions linker flag used to avoid
  dnl intra-library PLT jumps, if available.
@@@ -306,7 -356,7 +356,7 @@@ dnl define an ERROR_CFLAGS Makefile var
  AG_GST_SET_ERROR_CFLAGS($FATAL_WARNINGS, [
      -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef
      -Wwrite-strings -Wformat-nonliteral -Wformat-security -Wformat-nonliteral
-     -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return
+     -Winit-self -Wmissing-include-dirs -Waddress
      -Wno-multichar -Wnested-externs ])
  
  dnl define correct level for debugging messages
@@@ -403,11 -453,6 +453,6 @@@ omx/Makefil
  common/Makefile
  common/m4/Makefile
  tools/Makefile
- config/Makefile
- config/bellagio/Makefile
- config/rpi/Makefile
- config/exynos/Makefile
- config/exynos64/Makefile
  examples/Makefile
  examples/egl/Makefile
  m4/Makefile
diff --combined examples/egl/testegl.c
index bccf6c1,99aa810..99aa810
mode 100644,100644..100755
@@@ -1495,6 -1495,8 +1495,8 @@@ main (int argc, char **argv
    g_option_context_add_group (ctx, gst_init_get_option_group ());
    if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
      g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
+     g_option_context_free (ctx);
+     g_clear_error (&err);
      exit (1);
    }
    g_option_context_free (ctx);
diff --combined omx/Makefile.am
index 5462a4b,23742f3..23742f3
mode 100644,100644..100755
@@@ -5,11 -5,23 +5,23 @@@ VP8_C_FILES=gstomxvp8dec.
  VP8_H_FILES=gstomxvp8dec.h
  endif
  
+ if HAVE_VP9
+ VP9_C_FILES=gstomxvp9dec.c
+ VP9_H_FILES=gstomxvp9dec.h
+ endif
  if HAVE_THEORA
  THEORA_C_FILES=gstomxtheoradec.c
  THEORA_H_FILES=gstomxtheoradec.h
  endif
  
+ if HAVE_HEVC
+ HEVC_C_FILES=gstomxh265dec.c  \
+                       gstomxh265enc.c
+ HEVC_H_FILES=gstomxh265dec.h  \
+                       gstomxh265enc.h
+ endif
  libgstomx_la_SOURCES = \
        gstomx.c \
        gstomxbufferpool.c \
@@@ -25,7 -37,9 +37,9 @@@
        gstomxh263dec.c \
        gstomxwmvdec.c \
        $(VP8_C_FILES) \
+       $(VP9_C_FILES) \
        $(THEORA_C_FILES) \
+       $(HEVC_C_FILES) \
        gstomxmpeg4videoenc.c \
        gstomxh264enc.c \
        gstomxh263enc.c \
@@@ -35,7 -49,7 +49,7 @@@
        gstomxamrdec.c \
        gstomxaudiosink.c \
        gstomxanalogaudiosink.c \
-       gstomxhdmiaudiosink.c   
+       gstomxhdmiaudiosink.c
  
  noinst_HEADERS = \
        gstomx.h \
@@@ -52,7 -66,9 +66,9 @@@
        gstomxh263dec.h \
        gstomxwmvdec.h \
        $(VP8_H_FILES) \
+       $(VP9_H_FILES) \
        $(THEORA_H_FILES) \
+       $(HEVC_H_FILES) \
        gstomxmpeg4videoenc.h \
        gstomxh264enc.h \
        gstomxh263enc.h \
@@@ -70,6 -86,7 +86,7 @@@ endi
  
  libgstomx_la_CFLAGS = \
        -DGST_USE_UNSTABLE_API=1 \
+       $(CFLAGS) \
        $(OMX_INCLUDEPATH) \
        $(GST_GL_CFLAGS) \
        $(GST_PLUGINS_BASE_CFLAGS) \
@@@ -95,25 -112,9 +112,9 @@@ libgstomx_la_LDFLAGS = 
        $(TBM_LDFLAGS) \
        $(MM_COMMON_LDFLAGS)
  
  EXTRA_DIST = \
        openmax \
        gstomxvp8dec.c \
        gstomxvp8dec.h \
        gstomxtheoradec.c \
        gstomxtheoradec.h
- Android.mk: Makefile.am $(BUILT_SOURCES)
-       androgenizer \
-       -:PROJECT libgstomx -:SHARED libgstomx \
-        -:TAGS eng debug \
-          -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
-        -:SOURCES $(libgstomx_la_SOURCES) \
-                  $(nodist_libgstomx_la_SOURCES) \
-        -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstomx_la_CFLAGS) \
-        -:LDFLAGS $(libgstomx_la_LDFLAGS) \
-                  $(libgstomx_la_LIBADD) \
-                  -ldl \
-        -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
-                      LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-$(GST_API_VERSION)' \
-       > $@
diff --combined omx/gstomx.h
index 6e8398f,97141bc..97141bc
mode 100644,100644..100755
  # endif
  #endif
  
+ /* If the component may signal EOS before it has finished pushing
+  * out all of its buffers. Happens with egl_render on the rpi.
+  */
+ #define GST_OMX_HACK_SIGNALS_PREMATURE_EOS                            G_GUINT64_CONSTANT (0x0000000000000400)
  #include <OMX_Core.h>
  #include <OMX_Component.h>
  
- #ifdef USE_OMX_TARGET_EXYNOS
+ #ifdef TIZEN_FEATURE_OMX
  #include <tbm_type.h>
  #include <tbm_surface.h>
  #include <tbm_bufmgr.h>
+ #include <unistd.h>
  #endif
  
  #ifdef USE_OMX_TARGET_RPI
@@@ -78,6 -84,15 +84,15 @@@ G_BEGIN_DECL
    (st)->nVersion.s.nStep = OMX_VERSION_STEP; \
  } G_STMT_END
  
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+ #define OMX_INIT_PARAM(param) G_STMT_START { \
+   memset (&(param), 0, sizeof ((param))); \
+   (param).nSize = sizeof (param); \
+   (param).nVersion.s.nVersionMajor = 1; \
+   (param).nVersion.s.nVersionMinor = 1; \
+ } G_STMT_END
+ #endif
  /* Different hacks that are required to work around
   * bugs in different OpenMAX implementations
   */
   */
  #define GST_OMX_HACK_NO_DISABLE_OUTPORT                               G_GUINT64_CONSTANT (0x0000000000000100)
  
+ /* If the encoder requires input buffers that have a height
+  * which is a multiple of 16 pixels
+  */
+ #define GST_OMX_HACK_HEIGHT_MULTIPLE_16             G_GUINT64_CONSTANT (0x0000000000000200)
+ /* If we should pass the profile/level information from upstream to the
+  * OMX decoder. This is a violation of the OMX spec as
+  * OMX_IndexParamVideoProfileLevelCurrent is supposed to be r-o so
+  * do it as a platform specific hack.
+  */
+ #define GST_OMX_HACK_PASS_PROFILE_TO_DECODER        G_GUINT64_CONSTANT (0x0000000000000800)
  typedef struct _GstOMXCore GstOMXCore;
  typedef struct _GstOMXPort GstOMXPort;
  typedef enum _GstOMXPortDirection GstOMXPortDirection;
@@@ -134,17 -161,21 +161,21 @@@ typedef struct _GstOMXMessage GstOMXMes
  /* MODIFICATION */
  typedef enum GOmxVendor GOmxVendor; /* check omx vender */
  
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
  
  #define MFC_INPUT_BUFFER_PLANE      1
  #define MFC_OUTPUT_BUFFER_PLANE     2
+ #define MAX_BUFFER_PLANE            3
  
  #define MAX_INPUT_BUFFER            16
  #define MAX_OUTPUT_BUFFER           16
  
+ #define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
  typedef struct _TBMBuffer TBMBuffer;
  typedef struct _TBMInputBuffer TBMInputBuffer;
  typedef struct _TBMOutputBuffer TBMOutputBuffer;
+ typedef struct _EnableGemBuffersParams EnableGemBuffersParams;
  
  struct _TBMBuffer
  {
@@@ -168,8 -199,6 +199,6 @@@ struct _TBMOutputBuffe
      GList *buffers;
  };
  
- typedef struct _EnableGemBuffersParams EnableGemBuffersParams;
  struct _EnableGemBuffersParams
  {
    OMX_U32 nSize;
  };
  #endif
  
- enum
- {
-     BUF_SHARE_METHOD_PADDR = 0,
-     BUF_SHARE_METHOD_FD = 1,
-     BUF_SHARE_METHOD_TIZEN_BUFFER = 2,
-     BUF_SHARE_METHOD_FLUSH_BUFFER = 3,
- }; /* buf_share_method */
- /* Extended color formats */
- enum {
-     OMX_EXT_COLOR_FormatNV12TPhysicalAddress = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */
-     OMX_EXT_COLOR_FormatNV12LPhysicalAddress = 0x7F000002,
-     OMX_EXT_COLOR_FormatNV12Tiled = 0x7FC00002,
-     OMX_EXT_COLOR_FormatNV12TFdValue = 0x7F000012,
-     OMX_EXT_COLOR_FormatNV12LFdValue = 0x7F000013
- };
- #ifdef GST_TIZEN_MODIFICATION
- /* Extended port settings. */
- enum {
-     OMX_IndexParamEnablePlatformSpecificBuffers = 0x7F000011
- };
- #endif
- /* modification: Add_component_vendor */
- enum GOmxVendor
- {
-     GOMX_VENDOR_DEFAULT,
-     GOMX_VENDOR_SLSI_SEC,
-     GOMX_VENDOR_SLSI_EXYNOS,
-     GOMX_VENDOR_QCT,
-     GOMX_VENDOR_SPRD
- };
  typedef enum {
    /* Everything good and the buffer is valid */
    GST_OMX_ACQUIRE_BUFFER_OK = 0,
@@@ -236,7 -231,6 +231,6 @@@ struct _GstOMXCore 
    gint user_count; /* LOCK */
  
    /* MODIFICATION */
-   GOmxVendor component_vendor; /* to check omx vender */
    gboolean secure; /* trust zone */
  
    /* OpenMAX core library functions, protected with LOCK */
@@@ -311,6 -305,10 +305,10 @@@ struct _GstOMXPort 
    gboolean enabled_pending;  /* TRUE after OMX_Command{En,Dis}able */
    gboolean disabled_pending; /* was done until it took effect */
    gboolean eos; /* TRUE after a buffer with EOS flag was received */
+ #ifdef TIZEN_FEATURE_OMX
+   gboolean use_buffer;
+   gboolean flush_start;
+ #endif
  
    /* Increased whenever the settings of these port change.
     * If settings_cookie != configured_settings_cookie
@@@ -368,7 -366,7 +366,7 @@@ struct _GstOMXBuffer 
    /* TRUE if this is an EGLImage */
    gboolean eglimage;
  
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
    /* MMVideoBuffer array to use TBM buffers */
     MMVideoBuffer *mm_vbuffer;
  #endif
@@@ -383,6 -381,9 +381,9 @@@ struct _GstOMXClassData 
    const gchar *default_sink_template_caps;
  
    guint32 in_port_index, out_port_index;
+ #ifdef TIZEN_FEATURE_OMX
+   guint32 in_port_usebuffer, out_port_usebuffer;
+ #endif
  
    guint64 hacks;
  
@@@ -433,9 -434,11 +434,11 @@@ OMX_ERRORTYPE     gst_omx_port_set_flus
  gboolean          gst_omx_port_is_flushing (GstOMXPort *port);
  
  OMX_ERRORTYPE     gst_omx_port_allocate_buffers (GstOMXPort *port);
- #ifdef GST_TIZEN_MODIFICATION
- OMX_ERRORTYPE     gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr  bufMgr, int eCompressionFormat);
- OMX_ERRORTYPE     gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr  bufMgr, int eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+ OMX_ERRORTYPE     gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr  bufmgr, gboolean use_buffer);
+ OMX_ERRORTYPE     gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr  bufmgr, gboolean use_buffer);
+ OMX_ERRORTYPE     gst_omx_component_get_extension_index (GstOMXComponent * comp, OMX_STRING name, gpointer index);
+ void              gst_omx_port_flush_start (GstOMXPort * port, gboolean flush);
  #endif
  OMX_ERRORTYPE     gst_omx_port_use_buffers (GstOMXPort *port, const GList *buffers);
  OMX_ERRORTYPE     gst_omx_port_use_eglimages (GstOMXPort *port, const GList *images);
@@@ -452,50 -455,6 +455,6 @@@ gboolean          gst_omx_port_is_enabl
  
  void              gst_omx_set_default_role (GstOMXClassData *class_data, const gchar *default_role);
  
- #ifdef GST_TIZEN_MODIFICATION
- /*MFC Buffer alignment macros*/
- #define S5P_FIMV_DEC_BUF_ALIGN                  (8 * 1024)
- #define S5P_FIMV_ENC_BUF_ALIGN                  (8 * 1024)
- #define S5P_FIMV_NV12M_HALIGN                   16
- #define S5P_FIMV_NV12M_LVALIGN                  16
- #define S5P_FIMV_NV12M_CVALIGN                  8
- #define S5P_FIMV_NV12MT_HALIGN                  128
- #define S5P_FIMV_NV12MT_VALIGN                  64
- #define S5P_FIMV_NV12M_SALIGN                   2048
- #define S5P_FIMV_NV12MT_SALIGN                  8192
- #define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
- /* Buffer alignment defines */
- #define SZ_1M                                   0x00100000
- #define S5P_FIMV_D_ALIGN_PLANE_SIZE             64
- #define S5P_FIMV_MAX_FRAME_SIZE                 (2 * SZ_1M)
- #define S5P_FIMV_NUM_PIXELS_IN_MB_ROW           16
- #define S5P_FIMV_NUM_PIXELS_IN_MB_COL           16
- /* Macro */
- #define ALIGN_TO_4KB(x)   ((((x) + (1 << 12) - 1) >> 12) << 12)
- #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
- #define CHOOSE_MAX_SIZE(a,b) ((a) > (b) ? (a) : (b))
- int new_calc_plane(int width, int height);
- int new_calc_yplane(int width, int height);
- int new_calc_uvplane(int width, int height);
- int calc_plane(int width, int height);
- int calc_yplane(int width, int height);
- int calc_uvplane(int width, int height);
- int gst_omx_calculate_y_size(int compressionFormat, int width, int height);
- int gst_omx_calculate_uv_size(int compressionFormat, int width, int height);
- tbm_bo            gst_omx_tbm_allocate_bo(tbm_bufmgr hBufmgr, int size);
- void              gst_omx_tbm_deallocate_bo(tbm_bo bo);
- OMX_U32           gst_omx_tbm_get_bo_fd(tbm_bo bo);
- OMX_PTR           gst_omx_tbm_get_bo_ptr(tbm_bo bo);
- #endif
  /* refered by plugin_init */
  GST_DEBUG_CATEGORY_EXTERN (gst_omx_video_debug_category);
  
diff --combined omx/gstomxaudiodec.c
index 9b84555,b6fdf34..b6fdf34
mode 100755,100644..100755
@@@ -599,9 -599,15 +599,15 @@@ component_error
  flushing:
    {
      GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+     g_mutex_lock (&self->drain_lock);
+     if (self->draining) {
+       self->draining = FALSE;
+       g_cond_broadcast (&self->drain_cond);
+     }
      gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
      self->downstream_flow_ret = GST_FLOW_FLUSHING;
      self->started = FALSE;
+     g_mutex_unlock (&self->drain_lock);
      return;
    }
  
@@@ -673,8 -679,14 +679,14 @@@ flow_error
        self->started = FALSE;
      } else if (flow_ret == GST_FLOW_FLUSHING) {
        GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+       g_mutex_lock (&self->drain_lock);
+       if (self->draining) {
+         self->draining = FALSE;
+         g_cond_broadcast (&self->drain_cond);
+       }
        gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
        self->started = FALSE;
+       g_mutex_unlock (&self->drain_lock);
      }
      GST_AUDIO_DECODER_STREAM_UNLOCK (self);
      return;
diff --combined omx/gstomxaudioenc.c
index 8724f5e,a6ba861..a6ba861
mode 100644,100644..100755
@@@ -491,9 -491,15 +491,15 @@@ component_error
  flushing:
    {
      GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+     g_mutex_lock (&self->drain_lock);
+     if (self->draining) {
+       self->draining = FALSE;
+       g_cond_broadcast (&self->drain_cond);
+     }
      gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
      self->downstream_flow_ret = GST_FLOW_FLUSHING;
      self->started = FALSE;
+     g_mutex_unlock (&self->drain_lock);
      return;
    }
  eos:
@@@ -541,8 -547,14 +547,14 @@@ flow_error
        self->started = FALSE;
      } else if (flow_ret == GST_FLOW_FLUSHING) {
        GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+       g_mutex_lock (&self->drain_lock);
+       if (self->draining) {
+         self->draining = FALSE;
+         g_cond_broadcast (&self->drain_cond);
+       }
        gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
        self->started = FALSE;
+       g_mutex_unlock (&self->drain_lock);
      }
      GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
      return;
diff --combined omx/gstomxbufferpool.c
index fa3f8e7,460c7c2..460c7c2
mode 100755,100644..100755
@@@ -395,7 -395,6 +395,6 @@@ gst_omx_buffer_pool_alloc_buffer (GstBu
      g_ptr_array_add (pool->buffers, buf);
  
      switch (GST_VIDEO_INFO_FORMAT (&pool->video_info)) {
-         GST_WARNING_OBJECT (pool, "GST_VIDEO_CAPS");
        case GST_VIDEO_FORMAT_ABGR:
        case GST_VIDEO_FORMAT_ARGB:
        case GST_VIDEO_FORMAT_RGB16:
          break;
        case GST_VIDEO_FORMAT_SN12:
        case GST_VIDEO_FORMAT_ST12:
-         GST_WARNING_OBJECT (pool, "SN12SN12SN12SN12SN12");
          offset[0] = 0;
          stride[0] = pool->port->port_def.format.video.nStride;
          offset[1] = stride[0] * pool->port->port_def.format.video.nSliceHeight;
            break;
          }
        }
        pool->need_copy = need_copy;
      }
+ #ifdef TIZEN_FEATURE_OMX
+     pool->need_copy = FALSE;
+ #endif
  
      if (pool->need_copy || pool->add_videometa) {
        /* We always add the videometa. It's the job of the user
  
    *buffer = buf;
  
+   pool->num_buffers++;
+   GST_DEBUG_OBJECT (pool, "alloc buffers : %d %d", pool->num_buffers, pool->current_buffer_index);
    pool->current_buffer_index++;
  
    return GST_FLOW_OK;
@@@ -492,6 -494,8 +494,8 @@@ gst_omx_buffer_pool_free_buffer (GstBuf
  
    GST_BUFFER_POOL_CLASS (gst_omx_buffer_pool_parent_class)->free_buffer (bpool,
        buffer);
+   GST_DEBUG_OBJECT (pool, "free buffers : %d %d", pool->num_buffers, pool->current_buffer_index);
+   pool->num_buffers--;
  }
  
  static GstFlowReturn
@@@ -509,6 -513,8 +513,8 @@@ gst_omx_buffer_pool_acquire_buffer (Gst
      buf = g_ptr_array_index (pool->buffers, pool->current_buffer_index);
      g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
      *buffer = buf;
+     pool->num_buffers--;
+     GST_DEBUG_OBJECT (pool, "acquire buffers : %d %d", pool->num_buffers, pool->current_buffer_index);
      ret = GST_FLOW_OK;
  
      /* If it's our own memory we have to set the sizes */
@@@ -545,6 -551,8 +551,8 @@@ gst_omx_buffer_pool_release_buffer (Gst
          gst_omx_buffer_data_quark);
      if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used) {
        /* Release back to the port, can be filled again */
+       pool->num_buffers++;
+       GST_DEBUG_OBJECT (pool, "release buffers : %d %d", pool->num_buffers, pool->current_buffer_index);
        err = gst_omx_port_release_buffer (pool->port, omx_buf);
        if (err != OMX_ErrorNone) {
          GST_ELEMENT_ERROR (pool->element, LIBRARY, SETTINGS, (NULL),
diff --combined omx/gstomxbufferpool.h
index 76f9680,87b27d3..87b27d3
mode 100755,100644..100755
@@@ -78,6 -78,9 +78,9 @@@ struct _GstOMXBufferPoo
     * wrapped
     */
    gint current_buffer_index;
+ #ifdef TIZEN_FEATURE_OMX
+   gint num_buffers;
+ #endif
  };
  
  struct _GstOMXBufferPoolClass
diff --combined omx/gstomxh264enc.c
index aa33ae5,b055b3c..b055b3c
mode 100644,100644..100755
@@@ -54,6 -54,10 +54,10 @@@ enu
  #ifdef USE_OMX_TARGET_RPI
    PROP_INLINESPSPPSHEADERS,
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   PROP_NUM_REF_FRAME,
+   PROP_NUM_B_FRAME,
+ #endif
    PROP_PERIODICITYOFIDRFRAMES,
    PROP_INTERVALOFCODINGINTRAFRAMES
  };
  #ifdef USE_OMX_TARGET_RPI
  #define GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT      TRUE
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+ #define GST_OMX_VIDEO_ENC_NUM_REF_FRAME_DEFAULT (0x00000001)
+ #define GST_OMX_VIDEO_ENC_NUM_REF_FRAME_MAX (0x00000002)
+ #define GST_OMX_VIDEO_ENC_NUM_B_FRAME_DEFAULT (0x00000001)
+ #define GST_OMX_VIDEO_ENC_NUM_B_FRAME_MAX (0x00000002)
+ #endif
  #define GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT    (0xffffffff)
  #define GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT (0xffffffff)
  
@@@ -98,7 -108,23 +108,23 @@@ gst_omx_h264_enc_class_init (GstOMXH264
            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
            GST_PARAM_MUTABLE_READY));
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   g_object_class_install_property (gobject_class, PROP_NUM_REF_FRAME,
+       g_param_spec_uint ("reference-frame", "set number of reference frame",
+           "The number of reference frame (0x00000001=component default)",
+           GST_OMX_VIDEO_ENC_NUM_REF_FRAME_DEFAULT, GST_OMX_VIDEO_ENC_NUM_REF_FRAME_MAX,
+           GST_OMX_VIDEO_ENC_NUM_REF_FRAME_DEFAULT,
+           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+           GST_PARAM_MUTABLE_READY));
  
+   g_object_class_install_property (gobject_class, PROP_NUM_B_FRAME,
+       g_param_spec_uint ("b-frame", "set number of b frame",
+           "The number of reference frame (0x00000001=component default)",
+           GST_OMX_VIDEO_ENC_NUM_B_FRAME_DEFAULT, GST_OMX_VIDEO_ENC_NUM_B_FRAME_MAX,
+           GST_OMX_VIDEO_ENC_NUM_B_FRAME_DEFAULT,
+           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+           GST_PARAM_MUTABLE_READY));
+ #endif
    g_object_class_install_property (gobject_class, PROP_PERIODICITYOFIDRFRAMES,
        g_param_spec_uint ("periodicty-idr", "Target Bitrate",
            "Periodicity of IDR frames (0xffffffff=component default)",
@@@ -146,6 -172,14 +172,14 @@@ gst_omx_h264_enc_set_property (GObject 
        self->inline_sps_pps_headers = g_value_get_boolean (value);
        break;
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+     case PROP_NUM_REF_FRAME:
+       self->reference_frame = g_value_get_int (value);
+       break;
+     case PROP_NUM_B_FRAME:
+       self->b_frame = g_value_get_int (value);
+       break;
+ #endif
      case PROP_PERIODICITYOFIDRFRAMES:
        self->periodicty_idr = g_value_get_uint (value);
        break;
@@@ -170,6 -204,14 +204,14 @@@ gst_omx_h264_enc_get_property (GObject 
        g_value_set_boolean (value, self->inline_sps_pps_headers);
        break;
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+     case PROP_NUM_REF_FRAME:
+       g_value_set_uint (value, self->reference_frame);
+       break;
+     case PROP_NUM_B_FRAME:
+       g_value_set_uint (value, self->b_frame);
+       break;
+ #endif
      case PROP_PERIODICITYOFIDRFRAMES:
        g_value_set_uint (value, self->periodicty_idr);
        break;
@@@ -189,6 -231,9 +231,9 @@@ gst_omx_h264_enc_init (GstOMXH264Enc * 
    self->inline_sps_pps_headers =
        GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT;
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   self->reference_frame = GST_OMX_VIDEO_ENC_NUM_REF_FRAME_DEFAULT;
+ #endif
    self->periodicty_idr =
        GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT;
    self->interval_intraframes =
@@@ -229,6 -274,9 +274,9 @@@ gst_omx_h264_enc_set_format (GstOMXVide
  #ifdef USE_OMX_TARGET_RPI
    OMX_CONFIG_PORTBOOLEANTYPE config_inline_header;
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   OMX_VIDEO_PARAM_AVCTYPE avc_param;
+ #endif
    OMX_ERRORTYPE err;
    const gchar *profile_string, *level_string;
  
      return FALSE;
    }
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   GST_OMX_INIT_STRUCT (&avc_param);
+   err =
+       gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc,
+       OMX_IndexParamVideoAvc, &avc_param);
+   if (err != OMX_ErrorNone) {
+     GST_ERROR_OBJECT (self,
+         "can't get OMX_IndexParamVideoAvc %s (0x%08x)",
+         gst_omx_error_to_string (err), err);
+     return FALSE;
+   }
+   GST_DEBUG_OBJECT (self, "default nRefFrames:%u, nBFrames:%u",
+       (guint) avc_param.nRefFrames,
+       (guint) avc_param.nBFrames);
+   avc_param.nRefFrames = self->reference_frame;
+   avc_param.nBFrames = self->b_frame;
+   err =
+       gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
+       OMX_IndexParamVideoAvc, &avc_param);
+   if (err != OMX_ErrorNone) {
+     GST_ERROR_OBJECT (self,
+         "can't set OMX_IndexParamVideoAvc %s (0x%08x)",
+         gst_omx_error_to_string (err), err);
+     return FALSE;
+   }
+ #endif
  
    if (self->periodicty_idr !=
        GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT
diff --combined omx/gstomxh264enc.h
index 03326e1,8887c84..8887c84
mode 100644,100644..100755
@@@ -49,6 -49,10 +49,10 @@@ struct _GstOMXH264En
  #ifdef USE_OMX_TARGET_RPI
    gboolean inline_sps_pps_headers;
  #endif
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   guint32 reference_frame;
+   guint32 b_frame;
+ #endif
    guint32 periodicty_idr;
    guint32 interval_intraframes;
  
diff --combined omx/gstomxvideo.c
index 9eb6769,b4b7247..b4b7247
mode 100755,100644..100755
@@@ -45,7 -45,11 +45,11 @@@ gst_omx_video_get_format_from_omx (OMX_
        format = GST_VIDEO_FORMAT_I420;
        break;
      case OMX_COLOR_FormatYUV420SemiPlanar:
+ #ifdef TIZEN_FEATURE_OMX
+       format = GST_VIDEO_FORMAT_SN12;
+ #else
        format = GST_VIDEO_FORMAT_NV12;
+ #endif
        break;
      case OMX_COLOR_FormatYUV422SemiPlanar:
        format = GST_VIDEO_FORMAT_NV16;
      case OMX_COLOR_Format16bitBGR565:
        format = GST_VIDEO_FORMAT_BGR16;
        break;
- #ifdef GST_TIZEN_MODIFICATION
-     case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+ #ifdef TIZEN_FEATURE_OMX
+     case OMX_EXT_COLOR_FormatNV12LPhysicalAddress:
        format = GST_VIDEO_FORMAT_SN12;
        break;
+     case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+       format = GST_VIDEO_FORMAT_ST12;
+       break;
  #endif
      default:
        format = GST_VIDEO_FORMAT_UNKNOWN;
diff --combined omx/gstomxvideodec.c
index 7082bb8,0cbf372..d04daf7
mode 100755,100644..100755
@@@ -46,6 -46,7 +46,7 @@@
  #pragma GCC diagnostic pop
  #endif
  
+ //#define CODEC_DEC_INTPUT_DUMP
  //#define CODEC_DEC_OUTPUT_DUMP
  #include <stdio.h>
  #include <string.h>
@@@ -84,6 -85,11 +85,11 @@@ static OMX_ERRORTYPE gst_omx_video_dec_
  static OMX_ERRORTYPE gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec
      * self);
  
+ #ifdef TIZEN_FEATURE_OMX
+ static gboolean gst_omx_video_dec_acquire_request_flush_buffer (GstOMXVideoDec * self, GstBuffer ** flush_request_buffer);
+ static gboolean gst_omx_video_dec_handle_event (GstVideoDecoder * decoder, GstEvent *event);
+ #endif
  enum
  {
    PROP_0
@@@ -124,6 -130,10 +130,10 @@@ gst_omx_video_dec_class_init (GstOMXVid
    video_decoder_class->decide_allocation =
        GST_DEBUG_FUNCPTR (gst_omx_video_dec_decide_allocation);
  
+ #ifdef TIZEN_FEATURE_OMX
+   video_decoder_class->sink_event = GST_DEBUG_FUNCPTR (gst_omx_video_dec_handle_event);
+ #endif
    klass->cdata.type = GST_OMX_COMPONENT_TYPE_FILTER;
    klass->cdata.default_src_template_caps =
  #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
  #endif
        "video/x-raw, "
        "width = " GST_VIDEO_SIZE_RANGE ", "
-       "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE;
+         "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE ", "
+       "format = (string)SN12";
  }
  
  static void
@@@ -146,8 -157,8 +157,8 @@@ gst_omx_video_dec_init (GstOMXVideoDec 
    g_mutex_init (&self->drain_lock);
    g_cond_init (&self->drain_cond);
  
- #ifdef GST_TIZEN_MODIFICATION
-   self->hTBMBufMgr = NULL;
+ #ifdef TIZEN_FEATURE_OMX
+   self->bufmgr = NULL;
    self->drm_fd = -1;
  #endif
  }
@@@ -199,20 -210,49 +210,49 @@@ gst_omx_video_dec_open (GstVideoDecode
        out_port_index = param.nStartPortNumber + 1;
      }
    }
    self->dec_in_port = gst_omx_component_add_port (self->dec, in_port_index);
    self->dec_out_port = gst_omx_component_add_port (self->dec, out_port_index);
  
    if (!self->dec_in_port || !self->dec_out_port)
      return FALSE;
  
- #ifdef GST_TIZEN_MODIFICATION
-    self->hTBMBufMgr = tbm_bufmgr_init(self->drm_fd);
-    if(self->hTBMBufMgr == NULL){
+ #ifdef TIZEN_FEATURE_OMX
+   self->bufmgr = tbm_bufmgr_init(self->drm_fd);
+   if (self->bufmgr == NULL) {
      GST_ERROR_OBJECT (self, "TBM initialization failed.");
      return FALSE;
-    }
+   }
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   {
+     /* set plateform specific gem buffer settings. */
+     OMX_ERRORTYPE err;
+     EnableGemBuffersParams gem_param;
+     OMX_INDEXTYPE index = OMX_IndexComponentStartUnused;
+     err = gst_omx_component_get_extension_index (self->dec, (OMX_STRING) EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER, &index);
+     if (err != OMX_ErrorNone) {
+       GST_WARNING_OBJECT (self, "Failed to get extension index : %s (0x%08x)",
+           gst_omx_error_to_string (err), err);
+     }
+     OMX_INIT_PARAM (gem_param);
+     gem_param.enable = OMX_TRUE;
+     gem_param.nPortIndex = 1;
+     err = gst_omx_component_set_parameter(self->dec, index, &gem_param);
+     if (err != OMX_ErrorNone) {
+       GST_ERROR_OBJECT (self, "Failed to set platform specific buffer: %s (0x%08x)",
+           gst_omx_error_to_string (err), err);
+     }
+     self->dec_in_port->use_buffer = klass->cdata.in_port_usebuffer;
+     self->dec_out_port->use_buffer = klass->cdata.out_port_usebuffer;
+   }
  #endif
+ #endif
    GST_DEBUG_OBJECT (self, "Opened decoder");
  
  #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
@@@ -293,7 -333,7 +333,7 @@@ gst_omx_video_dec_shutdown (GstOMXVideo
      }
    }
  
-   /* Otherwise we didn't use EGL and just fall back to 
+   /* Otherwise we didn't use EGL and just fall back to
     * shutting down the decoder */
  #endif
  
        gst_omx_component_get_state (self->dec, 5 * GST_SECOND);
    }
  
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
     /* uninitialize tbm buffer manager */
-    if(self->hTBMBufMgr != NULL){
-     tbm_bufmgr_deinit(self->hTBMBufMgr);
-     self->hTBMBufMgr = NULL;
+    if(self->bufmgr != NULL){
+     tbm_bufmgr_deinit(self->bufmgr);
+     self->bufmgr = NULL;
     }
  
     if(self->drm_fd != -1) {
@@@ -410,9 -450,6 +450,6 @@@ gst_omx_video_dec_change_state (GstElem
        break;
    }
  
-   if (ret == GST_STATE_CHANGE_FAILURE)
-     return ret;
    ret =
        GST_ELEMENT_CLASS (gst_omx_video_dec_parent_class)->change_state
        (element, transition);
    return ret;
  }
  
+ #ifdef CODEC_DEC_INTPUT_DUMP /* for decoder input dump */
+ static inline void
+ decoder_input_dump (GstOMXBuffer * buf, gboolean use_buffer)
+ {
+   gchar *temp;
+   gchar filename[100]={0};
+   FILE *fp = NULL;
+   temp = use_buffer ? buf->mm_vbuffer->data[0] : buf->omx_buf->pBuffer;
+   sprintf(filename, "/tmp/dec_input_dump.out");
+   fp = fopen(filename, "ab");
+   fwrite(temp, buf->omx_buf->nFilledLen, 1, fp);
+   fclose(fp);
+ }
+ #endif
  #ifdef CODEC_DEC_OUTPUT_DUMP /* for decoder output dump */
  static inline void
  decoder_output_dump(GstOMXVideoDec *self, MMVideoBuffer *outbuf)
  
    GST_ERROR_OBJECT (self, "codec dec output dump start. w = %d, h = %d", outbuf->width[0], outbuf->height[0]);
  
-   sprintf(filename, "/tmp/dec_output_dump_%d_%d.yuv", outbuf->stride_width[0], outbuf->height[0]);
+   sprintf(filename, "/tmp/dec_output_dump_%d_%d.yuv", outbuf->width[0], outbuf->height[0]);
    fp = fopen(filename, "ab");
  
    for (i = 0; i < outbuf->height[0]; i++) {
@@@ -480,7 -536,9 +536,9 @@@ gst_omx_video_dec_fill_buffer (GstOMXVi
    GstVideoInfo *vinfo = &state->info;
    OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->dec_out_port->port_def;
    gboolean ret = FALSE;
+ #ifndef TIZEN_FEATURE_OMX
    GstVideoFrame frame;
+ #endif
  
    if (vinfo->width != port_def->format.video.nFrameWidth ||
        vinfo->height != port_def->format.video.nFrameHeight) {
    }
  
    /* Same strides and everything */
- #if 0  //ENS:a
+ #ifndef TIZEN_FEATURE_OMX
    if (gst_buffer_get_size (outbuf) == inbuf->omx_buf->nFilledLen) {
      GstMapInfo map = GST_MAP_INFO_INIT;
  
  #endif  //ENS:a
  
    /* Different strides */
+ #ifndef TIZEN_FEATURE_OMX
    if (gst_video_frame_map (&frame, vinfo, outbuf, GST_MAP_WRITE)) {
-     const guint nstride = port_def->format.video.nStride;
-     const guint nslice = port_def->format.video.nSliceHeight;
-     guint src_stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, };
-     guint src_size[GST_VIDEO_MAX_PLANES] = { nstride * nslice, 0, };
-     gint dst_width[GST_VIDEO_MAX_PLANES] = { 0, };
-     gint dst_height[GST_VIDEO_MAX_PLANES] =
-         { GST_VIDEO_INFO_HEIGHT (vinfo), 0, };
-     const guint8 *src;
-     guint p;
-     switch (GST_VIDEO_INFO_FORMAT (vinfo)) {
-       case GST_VIDEO_FORMAT_ABGR:
-       case GST_VIDEO_FORMAT_ARGB:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 4;
-         break;
-       case GST_VIDEO_FORMAT_RGB16:
-       case GST_VIDEO_FORMAT_BGR16:
-       case GST_VIDEO_FORMAT_YUY2:
-       case GST_VIDEO_FORMAT_UYVY:
-       case GST_VIDEO_FORMAT_YVYU:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 2;
-         break;
-       case GST_VIDEO_FORMAT_GRAY8:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
-         break;
-       case GST_VIDEO_FORMAT_I420:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
-         src_stride[1] = nstride / 2;
-         src_size[1] = (src_stride[1] * nslice) / 2;
-         dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo) / 2;
-         dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
-         src_stride[2] = nstride / 2;
-         src_size[2] = (src_stride[1] * nslice) / 2;
-         dst_width[2] = GST_VIDEO_INFO_WIDTH (vinfo) / 2;
-         dst_height[2] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
-         break;
-       case GST_VIDEO_FORMAT_NV12:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
-         src_stride[1] = nstride;
-         src_size[1] = src_stride[1] * nslice / 2;
-         dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
-         dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
-         break;
-       case GST_VIDEO_FORMAT_NV16:
-         dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
-         src_stride[1] = nstride;
-         src_size[1] = src_stride[1] * nslice;
-         dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
-         dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo);
-         break;
-       case GST_VIDEO_FORMAT_SN12:
-       case GST_VIDEO_FORMAT_ST12:{
-         GstMemory *mem_imgb = NULL;
-         void *imgb_data = NULL;
- #ifdef GST_TIZEN_MODIFICATION
-         MMVideoBuffer *mm_vbuffer = NULL;
-         mm_vbuffer = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer);
-         mm_vbuffer->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
-         if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
-           GST_LOG_OBJECT (self, "dec output buf: fd[0]:%d  fd[1]:%d fd[2]:%d  w[0]:%d h[0]:%d  buf_share_method:%d",
-                   mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2],
-                   mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type);
-         } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) {
-           GST_LOG_OBJECT (self, "dec output uses hw addr");
-         } else {
-           GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method");
-         }
+   const guint nstride = port_def->format.video.nStride;
+   const guint nslice = port_def->format.video.nSliceHeight;
+   guint src_stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, };
+   guint src_size[GST_VIDEO_MAX_PLANES] = { nstride * nslice, 0, };
+   gint dst_width[GST_VIDEO_MAX_PLANES] = { 0, };
+   gint dst_height[GST_VIDEO_MAX_PLANES] =
+       { GST_VIDEO_INFO_HEIGHT (vinfo), 0, };
+   const guint8 *src;
+   guint p;
+ #endif
+   switch (GST_VIDEO_INFO_FORMAT (vinfo)) {
+ #ifndef TIZEN_FEATURE_OMX
+     case GST_VIDEO_FORMAT_ABGR:
+     case GST_VIDEO_FORMAT_ARGB:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 4;
+       break;
+     case GST_VIDEO_FORMAT_RGB16:
+     case GST_VIDEO_FORMAT_BGR16:
+     case GST_VIDEO_FORMAT_YUY2:
+     case GST_VIDEO_FORMAT_UYVY:
+     case GST_VIDEO_FORMAT_YVYU:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 2;
+       break;
+     case GST_VIDEO_FORMAT_GRAY8:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
+       break;
+     case GST_VIDEO_FORMAT_I420:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
+       src_stride[1] = nstride / 2;
+       src_size[1] = (src_stride[1] * nslice) / 2;
+       dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo) / 2;
+       dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
+       src_stride[2] = nstride / 2;
+       src_size[2] = (src_stride[1] * nslice) / 2;
+       dst_width[2] = GST_VIDEO_INFO_WIDTH (vinfo) / 2;
+       dst_height[2] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
+       break;
+     case GST_VIDEO_FORMAT_NV12:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
+       src_stride[1] = nstride;
+       src_size[1] = src_stride[1] * nslice / 2;
+       dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
+       dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2;
+       break;
+     case GST_VIDEO_FORMAT_NV16:
+       dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
+       src_stride[1] = nstride;
+       src_size[1] = src_stride[1] * nslice;
+       dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
+       dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo);
+       break;
+ #endif
+ #ifdef TIZEN_FEATURE_OMX
+     case GST_VIDEO_FORMAT_SN12:
+     case GST_VIDEO_FORMAT_ST12: {
+       GstMemory *mem = NULL;
+       void *data = NULL;
+       MMVideoBuffer *mm_vbuffer = NULL;
+       mm_vbuffer = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer);
+       if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
+         GST_LOG_OBJECT (self, "dec output buf: bo[0] :%p, bo[1] : %p, fd[0]:%d  fd[1]:%d fd[2]:%d  w[0]:%d h[0]:%d  buf_share_method:%d",
+             mm_vbuffer->handle.bo[0], mm_vbuffer->handle.bo[1], mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2],
+             mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type);
+       } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) {
+         GST_LOG_OBJECT (self, "dec output uses hw addr");
+       } else {
+         GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method");
+       }
  #ifdef CODEC_DEC_OUTPUT_DUMP
-        decoder_output_dump(self, mm_vbuffer);
- #endif
- #endif
-         if (gst_buffer_n_memory(outbuf) < 2) {
-             imgb_data = g_malloc0(sizeof(*mm_vbuffer));
-             mem_imgb = gst_memory_new_wrapped(0, imgb_data, sizeof(*mm_vbuffer), 0, sizeof(*mm_vbuffer), imgb_data, g_free);
-             gst_buffer_append_memory(outbuf, mem_imgb);
-         } else {
-             GstMapInfo imgb_info = GST_MAP_INFO_INIT;
-             mem_imgb = gst_buffer_peek_memory(outbuf, 1);
-             gst_memory_map(mem_imgb, &imgb_info, GST_MAP_WRITE);
-             imgb_data = imgb_info.data;
-             gst_memory_unmap(mem_imgb, &imgb_info);
-         }
- #ifdef GST_TIZEN_MODIFICATION
-         memcpy(imgb_data, mm_vbuffer, sizeof(MMVideoBuffer));
+      decoder_output_dump(self, mm_vbuffer);
  #endif
-         ret = TRUE;
-         break;
+       if (gst_buffer_n_memory (outbuf) < 2) {
+         data = g_malloc0 (sizeof (MMVideoBuffer));
+         mem = gst_memory_new_wrapped (0, data, sizeof (MMVideoBuffer), 0, sizeof (MMVideoBuffer), data, g_free);
+         gst_buffer_append_memory (outbuf, mem);
+       } else {
+         GstMapInfo info = GST_MAP_INFO_INIT;
+         mem = gst_buffer_peek_memory (outbuf, 1);
+         gst_memory_map (mem, &info, GST_MAP_WRITE);
+         data = info.data;
+         gst_memory_unmap (mem, &info);
+       }
+       memcpy (data, mm_vbuffer, sizeof (MMVideoBuffer));
+       ret = TRUE;
+       break;
      }
+ #endif
  
        default:
          g_assert_not_reached ();
          break;
      }
+ #ifndef TIZEN_FEATURE_OMX
      src = inbuf->omx_buf->pBuffer + inbuf->omx_buf->nOffset;
      for (p = 0; p < GST_VIDEO_INFO_N_PLANES (vinfo); p++) {
        const guint8 *data;
        }
        src += src_size[p];
      }
+ #endif
  
+ #ifndef TIZEN_FEATURE_OMX
      gst_video_frame_unmap (&frame);
      ret = TRUE;
    } else {
      GST_ERROR_OBJECT (self, "Can't map output buffer to frame");
      goto done;
    }
+ #endif
  
  done:
    if (ret) {
@@@ -890,9 -954,8 +954,8 @@@ gst_omx_video_dec_allocate_output_buffe
        }
        was_enabled = FALSE;
      }
- #ifdef GST_TIZEN_MODIFICATION
-     err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr,
-       self->dec_in_port->port_def.format.video.eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+     err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
  #else
      err = gst_omx_port_allocate_buffers (port);
  #endif
            goto done;
          }
        }
- #ifdef GST_TIZEN_MODIFICATION
-       err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr,
-           self->dec_in_port->port_def.format.video.eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+       err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
  #else
        err = gst_omx_port_allocate_buffers (port);
  #endif
@@@ -1359,9 -1421,13 +1421,19 @@@ gst_omx_video_dec_loop (GstOMXVideoDec 
    GstOMXAcquireBufferReturn acq_return;
    GstClockTimeDiff deadline;
    OMX_ERRORTYPE err;
+ #ifdef TIZEN_FEATURE_OMX
+   GstBuffer *flush_request_buffer = NULL;
+   GstMessage *msg = NULL;
+ #endif
+ #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
+   port = self->eglimage ? self->egl_out_port : self->dec_out_port;
++#else
++  port = self->dec_out_port;
++#endif
 +
 +#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
 +  port = self->eglimage ? self->egl_out_port : self->dec_out_port;
  #else
    port = self->dec_out_port;
  #endif
      /* Reallocate all buffers */
      if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE
          && gst_omx_port_is_enabled (port)) {
+ #ifdef TIZEN_FEATURE_OMX
+       if (gst_omx_video_dec_acquire_request_flush_buffer (self, &flush_request_buffer)) {
+         flow_ret = gst_pad_push (GST_VIDEO_DECODER_SRC_PAD (self), flush_request_buffer);
+         if (flow_ret != GST_FLOW_OK) {
+           gst_buffer_unref (flush_request_buffer);
+           flush_request_buffer = NULL;
+           goto reconfigure_error;
+         }
+       }
+ #endif
        err = gst_omx_port_set_enabled (port, FALSE);
        if (err != OMX_ErrorNone)
          goto reconfigure_error;
        err = gst_omx_video_dec_reconfigure_output_port (self);
        if (err != OMX_ErrorNone)
          goto reconfigure_error;
+ #ifdef TIZEN_FEATURE_OMX
+       msg = gst_message_new_element (GST_OBJECT_CAST (self), gst_structure_new ("prepare-decode-buffers",
+                                  "num_buffers", G_TYPE_INT, self->dec_out_port->port_def.nBufferCountActual,
+                                  "extra_num_buffers", G_TYPE_INT, EXTRA_DECODER_OUTPUT_BUF, NULL));
+       gst_element_post_message (GST_ELEMENT_CAST (self), msg);
+ #endif
      } else {
        /* Just update caps */
        GST_VIDEO_DECODER_STREAM_LOCK (self);
              copy_frame (&GST_OMX_BUFFER_POOL (self->out_port_pool)->video_info,
              outbuf);
  
-       buf = NULL;
      } else {
        outbuf =
            gst_video_decoder_allocate_output_buffer (GST_VIDEO_DECODER (self));
          goto invalid_buffer;
        }
      }
+ #ifdef TIZEN_FEATURE_OMX
+     {
+       MMVideoBuffer *mm_vbuffer = NULL;
+       GstMemory *mem = NULL;
+       guint8 *data = NULL;
+       mm_vbuffer = (MMVideoBuffer*)(buf->omx_buf->pBuffer);
+       if (gst_buffer_n_memory (outbuf) < 2) {
+         data = g_malloc0 (sizeof (MMVideoBuffer));
+         mem = gst_memory_new_wrapped (0, data, sizeof(MMVideoBuffer), 0, sizeof(MMVideoBuffer), data, g_free);
+         gst_buffer_append_memory (outbuf, mem);
+       } else {
+         GstMapInfo info = GST_MAP_INFO_INIT;
+         mem = gst_buffer_peek_memory (outbuf, 1);
+         gst_memory_map (mem, &info, GST_MAP_WRITE);
+         data = info.data;
+         gst_memory_unmap (mem, &info);
+       }
+       memcpy(data, mm_vbuffer, sizeof(MMVideoBuffer));
+       buf = NULL;
  
+       if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
+         GST_LOG_OBJECT (self, "frame not found: bo[0] :%p, bo[1] : %p, fd[0]:%d  fd[1]:%d fd[2]:%d  w[0]:%d h[0]:%d  buf_share_method:%d",
+             mm_vbuffer->handle.bo[0], mm_vbuffer->handle.bo[1], mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2],
+             mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type);
+       } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) {
+         GST_LOG_OBJECT (self, "dec output uses hw addr");
+       } else {
+         GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method");
+       }
+     }
+ #endif
      flow_ret = gst_pad_push (GST_VIDEO_DECODER_SRC_PAD (self), outbuf);
    } else if (buf->omx_buf->nFilledLen > 0 || buf->eglimage) {
      if (self->out_port_pool) {
        gint i, n;
-       GstBuffer *outbuf;
+       GstBuffer *outbuf = NULL;
        GstBufferPoolAcquireParams params = { 0, };
  
        n = port->buffers->len;
        frame = NULL;
        buf = NULL;
        } else {
-           if(!gst_omx_video_dec_fill_buffer (self, buf, frame->output_buffer)) {
-               gst_buffer_replace (&frame->output_buffer, NULL);
-               flow_ret =
-                   gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
-               frame = NULL;
-               gst_omx_port_release_buffer (port, buf);
-               goto invalid_buffer;
-           }
+         if (!gst_omx_video_dec_fill_buffer (self, buf, frame->output_buffer)) {
+           gst_buffer_replace (&frame->output_buffer, NULL);
            flow_ret =
-               gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
+               gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
            frame = NULL;
-           buf = NULL;
+           gst_omx_port_release_buffer (port, buf);
+           goto invalid_buffer;
+         }
+         flow_ret =
+             gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
+         frame = NULL;
+         buf = NULL;
        }
      } else {
        if ((flow_ret =
@@@ -1657,9 -1772,15 +1778,15 @@@ component_error
  flushing:
    {
      GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+     g_mutex_lock (&self->drain_lock);
+     if (self->draining) {
+       self->draining = FALSE;
+       g_cond_broadcast (&self->drain_cond);
+     }
      gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
      self->downstream_flow_ret = GST_FLOW_FLUSHING;
      self->started = FALSE;
+     g_mutex_unlock (&self->drain_lock);
      return;
    }
  
@@@ -1717,8 -1838,14 +1844,14 @@@ flow_error
        self->started = FALSE;
      } else if (flow_ret == GST_FLOW_FLUSHING) {
        GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+       g_mutex_lock (&self->drain_lock);
+       if (self->draining) {
+         self->draining = FALSE;
+         g_cond_broadcast (&self->drain_cond);
+       }
        gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
        self->started = FALSE;
+       g_mutex_unlock (&self->drain_lock);
      }
      GST_VIDEO_DECODER_STREAM_UNLOCK (self);
      return;
@@@ -1844,11 -1971,10 +1977,10 @@@ gst_omx_video_dec_negotiate (GstOMXVide
    GstCaps *templ_caps, *intersection;
    GstVideoFormat format;
    GstStructure *s;
-   const gchar *format_str;
- #ifdef GST_TIZEN_MODIFICATION
-   gchar *format_tmp;
+   const gchar *format_str = NULL;
+ #ifdef TIZEN_FEATURE_OMX
+   const gchar *format_tmp;
    int i;
-   EnableGemBuffersParams gemBuffers;
  #endif
  
    GST_DEBUG_OBJECT (self, "Trying to negotiate a video format with downstream");
      return FALSE;
    }
  
-   for(i=0; i<gst_caps_get_size(intersection); i++)
+ #ifdef TIZEN_FEATURE_OMX
+   for(i = 0; i < gst_caps_get_size (intersection); i++)
    {
        s = gst_caps_get_structure (intersection, i);
-       format_tmp = gst_structure_get_string (s, "format");
+       if ((format_tmp = gst_structure_get_string (s, "format"))) {
  
-       if(!strncmp(format_tmp, "S", 1)) {
+         if (!strncmp (format_tmp, "S", 1)) {
            format_str = format_tmp;
            GST_DEBUG_OBJECT (self, "SEC format found");
            break;
+         }
        }
    }
  
-   if(!format_str) {
+   if (!format_str) {
      intersection = gst_caps_truncate (intersection);
      intersection = gst_caps_fixate (intersection);
  
      format_str = gst_structure_get_string (s, "format");
      GST_DEBUG_OBJECT (self, "first structure will be fixated");
    }
+ #endif
  
    if (!format_str ||
        (format =
          gst_omx_error_to_string (err), err);
    }
  
-   /* set plateform specific gem buffer settings. */
-     /* Set platform specific buffer settings. to avoid plane support error.. */
- #ifdef GST_TIZEN_MODIFICATION
-     OMX_INIT_STRUCTURE(gemBuffers);
-     gemBuffers.enable = OMX_TRUE;
-     gemBuffers.nPortIndex = 1;
-       err =
-       gst_omx_component_set_parameter (self->dec,
-       OMX_IndexParamEnablePlatformSpecificBuffers,&gemBuffers);
-   if (err != OMX_ErrorNone) {
-     GST_ERROR_OBJECT (self, "Failed to set video port format: %s (0x%08x)",
-         gst_omx_error_to_string (err), err);
-   }
- #endif
    gst_caps_unref (intersection);
    return (err == OMX_ErrorNone);
  }
@@@ -2034,6 -2148,9 +2154,9 @@@ gst_omx_video_dec_set_format (GstVideoD
        if (!gst_omx_video_dec_open (GST_VIDEO_DECODER (self)))
          return FALSE;
        needs_disable = FALSE;
+ #ifdef TIZEN_FEATURE_OMX
+       gst_omx_port_get_port_definition (self->dec_in_port, &port_def);
+ #endif
      } else {
  #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
        if (self->eglimage) {
          gst_omx_port_set_flushing (self->egl_out_port, 5 * GST_SECOND, TRUE);
        }
  #endif
        if (gst_omx_port_set_enabled (self->dec_in_port, FALSE) != OMX_ErrorNone)
          return FALSE;
-       if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone)
-         return FALSE;
        if (gst_omx_port_wait_buffers_released (self->dec_in_port,
                5 * GST_SECOND) != OMX_ErrorNone)
          return FALSE;
-       if (gst_omx_port_wait_buffers_released (out_port,
-               1 * GST_SECOND) != OMX_ErrorNone)
-         return FALSE;
        if (gst_omx_port_deallocate_buffers (self->dec_in_port) != OMX_ErrorNone)
          return FALSE;
-       if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone)
-         return FALSE;
        if (gst_omx_port_wait_enabled (self->dec_in_port,
                1 * GST_SECOND) != OMX_ErrorNone)
          return FALSE;
-       if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone)
+ #ifndef TIZEN_FEATURE_OMX
+       if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone)
+         return FALSE;
+       if (gst_omx_port_wait_buffers_released (out_port,
+               1 * GST_SECOND) != OMX_ErrorNone)
          return FALSE;
  
+       if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone)
+         return FALSE;
+       if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone)
+         return FALSE;
+ #endif
  #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
        if (self->eglimage) {
          OMX_STATETYPE egl_state;
    if (needs_disable) {
      if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone)
        return FALSE;
- #ifdef GST_TIZEN_MODIFICATION
-     if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+     if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
+         self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
       return FALSE;
  #else
      if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
        return FALSE;
  #endif
+ #ifndef TIZEN_FEATURE_OMX
      if ((klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) {
        if (gst_omx_port_set_enabled (self->dec_out_port, TRUE) != OMX_ErrorNone)
          return FALSE;
                5 * GST_SECOND) != OMX_ErrorNone)
          return FALSE;
      }
+ #endif
      if (gst_omx_port_wait_enabled (self->dec_in_port,
              5 * GST_SECOND) != OMX_ErrorNone)
        return FALSE;
      if (gst_omx_port_mark_reconfigured (self->dec_in_port) != OMX_ErrorNone)
        return FALSE;
    } else {
        GST_LOG_OBJECT (self, "Negotiation failed, will get output format later");
  
      if (!(klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) {
- #ifndef GST_TIZEN_MODIFICATION
        /* Disable output port */
        if (gst_omx_port_set_enabled (self->dec_out_port, FALSE) != OMX_ErrorNone)
          return FALSE;
        if (gst_omx_port_wait_enabled (self->dec_out_port,
                1 * GST_SECOND) != OMX_ErrorNone)
          return FALSE;
- #endif
        if (gst_omx_component_set_state (self->dec,
                OMX_StateIdle) != OMX_ErrorNone)
          return FALSE;
  
        /* Need to allocate buffers to reach Idle state */
- #ifdef GST_TIZEN_MODIFICATION
-       if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+       if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
+           self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
            return FALSE;
-       if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_out_port, self->hTBMBufMgr,
-           self->dec_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+       if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port,
+           self->bufmgr, self->dec_out_port->use_buffer) != OMX_ErrorNone)
            return FALSE;
  #else
        if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
          return FALSE;
  
        /* Need to allocate buffers to reach Idle state */
- #ifdef GST_TIZEN_MODIFICATION
-       if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+       if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
+           self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
            return FALSE;
-       if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_out_port, self->hTBMBufMgr,
-           self->dec_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+       if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port,
+           self->bufmgr, self->dec_out_port->use_buffer) != OMX_ErrorNone)
            return FALSE;
  #else
        if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
@@@ -2422,9 -2548,8 +2554,8 @@@ gst_omx_video_dec_handle_frame (GstVide
          GST_VIDEO_DECODER_STREAM_LOCK (self);
          goto reconfigure_error;
        }
- #ifdef GST_TIZEN_MODIFICATION
-       err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr,
-           self->dec_in_port->port_def.format.video.eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+       err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
  #else
        err = gst_omx_port_allocate_buffers (port);
  #endif
        buf->omx_buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
        buf->omx_buf->nFilledLen = gst_buffer_get_size (codec_data);;
  
- #ifdef GST_TIZEN_MODIFICATION
-       gst_buffer_extract (codec_data, 0,
-           buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
-           buf->omx_buf->nFilledLen);
- #else
-       gst_buffer_extract (codec_data, 0,
-           buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
-           buf->omx_buf->nFilledLen);
+ #ifdef TIZEN_FEATURE_OMX
+       if (port->use_buffer) {
+         gst_buffer_extract (codec_data, 0,
+             (OMX_U8 *) buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
+             buf->omx_buf->nFilledLen);
+       } else {
+         gst_buffer_extract (codec_data, 0,
+             buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
+             buf->omx_buf->nFilledLen);
+       }
+ #ifdef CODEC_DEC_INTPUT_DUMP
+       decoder_input_dump (buf, port->use_buffer);
+ #endif
  #endif
  
        if (GST_CLOCK_TIME_IS_VALID (timestamp))
       * by the port */
      buf->omx_buf->nFilledLen =
          MIN (size - offset, buf->omx_buf->nAllocLen - buf->omx_buf->nOffset);
-     GST_DEBUG_OBJECT (self, "nFilledLen %d, %p", buf->omx_buf->nFilledLen, buf->omx_buf->pBuffer);
+     GST_DEBUG_OBJECT (self, "nFilledLen %lu, %p", buf->omx_buf->nFilledLen, buf->omx_buf->pBuffer);
  
- #ifdef GST_TIZEN_MODIFICATION
-      gst_buffer_extract (frame->input_buffer, offset,
-           buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
+ #ifdef TIZEN_FEATURE_OMX
+     if (port->use_buffer) {
+       gst_buffer_extract (frame->input_buffer, offset,
+           (OMX_U8 *) buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
            buf->omx_buf->nFilledLen);
- #else
-     gst_buffer_extract (frame->input_buffer, offset,
-         buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
-         buf->omx_buf->nFilledLen);
+     } else {
+       gst_buffer_extract (frame->input_buffer, offset,
+           buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
+           buf->omx_buf->nFilledLen);
+     }
+ #ifdef CODEC_DEC_INTPUT_DUMP
+       decoder_input_dump (buf, port->use_buffer);
+ #endif
  #endif
      if (timestamp != GST_CLOCK_TIME_NONE) {
        buf->omx_buf->nTimeStamp =
            gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
@@@ -2780,3 -2914,72 +2920,72 @@@ gst_omx_video_dec_decide_allocation (Gs
  
    return TRUE;
  }
+ #ifdef TIZEN_FEATURE_OMX
+ static gboolean
+ gst_omx_video_dec_acquire_request_flush_buffer (GstOMXVideoDec * self, GstBuffer ** flush_request_buffer)
+ {
+   guint8 *dummy_data = NULL;
+   GstBuffer *buf = NULL;
+   MMVideoBuffer *mm_vbuffer = NULL;
+   GST_DEBUG_OBJECT (self, "flush buffer request");
+   if (self->out_port_pool) {
+     if (gst_buffer_pool_is_active(self->out_port_pool)) {
+       dummy_data = g_malloc0(128*128);
+       buf = gst_buffer_new_wrapped(dummy_data, 128*128);
+       mm_vbuffer = g_malloc(sizeof(MMVideoBuffer));
+       mm_vbuffer->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
+       mm_vbuffer->size[0] = 0;
+       mm_vbuffer->flush_request = TRUE;
+       gst_buffer_append_memory(buf,
+         gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, mm_vbuffer, sizeof(MMVideoBuffer), 0,
+           sizeof(MMVideoBuffer), mm_vbuffer, g_free));
+       *flush_request_buffer = buf;
+       GST_DEBUG_OBJECT (self, "flush buffer requested");
+       return TRUE;
+     } else {
+         GST_DEBUG_OBJECT (self, "the out port pool has not yet been activated");
+         return FALSE;
+     }
+   } else {
+     GST_DEBUG_OBJECT (self, "the output port has not yet been activated");
+     return FALSE;
+   }
+ }
+ static gboolean
+ gst_omx_video_dec_handle_event (GstVideoDecoder * decoder,
+     GstEvent * event)
+ {
+   GstOMXVideoDec *self;
+   self = GST_OMX_VIDEO_DEC (decoder);
+   GST_DEBUG_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
+   switch (GST_EVENT_TYPE (event)) {
+     case GST_EVENT_FLUSH_START:
+     {
+       gst_omx_port_flush_start (self->dec_in_port, TRUE);
+       gst_omx_port_flush_start (self->dec_out_port, TRUE);
+       break;
+     }
+     case GST_EVENT_FLUSH_STOP:
+     {
+       gst_omx_port_flush_start (self->dec_in_port, FALSE);
+       gst_omx_port_flush_start (self->dec_out_port, FALSE);
+       break;
+     }
+     default:
+       break;
+   }
+   return GST_VIDEO_DECODER_CLASS (gst_omx_video_dec_parent_class)->sink_event (decoder, event);
+ }
+ #endif
diff --combined omx/gstomxvideodec.h
index 4e41796,fd08a83..fd08a83
mode 100644,100644..100755
  
  #include "gstomx.h"
  
- #define OMX_VERSION_MAJOR 1
- #define OMX_VERSION_MINOR 1
- #define OMX_VERSION_REVISION 2
- #define OMX_VERSION_STEP 0
- #define OMX_VERSION ((OMX_VERSION_STEP<<24) | (OMX_VERSION_REVISION<<16) | (OMX_VERSION_MINOR<<8) | OMX_VERSION_MAJOR)
- #define OMX_INIT_STRUCTURE(a) \
-     memset(&(a), 0, sizeof(a)); \
-     (a).nSize = sizeof(a); \
-     (a).nVersion.nVersion = OMX_VERSION; \
-     (a).nVersion.s.nVersionMajor = OMX_VERSION_MAJOR; \
-     (a).nVersion.s.nVersionMinor = OMX_VERSION_MINOR; \
-     (a).nVersion.s.nRevision = OMX_VERSION_REVISION; \
-     (a).nVersion.s.nStep = OMX_VERSION_STEP
  G_BEGIN_DECLS
  
  #define GST_TYPE_OMX_VIDEO_DEC \
@@@ -62,6 -46,8 +46,8 @@@
  #define GST_IS_OMX_VIDEO_DEC_CLASS(obj) \
    (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_DEC))
  
+ #define EXTRA_DECODER_OUTPUT_BUF 4
  typedef struct _GstOMXVideoDec GstOMXVideoDec;
  typedef struct _GstOMXVideoDecClass GstOMXVideoDecClass;
  
@@@ -72,7 -58,7 +58,7 @@@ struct _GstOMXVideoDe
    /* < protected > */
    GstOMXComponent *dec;
    GstOMXPort *dec_in_port, *dec_out_port;
-   
    GstBufferPool *in_port_pool, *out_port_pool;
  
    /* < private > */
@@@ -91,9 -77,9 +77,9 @@@
    gboolean draining;
  
    GstFlowReturn downstream_flow_ret;
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
    gint drm_fd;
-   tbm_bufmgr hTBMBufMgr;
+   tbm_bufmgr bufmgr;
  #endif
  #ifdef USE_OMX_TARGET_RPI
    GstOMXComponent *egl_render;
diff --combined omx/gstomxvideoenc.c
index 5c1d7fc,0c84e6f..0c84e6f
mode 100644,100644..100755
  #include <OMX_Index.h>
  #endif
  
+ //#define CODEC_ENC_INPUT_DUMP
  GST_DEBUG_CATEGORY_STATIC (gst_omx_video_enc_debug_category);
  #define GST_CAT_DEFAULT gst_omx_video_enc_debug_category
  
  #define GST_TYPE_OMX_VIDEO_ENC_CONTROL_RATE (gst_omx_video_enc_control_rate_get_type ())
+ #ifdef CODEC_ENC_INPUT_DUMP
+ #include <stdio.h>
+ #endif
  static GType
  gst_omx_video_enc_control_rate_get_type (void)
  {
@@@ -110,6 -116,7 +116,7 @@@ enu
  #define GST_OMX_VIDEO_ENC_QUANT_P_FRAMES_DEFAULT (0xffffffff)
  #define GST_OMX_VIDEO_ENC_QUANT_B_FRAMES_DEFAULT (0xffffffff)
  
  /* class initialization */
  
  #define DEBUG_INIT \
@@@ -204,12 -211,42 +211,42 @@@ gst_omx_video_enc_init (GstOMXVideoEnc 
  
    g_mutex_init (&self->drain_lock);
    g_cond_init (&self->drain_cond);
- #ifdef GST_TIZEN_MODIFICATION
-   self->hTBMBufMgr = NULL;
+ #ifdef TIZEN_FEATURE_OMX
+   self->bufmgr = NULL;
    self->drm_fd = -1;
  #endif
  }
  
+ #ifdef CODEC_ENC_INPUT_DUMP
+ static inline void
+ gst_omx_video_enc_input_dump (MMVideoBuffer *inbuf)
+ {
+   char *temp = (char *)inbuf->data[0];
+   int i = 0;
+   char filename[100]={0};
+   FILE *fp = NULL;
+   GST_WARNING ("codec enc input dump start. w = %d, h = %d", inbuf->width[0], inbuf->height[0]);
+   sprintf(filename, "/tmp/enc_input_dump_%d_%d.yuv", inbuf->width[0], inbuf->height[0]);
+   fp = fopen(filename, "ab");
+   for (i = 0; i < inbuf->height[0]; i++) {
+       fwrite(temp, inbuf->width[0], 1, fp);
+       temp += inbuf->stride_width[0];
+   }
+   temp = (char*)inbuf->data[1];
+   for(i = 0; i < inbuf->height[1] ; i++) {
+       fwrite(temp, inbuf->width[1], 1, fp);
+       temp += inbuf->stride_width[1];
+   }
+   GST_WARNING ("codec encoder input dumped!!");
+   fclose(fp);
+ }
+ #endif
  static gboolean
  gst_omx_video_enc_open (GstVideoEncoder * encoder)
  {
    self->enc_in_port = gst_omx_component_add_port (self->enc, in_port_index);
    self->enc_out_port = gst_omx_component_add_port (self->enc, out_port_index);
  
    if (!self->enc_in_port || !self->enc_out_port)
      return FALSE;
  
        }
      }
    }
- #ifdef GST_TIZEN_MODIFICATION
-    self->hTBMBufMgr = tbm_bufmgr_init(self->drm_fd);
-    if(self->hTBMBufMgr == NULL){
+ #ifdef TIZEN_FEATURE_OMX
+    self->bufmgr = tbm_bufmgr_init (self->drm_fd);
+    if (self->bufmgr == NULL){
      GST_ERROR_OBJECT (self, "TBM initialization failed.");
      return FALSE;
     }
+   self->enc_in_port->use_buffer = klass->cdata.in_port_usebuffer;
+   self->enc_out_port->use_buffer = klass->cdata.out_port_usebuffer;
+   /* get extension index and set platform specific buffer enable */
+ #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
+   {
+     OMX_ERRORTYPE err;
+     OMX_INDEXTYPE index = OMX_IndexComponentStartUnused;
+     EnableGemBuffersParams gem_param;
+     err = gst_omx_component_get_extension_index (self->enc, (OMX_STRING) EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER, &index);
+     if (err != OMX_ErrorNone) {
+       GST_WARNING_OBJECT (self, "Failed to get extension index : %s (0x%08x)",
+           gst_omx_error_to_string (err), err);
+     }
+     OMX_INIT_PARAM (gem_param);
+     gem_param.enable = OMX_TRUE;
+     gem_param.nPortIndex = 0;
+     err = gst_omx_component_set_parameter (self->enc, index, &gem_param);
+     if (err != OMX_ErrorNone) {
+       GST_ERROR_OBJECT (self, "Failed to set platform specific buffer: %s (0x%08x)",
+           gst_omx_error_to_string (err), err);
+     }
+   }
+ #endif
  #endif
    return TRUE;
  }
@@@ -524,9 -592,6 +592,6 @@@ gst_omx_video_enc_change_state (GstElem
        break;
    }
  
-   if (ret == GST_STATE_CHANGE_FAILURE)
-     return ret;
    ret =
        GST_ELEMENT_CLASS (gst_omx_video_enc_parent_class)->change_state (element,
        transition);
@@@ -582,11 -647,20 +647,20 @@@ gst_omx_video_enc_handle_output_frame (
          self->input_state);
      state->codec_data = codec_data;
      gst_video_codec_state_unref (state);
+ #ifdef TIZEN_FEATURE_OMX
+     /*Modification : codec data already set_caps, so unref frame whenever negotiate ok or not*/
+     if (!gst_video_encoder_negotiate (GST_VIDEO_ENCODER (self)))
+       flow_ret = GST_FLOW_NOT_NEGOTIATED;
+     else
+       flow_ret = GST_FLOW_OK;
+     gst_video_codec_frame_unref (frame);
+ #else
      if (!gst_video_encoder_negotiate (GST_VIDEO_ENCODER (self))) {
        gst_video_codec_frame_unref (frame);
        return GST_FLOW_NOT_NEGOTIATED;
      }
      flow_ret = GST_FLOW_OK;
+ #endif
    } else if (buf->omx_buf->nFilledLen > 0) {
      GstBuffer *outbuf;
      GstMapInfo map = GST_MAP_INFO_INIT;
@@@ -720,9 -794,8 +794,8 @@@ gst_omx_video_enc_loop (GstOMXVideoEnc 
        err = gst_omx_port_set_enabled (port, TRUE);
        if (err != OMX_ErrorNone)
          goto reconfigure_error;
- #ifdef GST_TIZEN_MODIFICATION
-     err = gst_omx_port_tbm_allocate_enc_buffers(port, self->hTBMBufMgr,
-         self->enc_in_port->port_def.format.video.eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+     err = gst_omx_port_tbm_allocate_enc_buffers(port, self->bufmgr, port->use_buffer);
  #else
        err = gst_omx_port_allocate_buffers (port);
  #endif
@@@ -802,9 -875,15 +875,15 @@@ component_error
  flushing:
    {
      GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+     g_mutex_lock (&self->drain_lock);
+     if (self->draining) {
+       self->draining = FALSE;
+       g_cond_broadcast (&self->drain_cond);
+     }
      gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
      self->downstream_flow_ret = GST_FLOW_FLUSHING;
      self->started = FALSE;
+     g_mutex_unlock (&self->drain_lock);
      return;
    }
  
@@@ -853,8 -932,14 +932,14 @@@ flow_error
        self->started = FALSE;
      } else if (flow_ret == GST_FLOW_FLUSHING) {
        GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
+       g_mutex_lock (&self->drain_lock);
+       if (self->draining) {
+         self->draining = FALSE;
+         g_cond_broadcast (&self->drain_cond);
+       }
        gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
        self->started = FALSE;
+       g_mutex_unlock (&self->drain_lock);
      }
      GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
      return;
@@@ -1024,6 -1109,9 +1109,9 @@@ gst_omx_video_enc_set_format (GstVideoE
        case GST_VIDEO_FORMAT_NV12:
          port_def.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
          break;
+       case GST_VIDEO_FORMAT_SN12:
+         port_def.format.video.eColorFormat = OMX_EXT_COLOR_FormatNV12LPhysicalAddress;
+         break;
        default:
          GST_ERROR_OBJECT (self, "Unsupported format %s",
              gst_video_format_to_string (info->finfo->format));
    }
  
    port_def.format.video.nFrameWidth = info->width;
+ #ifdef TIZEN_FEATURE_OMX
+   port_def.format.video.nStride = ALIGN(info->width, 16);
+ #else
    if (port_def.nBufferAlignment)
      port_def.format.video.nStride =
          (info->width + port_def.nBufferAlignment - 1) &
          (~(port_def.nBufferAlignment - 1));
    else
      port_def.format.video.nStride = GST_ROUND_UP_4 (info->width);       /* safe (?) default */
+ #endif
  
    port_def.format.video.nFrameHeight = info->height;
+ #ifdef TIZEN_FEATURE_OMX
+   port_def.format.video.nSliceHeight = ALIGN(info->width, 16);
+ #else
    port_def.format.video.nSliceHeight = info->height;
+ #endif
  
    switch (port_def.format.video.eColorFormat) {
      case OMX_COLOR_FormatYUV420Planar:
  
      case OMX_EXT_COLOR_FormatNV12LPhysicalAddress: /* FALL THROUGH */
      case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
          port_def.nBufferSize = sizeof(MMVideoBuffer);
  #endif
          break;
            &port_def) != OMX_ErrorNone)
      return FALSE;
  
+ #ifdef TIZEN_FEATURE_OMX
+   GST_DEBUG_OBJECT (self, "Updating outport port definition");
+   gst_omx_port_get_port_definition (self->enc_out_port, &port_def);
+   port_def.format.video.nFrameWidth = info->width;
+   port_def.format.video.nFrameHeight = info->height;
+   if (gst_omx_port_update_port_definition (self->enc_out_port, &port_def) != OMX_ErrorNone)
+     return FALSE;
+ #endif
  #ifdef USE_OMX_TARGET_RPI
    /* aspect ratio */
    {
    if (needs_disable) {
      if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
        return FALSE;
- #ifdef GST_TIZEN_MODIFICATION
-     if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->hTBMBufMgr,
-         self->enc_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+     if (gst_omx_port_tbm_allocate_enc_buffers (self->enc_in_port, self->bufmgr,
+         self->enc_in_port->use_buffer) != OMX_ErrorNone)
          return FALSE;
  #else
      if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
          return FALSE;
  
        /* Need to allocate buffers to reach Idle state */
- #ifdef GST_TIZEN_MODIFICATION
-     if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->hTBMBufMgr,
-         self->enc_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+     if (gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->bufmgr,
+         self->enc_in_port->use_buffer) != OMX_ErrorNone)
          return FALSE;
  #else
        if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
          return FALSE;
  #endif
  
- #ifdef GST_TIZEN_MODIFICATION
-     if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_out_port, self->hTBMBufMgr,
-         self->enc_out_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+ #ifdef TIZEN_FEATURE_OMX
+     if (gst_omx_port_tbm_allocate_enc_buffers(self->enc_out_port, self->bufmgr,
+         self->enc_out_port->use_buffer) != OMX_ErrorNone)
  #else
        if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone)
  #endif
@@@ -1318,7 -1425,7 +1425,7 @@@ gst_omx_video_enc_fill_buffer (GstOMXVi
      GST_ERROR_OBJECT (self, "Width or height do not match");
      goto done;
    }
+ #ifndef TIZEN_FEATURE_OMX
    /* Same strides and everything */
    if (gst_buffer_get_size (inbuf) ==
        outbuf->omx_buf->nAllocLen - outbuf->omx_buf->nOffset) {
      ret = TRUE;
      goto done;
    }
+ #endif
    /* Different strides */
  
    switch (info->finfo->format) {
        break;
      }
      case GST_VIDEO_FORMAT_ST12:
-     case GST_VIDEO_FORMAT_SN12:{
-         GstMemory* ext_memory = gst_buffer_peek_memory(inbuf, 1);
-         GstMapInfo ext_info =  GST_MAP_INFO_INIT;
-         MMVideoBuffer *ext_buf = NULL;
-         if (!ext_memory) {
-           GST_WARNING_OBJECT (self, "null MMVideoBuffer pointer  in hw color format. skip this.");
-           goto done;
-         }
-         gst_memory_map(ext_memory, &ext_info, GST_MAP_READ);
-         ext_buf = (MMVideoBuffer*)ext_info.data;
-         gst_memory_unmap(ext_memory, &ext_info);
+     case GST_VIDEO_FORMAT_SN12:
+     {
+       GstMemory* ext_memory = gst_buffer_peek_memory(inbuf, 1);
+       GstMapInfo ext_info =  GST_MAP_INFO_INIT;
+       MMVideoBuffer *mm_vbuffer = NULL;
+       if (!ext_memory) {
+         GST_WARNING_OBJECT (self, "null MMVideoBuffer pointer  in hw color format. skip this.");
+         goto done;
+       }
  
-         if (ext_buf != NULL && ext_buf->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
+       gst_memory_map(ext_memory, &ext_info, GST_MAP_READ);
+       mm_vbuffer = (MMVideoBuffer*)ext_info.data;
+       gst_memory_unmap(ext_memory, &ext_info);
  
-           if (ext_buf->handle.dmabuf_fd[0] == NULL)
-             gst_omx_tbm_get_bo_fd(ext_buf->handle.bo[0]);
+       if (mm_vbuffer != NULL && mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
+         mm_vbuffer->handle.dmabuf_fd[0] = tbm_bo_get_handle (mm_vbuffer->handle.bo[0], TBM_DEVICE_MM).u32;
+         mm_vbuffer->handle.dmabuf_fd[1] = tbm_bo_get_handle (mm_vbuffer->handle.bo[1], TBM_DEVICE_MM).u32;
+         mm_vbuffer->data[0] = tbm_bo_get_handle (mm_vbuffer->handle.bo[0], TBM_DEVICE_CPU).ptr;
+         mm_vbuffer->data[1] = tbm_bo_get_handle (mm_vbuffer->handle.bo[1], TBM_DEVICE_CPU).ptr;
  
-           if (ext_buf->handle.dmabuf_fd[1] == NULL)
-             gst_omx_tbm_get_bo_fd(ext_buf->handle.bo[1]);
+         GST_LOG_OBJECT (self, "enc. fd[0]:%d  fd[1]:%d  a[0]:%p, a[1]:%p, w[0]:%d  h[0]:%d   %d, %d, buf_share_method:%d",
+             mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->data[0], mm_vbuffer->data[1],
+             mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->width[1], mm_vbuffer->height[1], mm_vbuffer->type);
  
-           GST_LOG_OBJECT (self, "enc. fd[0]:%d  fd[1]:%d  fd[2]:%d  w[0]:%d  h[0]:%d   buf_share_method:%d",
-               ext_buf->handle.dmabuf_fd[0], ext_buf->handle.dmabuf_fd[1], ext_buf->handle.dmabuf_fd[2], ext_buf->width[0], ext_buf->height[0], ext_buf->type);
-         } else {
-           GST_WARNING_OBJECT (self, "enc input buf has wrong buf_share_method[%d]", ext_buf->type);
-         }
-         outbuf->omx_buf->nAllocLen = sizeof(MMVideoBuffer);
-         outbuf->omx_buf->nFilledLen = sizeof(MMVideoBuffer);
-         memcpy (outbuf->omx_buf->pBuffer, ext_buf, sizeof(MMVideoBuffer));
+         outbuf->omx_buf->nAllocLen = sizeof (MMVideoBuffer);
+         outbuf->omx_buf->nFilledLen = sizeof (MMVideoBuffer);
+         memcpy (outbuf->omx_buf->pBuffer, mm_vbuffer, sizeof (MMVideoBuffer));
+       } else {
+         GST_WARNING_OBJECT (self, "enc input has wrong buf");
+       }
  
  #ifdef CODEC_ENC_INPUT_DUMP
-         gst_omx_video_enc_input_dump(ext_buf);
+       gst_omx_video_enc_input_dump(mm_vbuffer);
  #endif
  
-         ret = TRUE;
-         break;
+       ret = TRUE;
+       break;
      }
      default:
        GST_ERROR_OBJECT (self, "Unsupported format");
@@@ -1576,9 -1683,8 +1683,8 @@@ gst_omx_video_enc_handle_frame (GstVide
          GST_VIDEO_ENCODER_STREAM_LOCK (self);
          goto reconfigure_error;
        }
- #ifdef GST_TIZEN_MODIFICATION
-     err = gst_omx_port_tbm_allocate_enc_buffers(port, self->hTBMBufMgr,
-         self->enc_in_port->port_def.format.video.eCompressionFormat);
+ #ifdef TIZEN_FEATURE_OMX
+     err = gst_omx_port_tbm_allocate_enc_buffers (port, self->bufmgr, port->use_buffer);
  #else
        err = gst_omx_port_allocate_buffers (port);
  #endif
diff --combined omx/gstomxvideoenc.h
index 6dbb1c7,06748c0..06748c0
mode 100644,100644..100755
@@@ -76,9 -76,9 +76,9 @@@ struct _GstOMXVideoEn
    guint32 quant_b_frames;
  
    GstFlowReturn downstream_flow_ret;
- #ifdef GST_TIZEN_MODIFICATION
+ #ifdef TIZEN_FEATURE_OMX
    gint drm_fd;
-   tbm_bufmgr hTBMBufMgr;
+   tbm_bufmgr bufmgr;
  #endif
  };
  
diff --combined packaging/common.tar.gz
index 0000000,0000000..c3aef17
new file mode 100644 (file)
Binary files differ
diff --combined packaging/gst-omx.spec
index f251385,e62c5ae..2ff2c82
mode 100755,100644..100755
@@@ -1,33 -1,37 +1,37 @@@
  Name:           gst-omx
  Summary:        GStreamer plug-in that allows communication with OpenMAX IL components
 -Version:        1.2.4
 -Release:        9
 +Version:        1.3.0
 +Release:        0
  License:        LGPL-2.1+
  Group:          Multimedia/Framework
- Source:        %{name}-%{version}.tar.gz
+ Source0:        %{name}-%{version}.tar.gz
 -Source100:      common.tar.bz2
++Source100:      common.tar.gz
+ Source1001:     gst-omx.manifest
  BuildRequires:  which
  BuildRequires:  pkgconfig(gstreamer-1.0)
  BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
  BuildRequires: pkgconfig(libtbm)
  BuildRequires: pkgconfig(mm-common)
+ ExclusiveArch: %arm aarch64
  
  %description
  gst-openmax is a GStreamer plug-in that allows communication with OpenMAX IL components.
  Multiple OpenMAX IL implementations can be used.
  
  %prep
- %setup -q -n %{name}-%{version}
+ %setup -q
+ %setup -q -T -D -a 100
+ cp %{SOURCE1001} .
  
  %build
  ./autogen.sh --noconfigure
  
- export CFLAGS+=" -DEXYNOS_SPECIFIC"
- export CFLAGS+=" -DGST_TIZEN_MODIFICATION"
+ export CFLAGS+=" -DTIZEN_FEATURE_OMX"
  
  %ifarch aarch64
  %configure --disable-static --prefix=/usr --with-omx-target=exynos64
  %else
- %configure --disable-static --prefix=/usr --with-omx-target=exynos
+ %configure --disable-static --prefix=/usr --with-omx-target=exynos --enable-vp8 --enable-hevc
  %endif
  
  make %{?jobs:-j%jobs}
  
  %install
  rm -rf %{buildroot}
- mkdir -p %{buildroot}/usr/share/license
- cp COPYING %{buildroot}/usr/share/license/%{name}
  %make_install
  
  %files
  %manifest gst-omx.manifest
  %defattr(-,root,root,-)
  %{_libdir}/gstreamer-1.0/libgstomx.so
- /etc/xdg/gstomx.conf
- /usr/share/license/%{name}
+ %license COPYING