fix S1-14589, N_SE-39500
authorYounghwan Ahn <younghwan_.an@samsung.com>
Wed, 3 Jul 2013 07:21:58 +0000 (16:21 +0900)
committerYounghwan Ahn <younghwan_.an@samsung.com>
Wed, 3 Jul 2013 07:26:13 +0000 (16:26 +0900)
src/include/mm_player_capture.h
src/mm_player_capture.c
src/mm_player_priv.c

index b4349e8..be299c2 100644 (file)
@@ -1,73 +1,73 @@
-/*\r
- * libmm-player\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef __MM_PLAYER_CAPTURE_H__\r
-#define __MM_PLAYER_CAPTURE_H__\r
-\r
-/*=======================================================================================\r
-| INCLUDE FILES                                                                                |\r
-========================================================================================*/\r
-#include <mm_types.h>\r
-#include "mm_player_priv.h"\r
-\r
-#ifdef __cplusplus\r
-       extern "C" {\r
-#endif\r
-\r
-/*=======================================================================================\r
-| GLOBAL FUNCTION PROTOTYPES                                                           |\r
-========================================================================================*/\r
-/**\r
- * This function is to initialize video capture\r
- *\r
- * @param[in]  handle          Handle of player.\r
- * @return     This function returns zero on success, or negative value with errors.\r
- * @remarks\r
- * @see\r
- *\r
- */\r
-int _mmplayer_initialize_video_capture(mm_player_t* player);\r
-/**\r
- * This function is to release video capture\r
- *\r
- * @param[in]  handle          Handle of player.\r
- * @return     This function returns zero on success, or negative value with errors.\r
- * @remarks\r
- * @see\r
- *\r
- */\r
-int _mmplayer_release_video_capture(mm_player_t* player);\r
-/**\r
- * This function is to get video snapshot during playback.\r
- *\r
- * @param[in]  handle          Handle of player.\r
- * @return     This function returns zero on success, or negative value with errors.\r
- * @remarks\r
- * @see\r
- *\r
- */\r
-int _mmplayer_do_video_capture(MMHandleType hplayer);\r
-\r
-#ifdef __cplusplus\r
-       }\r
-#endif\r
-\r
-#endif\r
+/*
+ * libmm-player
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_PLAYER_CAPTURE_H__
+#define __MM_PLAYER_CAPTURE_H__
+
+/*=======================================================================================
+| INCLUDE FILES                                                                                |
+========================================================================================*/
+#include <mm_types.h>
+#include "mm_player_priv.h"
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+/*=======================================================================================
+| GLOBAL FUNCTION PROTOTYPES                                                           |
+========================================================================================*/
+/**
+ * This function is to initialize video capture
+ *
+ * @param[in]  handle          Handle of player.
+ * @return     This function returns zero on success, or negative value with errors.
+ * @remarks
+ * @see
+ *
+ */
+int _mmplayer_initialize_video_capture(mm_player_t* player);
+/**
+ * This function is to release video capture
+ *
+ * @param[in]  handle          Handle of player.
+ * @return     This function returns zero on success, or negative value with errors.
+ * @remarks
+ * @see
+ *
+ */
+int _mmplayer_release_video_capture(mm_player_t* player);
+/**
+ * This function is to get video snapshot during playback.
+ *
+ * @param[in]  handle          Handle of player.
+ * @return     This function returns zero on success, or negative value with errors.
+ * @remarks
+ * @see
+ *
+ */
+int _mmplayer_do_video_capture(MMHandleType hplayer);
+
+#ifdef __cplusplus
+       }
+#endif
+
+#endif
index f1299b3..8c333dc 100644 (file)
-/*\r
- * libmm-player\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
\r
-/*===========================================================================================\r
-|                                                                                                                                                                                      |\r
-|  INCLUDE FILES                                                                                                                                                       |\r
-|                                                                                                                                                                                      |\r
-========================================================================================== */\r
-#include "mm_player_capture.h"\r
-#include "mm_player_priv.h"\r
-\r
-#include <mm_util_imgp.h>\r
-\r
-/*---------------------------------------------------------------------------\r
-|    LOCAL VARIABLE DEFINITIONS for internal                                                           |\r
----------------------------------------------------------------------------*/\r
-\r
-/*---------------------------------------------------------------------------\r
-|    LOCAL FUNCTION PROTOTYPES:                                                                                                |\r
----------------------------------------------------------------------------*/\r
-static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data);\r
-static int  __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);\r
-static gpointer __mmplayer_capture_thread(gpointer data);\r
-static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int buttom);\r
-static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);\r
-static int __mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt);\r
-\r
-/*===========================================================================================\r
-|                                                                                                                                                                                      |\r
-|  FUNCTION DEFINITIONS                                                                                                                                                |\r
-|                                                                                                                                                                                      |\r
-========================================================================================== */\r
-int \r
-_mmplayer_initialize_video_capture(mm_player_t* player)\r
-{\r
-       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );\r
-       /* create capture mutex */\r
-       player->capture_thread_mutex = g_mutex_new();\r
-       if ( ! player->capture_thread_mutex )\r
-       {\r
-               debug_critical("Cannot create capture mutex");\r
-               goto ERROR;\r
-       }\r
-\r
-       /* create capture cond */\r
-       player->capture_thread_cond = g_cond_new();\r
-       if ( ! player->capture_thread_cond )\r
-       {\r
-               debug_critical("Cannot create capture cond");\r
-               goto ERROR;\r
-       }\r
-\r
-       player->capture_thread_exit = FALSE;\r
-\r
-       /* create video capture thread */\r
-       player->capture_thread =\r
-               g_thread_create (__mmplayer_capture_thread, (gpointer)player, TRUE, NULL);\r
-       if ( ! player->capture_thread )\r
-       {\r
-               goto ERROR;\r
-       }\r
-\r
-       return MM_ERROR_NONE;\r
-\r
-ERROR:\r
-       /* capture thread */\r
-       if ( player->capture_thread_mutex )\r
-               g_mutex_free ( player->capture_thread_mutex );\r
-\r
-       if ( player->capture_thread_cond )\r
-               g_cond_free ( player->capture_thread_cond );\r
-\r
-       return MM_ERROR_PLAYER_INTERNAL;\r
-}\r
-\r
-int\r
-_mmplayer_release_video_capture(mm_player_t* player)\r
-{\r
-       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );\r
-       /* release capture thread */\r
-       if ( player->capture_thread_cond &&\r
-                player->capture_thread_mutex &&\r
-                player->capture_thread )\r
-       {\r
-               g_mutex_lock(player->capture_thread_mutex);\r
-               player->capture_thread_exit = TRUE;\r
-               g_cond_signal( player->capture_thread_cond );\r
-               g_mutex_unlock(player->capture_thread_mutex);\r
-\r
-               debug_log("waitting for capture thread exit");\r
-               g_thread_join ( player->capture_thread );\r
-               g_mutex_free ( player->capture_thread_mutex );\r
-               g_cond_free ( player->capture_thread_cond );\r
-               debug_log("capture thread released");\r
-       }\r
-\r
-       return MM_ERROR_NONE;\r
-}\r
-\r
-int\r
-_mmplayer_do_video_capture(MMHandleType hplayer)\r
-{\r
-       mm_player_t* player = (mm_player_t*) hplayer;\r
-       int ret = MM_ERROR_NONE;\r
-       GstPad *pad = NULL;\r
-\r
-       debug_fenter();\r
-\r
-       return_val_if_fail(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);\r
-\r
-       /* capturing or not */\r
-       if (player->video_capture_cb_probe_id || player->capture.data || player->captured.a[0] || player->captured.a[1])\r
-       {\r
-               debug_warning("capturing... we can't do any more");\r
-               return MM_ERROR_PLAYER_INVALID_STATE;\r
-       }\r
-\r
-       /* check if video pipeline is linked or not */\r
-       if (!player->pipeline->videobin || !player->sent_bos)\r
-       {\r
-               debug_warning("not ready to capture");\r
-               return MM_ERROR_PLAYER_INVALID_STATE;\r
-       }\r
-\r
-       if (player->state != MM_PLAYER_STATE_PLAYING)\r
-       {\r
-               if (player->state == MM_PLAYER_STATE_PAUSED) // get last buffer from video sink\r
-               {\r
-                       GstBuffer *buf = NULL;\r
-                       g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL);\r
-\r
-                       if (buf)\r
-                       {\r
-                               ret = __mmplayer_get_video_frame_from_buffer(player, buf);\r
-                               gst_buffer_unref(buf);\r
-                       }\r
-                       return ret;\r
-               }\r
-               else\r
-               {\r
-                       debug_warning("invalid state(%d) to capture", player->state);\r
-                       return MM_ERROR_PLAYER_INVALID_STATE;\r
-               }\r
-       }\r
-\r
-       pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" );\r
-\r
-       /* register probe */\r
-       player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad,\r
-               G_CALLBACK (__mmplayer_video_capture_probe), player);\r
-\r
-       gst_object_unref(GST_OBJECT(pad));\r
-       pad = NULL;\r
-\r
-       debug_fleave();\r
-\r
-       return ret;\r
-}\r
-\r
-static gpointer\r
-__mmplayer_capture_thread(gpointer data)\r
-{\r
-       mm_player_t* player = (mm_player_t*) data;\r
-       MMMessageParamType msg = {0, };\r
-       unsigned char * linear_y_plane = NULL;\r
-       unsigned char * linear_uv_plane = NULL;\r
-\r
-       return_val_if_fail(player, NULL);\r
-\r
-       while (!player->capture_thread_exit)\r
-       {\r
-               debug_log("capture thread started. waiting for signal");\r
-\r
-               g_mutex_lock(player->capture_thread_mutex);\r
-               g_cond_wait( player->capture_thread_cond, player->capture_thread_mutex );\r
-\r
-               if ( player->capture_thread_exit )\r
-               {\r
-                       debug_log("exiting capture thread");\r
-                       goto EXIT;\r
-               }\r
-               debug_log("capture thread is recieved signal");\r
-\r
-               /* NOTE: Don't use MMPLAYER_CMD_LOCK() here.\r
-                * Because deadlock can be happened if other player api is used in message callback. \r
-                */\r
-               if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)\r
-               {\r
-                       /* Colorspace conversion : NV12T-> NV12-> RGB888 */\r
-                       int ret = 0;\r
-                       int linear_y_plane_size;\r
-                       int linear_uv_plane_size;\r
-                       unsigned char * src_buffer = NULL;\r
-\r
-                       debug_log("w[0]=%d, w[1]=%d", player->captured.w[0], player->captured.w[1]);\r
-                       debug_log("h[0]=%d, h[1]=%d", player->captured.h[0], player->captured.h[1]);\r
-                       debug_log("s[0]=%d, s[1]=%d", player->captured.s[0], player->captured.s[1]);\r
-                       debug_log("e[0]=%d, e[1]=%d", player->captured.e[0], player->captured.e[1]);\r
-                       debug_log("a[0]=%p, a[1]=%p", player->captured.a[0], player->captured.a[1]);\r
-\r
-                       #if 0\r
-                       if (mm_attrs_get_int_by_name(player->attrs, "content_video_width", &(player->captured.w[0])) != MM_ERROR_NONE)\r
-                       {\r
-                               debug_error("failed to get content width attribute");\r
-                               goto ERROR;\r
-                       }\r
-\r
-                       if (mm_attrs_get_int_by_name(player->attrs, "content_video_height", &(player->captured.h[0])) != MM_ERROR_NONE)\r
-                       {\r
-                               debug_error("failed to get content height attribute");\r
-                               goto ERROR;\r
-                       }\r
-                       #endif\r
-\r
-                       linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]);\r
-                       linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2);\r
-\r
-                       linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size);\r
-                       if (linear_y_plane == NULL)\r
-                       {\r
-                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;\r
-                               goto ERROR;\r
-                       }\r
-\r
-                       linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size);\r
-                       if (linear_uv_plane == NULL)\r
-                       {\r
-                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;\r
-                               goto ERROR;\r
-                       }\r
-                       /* NV12 tiled to linear */\r
-                       __csc_tiled_to_linear_crop(linear_y_plane, player->captured.a[0], player->captured.w[0], player->captured.h[0], 0,0,0,0);\r
-                       __csc_tiled_to_linear_crop(linear_uv_plane, player->captured.a[1], player->captured.w[0], player->captured.h[0]/2, 0,0,0,0);\r
-\r
-                       MMPLAYER_FREEIF(player->captured.a[0]);\r
-                       MMPLAYER_FREEIF(player->captured.a[1]);\r
-\r
-                       src_buffer = (unsigned char*) g_try_malloc(linear_y_plane_size+linear_uv_plane_size);\r
-\r
-                       if (src_buffer == NULL)\r
-                       {\r
-                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;\r
-                               goto ERROR;\r
-                       }\r
-                       memset(src_buffer, 0x00, linear_y_plane_size+linear_uv_plane_size);\r
-                       memcpy(src_buffer, linear_y_plane, linear_y_plane_size);\r
-                       memcpy(src_buffer+linear_y_plane_size, linear_uv_plane, linear_uv_plane_size);\r
-\r
-                       /* NV12 linear to RGB888 */\r
-                       ret = __mm_player_convert_colorspace(player, src_buffer, MM_UTIL_IMG_FMT_NV12,\r
-                               player->captured.w[0], player->captured.h[0], MM_UTIL_IMG_FMT_RGB888);\r
-\r
-                       if (ret != MM_ERROR_NONE)\r
-                       {\r
-                               debug_error("failed to convert nv12 linear");\r
-                               goto ERROR;\r
-                       }\r
-                       /* clean */\r
-                       MMPLAYER_FREEIF(src_buffer);\r
-                       MMPLAYER_FREEIF(linear_y_plane);\r
-                       MMPLAYER_FREEIF(linear_uv_plane);\r
-               }\r
-\r
-               player->capture.fmt = MM_PLAYER_COLORSPACE_RGB888;\r
-               msg.data = &player->capture;\r
-               msg.size = player->capture.size;\r
-\r
-               if (player->cmd >= MMPLAYER_COMMAND_START)\r
-               {\r
-                       MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_CAPTURED, &msg );\r
-                       debug_log("returned from capture message callback");\r
-               }\r
-\r
-               g_mutex_unlock(player->capture_thread_mutex);\r
-\r
-               //MMPLAYER_FREEIF(player->capture.data);\r
-               continue;\r
-ERROR:\r
-               if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)\r
-               {\r
-                       /* clean */\r
-                       MMPLAYER_FREEIF(linear_y_plane);\r
-                       MMPLAYER_FREEIF(linear_uv_plane);\r
-                       MMPLAYER_FREEIF(player->captured.a[0]);\r
-                       MMPLAYER_FREEIF(player->captured.a[1]);\r
-               }\r
-\r
-               msg.union_type = MM_MSG_UNION_CODE;\r
-\r
-               g_mutex_unlock(player->capture_thread_mutex);\r
-               MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_NOT_CAPTURED, &msg );\r
-       }\r
-       return NULL;\r
-EXIT:\r
-       g_mutex_unlock(player->capture_thread_mutex);\r
-       return NULL;\r
-}\r
-\r
-/**\r
-  * The output is fixed as RGB888\r
-  */\r
-static int\r
-__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)\r
-{\r
-       gint yplane_size = 0;\r
-       gint uvplane_size = 0;\r
-       gint src_width = 0;\r
-       gint src_height = 0;\r
-       guint32 fourcc = 0;\r
-       GstCaps *caps = NULL;\r
-       GstStructure *structure = NULL;\r
-       mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420;\r
-       mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed\r
-\r
-       debug_fenter();\r
-\r
-       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );\r
-       return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT );\r
-\r
-       /* get fourcc */\r
-       caps = GST_BUFFER_CAPS(buffer);\r
-\r
-       return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT );\r
-       debug_log("caps to capture: %s\n", gst_caps_to_string(caps));\r
-\r
-       structure = gst_caps_get_structure (caps, 0);\r
-\r
-       return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL);\r
-\r
-       /* init capture image buffer */\r
-       memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture));\r
-\r
-       gst_structure_get_int (structure, "width", &src_width);\r
-       gst_structure_get_int (structure, "height", &src_height);\r
-\r
-       /* check rgb or yuv */\r
-       if (gst_structure_has_name(structure, "video/x-raw-yuv"))\r
-       {\r
-               gst_structure_get_fourcc (structure, "format", &fourcc);\r
-\r
-               switch(fourcc)\r
-               {\r
-                       /* NV12T */\r
-                       case GST_MAKE_FOURCC ('S', 'T', '1', '2'):\r
-                       {\r
-                               debug_msg ("captured format is ST12\n");\r
-\r
-                               MMPlayerMPlaneImage *proved = NULL;\r
-                               player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;\r
-\r
-                               /* get video frame info from proved buffer */\r
-                               proved = (MMPlayerMPlaneImage *)GST_BUFFER_MALLOCDATA(buffer);\r
-\r
-                               if ( !proved || !proved->a[0] || !proved->a[1] )\r
-                                       return MM_ERROR_PLAYER_INTERNAL;\r
-\r
-                               yplane_size = proved->y_size;\r
-                               uvplane_size = proved->uv_size;\r
-\r
-                               debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size);\r
-                               memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage));\r
-                               memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage));\r
-\r
-                               player->captured.a[0] = g_try_malloc(yplane_size);\r
-                               if ( !player->captured.a[0] )\r
-                                       return MM_ERROR_SOUND_NO_FREE_SPACE;\r
-\r
-                               player->captured.a[1] = g_try_malloc(uvplane_size);\r
-                               if ( !player->captured.a[1] )\r
-                                       return MM_ERROR_SOUND_NO_FREE_SPACE;\r
-\r
-                               memcpy(player->captured.a[0], proved->a[0], yplane_size);\r
-                               memcpy(player->captured.a[1], proved->a[1], uvplane_size);\r
-                               goto DONE;\r
-                       }\r
-                       break;\r
-\r
-                       case GST_MAKE_FOURCC ('I', '4', '2', '0'):\r
-                       {\r
-                               src_fmt = MM_UTIL_IMG_FMT_I420;\r
-                       }\r
-                       break;\r
-\r
-                       default:\r
-                       {\r
-                               goto UNKNOWN;\r
-                       }\r
-                       break;\r
-               }\r
-       }\r
-       else if (gst_structure_has_name(structure, "video/x-raw-rgb"))\r
-       {\r
-               gint bpp;\r
-               gint depth;\r
-               gint endianess;\r
-               gint blue_mask;\r
-               gboolean bigendian = FALSE;\r
-               gboolean isbluefirst = FALSE;\r
-\r
-            /**\r
-               * The followings will be considered.\r
-               * RGBx, xRGB, BGRx, xBGR\r
-               * RGB888, BGR888\r
-               * RGB565\r
-               *\r
-               */\r
-               gst_structure_get_int (structure, "bpp", &bpp);\r
-               gst_structure_get_int (structure, "depth", &depth);\r
-               gst_structure_get_int (structure, "endianness", &endianess);\r
-               gst_structure_get_int (structure, "blue_mask", &blue_mask);\r
-\r
-               if (endianess == 4321)\r
-                       bigendian = TRUE;\r
-\r
-               if (blue_mask == -16777216)\r
-                       isbluefirst = TRUE;\r
-\r
-               switch(bpp)\r
-               {\r
-                       case 32:\r
-                       {\r
-                               switch(depth)\r
-                               {\r
-                                       case 32:\r
-                                               if (bigendian && isbluefirst)\r
-                                                       src_fmt = MM_UTIL_IMG_FMT_BGRA8888;\r
-                                       case 24:\r
-                                               if (bigendian && isbluefirst)\r
-                                                       src_fmt = MM_UTIL_IMG_FMT_BGRX8888;\r
-                                               break;\r
-                                       default:\r
-                                               goto UNKNOWN;\r
-                                               break;\r
-                               }\r
-                       }\r
-                       break;\r
-\r
-                       case 24:\r
-                       default:\r
-                       {\r
-                               goto UNKNOWN;\r
-                       }\r
-                       break;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               goto UNKNOWN;\r
-       }\r
-       __mm_player_convert_colorspace(player, GST_BUFFER_DATA(buffer), src_fmt, src_width, src_height, dst_fmt);\r
-\r
-DONE:\r
-       /* do convert colorspace */\r
-       g_cond_signal( player->capture_thread_cond );\r
-\r
-       debug_fleave();\r
-\r
-       return MM_ERROR_NONE;\r
-\r
-UNKNOWN:\r
-       debug_error("unknown format to capture\n");\r
-       return MM_ERROR_PLAYER_INTERNAL;\r
-}\r
-\r
-static gboolean\r
-__mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data)\r
-{\r
-       mm_player_t* player = (mm_player_t*) u_data;\r
-       int ret = MM_ERROR_NONE;\r
-\r
-       return_val_if_fail ( buffer, FALSE);\r
-       debug_fenter();\r
-\r
-       ret = __mmplayer_get_video_frame_from_buffer(player, buffer);\r
-\r
-       if ( ret != MM_ERROR_NONE)\r
-       {\r
-               debug_error("faild to get video frame. %x\n", ret);\r
-               return FALSE;\r
-       }\r
-\r
-       /* remove probe to be called at one time */\r
-       if (player->video_capture_cb_probe_id)\r
-       {\r
-               gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id);\r
-               player->video_capture_cb_probe_id = 0;\r
-       }\r
-\r
-       debug_fleave();\r
-\r
-       return TRUE;\r
-}\r
-\r
-static int\r
-__mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt)\r
-{\r
-       unsigned char *dst_data = NULL;\r
-       unsigned int dst_size;\r
-       int ret = MM_ERROR_NONE;\r
-\r
-       return_val_if_fail(player, MM_ERROR_PLAYER_INTERNAL);\r
-       ret = mm_util_get_image_size(dst_fmt, src_w, src_h, &dst_size);\r
-\r
-       if (ret != MM_ERROR_NONE)\r
-       {\r
-               debug_error("failed to get image size for capture, %d\n", ret);\r
-               return MM_ERROR_PLAYER_INTERNAL;\r
-       }\r
-\r
+/*
+ * libmm-player
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/*===========================================================================================
+|                                                                                                                                                                                      |
+|  INCLUDE FILES                                                                                                                                                       |
+|                                                                                                                                                                                      |
+========================================================================================== */
+#include "mm_player_capture.h"
+#include "mm_player_priv.h"
+
+#include <mm_util_imgp.h>
+
+/*---------------------------------------------------------------------------
+|    LOCAL VARIABLE DEFINITIONS for internal                                                           |
+---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+|    LOCAL FUNCTION PROTOTYPES:                                                                                                |
+---------------------------------------------------------------------------*/
+static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data);
+static int  __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);
+static gpointer __mmplayer_capture_thread(gpointer data);
+static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int buttom);
+static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);
+static int __mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt);
+
+/*===========================================================================================
+|                                                                                                                                                                                      |
+|  FUNCTION DEFINITIONS                                                                                                                                                |
+|                                                                                                                                                                                      |
+========================================================================================== */
+int
+_mmplayer_initialize_video_capture(mm_player_t* player)
+{
+       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       /* create capture mutex */
+       player->capture_thread_mutex = g_mutex_new();
+       if ( ! player->capture_thread_mutex )
+       {
+               debug_critical("Cannot create capture mutex");
+               goto ERROR;
+       }
+
+       /* create capture cond */
+       player->capture_thread_cond = g_cond_new();
+       if ( ! player->capture_thread_cond )
+       {
+               debug_critical("Cannot create capture cond");
+               goto ERROR;
+       }
+
+       player->capture_thread_exit = FALSE;
+
+       /* create video capture thread */
+       player->capture_thread =
+               g_thread_create (__mmplayer_capture_thread, (gpointer)player, TRUE, NULL);
+       if ( ! player->capture_thread )
+       {
+               goto ERROR;
+       }
+
+       return MM_ERROR_NONE;
+
+ERROR:
+       /* capture thread */
+       if ( player->capture_thread_mutex )
+               g_mutex_free ( player->capture_thread_mutex );
+
+       if ( player->capture_thread_cond )
+               g_cond_free ( player->capture_thread_cond );
+
+       return MM_ERROR_PLAYER_INTERNAL;
+}
+
+int
+_mmplayer_release_video_capture(mm_player_t* player)
+{
+       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       /* release capture thread */
+       if ( player->capture_thread_cond &&
+                player->capture_thread_mutex &&
+                player->capture_thread )
+       {
+               g_mutex_lock(player->capture_thread_mutex);
+               player->capture_thread_exit = TRUE;
+               g_cond_signal( player->capture_thread_cond );
+               g_mutex_unlock(player->capture_thread_mutex);
+
+               debug_log("waitting for capture thread exit");
+               g_thread_join ( player->capture_thread );
+               g_mutex_free ( player->capture_thread_mutex );
+               g_cond_free ( player->capture_thread_cond );
+               debug_log("capture thread released");
+       }
+
+       return MM_ERROR_NONE;
+}
+
+int
+_mmplayer_do_video_capture(MMHandleType hplayer)
+{
+       mm_player_t* player = (mm_player_t*) hplayer;
+       int ret = MM_ERROR_NONE;
+       GstPad *pad = NULL;
+
+       debug_fenter();
+
+       return_val_if_fail(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       /* capturing or not */
+       if (player->video_capture_cb_probe_id || player->capture.data || player->captured.a[0] || player->captured.a[1])
+       {
+               debug_warning("capturing... we can't do any more");
+               return MM_ERROR_PLAYER_INVALID_STATE;
+       }
+
+       /* check if video pipeline is linked or not */
+       if (!player->pipeline->videobin || !player->sent_bos)
+       {
+               debug_warning("not ready to capture");
+               return MM_ERROR_PLAYER_INVALID_STATE;
+       }
+
+       if (player->state != MM_PLAYER_STATE_PLAYING)
+       {
+               if (player->state == MM_PLAYER_STATE_PAUSED) // get last buffer from video sink
+               {
+                       GstBuffer *buf = NULL;
+
+                       gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, NULL, NULL, GST_CLOCK_TIME_NONE);
+                       g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL);
+
+                       if (buf)
+                       {
+                               ret = __mmplayer_get_video_frame_from_buffer(player, buf);
+                               gst_buffer_unref(buf);
+                       }
+                       else
+                       {
+                               debug_warning("Last buffer is NULL");
+                       }
+                       return ret;
+               }
+               else
+               {
+                       debug_warning("invalid state(%d) to capture", player->state);
+                       return MM_ERROR_PLAYER_INVALID_STATE;
+               }
+       }
+
+       pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" );
+
+       /* register probe */
+       player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad,
+               G_CALLBACK (__mmplayer_video_capture_probe), player);
+
+       gst_object_unref(GST_OBJECT(pad));
+       pad = NULL;
+
+       debug_fleave();
+
+       return ret;
+}
+
+static gpointer
+__mmplayer_capture_thread(gpointer data)
+{
+       mm_player_t* player = (mm_player_t*) data;
+       MMMessageParamType msg = {0, };
+       unsigned char * linear_y_plane = NULL;
+       unsigned char * linear_uv_plane = NULL;
+
+       return_val_if_fail(player, NULL);
+
+       while (!player->capture_thread_exit)
+       {
+               debug_log("capture thread started. waiting for signal");
+
+               g_mutex_lock(player->capture_thread_mutex);
+               g_cond_wait( player->capture_thread_cond, player->capture_thread_mutex );
+
+               if ( player->capture_thread_exit )
+               {
+                       debug_log("exiting capture thread");
+                       goto EXIT;
+               }
+               debug_log("capture thread is recieved signal");
+
+               /* NOTE: Don't use MMPLAYER_CMD_LOCK() here.
+                * Because deadlock can be happened if other player api is used in message callback.
+                */
+               if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
+               {
+                       /* Colorspace conversion : NV12T-> NV12-> RGB888 */
+                       int ret = 0;
+                       int linear_y_plane_size;
+                       int linear_uv_plane_size;
+                       unsigned char * src_buffer = NULL;
+
+                       debug_log("w[0]=%d, w[1]=%d", player->captured.w[0], player->captured.w[1]);
+                       debug_log("h[0]=%d, h[1]=%d", player->captured.h[0], player->captured.h[1]);
+                       debug_log("s[0]=%d, s[1]=%d", player->captured.s[0], player->captured.s[1]);
+                       debug_log("e[0]=%d, e[1]=%d", player->captured.e[0], player->captured.e[1]);
+                       debug_log("a[0]=%p, a[1]=%p", player->captured.a[0], player->captured.a[1]);
+
+                       #if 0
+                       if (mm_attrs_get_int_by_name(player->attrs, "content_video_width", &(player->captured.w[0])) != MM_ERROR_NONE)
+                       {
+                               debug_error("failed to get content width attribute");
+                               goto ERROR;
+                       }
+
+                       if (mm_attrs_get_int_by_name(player->attrs, "content_video_height", &(player->captured.h[0])) != MM_ERROR_NONE)
+                       {
+                               debug_error("failed to get content height attribute");
+                               goto ERROR;
+                       }
+                       #endif
+
+                       linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]);
+                       linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2);
+
+                       linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size);
+                       if (linear_y_plane == NULL)
+                       {
+                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
+                               goto ERROR;
+                       }
+
+                       linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size);
+                       if (linear_uv_plane == NULL)
+                       {
+                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
+                               goto ERROR;
+                       }
+                       /* NV12 tiled to linear */
+                       __csc_tiled_to_linear_crop(linear_y_plane, player->captured.a[0], player->captured.w[0], player->captured.h[0], 0,0,0,0);
+                       __csc_tiled_to_linear_crop(linear_uv_plane, player->captured.a[1], player->captured.w[0], player->captured.h[0]/2, 0,0,0,0);
+
+                       MMPLAYER_FREEIF(player->captured.a[0]);
+                       MMPLAYER_FREEIF(player->captured.a[1]);
+
+                       src_buffer = (unsigned char*) g_try_malloc(linear_y_plane_size+linear_uv_plane_size);
+
+                       if (src_buffer == NULL)
+                       {
+                               msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
+                               goto ERROR;
+                       }
+                       memset(src_buffer, 0x00, linear_y_plane_size+linear_uv_plane_size);
+                       memcpy(src_buffer, linear_y_plane, linear_y_plane_size);
+                       memcpy(src_buffer+linear_y_plane_size, linear_uv_plane, linear_uv_plane_size);
+
+                       /* NV12 linear to RGB888 */
+                       ret = __mm_player_convert_colorspace(player, src_buffer, MM_UTIL_IMG_FMT_NV12,
+                               player->captured.w[0], player->captured.h[0], MM_UTIL_IMG_FMT_RGB888);
+
+                       if (ret != MM_ERROR_NONE)
+                       {
+                               debug_error("failed to convert nv12 linear");
+                               goto ERROR;
+                       }
+                       /* clean */
+                       MMPLAYER_FREEIF(src_buffer);
+                       MMPLAYER_FREEIF(linear_y_plane);
+                       MMPLAYER_FREEIF(linear_uv_plane);
+               }
+
+               player->capture.fmt = MM_PLAYER_COLORSPACE_RGB888;
+               msg.data = &player->capture;
+               msg.size = player->capture.size;
+
+               if (player->cmd >= MMPLAYER_COMMAND_START)
+               {
+                       MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_CAPTURED, &msg );
+                       debug_log("returned from capture message callback");
+               }
+
+               g_mutex_unlock(player->capture_thread_mutex);
+
+               //MMPLAYER_FREEIF(player->capture.data);
+               continue;
+ERROR:
+               if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
+               {
+                       /* clean */
+                       MMPLAYER_FREEIF(linear_y_plane);
+                       MMPLAYER_FREEIF(linear_uv_plane);
+                       MMPLAYER_FREEIF(player->captured.a[0]);
+                       MMPLAYER_FREEIF(player->captured.a[1]);
+               }
+
+               msg.union_type = MM_MSG_UNION_CODE;
+
+               g_mutex_unlock(player->capture_thread_mutex);
+               MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_NOT_CAPTURED, &msg );
+       }
+       return NULL;
+EXIT:
+       g_mutex_unlock(player->capture_thread_mutex);
+       return NULL;
+}
+
+/**
+  * The output is fixed as RGB888
+  */
+static int
+__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)
+{
+       gint yplane_size = 0;
+       gint uvplane_size = 0;
+       gint src_width = 0;
+       gint src_height = 0;
+       guint32 fourcc = 0;
+       GstCaps *caps = NULL;
+       GstStructure *structure = NULL;
+       mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420;
+       mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed
+
+       debug_fenter();
+
+       return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT );
+
+       /* get fourcc */
+       caps = GST_BUFFER_CAPS(buffer);
+
+       return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT );
+       debug_log("caps to capture: %s\n", gst_caps_to_string(caps));
+
+       structure = gst_caps_get_structure (caps, 0);
+
+       return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL);
+
+       /* init capture image buffer */
+       memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture));
+
+       gst_structure_get_int (structure, "width", &src_width);
+       gst_structure_get_int (structure, "height", &src_height);
+
+       /* check rgb or yuv */
+       if (gst_structure_has_name(structure, "video/x-raw-yuv"))
+       {
+               gst_structure_get_fourcc (structure, "format", &fourcc);
+
+               switch(fourcc)
+               {
+                       /* NV12T */
+                       case GST_MAKE_FOURCC ('S', 'T', '1', '2'):
+                       {
+                               debug_msg ("captured format is ST12\n");
+
+                               MMPlayerMPlaneImage *proved = NULL;
+                               player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;
+
+                               /* get video frame info from proved buffer */
+                               proved = (MMPlayerMPlaneImage *)GST_BUFFER_MALLOCDATA(buffer);
+
+                               if ( !proved || !proved->a[0] || !proved->a[1] )
+                                       return MM_ERROR_PLAYER_INTERNAL;
+
+                               yplane_size = proved->y_size;
+                               uvplane_size = proved->uv_size;
+
+                               debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size);
+                               memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage));
+                               memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage));
+
+                               player->captured.a[0] = g_try_malloc(yplane_size);
+                               if ( !player->captured.a[0] )
+                                       return MM_ERROR_SOUND_NO_FREE_SPACE;
+
+                               player->captured.a[1] = g_try_malloc(uvplane_size);
+                               if ( !player->captured.a[1] )
+                                       return MM_ERROR_SOUND_NO_FREE_SPACE;
+
+                               memcpy(player->captured.a[0], proved->a[0], yplane_size);
+                               memcpy(player->captured.a[1], proved->a[1], uvplane_size);
+                               goto DONE;
+                       }
+                       break;
+
+                       case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+                       {
+                               src_fmt = MM_UTIL_IMG_FMT_I420;
+                       }
+                       break;
+
+                       default:
+                       {
+                               goto UNKNOWN;
+                       }
+                       break;
+               }
+       }
+       else if (gst_structure_has_name(structure, "video/x-raw-rgb"))
+       {
+               gint bpp;
+               gint depth;
+               gint endianess;
+               gint blue_mask;
+               gboolean bigendian = FALSE;
+               gboolean isbluefirst = FALSE;
+
+            /**
+               * The followings will be considered.
+               * RGBx, xRGB, BGRx, xBGR
+               * RGB888, BGR888
+               * RGB565
+               *
+               */
+               gst_structure_get_int (structure, "bpp", &bpp);
+               gst_structure_get_int (structure, "depth", &depth);
+               gst_structure_get_int (structure, "endianness", &endianess);
+               gst_structure_get_int (structure, "blue_mask", &blue_mask);
+
+               if (endianess == 4321)
+                       bigendian = TRUE;
+
+               if (blue_mask == -16777216)
+                       isbluefirst = TRUE;
+
+               switch(bpp)
+               {
+                       case 32:
+                       {
+                               switch(depth)
+                               {
+                                       case 32:
+                                               if (bigendian && isbluefirst)
+                                                       src_fmt = MM_UTIL_IMG_FMT_BGRA8888;
+                                       case 24:
+                                               if (bigendian && isbluefirst)
+                                                       src_fmt = MM_UTIL_IMG_FMT_BGRX8888;
+                                               break;
+                                       default:
+                                               goto UNKNOWN;
+                                               break;
+                               }
+                       }
+                       break;
+
+                       case 24:
+                       default:
+                       {
+                               goto UNKNOWN;
+                       }
+                       break;
+               }
+       }
+       else
+       {
+               goto UNKNOWN;
+       }
+       __mm_player_convert_colorspace(player, GST_BUFFER_DATA(buffer), src_fmt, src_width, src_height, dst_fmt);
+
+DONE:
+       /* do convert colorspace */
+       g_cond_signal( player->capture_thread_cond );
+
+       debug_fleave();
+
+       return MM_ERROR_NONE;
+
+UNKNOWN:
+       debug_error("unknown format to capture\n");
+       return MM_ERROR_PLAYER_INTERNAL;
+}
+
+static gboolean
+__mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data)
+{
+       mm_player_t* player = (mm_player_t*) u_data;
+       int ret = MM_ERROR_NONE;
+
+       return_val_if_fail ( buffer, FALSE);
+       debug_fenter();
+
+       ret = __mmplayer_get_video_frame_from_buffer(player, buffer);
+
+       if ( ret != MM_ERROR_NONE)
+       {
+               debug_error("faild to get video frame. %x\n", ret);
+               return FALSE;
+       }
+
+       /* remove probe to be called at one time */
+       if (player->video_capture_cb_probe_id)
+       {
+               gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id);
+               player->video_capture_cb_probe_id = 0;
+       }
+
+       debug_fleave();
+
+       return TRUE;
+}
+
+static int
+__mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt)
+{
+       unsigned char *dst_data = NULL;
+       unsigned int dst_size;
+       int ret = MM_ERROR_NONE;
+
+       return_val_if_fail(player, MM_ERROR_PLAYER_INTERNAL);
+       ret = mm_util_get_image_size(dst_fmt, src_w, src_h, &dst_size);
+
+       if (ret != MM_ERROR_NONE)
+       {
+               debug_error("failed to get image size for capture, %d\n", ret);
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
        debug_log("width: %d, height: %d to capture, dest size: %d\n", src_w, src_h, dst_size);\r
-\r
-       dst_data = (unsigned char*)g_malloc0(dst_size);\r
-\r
-       if (!dst_data)\r
-       {\r
-               debug_error("no free space to capture\n");\r
-               return MM_ERROR_PLAYER_NO_FREE_SPACE;\r
-       }\r
-\r
-       ret = mm_util_convert_colorspace(src_data, src_w, src_h, src_fmt, dst_data, dst_fmt);\r
-\r
-       if (ret != MM_ERROR_NONE)\r
-       {\r
-               debug_error("failed to convert for capture, %d\n", ret);\r
-               return MM_ERROR_PLAYER_INTERNAL;\r
-       }\r
-\r
-       player->capture.size = dst_size;\r
-       player->capture.data = dst_data;\r
-\r
-       return MM_ERROR_NONE;\r
-}\r
-\r
-/*\r
- * Get tiled address of position(x,y)\r
- *\r
- * @param x_size\r
- *   width of tiled[in]\r
- *\r
- * @param y_size\r
- *   height of tiled[in]\r
- *\r
- * @param x_pos\r
- *   x position of tield[in]\r
- *\r
- * @param src_size\r
- *   y position of tield[in]\r
- *\r
- * @return\r
- *   address of tiled data\r
- */\r
-static int\r
-__tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)\r
-{\r
-    int pixel_x_m1, pixel_y_m1;\r
-    int roundup_x, roundup_y;\r
-    int linear_addr0, linear_addr1, bank_addr ;\r
-    int x_addr;\r
-    int trans_addr;\r
-\r
-    pixel_x_m1 = x_size -1;\r
-    pixel_y_m1 = y_size -1;\r
-\r
-    roundup_x = ((pixel_x_m1 >> 7) + 1);\r
-    roundup_y = ((pixel_x_m1 >> 6) + 1);\r
-\r
-    x_addr = x_pos >> 2;\r
-\r
-    if ((y_size <= y_pos+32) && ( y_pos < y_size) &&\r
-        (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {\r
-        linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));\r
-        linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));\r
-\r
-        if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))\r
-            bank_addr = ((x_addr >> 4) & 0x1);\r
-        else\r
-            bank_addr = 0x2 | ((x_addr >> 4) & 0x1);\r
-    } else {\r
-        linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));\r
-        linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));\r
-\r
-        if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))\r
-            bank_addr = ((x_addr >> 4) & 0x1);\r
-        else\r
-            bank_addr = 0x2 | ((x_addr >> 4) & 0x1);\r
-    }\r
-\r
-    linear_addr0 = linear_addr0 << 2;\r
-    trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;\r
-\r
-    return trans_addr;\r
-}\r
-\r
-/*\r
- * Converts tiled data to linear\r
- * Crops left, top, right, buttom\r
- * 1. Y of NV12T to Y of YUV420P\r
- * 2. Y of NV12T to Y of YUV420S\r
- * 3. UV of NV12T to UV of YUV420S\r
- *\r
- * @param yuv420_dest\r
- *   Y or UV plane address of YUV420[out]\r
- *\r
- * @param nv12t_src\r
- *   Y or UV plane address of NV12T[in]\r
- *\r
- * @param yuv420_width\r
- *   Width of YUV420[in]\r
- *\r
- * @param yuv420_height\r
- *   Y: Height of YUV420, UV: Height/2 of YUV420[in]\r
- *\r
- * @param left\r
- *   Crop size of left\r
- *\r
- * @param top\r
- *   Crop size of top\r
- *\r
- * @param right\r
- *   Crop size of right\r
- *\r
- * @param buttom\r
- *   Crop size of buttom\r
- */\r
-static void\r
-__csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height,\r
-                                int left, int top, int right, int buttom)\r
-{\r
-    int i, j;\r
-    int tiled_offset = 0, tiled_offset1 = 0;\r
-    int linear_offset = 0;\r
-    int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;\r
-\r
-    temp3 = yuv420_width-right;\r
-    temp1 = temp3-left;\r
-    /* real width is greater than or equal 256 */\r
-    if (temp1 >= 256) {\r
-        for (i=top; i<yuv420_height-buttom; i=i+1) {\r
-            j = left;\r
-            temp3 = (j>>8)<<8;\r
-            temp3 = temp3>>6;\r
-            temp4 = i>>5;\r
-            if (temp4 & 0x1) {\r
-                /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */\r
-                tiled_offset = temp4-1;\r
-                temp1 = ((yuv420_width+127)>>7)<<7;\r
-                tiled_offset = tiled_offset*(temp1>>6);\r
-                tiled_offset = tiled_offset+temp3;\r
-                tiled_offset = tiled_offset+2;\r
-                temp1 = (temp3>>2)<<2;\r
-                tiled_offset = tiled_offset+temp1;\r
-                tiled_offset = tiled_offset<<11;\r
-                tiled_offset1 = tiled_offset+2048*2;\r
-                temp4 = 8;\r
-            } else {\r
-                temp2 = ((yuv420_height+31)>>5)<<5;\r
-                if ((i+32)<temp2) {\r
-                    /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */\r
-                    temp1 = temp3+2;\r
-                    temp1 = (temp1>>2)<<2;\r
-                    tiled_offset = temp3+temp1;\r
-                    temp1 = ((yuv420_width+127)>>7)<<7;\r
-                    tiled_offset = tiled_offset+temp4*(temp1>>6);\r
-                    tiled_offset = tiled_offset<<11;\r
-                    tiled_offset1 = tiled_offset+2048*6;\r
-                    temp4 = 8;\r
-                } else {\r
-                    /* even2 fomula: x+x_block_num*y */\r
-                    temp1 = ((yuv420_width+127)>>7)<<7;\r
-                    tiled_offset = temp4*(temp1>>6);\r
-                    tiled_offset = tiled_offset+temp3;\r
-                    tiled_offset = tiled_offset<<11;\r
-                    tiled_offset1 = tiled_offset+2048*2;\r
-                    temp4 = 4;\r
-                }\r
-            }\r
-\r
-            temp1 = i&0x1F;\r
-            tiled_offset = tiled_offset+64*(temp1);\r
-            tiled_offset1 = tiled_offset1+64*(temp1);\r
-            temp2 = yuv420_width-left-right;\r
-            linear_offset = temp2*(i-top);\r
-            temp3 = ((j+256)>>8)<<8;\r
-            temp3 = temp3-j;\r
-            temp1 = left&0x3F;\r
-            if (temp3 > 192) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);\r
-                temp2 = ((left+63)>>6)<<6;\r
-                temp3 = ((yuv420_width-right)>>6)<<6;\r
-                if (temp2 == temp3) {\r
-                    temp2 = yuv420_width-right-(64-temp1);\r
-                }\r
-                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);\r
-                memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);\r
-                memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);\r
-                linear_offset = linear_offset+256-temp1;\r
-            } else if (temp3 > 128) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);\r
-                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);\r
-                memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);\r
-                linear_offset = linear_offset+192-temp1;\r
-            } else if (temp3 > 64) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);\r
-                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);\r
-                linear_offset = linear_offset+128-temp1;\r
-            } else if (temp3 > 0) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);\r
-                linear_offset = linear_offset+64-temp1;\r
-            }\r
-\r
-            tiled_offset = tiled_offset+temp4*2048;\r
-            j = (left>>8)<<8;\r
-            j = j + 256;\r
-            temp2 = yuv420_width-right-256;\r
-            for (; j<=temp2; j=j+256) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                tiled_offset1 = tiled_offset1+temp4*2048;\r
-                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);\r
-                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);\r
-                tiled_offset = tiled_offset+temp4*2048;\r
-                memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);\r
-                linear_offset = linear_offset+256;\r
-            }\r
-\r
-            tiled_offset1 = tiled_offset1+temp4*2048;\r
-            temp2 = yuv420_width-right-j;\r
-            if (temp2 > 192) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);\r
-                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);\r
-                memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);\r
-            } else if (temp2 > 128) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);\r
-                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, temp2-128);\r
-            } else if (temp2 > 64) {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);\r
-            } else {\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);\r
-            }\r
-        }\r
-    } else if (temp1 >= 64) {\r
-        for (i=top; i<(yuv420_height-buttom); i=i+1) {\r
-            j = left;\r
-            tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);\r
-            temp2 = ((j+64)>>6)<<6;\r
-            temp2 = temp2-j;\r
-            linear_offset = temp1*(i-top);\r
-            temp4 = j&0x3;\r
-            tiled_offset = tiled_offset+temp4;\r
-            memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);\r
-            linear_offset = linear_offset+temp2;\r
-            j = j+temp2;\r
-            if ((j+64) <= temp3) {\r
-                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                linear_offset = linear_offset+64;\r
-                j = j+64;\r
-            }\r
-            if ((j+64) <= temp3) {\r
-                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);\r
-                linear_offset = linear_offset+64;\r
-                j = j+64;\r
-            }\r
-            if (j < temp3) {\r
-                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);\r
-                temp2 = temp3-j;\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);\r
-            }\r
-        }\r
-    } else {\r
-        for (i=top; i<(yuv420_height-buttom); i=i+1) {\r
-            linear_offset = temp1*(i-top);\r
-            for (j=left; j<(yuv420_width-right); j=j+2) {\r
-                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);\r
-                temp4 = j&0x3;\r
-                tiled_offset = tiled_offset+temp4;\r
-                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);\r
-                linear_offset = linear_offset+2;\r
-            }\r
-        }\r
-    }\r
-}\r
+
+       dst_data = (unsigned char*)g_malloc0(dst_size);
+
+       if (!dst_data)
+       {
+               debug_error("no free space to capture\n");
+               return MM_ERROR_PLAYER_NO_FREE_SPACE;
+       }
+
+       ret = mm_util_convert_colorspace(src_data, src_w, src_h, src_fmt, dst_data, dst_fmt);
+
+       if (ret != MM_ERROR_NONE)
+       {
+               debug_error("failed to convert for capture, %d\n", ret);
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       player->capture.size = dst_size;
+       player->capture.data = dst_data;
+
+       return MM_ERROR_NONE;
+}
+
+/*
+ * Get tiled address of position(x,y)
+ *
+ * @param x_size
+ *   width of tiled[in]
+ *
+ * @param y_size
+ *   height of tiled[in]
+ *
+ * @param x_pos
+ *   x position of tield[in]
+ *
+ * @param src_size
+ *   y position of tield[in]
+ *
+ * @return
+ *   address of tiled data
+ */
+static int
+__tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)
+{
+    int pixel_x_m1, pixel_y_m1;
+    int roundup_x, roundup_y;
+    int linear_addr0, linear_addr1, bank_addr ;
+    int x_addr;
+    int trans_addr;
+
+    pixel_x_m1 = x_size -1;
+    pixel_y_m1 = y_size -1;
+
+    roundup_x = ((pixel_x_m1 >> 7) + 1);
+    roundup_y = ((pixel_x_m1 >> 6) + 1);
+
+    x_addr = x_pos >> 2;
+
+    if ((y_size <= y_pos+32) && ( y_pos < y_size) &&
+        (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {
+        linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));
+        linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));
+
+        if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
+            bank_addr = ((x_addr >> 4) & 0x1);
+        else
+            bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
+    } else {
+        linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));
+        linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));
+
+        if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
+            bank_addr = ((x_addr >> 4) & 0x1);
+        else
+            bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
+    }
+
+    linear_addr0 = linear_addr0 << 2;
+    trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;
+
+    return trans_addr;
+}
+
+/*
+ * Converts tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ *   Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ *   Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ *   Width of YUV420[in]
+ *
+ * @param yuv420_height
+ *   Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ *   Crop size of left
+ *
+ * @param top
+ *   Crop size of top
+ *
+ * @param right
+ *   Crop size of right
+ *
+ * @param buttom
+ *   Crop size of buttom
+ */
+static void
+__csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height,
+                                int left, int top, int right, int buttom)
+{
+    int i, j;
+    int tiled_offset = 0, tiled_offset1 = 0;
+    int linear_offset = 0;
+    int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
+
+    temp3 = yuv420_width-right;
+    temp1 = temp3-left;
+    /* real width is greater than or equal 256 */
+    if (temp1 >= 256) {
+        for (i=top; i<yuv420_height-buttom; i=i+1) {
+            j = left;
+            temp3 = (j>>8)<<8;
+            temp3 = temp3>>6;
+            temp4 = i>>5;
+            if (temp4 & 0x1) {
+                /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+                tiled_offset = temp4-1;
+                temp1 = ((yuv420_width+127)>>7)<<7;
+                tiled_offset = tiled_offset*(temp1>>6);
+                tiled_offset = tiled_offset+temp3;
+                tiled_offset = tiled_offset+2;
+                temp1 = (temp3>>2)<<2;
+                tiled_offset = tiled_offset+temp1;
+                tiled_offset = tiled_offset<<11;
+                tiled_offset1 = tiled_offset+2048*2;
+                temp4 = 8;
+            } else {
+                temp2 = ((yuv420_height+31)>>5)<<5;
+                if ((i+32)<temp2) {
+                    /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+                    temp1 = temp3+2;
+                    temp1 = (temp1>>2)<<2;
+                    tiled_offset = temp3+temp1;
+                    temp1 = ((yuv420_width+127)>>7)<<7;
+                    tiled_offset = tiled_offset+temp4*(temp1>>6);
+                    tiled_offset = tiled_offset<<11;
+                    tiled_offset1 = tiled_offset+2048*6;
+                    temp4 = 8;
+                } else {
+                    /* even2 fomula: x+x_block_num*y */
+                    temp1 = ((yuv420_width+127)>>7)<<7;
+                    tiled_offset = temp4*(temp1>>6);
+                    tiled_offset = tiled_offset+temp3;
+                    tiled_offset = tiled_offset<<11;
+                    tiled_offset1 = tiled_offset+2048*2;
+                    temp4 = 4;
+                }
+            }
+
+            temp1 = i&0x1F;
+            tiled_offset = tiled_offset+64*(temp1);
+            tiled_offset1 = tiled_offset1+64*(temp1);
+            temp2 = yuv420_width-left-right;
+            linear_offset = temp2*(i-top);
+            temp3 = ((j+256)>>8)<<8;
+            temp3 = temp3-j;
+            temp1 = left&0x3F;
+            if (temp3 > 192) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
+                temp2 = ((left+63)>>6)<<6;
+                temp3 = ((yuv420_width-right)>>6)<<6;
+                if (temp2 == temp3) {
+                    temp2 = yuv420_width-right-(64-temp1);
+                }
+                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
+                memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
+                memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
+                linear_offset = linear_offset+256-temp1;
+            } else if (temp3 > 128) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);
+                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);
+                memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);
+                linear_offset = linear_offset+192-temp1;
+            } else if (temp3 > 64) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);
+                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);
+                linear_offset = linear_offset+128-temp1;
+            } else if (temp3 > 0) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);
+                linear_offset = linear_offset+64-temp1;
+            }
+
+            tiled_offset = tiled_offset+temp4*2048;
+            j = (left>>8)<<8;
+            j = j + 256;
+            temp2 = yuv420_width-right-256;
+            for (; j<=temp2; j=j+256) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                tiled_offset1 = tiled_offset1+temp4*2048;
+                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
+                tiled_offset = tiled_offset+temp4*2048;
+                memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);
+                linear_offset = linear_offset+256;
+            }
+
+            tiled_offset1 = tiled_offset1+temp4*2048;
+            temp2 = yuv420_width-right-j;
+            if (temp2 > 192) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
+                memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);
+            } else if (temp2 > 128) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+                memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, temp2-128);
+            } else if (temp2 > 64) {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);
+            } else {
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+            }
+        }
+    } else if (temp1 >= 64) {
+        for (i=top; i<(yuv420_height-buttom); i=i+1) {
+            j = left;
+            tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
+            temp2 = ((j+64)>>6)<<6;
+            temp2 = temp2-j;
+            linear_offset = temp1*(i-top);
+            temp4 = j&0x3;
+            tiled_offset = tiled_offset+temp4;
+            memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+            linear_offset = linear_offset+temp2;
+            j = j+temp2;
+            if ((j+64) <= temp3) {
+                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                linear_offset = linear_offset+64;
+                j = j+64;
+            }
+            if ((j+64) <= temp3) {
+                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+                linear_offset = linear_offset+64;
+                j = j+64;
+            }
+            if (j < temp3) {
+                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
+                temp2 = temp3-j;
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+            }
+        }
+    } else {
+        for (i=top; i<(yuv420_height-buttom); i=i+1) {
+            linear_offset = temp1*(i-top);
+            for (j=left; j<(yuv420_width-right); j=j+2) {
+                tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
+                temp4 = j&0x3;
+                tiled_offset = tiled_offset+temp4;
+                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);
+                linear_offset = linear_offset+2;
+            }
+        }
+    }
+}
index 7a5fd56..fb81398 100755 (executable)
@@ -1772,6 +1772,10 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @
                {
                        debug_log("GST_MESSAGE_ASYNC_DONE : %s\n", gst_element_get_name(GST_MESSAGE_SRC(msg)));
 
+                       /* we only handle message from pipeline */
+                       if (msg->src != (GstObject *)player->pipeline->mainbin[MMPLAYER_M_PIPE].gst)
+                               break;
+
                        if (player->doing_seek)
                        {
                                if (MMPLAYER_TARGET_STATE(player) == MM_PLAYER_STATE_PAUSED)
@@ -10202,6 +10206,17 @@ __gst_send_event_to_sink( mm_player_t* player, GstEvent* event )
 
                if (GST_IS_ELEMENT(sink))
                {
+                       /* in the case of some video/audio file,
+                        * it's possible video sink don't consider same position seek
+                        * with current postion
+                        */
+                       if ( !MMPLAYER_IS_STREAMING(player) && player->pipeline->videobin
+                               && player->pipeline->audiobin && (!g_strrstr(GST_ELEMENT_NAME(sink), "audiosink")) )
+                       {
+                               sinks = g_list_next (sinks);
+                               continue;
+                       }
+
                        /* keep ref to the event */
                        gst_event_ref (event);