| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------*/
static GstPadProbeReturn __mmplayer_video_capture_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuffer *buffer);
+static int __mmplayer_get_video_frame_from_buffer(mm_player_t *player, GstPad *pad, 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_color_format_e src_fmt, unsigned int src_w, unsigned int src_h, mm_util_color_format_e dst_fmt);
+static int __mm_player_convert_colorspace(mm_player_t *player, unsigned char *src_data, mm_util_color_format_e src_fmt, unsigned int src_w, unsigned int src_h, mm_util_color_format_e dst_fmt);
static int __mm_player_convert_NV12_tiled(mm_player_t *player);
static int __mm_player_convert_NV12(mm_player_t *player);
static int __mm_player_convert_I420(mm_player_t *player);
static int __mm_player_convert_BGRx(mm_player_t *player);
#ifdef CAPTURE_OUTPUT_DUMP
-static void capture_output_dump(mm_player_t* player);
+static void capture_output_dump(mm_player_t *player);
#endif
/*===========================================================================================
| |
========================================================================================== */
int
-_mmplayer_initialize_video_capture(mm_player_t* player)
+_mmplayer_initialize_video_capture(mm_player_t *player)
{
int ret = MM_ERROR_NONE;
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
/* create capture cond */
g_cond_init(&player->capture_thread_cond);
-
player->capture_thread_exit = FALSE;
/* create video capture thread */
ERROR:
/* capture thread */
g_mutex_clear(&player->capture_thread_mutex);
-
g_cond_clear(&player->capture_thread_cond);
-
return ret;
}
int
-_mmplayer_release_video_capture(mm_player_t* player)
+_mmplayer_release_video_capture(mm_player_t *player)
{
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
/* release capture thread */
int
_mmplayer_do_video_capture(MMHandleType hplayer)
{
- mm_player_t* player = (mm_player_t*) hplayer;
+ mm_player_t *player = (mm_player_t *)hplayer;
int ret = MM_ERROR_NONE;
GstPad *pad = NULL;
}
int
-__mmplayer_handle_orientation(mm_player_t* player, int orientation, int format)
+__mmplayer_handle_orientation(mm_player_t *player, int orientation, int format)
{
unsigned char *src_buffer = NULL;
int ret = MM_ERROR_NONE;
player->capture.width = player->captured.width[0];
player->capture.height = player->captured.height[0];
return MM_ERROR_NONE;
- } else
+ } else {
LOGE("wrong orientation value...");
+ }
/* height & width will be interchanged for 90 and 270 orientation */
LOGD("before rotation : dst_width = %d and dst_height = %d", dst_width, dst_height);
return ret;
}
-
static gpointer
__mmplayer_capture_thread(gpointer data)
{
- mm_player_t *player = (mm_player_t *) data;
+ mm_player_t *player = (mm_player_t *)data;
MMMessageParamType msg = {0, };
int orientation = 0;
int display_angle = 0;
* The output is fixed as RGB888
*/
static int
-__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuffer *buffer)
+__mmplayer_get_video_frame_from_buffer(mm_player_t *player, GstPad *pad, GstBuffer *buffer)
{
gint i = 0;
guint plane_size = 0;
gst_caps_unref(caps);
- LOGI("captured format is %s\n", gst_video_format_to_string(GST_VIDEO_INFO_FORMAT(&vinfo)));
+ LOGI("captured format is %s", gst_video_format_to_string(GST_VIDEO_INFO_FORMAT(&vinfo)));
player->captured.width[0] = GST_VIDEO_INFO_WIDTH(&vinfo);
player->captured.height[0] = GST_VIDEO_INFO_HEIGHT(&vinfo);
case GST_VIDEO_FORMAT_SN12:
player->video_cs = MM_PLAYER_COLORSPACE_NV12;
player->captured.width[1] = player->captured.width[0];
- player->captured.height[1] = player->captured.height[0]>>1;
+ player->captured.height[1] = player->captured.height[0] >> 1;
break;
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_S420:
player->video_cs = MM_PLAYER_COLORSPACE_I420;
- player->captured.width[1] = player->captured.width[2] = player->captured.width[0]>>1;
- player->captured.height[1] = player->captured.height[2] = player->captured.height[0]>>1;
+ player->captured.width[1] = player->captured.width[2] = player->captured.width[0] >> 1;
+ player->captured.height[1] = player->captured.height[2] = player->captured.height[0] >> 1;
break;
case GST_VIDEO_FORMAT_ST12:
player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;
player->captured.width[1] = player->captured.width[0];
- player->captured.height[1] = player->captured.height[0]>>1;
+ player->captured.height[1] = player->captured.height[0] >> 1;
break;
case GST_VIDEO_FORMAT_BGRx:
player->video_cs = MM_PLAYER_COLORSPACE_BGRx;
}
if (ret != MM_ERROR_NONE) {
- LOGE("unknown format to capture\n");
+ LOGE("unknown format to capture");
return ret;
}
player->captured.stride_width[i] = GST_VIDEO_FRAME_PLANE_STRIDE(&vframe, i);
player->captured.stride_height[i] = player->captured.height[i];
plane_size = player->captured.stride_width[i] * player->captured.stride_height[i];
-
if (!plane_size) {
LOGE("invalid plane size");
return MM_ERROR_PLAYER_INTERNAL;
static GstPadProbeReturn
__mmplayer_video_capture_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
- mm_player_t* player = (mm_player_t*) u_data;
+ mm_player_t *player = (mm_player_t *)u_data;
GstBuffer *buffer = NULL;
int ret = MM_ERROR_NONE;
buffer = gst_pad_probe_info_get_buffer(info);
ret = __mmplayer_get_video_frame_from_buffer(player, pad, buffer);
-
if (ret != MM_ERROR_NONE) {
LOGE("failed to get video frame");
return GST_PAD_PROBE_REMOVE;
}
static int
-__mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_color_format_e src_fmt, unsigned int src_w, unsigned int src_h, mm_util_color_format_e dst_fmt)
+__mm_player_convert_colorspace(mm_player_t *player, unsigned char *src_data, mm_util_color_format_e src_fmt, unsigned int src_w, unsigned int src_h, mm_util_color_format_e dst_fmt)
{
unsigned char *dst_data = NULL;
unsigned int dst_width = 0;
int ret = MM_ERROR_NONE;
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_INTERNAL);
- SECURE_LOGD("src size info. width: %d, height: %d \n", src_w, src_h);
+ SECURE_LOGD("src size info. width: %d, height: %d", src_w, src_h);
ret = mm_util_convert_colorspace(src_data, src_w, src_h, src_fmt, dst_fmt, &dst_data, &dst_width, &dst_height, &dst_size);
if (ret != MM_ERROR_NONE || !dst_data) {
- LOGE("failed to convert for capture, %d\n", ret);
+ LOGE("failed to convert for capture, %d", ret);
free(dst_data);
return MM_ERROR_PLAYER_INTERNAL;
}
- SECURE_LOGD("dst size info. width: %d, height: %d, size: %zu\n", dst_width, dst_height, dst_size);
+ SECURE_LOGD("dst size info. width: %d, height: %d, size: %zu", dst_width, dst_height, dst_size);
player->capture.size = (int)dst_size;
player->capture.data = dst_data;
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));
+ 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);
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));
+ 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);
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;
+ 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;
+ /* 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;
+ 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;
+ /* 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;
+ 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);
- 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;
+ memcpy(yuv420_dest + linear_offset, nv12t_src + tiled_offset + temp1, 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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);
+ 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);
+ 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);
+ 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) {
+ for (i = top; i < (yuv420_height - buttom); i++) {
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) {
+ 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;
+ memcpy(yuv420_dest + linear_offset, nv12t_src + tiled_offset, 64);
+ linear_offset = linear_offset + 64;
+ j += 64;
}
- if ((j+64) <= temp3) {
+ 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;
+ memcpy(yuv420_dest+linear_offset, nv12t_src + tiled_offset, 64);
+ linear_offset = linear_offset + 64;
+ 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);
+ 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) {
+ for (i = top; i < (yuv420_height - buttom); i++) {
+ linear_offset = temp1 * (i - top);
+ for (j = left; j < (yuv420_width - right); 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;
+ temp4 = j & 0x3;
+ tiled_offset = tiled_offset + temp4;
+ memcpy(yuv420_dest + linear_offset, nv12t_src + tiled_offset, 2);
+ linear_offset = linear_offset + 2;
}
}
}
}
#ifdef CAPTURE_OUTPUT_DUMP /* for capture output dump */
-static void capture_output_dump(mm_player_t* player)
+static void
+capture_output_dump(mm_player_t *player)
{
unsigned char *temp = NULL;
char file[100] = { 0, };
guint width = player->captured.width[0];
guint height = player->captured.height[0];
- linear_y_plane_size = (width * height);
+ linear_y_plane_size = width * height;
linear_uv_plane_size = linear_y_plane_size / 2;
if (!linear_y_plane_size || !linear_uv_plane_size) {