fixed prevent issues.
authorKitae Kim <kt920.kim@samsung.com>
Wed, 21 Aug 2013 06:05:45 +0000 (15:05 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Wed, 21 Aug 2013 06:05:45 +0000 (15:05 +0900)
Change-Id: I28999bbda032b74f620a5845d10d4097c5d3d709
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
packaging/gst-plugins-emulator.changes
packaging/gst-plugins-emulator.spec
src/gstemuldec.c
src/gstemulenc.c

index 54bbcf4..0bc41b7 100644 (file)
@@ -1,3 +1,6 @@
+* Wed Aug 21 06:04:11 UTC 2013 Kitae Kim <kt920.kim@samsung.com>
+- fixed prevent issues.
+
 * Fri Jul  5 11:33:44 UTC 2013 Kitae Kim <kt920.kim@samsung.com>
 - fixed prevent issues.
 
index 544a544..81fd9a4 100644 (file)
@@ -1,5 +1,5 @@
 Name: gst-plugins-emulator
-Version: 0.1.3
+Version: 0.1.4
 Release: 2 
 Summary: GStreamer Streaming-media framework plug-in for Tizen emulator.
 Group: TO_BE/FILLED_IN
index 53ae410..f4b9201 100644 (file)
@@ -428,18 +428,9 @@ gst_emuldec_init (GstEmulDec *emuldec)
   gst_element_add_pad (GST_ELEMENT(emuldec), emuldec->sinkpad);
   gst_element_add_pad (GST_ELEMENT(emuldec), emuldec->srcpad);
 
-  // init
   emuldec->context = g_malloc0 (sizeof(CodecContext));
-  if (!emuldec->context) {
-    CODEC_LOG (ERR, "failed to allocate memory.\n");
-  }
-
   emuldec->context->video.pix_fmt = PIX_FMT_NONE;
   emuldec->context->audio.sample_fmt = SAMPLE_FMT_NONE;
-  emuldec->dev = g_malloc0 (sizeof(CodecDevice));
-  if (!emuldec->dev) {
-    CODEC_LOG (ERR, "failed to allocate memory.\n");
-  }
 
   emuldec->opened = FALSE;
   emuldec->format.video.par_n = -1;
@@ -448,6 +439,11 @@ gst_emuldec_init (GstEmulDec *emuldec)
 
   emuldec->queued = NULL;
   gst_segment_init (&emuldec->segment, GST_FORMAT_TIME);
+
+  emuldec->dev = g_malloc0 (sizeof(CodecDevice));
+  if (!emuldec->dev) {
+    CODEC_LOG (ERR, "failed to allocate memory.\n");
+  }
 }
 
 static void
@@ -926,10 +922,19 @@ get_output_buffer (GstEmulDec *emuldec, GstBuffer **outbuf)
 
   pict_size = gst_emul_avpicture_size (emuldec->context->video.pix_fmt,
     emuldec->context->video.width, emuldec->context->video.height);
+  if (pict_size < 0) {
+    GST_DEBUG_OBJECT (emuldec, "size of a picture is negative. "
+      "pixel format: %d, width: %d, height: %d",
+      emuldec->context->video.pix_fmt, emuldec->context->video.width,
+      emuldec->context->video.height);
+    return GST_FLOW_ERROR;
+  }
 
-//
-  gst_pad_set_bufferalloc_function(GST_PAD_PEER(emuldec->srcpad), (GstPadBufferAllocFunction) emul_buffer_alloc);
-//
+  /* GstPadBufferAllocFunction is mostly overridden by elements that can
+   * provide a hardware buffer in order to avoid additional memcpy operations.
+   */
+  gst_pad_set_bufferalloc_function(GST_PAD_PEER(emuldec->srcpad),
+    (GstPadBufferAllocFunction) emul_buffer_alloc);
 
   ret = gst_pad_alloc_buffer_and_set_caps (emuldec->srcpad,
     GST_BUFFER_OFFSET_NONE, pict_size,
@@ -946,7 +951,6 @@ get_output_buffer (GstEmulDec *emuldec, GstBuffer **outbuf)
     gst_buffer_unref (*outbuf);
     *outbuf = new_aligned_buffer (pict_size, GST_PAD_CAPS (emuldec->srcpad));
   }
-
   gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (emuldec->srcpad));
 
   emul_av_picture_copy (emuldec->context, GST_BUFFER_DATA (*outbuf),
@@ -1531,7 +1535,7 @@ gst_emuldec_register (GstPlugin *plugin, GList *element)
   CodecElement *codec = NULL;
 
   if (!elem) {
-         return FALSE;
+    return FALSE;
   }
 
   /* register element */
index 585c40d..8896084 100644 (file)
@@ -221,11 +221,7 @@ gst_emulenc_init (GstEmulEnc *emulenc)
   gst_element_add_pad (GST_ELEMENT (emulenc), emulenc->sinkpad);
   gst_element_add_pad (GST_ELEMENT (emulenc), emulenc->srcpad);
 
-  // init
   emulenc->context = g_malloc0 (sizeof(CodecContext));
-  if (!emulenc->context) {
-    printf("failed to allocate memory.\n");
-  }
   emulenc->context->video.pix_fmt = PIX_FMT_NONE;
   emulenc->context->audio.sample_fmt = SAMPLE_FMT_NONE;