remove unused sources and write some comments. 74/34474/1 archives/tizen_20150513
authorKitae Kim <kt920.kim@samsung.com>
Wed, 28 Jan 2015 00:51:03 +0000 (09:51 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Wed, 28 Jan 2015 00:54:17 +0000 (09:54 +0900)
Change-Id: I931d7e8678f049ca62ad59d1934bca625ecb6b5b
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
src/audioconvert.h
src/gstmarudec.c
src/gstmaruenc.c
src/gstmaruinterface3.c
src/gstmarumem.c
src/gstmaruutils.c

index be7734d..e6b986c 100644 (file)
 #define AV_CH_LAYOUT_7POINT1_WIDE      (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
 #define AV_CH_LAYOUT_STEREO_DOWNMIX    (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
 
-#if 0
-/**
- * Return a channel layout id that matches name, 0 if no match.
- */
-int64_t av_get_channel_layout(const char *name);
-
-/**
- * Return a description of a channel layout.
- * If nb_channels is <= 0, it is guessed from the channel_layout.
- *
- * @param buf put here the string containing the channel layout
- * @param buf_size size in bytes of the buffer
- */
-void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
-
-/**
- * Return the number of channels in the channel layout.
- */
-int av_get_channel_layout_nb_channels(int64_t channel_layout);
-#endif
-
 #endif /* AVUTIL_AUDIOCONVERT_H */
index e40dff8..2e41891 100644 (file)
@@ -304,12 +304,8 @@ flush_queued (GstMaruDec *marudec)
 static void
 gst_marudec_drain (GstMaruDec *marudec)
 {
-#if 0
-  GstMaruDecClass *oclass;
-  oclass = (GstMaruDecClass *) (G_OBJECT_GET_CLASS (marudec));
-#endif
-
   GST_DEBUG_OBJECT (marudec, "drain frame");
+
   {
     gint have_data, len, try = 0;
 
@@ -406,6 +402,8 @@ gst_marudec_class_init (GstMaruDecClass *klass)
   parent_class = g_type_class_peek_parent (klass);
 
 #if 0
+  // use these function when defines new properties.
+
   gobject_class->set_property = gst_marudec_set_property
   gobject_class->get_property = gst_marudec_get_property
 #endif
@@ -674,15 +672,6 @@ gst_marudec_setcaps (GstPad *pad, GstCaps *caps)
     GST_DEBUG_OBJECT (marudec, "Using framerate from codec");
   }
 
-#if 0
-  if (strcmp (oclass->codec->name, "aac") == 0) {
-    const gchar *format = gst_structure_get_string (structure, "stream-format");
-    if (format == NULL || strcmp ("format", "raw") == 0) {
-      marudec->turnoff_parser = TRUE;
-    }
-  }
-#endif
-
   if (!gst_marudec_open (marudec)) {
     GST_DEBUG_OBJECT (marudec, "Failed to open");
     GST_OBJECT_UNLOCK (marudec);
index 9f8492e..5cfbe88 100644 (file)
@@ -246,9 +246,6 @@ gst_maruenc_init (GstMaruEnc *maruenc)
   maruenc->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
   gst_pad_use_fixed_caps (maruenc->srcpad);
 
-#if 0
-  maruenc->file = NULL;
-#endif
   maruenc->delay = g_queue_new ();
 
   // instead of AVCodecContext
@@ -677,28 +674,11 @@ gst_maruenc_chain_video (GstPad *pad, GstBuffer *buffer)
       "Received buffer of time %" GST_TIME_FORMAT,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
 
-#if 0
-  GST_OBJECT_LOCK (maruenc);
-  force_keyframe = maruenc->force_keyframe;
-  maruenc->force_keyframe = FALSE;
-  GST_OBJECT_UNLOCK (maruenc);
-
-  if (force_keyframe) {
-    maruenc->picture->pict_type = FF_I_TYPE;
-  }
-#endif
-
   frame_size = gst_maru_avpicture_size (maruenc->context->video.pix_fmt,
       maruenc->context->video.width, maruenc->context->video.height);
   g_return_val_if_fail (frame_size == GST_BUFFER_SIZE (buffer),
       GST_FLOW_ERROR);
 
-#if 0
-  pts = gst_maru_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buffer) /
-    maruenc->context.video.ticks_per_frame,
-    maruenc->context.video.fps_n, maruen->context.video.fps_d);
-#endif
-
   gst_maruenc_setup_working_buf (maruenc);
 
   ret_size =
@@ -723,34 +703,15 @@ gst_maruenc_chain_video (GstPad *pad, GstBuffer *buffer)
     return GST_FLOW_OK;
   }
 
-#if 0
-  if (maruenc->file && maruenc->context->stats_out) {
-    if (fprintf (maruenc->file, "%s", maruenc->context->stats_out) < 0) {
-      GST_ELEMENT_ERROR (maruenc, RESOURCE, WRITE,
-        (("Could not write to file \"%s\"."), maruenc->filename),
-        GST_ERROR_SYSTEM);
-    }
-  }
-#endif
-
-  // mem_offset = maruenc->dev->mem_info.offset;
-  // working_buf = maruenc->dev->buf + mem_offset;
-
   GST_DEBUG_OBJECT (maruenc, "encoded video. mem_offset = 0x%x",  mem_offset);
 
+  // encode_video copies output buffers twice.
+  // device memory to working_buf and working_buf to GstBuffer
   outbuf = gst_buffer_new_and_alloc (ret_size);
   memcpy (GST_BUFFER_DATA (outbuf), maruenc->working_buf, ret_size);
-  // memcpy (GST_BUFFER_DATA (outbuf), working_buf, ret_size);
   GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
   GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
 
-#if 0
-  ret = ioctl(maruenc->dev->fd, CODEC_CMD_RELEASE_BUFFER, &mem_offset);
-  if (ret < 0) {
-    GST_ERROR_OBJECT (maruenc, "failed to release used buffer");
-  }
-#endif
-
   if (coded_frame) {
     if (!is_keyframe) {
       GST_DEBUG_OBJECT (maruenc, "this frame is not a keyframe");
@@ -768,15 +729,6 @@ gst_maruenc_chain_video (GstPad *pad, GstBuffer *buffer)
   gst_buffer_set_caps (outbuf, GST_PAD_CAPS (maruenc->srcpad));
   gst_buffer_unref (buffer);
 
-#if 0
-  if (force_keyframe) {
-    gst_pad_push_event (maruenc->srcpad,
-      gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
-      gst_structure_new ("GstForceKeyUnit", "timestamp",
-                         G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (outbuf), NULL)));
-  }
-#endif
-
   return gst_pad_push (maruenc->srcpad, outbuf);
 }
 
@@ -828,7 +780,6 @@ static GstFlowReturn
 gst_maruenc_chain_audio (GstPad *pad, GstBuffer *buffer)
 {
   GstMaruEnc *maruenc;
-  // GstMaruEncClass *oclass;
   GstClockTime timestamp, duration;
   guint in_size, frame_size;
   gint osize;
@@ -839,7 +790,6 @@ gst_maruenc_chain_audio (GstPad *pad, GstBuffer *buffer)
   CodecContext *ctx;
 
   maruenc = (GstMaruEnc *) (GST_OBJECT_PARENT (pad));
-  // oclass = (GstMaruEncClass *) G_OBJECT_GET_CLASS (maruenc);
 
   ctx = maruenc->context;
 
@@ -944,16 +894,6 @@ gst_maruenc_chain_audio (GstPad *pad, GstBuffer *buffer)
     }
     GST_LOG_OBJECT (maruenc, "%u bytes left in the adapter", avail);
   } else {
-#if 0
-    int coded_bps = av_get_bits_per_sample (oclass->codec->name);
-
-    GST_LOG_OBJECT (maruenc, "coded bps %d, osize %d", coded_bps, osize);
-
-    out_size = in_size / osize;
-    if (coded_bps) {
-      out_size = (out_size * coded_bps) / 8;
-    }
-#endif
     in_data = (guint8 *) GST_BUFFER_DATA (buffer);
     ret = gst_maruenc_encode_audio (maruenc, in_data, in_size, out_size,
       timestamp, duration, discont);
@@ -970,11 +910,6 @@ gst_maruenc_chain_audio (GstPad *pad, GstBuffer *buffer)
 static void
 gst_maruenc_flush_buffers (GstMaruEnc *maruenc, gboolean send)
 {
-#if 0
-  GstBuffer *outbuf, *inbuf;
-  gint ret_size = 0;
-#endif
-
   GST_DEBUG_OBJECT (maruenc, "flushing buffers with sending %d", send);
 
   if (!maruenc->opened) {
@@ -983,55 +918,6 @@ gst_maruenc_flush_buffers (GstMaruEnc *maruenc, gboolean send)
     }
   }
 
-#if 0
-  while (!g_queue_is_empty (maruenc->delay)) {
-    maruenc_setup_working_buf (maruenc);
-
-    ret_size = codec_encode_video (maruenc->context,
-      maruenc->working_buf, maruenc->working_buf_size, NULL, NULL, 0,
-      maruenc->dev);
-
-    if (ret_size < 0) {
-      GstMaruEncClass *oclass =
-        (GstMaruEncClass *) (G_OBJECT_GET_CLASS (maruenc));
-      GST_WARNING_OBJECT (maruenc,
-        "maru_%senc: failed to flush buffer", oclass->codec->name);
-      break;
-    }
-
-    if (maruenc->file && maruenc->context->stats_out) {
-      if (fprintf (maruenc->file, "%s", maruenc->context->stats_out) < 0) {
-        GST_ELEMENT_ERROR (emeulenc, RESOURCE, WRITE,
-          (("Could not write to file \"%s\"."), maruenc->filename),
-          GST_ERROR_SYSTEM);
-      }
-    }
-
-    inbuf = g_queue_pop_head (maruenc->delay);
-
-    outbuf = gst_buffer_new_and_alloc (ret_size);
-    memcpy (GST_BUFFER_DATA (outbuf), maruenc->working_buf, ret_size);
-    GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
-    GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
-
-    if (!maruenc->context->coded_frame->key_frame) {
-      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
-    }
-    gst_buffer_set_caps (outbuf, GST_PAD_CAPS (maruenc->srcpad));
-
-    gst_buffer_unref (inbuf);
-
-    if (send) {
-      gst_pad_push (maruenc->srcpad, outbuf);
-    } else {
-      gst_buffer_unref (outbuf);
-    }
-  }
-
-  while (!g_queue_is_empty (maruenc->delay)) {
-    gst_buffer_unref (g_queue_pop_head (maruenc->delay));
-  }
-#endif
 }
 
 static gboolean
@@ -1045,16 +931,6 @@ gst_maruenc_event_video (GstPad *pad, GstEvent *event)
     gst_maruenc_flush_buffers (maruenc, TRUE);
     break;
   case GST_EVENT_CUSTOM_DOWNSTREAM:
-  {
-    const GstStructure *s;
-    s = gst_event_get_structure (event);
-
-    if (gst_structure_has_name (s, "GstForceKeyUnit")) {
-#if 0
-      maruenc->picture->pict_type = FF_I_TYPE;
-#endif
-    }
-  }
     break;
   default:
     break;
@@ -1076,11 +952,6 @@ gst_maruenc_event_src (GstPad *pad, GstEvent *event)
     s = gst_event_get_structure (event);
 
     if (gst_structure_has_name (s, "GstForceKeyUnit")) {
-#if 0
-      GST_OBJECT_LOCK (maruenc);
-      maruenc->force_keyframe = TRUE;
-      GST_OBJECT_UNLOCK (maruenc);
-#endif
       forward = FALSE;
       gst_event_unref (event);
     }
@@ -1120,13 +991,6 @@ gst_maruenc_change_state (GstElement *element, GstStateChange transition)
     }
     gst_adapter_clear (maruenc->adapter);
 
-#if 0
-    if (maruenc->flie) {
-      fclose (maruenc->file);
-      maruenc->file = NULL;
-    }
-#endif
-
     if (maruenc->working_buf) {
       g_free (maruenc->working_buf);
       maruenc->working_buf = NULL;
index 088b549..5e9ae1a 100644 (file)
@@ -266,11 +266,12 @@ decode_video (GstMaruDec *marudec, uint8_t *inbuf, int inbuf_size,
     }
     ret = invoke_device_api(dev->fd, ctx->index, CODEC_DECODE_VIDEO_AND_PICTURE_COPY, &mem_offset, picture_size);
   } else {
+    // in case of this, a decoded frame is not given from codec device.
     ret = invoke_device_api(dev->fd, ctx->index, CODEC_DECODE_VIDEO, &mem_offset, SMALLDATA);
   }
 
   if (ret < 0) {
-    GST_ERROR ("Invoke API failed");
+    GST_ERROR ("invoke API failed");
     return -1;
   }
 
@@ -405,7 +406,6 @@ encode_video (CodecContext *ctx, uint8_t *outbuf,
 
   mem_offset = GET_OFFSET(buffer);
 
-  // FIXME: how can we know output data size ?
   ret = invoke_device_api(dev->fd, ctx->index, CODEC_ENCODE_VIDEO, &mem_offset, SMALLDATA);
 
   if (ret < 0) {
index ea711e0..f6b1cfe 100644 (file)
@@ -34,7 +34,7 @@
  *  codec data such as codec name, longname, media type and etc.
  */
 static int
-_codec_info_data (CodecElement *codec, gpointer buffer)
+codec_element_data (CodecElement *codec, gpointer buffer)
 {
   int size = sizeof(size);
 
@@ -54,11 +54,13 @@ codec_init_data_to (CodecContext *ctx, CodecElement *codec, gpointer buffer)
 {
   int size = 0;
 
-  size = _codec_info_data (codec, buffer);
+  size = codec_element_data (codec, buffer);
 
   GST_INFO ("context_id: %d, name: %s, media type: %s",
     ctx->index, codec->name, codec->media_type ? "audio" : "video");
 
+  // copy VideoData, AudioData, bit_rate, codec_tag and codecdata_size
+  // into device memory. the size of codecdata is variable.
   memcpy (buffer + size, ctx, sizeof(CodecContext) - 12);
   size += (sizeof(CodecContext) - 12);
   memcpy (buffer + size, ctx->codecdata, ctx->codecdata_size);
index 00bbc5e..ba6db8b 100644 (file)
@@ -1063,16 +1063,6 @@ gst_maru_codecname_to_caps (const char *name, CodecContext *ctx, gboolean encode
     caps = gst_maru_video_caps_new (ctx, name, "video/x-h263",
               "variant", G_TYPE_STRING, "itu",
               "h263version", G_TYPE_STRING, "h263p", NULL);
-#if 0
-    if (encode && ctx) {
-      gst_caps_set_simple (caps,
-        "annex-f", G_TYPE_BOOLEAN, ctx->flags & CODEC_FLAG_4MV,
-        "annex-j", G_TYPE_BOOLEAN, ctx->flags & CODEC_FLAG_LOOP_FILTER,
-        "annex-i", G_TYPE_BOOLEAN, ctx->flags & CODEC_FLAG_AC_PRED,
-        "annex-t", G_TYPE_BOOLEAN, ctx->flags & CODEC_FLAG_AC_PRED,
-        NULL);
-    }
-#endif
   } else if (strcmp (name, "mpeg2video") == 0) {
     if (encode) {
       caps = gst_maru_video_caps_new (ctx, name, "video/mpeg",
@@ -1142,12 +1132,6 @@ gst_maru_codecname_to_caps (const char *name, CodecContext *ctx, gboolean encode
     caps = gst_maru_video_caps_new (ctx, name, "video/x-wmv",
                 "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
                 GST_MAKE_FOURCC ('W', 'V', 'C', '1'),  NULL);
-#if 0
-  } else if (strcmp (name, "vp3") == 0) {
-    mime_type = g_strdup ("video/x-vp3");
-  } else if (strcmp (name, "vp8") == 0) {
-    mime_type = g_strdup ("video/x-vp8");
-#endif
   } else if (strcmp (name, "aac") == 0) {
     caps = gst_maru_audio_caps_new (ctx, name, "audio/mpeg", NULL);
     if (!encode) {