return FALSE;
}
+static int __mm_util_get_crop_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+ unsigned char x_chroma_shift = 0;
+ unsigned char y_chroma_shift = 0;
+ int size, w2, h2, size2;
+ int stride, stride2;
+
+ TTRACE_BEGIN("MM_UTILITY:IMGP:GET_SIZE");
+
+ if (!imgsize) {
+ mm_util_error("imgsize can't be null");
+ TTRACE_END();
+ return MM_UTIL_ERROR_NO_SUCH_FILE;
+ }
+
+ *imgsize = 0;
+
+ if (check_valid_picture_size(width, height) < 0) {
+ mm_util_error("invalid width and height");
+ TTRACE_END();
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (format) {
+ case MM_UTIL_IMG_FMT_I420:
+ case MM_UTIL_IMG_FMT_YUV420:
+ x_chroma_shift = 1;
+ y_chroma_shift = 1;
+ stride = MM_UTIL_ROUND_UP_4(width);
+ h2 = ROUND_UP_X(height, x_chroma_shift);
+ size = stride * h2;
+ w2 = DIV_ROUND_UP_X(width, x_chroma_shift);
+ stride2 = MM_UTIL_ROUND_UP_4(w2);
+ h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
+ size2 = stride2 * h2;
+ *imgsize = size + 2 * size2;
+ break;
+ case MM_UTIL_IMG_FMT_YUV422:
+ case MM_UTIL_IMG_FMT_YUYV:
+ case MM_UTIL_IMG_FMT_UYVY:
+ case MM_UTIL_IMG_FMT_NV16:
+ case MM_UTIL_IMG_FMT_NV61:
+ stride = MM_UTIL_ROUND_UP_4(width) * 2;
+ size = stride * height;
+ *imgsize = size;
+ break;
+
+ case MM_UTIL_IMG_FMT_RGB565:
+ stride = width * 2;
+ size = stride * height;
+ *imgsize = size;
+ break;
+
+ case MM_UTIL_IMG_FMT_RGB888:
+ stride = width * 3;
+ size = stride * height;
+ *imgsize = size;
+ break;
+
+ case MM_UTIL_IMG_FMT_ARGB8888:
+ case MM_UTIL_IMG_FMT_BGRA8888:
+ case MM_UTIL_IMG_FMT_RGBA8888:
+ case MM_UTIL_IMG_FMT_BGRX8888:
+ stride = width * 4;
+ size = stride * height;
+ *imgsize = size;
+ break;
+
+
+ case MM_UTIL_IMG_FMT_NV12:
+ case MM_UTIL_IMG_FMT_NV12_TILED:
+ x_chroma_shift = 1;
+ y_chroma_shift = 1;
+ stride = MM_UTIL_ROUND_UP_4(width);
+ h2 = ROUND_UP_X(height, y_chroma_shift);
+ size = stride * h2;
+ w2 = 2 * DIV_ROUND_UP_X(width, x_chroma_shift);
+ stride2 = MM_UTIL_ROUND_UP_4(w2);
+ h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
+ size2 = stride2 * h2;
+ *imgsize = size + size2;
+ break;
+
+ default:
+ mm_util_error("Not supported format");
+ TTRACE_END();
+ return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+ mm_util_debug("format: %d, *imgsize: %d", format, *imgsize);
+
+ TTRACE_END();
+ return ret;
+}
+
int __mm_util_get_buffer_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
{
int ret = MM_UTIL_ERROR_NONE;
memcpy(dst_buf[src_index], handle->src, handle->src_buf_size);
if (handle->set_crop) {
dst_index++;
- mm_util_get_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
+ __mm_util_get_crop_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
dst_buf[dst_index] = g_malloc(dst_buf_size);
if (dst_buf[dst_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
uint64_t size = 0;
void *ptr = NULL;
- if ((fmt == NULL) || (pkt == NULL) || (ptr == NULL) || (size == 0)) {
+ if ((fmt == NULL) || (pkt == NULL) || (buffer == NULL) || (buffer_size == 0)) {
mm_util_error("Invalid parameter");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
return MM_UTIL_ERROR_INVALID_OPERATION;
}
- if (size < buffer_size) {
- mm_util_error("The buffer(%lu) of media_packet is smaller than result(%d)", size, buffer_size);
+ if (size < (uint64_t)buffer_size) {
+ mm_util_error("The buffer(%lu) of media_packet is smaller than result(%u)", size, buffer_size);
media_packet_destroy(*pkt);
return MM_UTIL_ERROR_INVALID_OPERATION;
}
mm_util_debug("src: %p (%u X %u)", src_packet, handle->src_width, handle->src_height);
ret = __mm_util_processing(handle);
-
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_util_processing failed");
handle->dst_packet = NULL;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
+ mm_util_debug("handle->src_packet: %p [%d] %d X %d (%d) => handle->dst_packet: %p [%d] %d X %d (%d)",
+ handle->src_packet, handle->src_format, handle->src_width, handle->src_height, handle->src_buf_size,
+ handle->dst_packet, handle->dst_format, handle->dst_width, handle->dst_height, handle->dst_buf_size);
ret = __mm_create_media_format(src_fmt, handle->dst_format_mime, handle->dst_width, handle->dst_height, &dst_fmt);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- mm_util_debug("handle->src_packet: %p [%d] %d X %d (%d) => handle->dst_packet: %p [%d] %d X %d (%d)",
- handle->src_packet, handle->src_format, handle->src_width, handle->src_height, handle->src_buf_size,
- handle->dst_packet, handle->dst_format, handle->dst_width, handle->dst_height, handle->dst_buf_size);
-
media_format_unref(dst_fmt);
IMGP_FREE(handle->dst);