fix video playback issues 52/158852/5
authorKwangCheol Lee <kclee@dignsys.com>
Fri, 3 Nov 2017 10:47:05 +0000 (19:47 +0900)
committerKwangCheol Lee <kclee@dignsys.com>
Fri, 24 Nov 2017 03:18:29 +0000 (12:18 +0900)
 - increase output buffer count
 - reopen the video decoder when the format is changed
 - h264 codec accept only au alignment type stream
 - change g_print to GST_LOG for function debugging

Change-Id: I6926f83b5e04df6431ccf09690c004ce46fc09f3
Signed-off-by: KwangCheol Lee <kclee@dignsys.com>
packaging/gst-plugins-video-dec.spec
src/decoder.c
src/decoder.h
src/gstnxvideodec.c
src/gstnxvideodec.h

index d24fccc6c5ba4f4863bf51933d210fb0ae3dd9ee..47419fa8e9d077569e1cdc17c4124d593455eef1 100644 (file)
@@ -1,6 +1,6 @@
 Name:    gst-plugins-video-dec
 Version: 1.0.3
-Release: 1
+Release: 2
 License: LGPLv2+
 Summary: nexell video decoder gstreamer plugin
 Group: Development/Libraries
index 8011eee2878200f09b2ac7081320187287550e3c..2a7a95c7664c1fd8e374f48f477f4c99163adf13 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "gstnxvideodec.h"
 
-#define        MAX_OUTPUT_BUF  6
+#define        MAX_OUTPUT_BUF  12
 
 static gint ParseH264Info (guint8 * pData, gint size, NX_AVCC_TYPE * pH264Info);
 static gint ParseAvcStream (guint8 * pInBuf, gint inSize, gint nalLengthSize,
index 771a55f629a7ffd0898f7c293909030d1de9482f..2fff5dab75a9e88ecec3dcd0ef2aa1fe32514d86 100644 (file)
@@ -110,6 +110,9 @@ struct _NX_VIDEO_DEC_STRUCT
   gboolean bIsFlush;
 
   NX_VDEC_SEMAPHORE *pSem;
+#ifdef TIZEN_FEATURE_ARTIK530
+  GstBuffer *codec_data;
+#endif
 };
 //
 //////////////////////////////////////////////////////////////////////////////
index 56f6a53716e00058f18bbd8a0b58a0f2417cf722..fa52d089c710be533c702196ca2f2a307af118de 100644 (file)
@@ -166,6 +166,7 @@ nxvideodec_base_init (gpointer gclass)
   //      H.264
   gst_caps_append_structure (pCapslist,
       gst_structure_new ("video/x-h264",
+          "alignment", G_TYPE_STRING, "au",
           "width", GST_TYPE_INT_RANGE, 64, NX_MAX_WIDTH,
           "height", GST_TYPE_INT_RANGE, 64, NX_MAX_HEIGHT, NULL));
 
@@ -389,6 +390,9 @@ gst_nxvideodec_set_format (GstVideoDecoder * pDecoder,
   GstVideoCodecState *pOutputState = NULL;
   NX_VIDEO_DEC_STRUCT *pDecHandle = NULL;
   gint ret = FALSE;
+#ifdef TIZEN_FEATURE_ARTIK530
+  gboolean bIsFormatChange = FALSE;
+#endif
 
   FUNC_IN ();
 
@@ -410,6 +414,36 @@ gst_nxvideodec_set_format (GstVideoDecoder * pDecoder,
     return FALSE;
   }
 
+#ifdef TIZEN_FEATURE_ARTIK530
+  GST_DEBUG_OBJECT (pNxVideoDec, "old %dx%d fps=%d/%d %p",
+      pDecHandle->width, pDecHandle->height,
+      pDecHandle->fpsNum, pDecHandle->fpsDen,
+      pDecHandle->codec_data);
+  GST_DEBUG_OBJECT (pNxVideoDec, "new %dx%d fps=%d/%d %p",
+      GST_VIDEO_INFO_WIDTH (&pState->info),
+      GST_VIDEO_INFO_HEIGHT (&pState->info),
+      GST_VIDEO_INFO_FPS_N (&pState->info),
+      GST_VIDEO_INFO_FPS_D (&pState->info),
+      pState->codec_data);
+
+  bIsFormatChange |=
+      pDecHandle->width != GST_VIDEO_INFO_WIDTH (&pState->info);
+  bIsFormatChange |=
+      pDecHandle->height != GST_VIDEO_INFO_HEIGHT (&pState->info);
+  if (GST_VIDEO_INFO_FPS_N (&pState->info) != 0) {
+    bIsFormatChange |=
+        pDecHandle->fpsNum != GST_VIDEO_INFO_FPS_N (&pState->info);
+    bIsFormatChange |=
+        pDecHandle->fpsDen != GST_VIDEO_INFO_FPS_D (&pState->info);
+  } else {
+    bIsFormatChange |= pDecHandle->fpsNum != 30;
+    bIsFormatChange |= pDecHandle->fpsDen != 1;
+  }
+  bIsFormatChange |= (pDecHandle->codec_data != pState->codec_data);
+  gst_buffer_replace (&pDecHandle->codec_data, pState->codec_data);
+  GST_DEBUG_OBJECT (pNxVideoDec, "format changed=%d", bIsFormatChange);
+#endif
+
   pDecHandle->codecType = FindCodecInfo (pState, pDecHandle);
 
   if (pDecHandle->codecType < 0) {
@@ -492,6 +526,25 @@ gst_nxvideodec_set_format (GstVideoDecoder * pDecoder,
     return ret;
   }
 
+#ifdef TIZEN_FEATURE_ARTIK530
+  if (!bIsFormatChange) {
+    FUNC_OUT ();
+    return TRUE;
+  }
+
+  if (pDecHandle->hCodec) {
+    NX_V4l2DecClose (pDecHandle->hCodec);
+    pDecHandle->hCodec = NULL;
+
+    if (pDecHandle->pTmpStrmBuf) {
+      g_free (pDecHandle->pTmpStrmBuf);
+      pDecHandle->pTmpStrmBuf = NULL;
+    }
+
+    pDecHandle->bInitialized = FALSE;
+  }
+#endif
+
   if (0 != InitVideoDec (pNxVideoDec->pNxVideoDecHandle)) {
     return FALSE;
   }
index c1e50def11971dc8493c864e48fa64ca9a89e3aa..0e50e608ada74c0b857e7198b1e9144f227a41e4 100644 (file)
@@ -54,8 +54,8 @@
 #define        DBG_FUNCTION            0
 
 #if    DBG_FUNCTION
-#define        FUNC_IN()                       g_print("%s() In\n", __func__)
-#define        FUNC_OUT()                      g_print("%s() Out\n", __func__)
+#define        FUNC_IN()                       GST_LOG("%s() In", __func__)
+#define        FUNC_OUT()                      GST_LOG("%s() Out", __func__)
 #else
 #define        FUNC_IN()                       do{}while(0)
 #define        FUNC_OUT()                      do{}while(0)