+
+static int
+__mm_player_convert_NV12_tiled(mmplayer_t *player)
+{
+ /* Colorspace conversion : NV12T-> NV12-> RGB888 */
+ int i;
+ int ret = MM_ERROR_NONE;
+ unsigned char *src_buffer = NULL;
+ unsigned char *linear_y_plane = NULL;
+ unsigned char *linear_uv_plane = NULL;
+ guint linear_y_plane_size;
+ guint linear_uv_plane_size;
+ guint width = player->captured.width[0];
+ guint height = player->captured.height[0];
+
+ linear_y_plane_size = width * height;
+ linear_uv_plane_size = linear_y_plane_size / 2;
+
+ if (!linear_y_plane_size || !linear_uv_plane_size) {
+ LOGE("invalid plane size");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+ linear_y_plane = (unsigned char *)g_malloc(linear_y_plane_size);
+ linear_uv_plane = (unsigned char *)g_malloc(linear_uv_plane_size);
+
+ /* NV12 tiled to linear */
+ __csc_tiled_to_linear_crop(linear_y_plane,
+ player->captured.data[0], width, height, 0, 0, 0, 0);
+ __csc_tiled_to_linear_crop(linear_uv_plane,
+ player->captured.data[1], width, height / 2, 0, 0, 0, 0);
+
+ src_buffer = (unsigned char *)g_malloc(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, (size_t)(linear_y_plane_size + linear_uv_plane_size),
+ MM_UTIL_COLOR_NV12, width, height, MM_UTIL_COLOR_RGB24);
+
+ MMPLAYER_FREEIF(src_buffer);
+ MMPLAYER_FREEIF(linear_y_plane);
+ MMPLAYER_FREEIF(linear_uv_plane);
+
+ for (i = 0; i < player->captured.plane_num; i++)
+ MMPLAYER_FREEIF(player->captured.data[i]);
+
+ return ret;
+}
+
+static int
+__mm_player_convert_NV12(mmplayer_t *player)
+{
+ unsigned char *src_buffer = NULL;
+ unsigned char *p_buf = NULL;
+ unsigned char *temp = NULL;
+ int planes[MAX_BUFFER_PLANE] = {0, };
+ int ret = MM_ERROR_NONE;
+ int i, j;
+
+ /* using original width otherwise, app can't know aligned to resize */
+ planes[0] = player->captured.stride_width[0] * player->captured.stride_height[0];
+ planes[1] = player->captured.stride_width[1] * player->captured.stride_height[1];
+ guint src_buffer_size = planes[0] + planes[1];
+
+ if (!src_buffer_size) {
+ LOGE("invalid data size");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+ src_buffer = (unsigned char *)g_malloc(src_buffer_size);
+
+ p_buf = src_buffer;
+
+ temp = player->captured.data[0];
+
+ /* set Y plane */
+ for (i = 0; i < player->captured.height[0]; i++) {
+ memcpy(p_buf, temp, player->captured.width[0]);
+ p_buf += player->captured.width[0];
+ temp += player->captured.stride_width[0];
+ }
+
+ temp = player->captured.data[1];
+
+ /* set UV plane*/
+ for (j = 0; j < player->captured.height[1]; j++) {
+ memcpy(p_buf, temp, player->captured.width[1]);
+ p_buf += player->captured.width[1];
+ temp += player->captured.stride_width[1];
+ }
+
+ /* NV12 -> RGB888 */
+ ret = __mm_player_convert_colorspace(player, (unsigned char *)src_buffer, (size_t)src_buffer_size,
+ MM_UTIL_COLOR_NV12, player->captured.width[0],
+ player->captured.height[0], MM_UTIL_COLOR_RGB24);
+
+#ifdef CAPTURE_OUTPUT_DUMP
+ capture_output_dump(player);
+#endif
+ MMPLAYER_FREEIF(src_buffer);
+
+ for (i = 0; i < player->captured.plane_num; i++)
+ MMPLAYER_FREEIF(player->captured.data[i]);
+
+ return ret;
+}
+
+static int
+__mm_player_convert_I420(mmplayer_t *player)
+{
+ unsigned char *src_buffer = NULL;
+ unsigned char *p_buf = NULL;
+ unsigned char *temp = NULL;
+ int planes[MAX_BUFFER_PLANE] = {0, };
+ int ret = MM_ERROR_NONE;
+ int i;
+
+ /* using original width otherwise, app can't know aligned to resize */
+ planes[0] = player->captured.stride_width[0] * player->captured.stride_height[0];
+ planes[1] = planes[2] = (player->captured.stride_width[0] >> 1)
+ * (player->captured.stride_height[0] >> 1);
+
+ if (!planes[0] || !planes[1] || !planes[2]) {
+ LOGE("invalid plane size");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+ src_buffer = (unsigned char *)g_malloc(planes[0] + planes[1] + planes[2]);
+
+ /* set Y plane */
+ p_buf = src_buffer;
+
+ temp = player->captured.data[0];
+
+ for (i = 0; i < player->captured.height[0]; i++) {
+ memcpy(p_buf, temp, player->captured.width[0]);
+ temp += player->captured.stride_width[0];
+ p_buf += player->captured.width[0];
+ }
+
+ /* set U plane */
+ temp = player->captured.data[1];
+
+ for (i = 0; i < player->captured.height[1]; i++) {
+ memcpy(p_buf, temp, player->captured.width[1]);
+ temp += player->captured.stride_width[1];
+ p_buf += player->captured.width[1];
+ }
+
+ /* set V plane */
+ temp = player->captured.data[2];
+
+ for (i = 0; i < player->captured.height[2]; i++) {
+ memcpy(p_buf, temp, player->captured.width[2]);
+ temp += player->captured.stride_width[2];
+ p_buf += player->captured.width[2];
+ }
+
+ /* I420 -> RGB888 */
+ ret = __mm_player_convert_colorspace(player, (unsigned char *)src_buffer, (size_t)(planes[0] + planes[1] + planes[2]),
+ MM_UTIL_COLOR_I420, player->captured.width[0], player->captured.height[0], MM_UTIL_COLOR_RGB24);
+
+#ifdef CAPTURE_OUTPUT_DUMP
+ capture_output_dump(player);
+#endif
+ MMPLAYER_FREEIF(src_buffer);
+
+ for (i = 0; i < player->captured.plane_num; i++)
+ MMPLAYER_FREEIF(player->captured.data[i]);
+
+ return ret;
+}
+
+static int
+__mm_player_convert_BGRx(mmplayer_t *player)
+{
+ int i;
+ guint size;
+ int ret = MM_ERROR_NONE;
+ unsigned char *src_buffer = NULL;
+
+ size = (player->captured.stride_width[0] * player->captured.stride_height[0]);
+
+ if (!size) {
+ LOGE("invalid size");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+ src_buffer = (unsigned char *)g_malloc(size);
+ memcpy(src_buffer, player->captured.data[0], size);
+
+ /* BGRx -> RGB888 */
+ ret = __mm_player_convert_colorspace(player, (unsigned char *)src_buffer, (size_t)size, MM_UTIL_COLOR_BGRX,
+ player->captured.width[0], player->captured.height[0], MM_UTIL_COLOR_RGB24);
+
+#ifdef CAPTURE_OUTPUT_DUMP
+ capture_output_dump(player);
+#endif
+ MMPLAYER_FREEIF(src_buffer);
+
+ for (i = 0; i < player->captured.plane_num; i++)
+ MMPLAYER_FREEIF(player->captured.data[i]);
+
+ return ret;
+}