From: Sejun Park Date: Wed, 13 Dec 2017 01:34:51 +0000 (+0900) Subject: Fix tc fail issue at capture video X-Git-Tag: submit/tizen/20180105.085839~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b8bf5308ef9bdaae9e0941879cc1003d738e70e;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git Fix tc fail issue at capture video Change-Id: I5198de5f8e31cfb794aabdf04e25bfad56fbc827 --- diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 0faf02d..6f8b960 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.82 +Version: 0.6.83 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c index 4ed21ae..7f1e5df 100755 --- a/src/mm_player_capture.c +++ b/src/mm_player_capture.c @@ -33,6 +33,7 @@ #include #include +//#define CAPTURE_OUTPUT_DUMP 1 /*--------------------------------------------------------------------------- | LOCAL VARIABLE DEFINITIONS for internal | ---------------------------------------------------------------------------*/ @@ -46,6 +47,9 @@ 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); +#ifdef CAPTURE_OUTPUT_DUMP +static void capture_output_dump(mm_player_t* player); +#endif /*=========================================================================================== | | @@ -362,8 +366,8 @@ __mmplayer_capture_thread(gpointer data) #define MM_ALIGN(x, a) (((x) +(a) - 1) & ~((a) - 1)) int ret = 0; /* using original width otherwises, app can't know aligned to resize */ - planes[0] = player->captured.width[0] * player->captured.height[0]; - planes[1] = player->captured.width[0] * player->captured.height[1]; + planes[0] = player->captured.stride_width[0] * player->captured.stride_height[0]; + planes[1] = player->captured.stride_width[1] * player->captured.stride_height[1]; int src_buffer_size = planes[0] + planes[1]; src_buffer = (unsigned char*) g_try_malloc(src_buffer_size); p_buf = src_buffer; @@ -378,7 +382,7 @@ __mmplayer_capture_thread(gpointer data) goto ERROR; } - memset(p_buf, 0x00, src_buffer_size); + memset(src_buffer, 0x00, src_buffer_size); temp = player->captured.data[0]; @@ -393,16 +397,11 @@ __mmplayer_capture_thread(gpointer data) /* set UV plane*/ for (j = 0; j < player->captured.height[1]; j++) { - memcpy(p_buf, temp, player->captured.width[0]); - p_buf += player->captured.width[0]; + memcpy(p_buf, temp, player->captured.width[1]); + p_buf += player->captured.width[1]; temp += player->captured.stride_width[1]; } - /* free captured buf */ - for (i = 0; i < player->captured.handle_num; i++) { - MMPLAYER_FREEIF(player->captured.data[i]); - } - /* NV12 -> RGB888 */ ret = __mm_player_convert_colorspace(player, (unsigned char*)src_buffer, MM_UTIL_IMG_FMT_NV12, player->captured.width[0], player->captured.height[0], MM_UTIL_IMG_FMT_RGB888); @@ -410,14 +409,20 @@ __mmplayer_capture_thread(gpointer data) LOGE("failed to convert nv12 linear"); goto ERROR; } - +#ifdef CAPTURE_OUTPUT_DUMP + capture_output_dump(player); +#endif /* clean */ MMPLAYER_FREEIF(src_buffer); + /* free captured buf */ + for (i = 0; i < player->captured.handle_num; i++) { + MMPLAYER_FREEIF(player->captured.data[i]); + } } else if (MM_PLAYER_COLORSPACE_I420 == player->video_cs) { - planes[0] = player->captured.width[0] * player->captured.height[0]; - planes[1] = planes[2] = (player->captured.width[0]>>1) * (player->captured.height[0]>>1); + 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); - src_buffer = (unsigned char*) g_try_malloc(player->captured.width[0] * player->captured.height[0]*3/2); + src_buffer = (unsigned char*) g_try_malloc(player->captured.stride_width[0] * player->captured.stride_height[0]*3/2); p_buf = src_buffer; /* set Y plane */ memset(p_buf, 0x00, planes[0]); @@ -456,9 +461,12 @@ __mmplayer_capture_thread(gpointer data) LOGE("failed to convert I420 linear"); goto ERROR; } - - /* free captured buf */ +#ifdef CAPTURE_OUTPUT_DUMP + capture_output_dump(player); +#endif + /* clean */ MMPLAYER_FREEIF(src_buffer); + /* free captured buf */ for (i = 0; i < player->captured.handle_num; i++) { MMPLAYER_FREEIF(player->captured.data[i]); } @@ -628,27 +636,29 @@ __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuff LOGD("Buffer type %d", proved->type); if (proved->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) { - tbm_bo_ref(proved->handle.bo[0]); - tbm_bo_ref(proved->handle.bo[1]); + + for (i = 0; i < player->captured.handle_num; i++) { + tbm_bo_ref(proved->handle.bo[i]); + } LOGD("plane[0] : %p, size %d", proved->data[0], planes[0]); + if (proved->data[0]) memcpy(player->captured.data[0], proved->data[0], planes[0]); LOGD("plane[1] : %p, size %d", proved->data[1], planes[1]); + if (proved->data[1]) memcpy(player->captured.data[1], proved->data[1], planes[1]); - tbm_bo_unref(proved->handle.bo[0]); - tbm_bo_unref(proved->handle.bo[1]); - if (player->video_cs == MM_PLAYER_COLORSPACE_I420) { - tbm_bo_ref(proved->handle.bo[2]); LOGD("plane[2] : %p, size %d", proved->data[2], planes[2]); if (proved->data[2]) memcpy(player->captured.data[2], proved->data[2], planes[2]); + } - tbm_bo_unref(proved->handle.bo[2]); + for (i = 0; i < player->captured.handle_num; i++) { + tbm_bo_unref(proved->handle.bo[i]); } } else { LOGE("Not support video buffer type %d", proved->type); @@ -694,7 +704,15 @@ DONE: /* do convert colorspace */ MMPLAYER_CAPTURE_THREAD_SIGNAL(player); + if (caps) { + gst_caps_unref(caps); + caps = NULL; + } + + return ret; + ERROR: + if (caps) { gst_caps_unref(caps); caps = NULL; @@ -1021,3 +1039,36 @@ __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, } } } + +#ifdef CAPTURE_OUTPUT_DUMP /* for capture output dump */ +static void capture_output_dump(mm_player_t* player) +{ + unsigned char *temp = NULL; + char file[100] = { 0, }; + FILE *fp = NULL; + int ret = 0; + int i = 0, j = 0; + + LOGE("capture output dump start. size = %d", player->capture.size); + sprintf(file, "/tmp/dec_output_dump_%dx%d.yuv", player->captured.width[0], player->captured.height[0]); + fp = fopen(file, "ab"); + + for (i = 0; i < player->captured.plane_num; i++) { + temp = player->captured.data[i]; + + for (j = 0; j < player->captured.height[i]; j++) { + ret = fwrite(temp, player->captured.width[i], 1, fp); + temp += player->captured.width[i]; + } + } + LOGE("capture yuv dumped!! ret = %d", ret); + fclose(fp); + + temp = (unsigned char *)player->capture.data; + sprintf(file, "/tmp/dec_output_dump_%dx%d.rgb", player->captured.width[0], player->captured.height[0]); + fp = fopen(file, "ab"); + ret = fwrite(temp, player->capture.size, 1, fp); + fclose(fp); + LOGE("capture rgb dumped!! ret = %d", ret); +} +#endif