#include <mm_util_imgp.h>
#include <gst/video/video-info.h>
+//#define CAPTURE_OUTPUT_DUMP 1
/*---------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------*/
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
/*===========================================================================================
| |
#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;
goto ERROR;
}
- memset(p_buf, 0x00, src_buffer_size);
+ memset(src_buffer, 0x00, src_buffer_size);
temp = player->captured.data[0];
/* 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);
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]);
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]);
}
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);
/* 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;
}
}
}
+
+#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