unsigned char *dst_frame = NULL;
unsigned int dst_width = 0;
unsigned int dst_height = 0;
- unsigned int dst_size = 0;
+ size_t dst_size = 0;
mm_util_img_rotate_type rot_enum = MM_UTIL_ROTATE_NUM;
player->capture.orientation = orientation;
} else
LOGE("wrong orientation value...");
- /* height & width will be interchanged for 90 and 270 orientation */
- ret = mm_util_get_image_size(format, dst_width, dst_height, &dst_size);
- if (ret != MM_ERROR_NONE) {
- LOGE("failed to get destination frame size");
- return ret;
- }
-
+ /* height & width will be interchanged for 90 and 270 orientation */
LOGD("before rotation : dst_width = %d and dst_height = %d", dst_width, dst_height);
-
- dst_frame = (unsigned char*) malloc(dst_size);
- if (!dst_frame) {
- LOGE("failed to allocate memory");
- return MM_ERROR_PLAYER_NO_FREE_SPACE;
- }
-
src_buffer = (unsigned char*)player->capture.data;
/* convert orientation degree into enum here */
LOGD("source buffer for rotation = %p and rotation = %d", src_buffer, rot_enum);
ret = mm_util_rotate_image(src_buffer,
- player->captured.width[0], player->captured.height[0], format,
- dst_frame, &dst_width, &dst_height, rot_enum);
- if (ret != MM_ERROR_NONE) {
+ player->captured.width[0], player->captured.height[0], format, rot_enum,
+ &dst_frame, &dst_width, &dst_height, &dst_size);
+ if (ret != MM_ERROR_NONE || !dst_frame) {
LOGE("failed to do rotate image");
free(dst_frame);
return ret;
}
- LOGD("after rotation same stride: dst_width = %d and dst_height = %d", dst_width, dst_height);
+ LOGD("after rotation same stride: dst_width = %d and dst_height = %d, dst_size = %zu", dst_width, dst_height, dst_size);
g_free(src_buffer);
player->capture.data = dst_frame;
- player->capture.size = dst_size;
+ player->capture.size = (int)dst_size;
player->capture.orientation = orientation;
player->capture.width = dst_width;
player->capture.height = dst_height;
__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_size;
+ unsigned int dst_width = 0;
+ unsigned int dst_height = 0;
+ size_t dst_size = 0;
int ret = MM_ERROR_NONE;
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_INTERNAL);
- ret = mm_util_get_image_size(dst_fmt, src_w, src_h, &dst_size);
+ SECURE_LOGD("src size info. width: %d, height: %d \n", src_w, src_h);
- if (ret != MM_ERROR_NONE) {
- LOGE("failed to get image size for capture, %d\n", ret);
- return MM_ERROR_PLAYER_INTERNAL;
- }
-
- SECURE_LOGD("width: %d, height: %d to capture, dest size: %d\n", src_w, src_h, dst_size);
-
- dst_data = (unsigned char*)g_malloc0(dst_size);
-
- if (!dst_data) {
- LOGE("no free space to capture\n");
- g_free(dst_data);
- 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) {
+ 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);
g_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);
- player->capture.size = dst_size;
+ player->capture.size = (int)dst_size;
player->capture.data = dst_data;
return MM_ERROR_NONE;