#define GST "gstcs"
typedef gboolean(*IMGPInfoFunc) (imgp_info_s*, const unsigned char*, unsigned char*, imgp_plugin_type_e);
+static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packet);
-static int
-check_valid_picture_size(int width, int height)
+static int check_valid_picture_size(int width, int height)
{
if((int)width>0 && (int)height>0 && (width+128)*(unsigned long long)(height+128) < INT_MAX/4) {
return MM_ERROR_NONE;
return MM_ERROR_IMAGE_INVALID_VALUE;
}
-static void
-__mm_destroy_temp_buffer(unsigned char *buffer[])
+static void __mm_destroy_temp_buffer(unsigned char *buffer[])
{
int i = 0;
for(i=0; i < 4; i++) {
}
}
-static gboolean
-_mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format )
+static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format )
{
gboolean _bool=FALSE;
debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
return _bool;
}
-static gboolean
-_mm_gst_can_resize_format(char* __format_label)
+static gboolean __mm_gst_can_resize_format(char* __format_label)
{
gboolean _bool = FALSE;
debug_log("Format label: %s",__format_label);
return _bool;
}
-static gboolean
-_mm_gst_can_rotate_format(const char* __format_label)
+static gboolean __mm_gst_can_rotate_format(const char* __format_label)
{
gboolean _bool = FALSE;
debug_log("Format label: %s boolean: %d",__format_label, _bool);
return _bool;
}
-static gboolean
-_mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format )
+static gboolean __mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format )
{
gboolean _bool=FALSE;
debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
return _bool;
}
-static gboolean
-_mm_select_resize_plugin(mm_util_img_format _format)
+static gboolean __mm_select_resize_plugin(mm_util_img_format _format)
{
gboolean _bool = FALSE;
debug_log("_format: %d", _format);
return _bool;
}
-static gboolean
-_mm_select_rotate_plugin(mm_util_img_format _format, unsigned int width, unsigned int height, mm_util_img_rotate_type angle)
+static gboolean __mm_select_rotate_plugin(mm_util_img_format _format, unsigned int width, unsigned int height, mm_util_img_rotate_type angle)
{
debug_log("_format: %d (angle: %d)", _format, angle);
return FALSE;
}
-static int
-_mm_confirm_dst_width_height(unsigned int src_width, unsigned int src_height, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
+static int __mm_confirm_dst_width_height(unsigned int src_width, unsigned int src_height, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_ERROR_NONE;
return ret;
}
-static int
-_mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, mm_util_img_format dst_format)
+static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, mm_util_img_format dst_format)
{
int ret = MM_ERROR_NONE;
char *src_fmt_lable = NULL;
switch(src_format) {
case MM_UTIL_IMG_FMT_YUV420:
- src_fmt_lable = "YV12";
+ src_fmt_lable = (char *)"YV12";
break;
case MM_UTIL_IMG_FMT_YUV422:
- src_fmt_lable = "Y42B";
+ src_fmt_lable = (char *)"Y42B";
break;
case MM_UTIL_IMG_FMT_I420:
- src_fmt_lable = "I420";
+ src_fmt_lable = (char *)"I420";
break;
case MM_UTIL_IMG_FMT_NV12:
- src_fmt_lable = "NV12";
+ src_fmt_lable = (char *)"NV12";
break;
case MM_UTIL_IMG_FMT_UYVY:
- src_fmt_lable = "UYVY";
+ src_fmt_lable = (char *)"UYVY";
break;
case MM_UTIL_IMG_FMT_YUYV:
- src_fmt_lable = "YUYV";
+ src_fmt_lable = (char *)"YUYV";
break;
case MM_UTIL_IMG_FMT_RGB565:
- src_fmt_lable = "RGB565";
+ src_fmt_lable = (char *)"RGB565";
break;
case MM_UTIL_IMG_FMT_RGB888:
- src_fmt_lable = "RGB888";
+ src_fmt_lable = (char *)"RGB888";
break;
case MM_UTIL_IMG_FMT_ARGB8888:
- src_fmt_lable = "ARGB8888";
+ src_fmt_lable = (char *)"ARGB8888";
break;
case MM_UTIL_IMG_FMT_BGRA8888:
- src_fmt_lable = "BGRA8888";
+ src_fmt_lable = (char *)"BGRA8888";
break;
case MM_UTIL_IMG_FMT_RGBA8888:
- src_fmt_lable = "RGBA8888";
+ src_fmt_lable = (char *)"RGBA8888";
break;
case MM_UTIL_IMG_FMT_BGRX8888:
- src_fmt_lable = "BGRX";
+ src_fmt_lable = (char *)"BGRX";
break;
default:
debug_log("[%d] Not supported format", src_fmt_lable);
switch(dst_format) {
case MM_UTIL_IMG_FMT_YUV420:
- dst_fmt_lable = "YV12";
+ dst_fmt_lable = (char *)"YV12";
break;
case MM_UTIL_IMG_FMT_YUV422:
- dst_fmt_lable = "Y42B";
+ dst_fmt_lable = (char *)"Y42B";
break;
case MM_UTIL_IMG_FMT_I420:
- dst_fmt_lable = "I420";
+ dst_fmt_lable = (char *)"I420";
break;
case MM_UTIL_IMG_FMT_NV12:
- dst_fmt_lable = "NV12";
+ dst_fmt_lable = (char *)"NV12";
break;
case MM_UTIL_IMG_FMT_UYVY:
- dst_fmt_lable = "UYVY";
+ dst_fmt_lable = (char *)"UYVY";
break;
case MM_UTIL_IMG_FMT_YUYV:
- dst_fmt_lable = "YUYV";
+ dst_fmt_lable = (char *)"YUYV";
break;
case MM_UTIL_IMG_FMT_RGB565:
- dst_fmt_lable = "RGB565";
+ dst_fmt_lable = (char *)"RGB565";
break;
case MM_UTIL_IMG_FMT_RGB888:
- dst_fmt_lable = "RGB888";
+ dst_fmt_lable = (char *)"RGB888";
break;
case MM_UTIL_IMG_FMT_ARGB8888:
- dst_fmt_lable = "ARGB8888";
+ dst_fmt_lable = (char *)"ARGB8888";
break;
case MM_UTIL_IMG_FMT_BGRA8888:
- dst_fmt_lable = "BGRA8888";
+ dst_fmt_lable = (char *)"BGRA8888";
break;
case MM_UTIL_IMG_FMT_RGBA8888:
- dst_fmt_lable = "RGBA8888";
+ dst_fmt_lable = (char *)"RGBA8888";
break;
case MM_UTIL_IMG_FMT_BGRX8888:
- dst_fmt_lable = "BGRX";
+ dst_fmt_lable = (char *)"BGRX";
break;
default:
debug_error("[%d] Not supported format", dst_format);
return ret;
}
-static int
-_mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, unsigned int src_width, unsigned int src_height, mm_util_img_format dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
+static int __mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, unsigned int src_width, unsigned int src_height, mm_util_img_format dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_ERROR_NONE;
+
if(_imgp_info_s == NULL) {
debug_error("_imgp_info_s is NULL");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret=_mm_set_format_label(_imgp_info_s, src_format, dst_format);
+ ret = __mm_set_format_label(_imgp_info_s, src_format, dst_format);
if(ret != MM_ERROR_NONE) {
debug_error("[input] mm_set_format_label error");
return MM_ERROR_IMAGE_INVALID_VALUE;
return ret;
}
-static GModule *
-_mm_util_imgp_initialize(imgp_plugin_type_e _imgp_plugin_type_e)
+static GModule * __mm_util_imgp_initialize(imgp_plugin_type_e _imgp_plugin_type_e)
{
GModule *module = NULL;
debug_log("#Start dlopen#");
return module;
}
-static IMGPInfoFunc
-_mm_util_imgp_process(GModule *module)
+static IMGPInfoFunc __mm_util_imgp_process(GModule *module)
{
IMGPInfoFunc mm_util_imgp_func = NULL;
return NULL;
}
- debug_log("#_mm_util_imgp_process#");
+ debug_log("#__mm_util_imgp_process#");
g_module_symbol(module, IMGP_FUNC_NAME, (gpointer*)&mm_util_imgp_func);
debug_log("mm_util_imgp_func: %p", mm_util_imgp_func);
return MEDIA_PACKET_FINALIZE;
}
-static int
-_mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
+static int __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
{
int ret = MM_ERROR_NONE;
return ret;
}
-static int
-_mm_util_crop_rgba32(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgba32(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
- int i;
+ unsigned int idx = 0;
int src_bytesperline = src_width * 4;
int dst_bytesperline = crop_dest_width * 4;
src, src_width, src_height, src_format, crop_start_x, crop_start_y, crop_dest_width, crop_dest_height);
src += crop_start_y * src_bytesperline + 4 * crop_start_x;
- for (i = 0; i < crop_dest_height; i++) {
+ for (idx = 0; idx < crop_dest_height; idx++) {
memcpy(dst, src, dst_bytesperline);
src += src_bytesperline;
dst += dst_bytesperline;
return ret;
}
-static int
-_mm_util_crop_rgb888(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgb888(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
- int i;
+ unsigned int idx = 0;
int src_bytesperline = src_width * 3;
int dst_bytesperline = crop_dest_width * 3;
src, src_width, src_height, src_format, crop_start_x, crop_start_y, crop_dest_width, crop_dest_height);
src += crop_start_y * src_bytesperline + 3 * crop_start_x;
- for (i = 0; i < crop_dest_height; i++) {
+ for (idx = 0; idx < crop_dest_height; idx++) {
memcpy(dst, src, dst_bytesperline);
src += src_bytesperline;
dst += dst_bytesperline;
return ret;
}
-static int
-_mm_util_crop_rgb565(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgb565(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
- int i;
+ unsigned int idx = 0;
int src_bytesperline = src_width * 2;
int dst_bytesperline = crop_dest_width * 2;
src, src_width, src_height, src_format, crop_start_x, crop_start_y, crop_dest_width, crop_dest_height);
src += crop_start_y * src_bytesperline + 2 * crop_start_x;
- for (i = 0; i < crop_dest_height; i++) {
+ for (idx = 0; idx < crop_dest_height; idx++) {
memcpy(dst, src, dst_bytesperline);
src += src_bytesperline;
dst += dst_bytesperline;
return ret;
}
-static int
-_mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
- int i;
+ unsigned int idx = 0;
int start_x = crop_start_x;
int start_y = crop_start_y;
debug_log("[Input] src: 0x%2x src, src_width: %d src_height: %d src_format: %d crop_start_x: %d crop_start_y: %d crop_dest_width: %d crop_dest_height: %d\n",
const unsigned char *_src = src + start_y * src_width + start_x;
/* Y */
- for (i = 0; i < crop_dest_height; i++) {
+ for (idx = 0; idx < crop_dest_height; idx++) {
memcpy(dst, _src, crop_dest_width);
_src += src_width;
dst += crop_dest_width;
/* U */
_src = src + src_height * src_width + (start_y / 2) * src_width / 2 + start_x / 2;
- for (i = 0; i < crop_dest_height / 2; i++) {
+ for (idx = 0; idx < crop_dest_height / 2; idx++) {
memcpy(dst, _src, crop_dest_width / 2);
_src += src_width / 2;
dst += crop_dest_width / 2;
/* V */
_src = src + src_height * src_width * 5 / 4 + (start_y / 2) * src_width / 2 + start_x / 2;
- for (i = 0; i < crop_dest_height / 2; i++) {
+ for (idx = 0; idx < crop_dest_height / 2; idx++) {
memcpy(dst, _src, crop_dest_width / 2);
_src += src_width / 2;
dst += crop_dest_width / 2;
return ret;
}
-static bool
-_mm_util_check_resolution(unsigned int width, unsigned int height)
+static bool __mm_util_check_resolution(unsigned int width, unsigned int height)
{
if(width == 0)
{
return true;
}
-static int
-_mm_util_handle_init(mm_util_s *handle)
+static int __mm_util_handle_init(mm_util_s *handle)
{
int ret = MM_ERROR_NONE;
handle->src = 0;
handle->dst = 0;
handle->drm_fd = -1;
- handle->dst_format = -1;
+ handle->dst_format = MM_UTIL_IMG_FMT_NUM;
handle->dst_format_mime = -1;
handle->src_buf_idx = 0;
handle->dst_buf_idx = 0;
return ret;
}
-static int
-_mm_util_handle_refresh(mm_util_s *handle)
+static int __mm_util_handle_refresh(mm_util_s *handle)
{
int ret = MM_ERROR_NONE;
return ret;
}
-media_format_mimetype_e
-_mm_util_mapping_imgp_format_to_mime(mm_util_img_format format)
+static media_format_mimetype_e __mm_util_mapping_imgp_format_to_mime(mm_util_img_format format)
{
media_format_mimetype_e mimetype = -1;
case MM_UTIL_IMG_FMT_ARGB8888 :
mimetype = MEDIA_FORMAT_ARGB;
break;
- case MM_UTIL_IMG_FMT_BGRA8888 :
- case MM_UTIL_IMG_FMT_BGRX8888 :
- case MM_UTIL_IMG_FMT_NV61 :
- case MM_UTIL_IMG_FMT_NUM :
- mimetype = -1;
- debug_error("Not Supported Format");
- break;
case MM_UTIL_IMG_FMT_NV12_TILED :
mimetype = MEDIA_FORMAT_NV12T;
break;
+ default:
+ mimetype = -1;
+ debug_error("Not Supported Format [%d]", format);
+ break;
}
debug_log("imgp fmt: %d mimetype fmt: %d", format, mimetype);
+
return mimetype;
}
-mm_util_img_format
-_mm_util_mapping_mime_format_to_imgp(media_format_mimetype_e mimetype)
+static mm_util_img_format __mm_util_mapping_mime_format_to_imgp(media_format_mimetype_e mimetype)
{
mm_util_img_format format = -1;
case MEDIA_FORMAT_ARGB :
format = MM_UTIL_IMG_FMT_ARGB8888;
break;
- case MEDIA_FORMAT_NV21 :
- case MEDIA_FORMAT_H261 :
- case MEDIA_FORMAT_H263 :
- case MEDIA_FORMAT_H263P :
- case MEDIA_FORMAT_H264_SP :
- case MEDIA_FORMAT_H264_MP :
- case MEDIA_FORMAT_H264_HP :
- case MEDIA_FORMAT_MJPEG :
- case MEDIA_FORMAT_MPEG1 :
- case MEDIA_FORMAT_MPEG2_SP :
- case MEDIA_FORMAT_MPEG2_MP :
- case MEDIA_FORMAT_MPEG2_HP :
- case MEDIA_FORMAT_MPEG4_SP :
- case MEDIA_FORMAT_MPEG4_ASP :
- case MEDIA_FORMAT_L16:
- case MEDIA_FORMAT_PCM :
- case MEDIA_FORMAT_PCMA :
- case MEDIA_FORMAT_ALAW :
- case MEDIA_FORMAT_PCMU :
- case MEDIA_FORMAT_ULAW :
- case MEDIA_FORMAT_AMR :
- case MEDIA_FORMAT_G729 :
- case MEDIA_FORMAT_AAC:
- case MEDIA_FORMAT_MP3:
- case MEDIA_FORMAT_MAX :
- format = -1;
- debug_error("Not Supported Format");
- break;
case MEDIA_FORMAT_NV12T :
format = MM_UTIL_IMG_FMT_NV12_TILED;
break;
+ default:
+ format = -1;
+ debug_error("Not Supported Format [%d]", mimetype);
+ break;
}
+
debug_log("mimetype: %d imgp fmt: %d", mimetype, format);
+
return format;
}
-
-gpointer
-_mm_util_thread_repeate(gpointer data)
+gpointer _mm_util_thread_repeate(gpointer data)
{
mm_util_s* handle = (mm_util_s*) data;
int ret = MM_ERROR_NONE;
+ gint64 end_time = 0;
if (!handle) {
debug_error("[ERROR] - handle");
return NULL;
}
- g_mutex_lock (handle->thread_mutex);
-
while (!handle->is_finish) {
+ end_time = g_get_monotonic_time() + 1 * G_TIME_SPAN_SECOND;
debug_log("waiting...");
- g_cond_wait(handle->thread_cond, handle->thread_mutex);
+ g_mutex_lock (&(handle->thread_mutex));
+ g_cond_wait_until(&(handle->thread_cond), &(handle->thread_mutex), end_time);
debug_log("<=== get run transform thread signal");
- g_mutex_unlock (handle->thread_mutex);
+ g_mutex_unlock (&(handle->thread_mutex));
if (handle->is_finish) {
debug_log("exit loop");
break;
}
- media_packet_h pop_data = (media_packet_h) g_async_queue_pop(handle->queue);
+ media_packet_h pop_data = (media_packet_h) g_async_queue_try_pop(handle->queue);
if(!pop_data) {
debug_error("[NULL] Queue data");
} else {
- ret = _mm_util_transform_exec(handle, pop_data); /* Need to block */
+ ret = __mm_util_transform_exec(handle, pop_data); /* Need to block */
if(ret == MM_ERROR_NONE) {
debug_log("Success - transform_exec");
} else{
handle->_util_cb->completed_cb(&handle->dst_packet, ret, handle->_util_cb->user_data);
debug_log("completed_cb %p", &handle->dst);
}
- }
- _mm_util_handle_refresh(handle);
+ __mm_util_handle_refresh(handle);
+ }
}
debug_log("exit thread");
return NULL;
}
-int
-_mm_util_create_thread(mm_util_s *handle)
+static int __mm_util_create_thread(mm_util_s *handle)
{
int ret = MM_ERROR_NONE;
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if(!handle->thread_mutex) {
- handle->thread_mutex = g_mutex_new();
- } else {
- debug_error("ERROR - thread_mutex is already created");
- }
+ g_mutex_init(&(handle->thread_mutex));
/*These are a communicator for thread*/
if(!handle->queue) {
debug_error("ERROR - async queue is already created");
}
- if(!handle->thread_cond) {
- handle->thread_cond = g_cond_new();
- } else {
- debug_error("thread cond is already created");
- }
+ g_cond_init(&(handle->thread_cond));
/*create threads*/
handle->thread = g_thread_new("transform_thread", (GThreadFunc)_mm_util_thread_repeate, (gpointer)handle);
return ret;
}
-int _mm_util_processing(mm_util_s *handle)
+static int __mm_util_processing(mm_util_s *handle)
{
int ret = MM_ERROR_NONE;
unsigned char *dst_buf[4] = {NULL,};
handle->dst_width = handle->dst_height;
handle->dst_height = temp_swap;
break;
+ default:
+ break;
}
}
mm_util_get_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
return ret;
}
-int
-_mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packet)
+static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packet)
{
int ret = MM_ERROR_NONE;
media_format_h src_fmt;
unsigned int dst_width = 0, dst_height = 0;
uint64_t size = 0;
- g_mutex_lock (handle->thread_mutex);
-
if(media_packet_get_format(src_packet, &src_fmt) != MM_ERROR_NONE) {
debug_error("Imedia_packet_get_format)");
return MM_ERROR_IMAGE_INVALID_VALUE;
debug_log("[Fotmat: %d] W x H : %d x %d", src_mimetype, src_width, src_height);
}
- if(_mm_util_check_resolution(src_width, src_height)) {
+ if(__mm_util_check_resolution(src_width, src_height)) {
/* src */
handle->src_packet = src_packet;
debug_log("src_packet: %p handle->src_packet: %p 0x%2x [W X H] %d X %d", src_packet, handle->src_packet, src_fmt, src_width, src_height);
if(handle->src_packet) {
- handle->src_format = _mm_util_mapping_mime_format_to_imgp(src_mimetype);
+ handle->src_format = __mm_util_mapping_mime_format_to_imgp(src_mimetype);
handle->src_width = src_width;
handle->src_height = src_height;
} else {
debug_error("Error buffer size");
}
- if(handle->dst_format == -1) {
+ if(handle->dst_format == MM_UTIL_IMG_FMT_NUM) {
debug_log("dst format is changed");
handle->dst_format = handle->src_format;
handle->dst_format_mime = src_mimetype;
dst_width = handle->dst_width = handle->src_width;
dst_height = handle->dst_height = handle->src_height;
break;
+ default:
+ debug_error("[Error] Wrong dst_rotation");
+ break;
}
}
} else {
- dst_width = handle->dst_width = handle->src_width;
- dst_height = handle->dst_height = handle->src_height;
+ if ((handle->set_crop) || (handle->set_resize)) {
+ dst_width = handle->dst_width;
+ dst_height = handle->dst_height;
+ } else {
+ dst_width = handle->dst_width = handle->src_width;
+ dst_height = handle->dst_height = handle->src_height;
+ }
}
debug_log("dst (%d X %d)", dst_width, dst_height);
if(media_format_make_writable(src_fmt, &dst_fmt) != MEDIA_FORMAT_ERROR_NONE) {
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = _mm_util_processing(handle);
+ ret = __mm_util_processing(handle);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_util_processing failed");
+ debug_error("__mm_util_processing failed");
IMGP_FREE(handle);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
}
/* g_thread_exit(handle->thread); */
- if(handle->_MMHandle) {
- if(handle->thread) {
- g_mutex_lock (handle->thread_mutex);
- handle->is_finish = TRUE;
- g_cond_signal(handle->thread_cond);
- debug_log("===> send signal(finish) to transform_thread");
- g_mutex_unlock (handle->thread_mutex);
-
- g_thread_join(handle->thread);
- }
+ if(handle->thread) {
+ handle->is_finish = TRUE;
+ g_mutex_lock (&(handle->thread_mutex));
+ g_cond_signal(&(handle->thread_cond));
+ debug_log("===> send signal(finish) to transform_thread");
+ g_mutex_unlock (&(handle->thread_mutex));
+
+ g_thread_join(handle->thread);
}
if(handle->queue) {
handle->queue = NULL;
}
- if(handle->thread_mutex) {
- g_mutex_free (handle->thread_mutex);
- handle->thread_mutex = NULL;
- }
+ g_mutex_clear(&(handle->thread_mutex));
+
+ g_cond_clear(&(handle->thread_cond));
- if(handle->thread_cond) {
- g_cond_free (handle->thread_cond);
- handle->thread_cond = NULL;
- }
debug_log("Success - Finalize Handle");
return ret;
}
-int
-mm_util_create(MMHandleType* MMHandle)
+int mm_util_create(MMHandleType* MMHandle)
{
int ret = MM_ERROR_NONE;
ret = MM_ERROR_IMAGE_INTERNAL;
}
- ret = _mm_util_handle_init (handle);
+ ret = __mm_util_handle_init (handle);
if(ret != MM_ERROR_NONE) {
debug_error("_mm_util_handle_init failed");
IMGP_FREE(handle);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = _mm_util_create_thread(handle);
+ ret = __mm_util_create_thread(handle);
if(ret != MM_ERROR_NONE) {
debug_error("ERROR - Create thread");
TTRACE_END();
return ret;
} else {
- debug_log("Success -_mm_util_create_thread");
+ debug_log("Success -__mm_util_create_thread");
}
*MMHandle = (MMHandleType)handle;
- handle->_MMHandle = 0;
TTRACE_END();
return ret;
}
-int
-mm_util_set_hardware_acceleration(MMHandleType MMHandle, bool mode)
+int mm_util_set_hardware_acceleration(MMHandleType MMHandle, bool mode)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
return ret;
}
-int
-mm_util_set_colorspace_convert(MMHandleType MMHandle, mm_util_img_format colorspace)
+int mm_util_set_colorspace_convert(MMHandleType MMHandle, mm_util_img_format colorspace)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
handle->set_convert = TRUE;
handle->dst_format = colorspace;
- handle->dst_format_mime = _mm_util_mapping_imgp_format_to_mime(colorspace);
+ handle->dst_format_mime = __mm_util_mapping_imgp_format_to_mime(colorspace);
debug_log("imgp fmt: %d mimetype: %d", handle->dst_format, handle->dst_format_mime);
TTRACE_END();
return ret;
}
-int
-mm_util_set_resolution(MMHandleType MMHandle, unsigned int width, unsigned int height)
+int mm_util_set_resolution(MMHandleType MMHandle, unsigned int width, unsigned int height)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
return ret;
}
-int
-mm_util_set_rotation(MMHandleType MMHandle, mm_util_img_rotate_type rotation)
+int mm_util_set_rotation(MMHandleType MMHandle, mm_util_img_rotate_type rotation)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
return ret;
}
-int
-mm_util_set_crop_area(MMHandleType MMHandle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y)
+int mm_util_set_crop_area(MMHandleType MMHandle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
return ret;
}
-int
-mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_completed_callback completed_callback, void * user_data)
+int mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_completed_callback completed_callback, void * user_data)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) MMHandle;
debug_error("[ERROR] _util_cb_s");
}
- handle->_MMHandle++;
-
if(handle->queue) {
debug_log("g_async_queue_push");
g_async_queue_push (handle->queue, GINT_TO_POINTER(src_packet));
-
- g_mutex_lock (handle->thread_mutex);
- g_cond_signal(handle->thread_cond);
+ g_mutex_lock (&(handle->thread_mutex));
+ g_cond_signal(&(handle->thread_cond));
debug_log("===> send signal to transform_thread");
- g_mutex_unlock (handle->thread_mutex);
+ g_mutex_unlock (&(handle->thread_mutex));
}
TTRACE_END();
return ret;
}
-int
-mm_util_transform_is_completed(MMHandleType MMHandle, bool *is_completed)
+int mm_util_transform_is_completed(MMHandleType MMHandle, bool *is_completed)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int
-mm_util_destroy(MMHandleType MMHandle)
+int mm_util_destroy(MMHandleType MMHandle)
{
int ret = MM_ERROR_NONE;
mm_util_s *handle = (mm_util_s*) MMHandle;
return ret;
}
-EXPORT_API int
-mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, mm_util_img_format dst_format)
+EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, mm_util_img_format dst_format)
{
int ret = MM_ERROR_NONE;
debug_log("#START#");
- if(_mm_cannot_convert_format(src_format, dst_format)) {
+ if(__mm_cannot_convert_format(src_format, dst_format)) {
debug_error("#ERROR# Cannot Support Image Format Convert");
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
- if(_mm_select_convert_plugin(src_format, dst_format)) {
+ if(__mm_select_convert_plugin(src_format, dst_format)) {
_imgp_plugin_type_e = IMGP_NEON;
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
debug_log("plugin type: %d", _imgp_plugin_type_e);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
- debug_log("_mm_util_imgp_init: %p", _module);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ debug_log("__mm_util_imgp_initialize: %p", _module);
if(_module == NULL) { /* when IMGP_NEON is NULL */
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
}
debug_log("mm_util_imgp_func: %p", _module);
- ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
+
+ ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_set_imgp_info_s failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ debug_error("__mm_set_imgp_info_s failed");
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- debug_log("Sucess _mm_set_imgp_info_s");
+ debug_log("Sucess __mm_set_imgp_info_s");
/* image processing */
- _mm_util_imgp_func = _mm_util_imgp_process(_module);
- debug_log("Sucess _mm_util_imgp_process");
+ _mm_util_imgp_func = __mm_util_imgp_process(_module);
+ debug_log("Sucess __mm_util_imgp_process");
if(_mm_util_imgp_func) {
ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_CSC);
if (ret != MM_ERROR_NONE)
{
debug_error("image processing failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
}else {
debug_error("g_module_symbol failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
debug_log("#Success# dst");
/* Finalize */
- ret = _mm_util_imgp_finalize(_module, _imgp_info_s);
+ ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_util_imgp_finalize failed");
+ debug_error("__mm_util_imgp_finalize failed");
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
return ret;
}
-EXPORT_API int
-mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height)
+EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height)
{
int ret = MM_ERROR_NONE;
imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
- if(_mm_select_resize_plugin(src_format)) {
+ if(__mm_select_resize_plugin(src_format)) {
_imgp_plugin_type_e = IMGP_NEON;
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
debug_log("plugin type: %d", _imgp_plugin_type_e);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
- debug_log("_mm_util_imgp_init: %p", _module);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ debug_log("__mm_util_imgp_initialize: %p", _module);
if(_module == NULL) /* when IMGP_NEON is NULL */
{
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
}
- debug_log("_mm_set_imgp_info_s");
- ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
- debug_log("_mm_set_imgp_info_s ret: %d", ret);
+
+ debug_log("__mm_set_imgp_info_s");
+ ret =__mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
+ debug_log("__mm_set_imgp_info_s ret: %d", ret);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_set_imgp_info_s failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ debug_error("__mm_set_imgp_info_s failed");
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- debug_log("Sucess _mm_set_imgp_info_s");
+ debug_log("Sucess __mm_set_imgp_info_s");
if(g_strrstr(g_module_name (_module), GST)) {
- if(_mm_gst_can_resize_format(_imgp_info_s->input_format_label) == FALSE) {
+ if(__mm_gst_can_resize_format(_imgp_info_s->input_format_label) == FALSE) {
debug_error("[%s][%05d] #RESIZE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
}
/* image processing */
- _mm_util_imgp_func = _mm_util_imgp_process(_module);
- debug_log("Sucess _mm_util_imgp_process");
+ _mm_util_imgp_func = __mm_util_imgp_process(_module);
+ debug_log("Sucess __mm_util_imgp_process");
if(_mm_util_imgp_func) {
ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_RSZ);
debug_log("_mm_util_imgp_func, ret: %d", ret);
if (ret != MM_ERROR_NONE)
{
debug_error("image processing failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
}else {
debug_error("g_module_symbol failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
*dst_height = _imgp_info_s->dst_height;
/* Finalize */
- ret = _mm_util_imgp_finalize(_module, _imgp_info_s);
+ ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_util_imgp_finalize failed");
+ debug_error("__mm_util_imgp_finalize failed");
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
return ret;
}
-EXPORT_API int
-mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
+EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_ERROR_NONE;
imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
- if( _mm_select_rotate_plugin(src_format, src_width, src_height, angle)) {
+ if( __mm_select_rotate_plugin(src_format, src_width, src_height, angle)) {
_imgp_plugin_type_e = IMGP_NEON;
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
debug_log("plugin type: %d", _imgp_plugin_type_e);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
- debug_log("_mm_util_imgp_func: %p", _module);
+
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ debug_log("__mm_util_imgp_initialize: %p", _module);
if(_module == NULL) { /* when IMGP_NEON is NULL */
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
- _module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
}
- debug_log("_mm_set_imgp_info_s");
- ret=_mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle);
+
+ debug_log("__mm_confirm_dst_width_height");
+ ret = __mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle);
if(ret != MM_ERROR_NONE) {
debug_error("dst_width || dest_height size Error");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
- debug_log("_mm_set_imgp_info_s");
+ ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
+ debug_log("__mm_set_imgp_info_s");
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_set_imgp_info_s failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ debug_error("__mm_set_imgp_info_s failed");
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
- debug_log("Sucess _mm_set_imgp_info_s");
+ debug_log("Sucess __mm_set_imgp_info_s");
if(g_strrstr(g_module_name (_module), GST)) {
- if(_mm_gst_can_rotate_format(_imgp_info_s->input_format_label) == FALSE) {
+ if(__mm_gst_can_rotate_format(_imgp_info_s->input_format_label) == FALSE) {
debug_error("[%s][%05d] #gstreamer ROTATE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
}
/* image processing */
- _mm_util_imgp_func = _mm_util_imgp_process(_module);
- debug_log("Sucess _mm_util_imgp_process");
+ _mm_util_imgp_func = __mm_util_imgp_process(_module);
+ debug_log("Sucess __mm_util_imgp_process");
if(_mm_util_imgp_func) {
ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_ROT);
if (ret!= MM_ERROR_NONE) {
debug_error("image processing failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
}else {
debug_error("g_module_symbol failed");
- _mm_util_imgp_finalize(_module, _imgp_info_s);
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
*dst_height = _imgp_info_s->dst_height;
/* Finalize */
- ret = _mm_util_imgp_finalize(_module, _imgp_info_s);
+ ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if(ret != MM_ERROR_NONE) {
- debug_error("_mm_util_imgp_finalize failed");
+ debug_error("__mm_util_imgp_finalize failed");
TTRACE_END();
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
return ret;
}
-EXPORT_API int
-mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+EXPORT_API int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int *crop_dest_width, unsigned int *crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
switch (src_format) {
case MM_UTIL_IMG_FMT_RGB888: {
- ret = _mm_util_crop_rgb888(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ ret = __mm_util_crop_rgb888(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
case MM_UTIL_IMG_FMT_RGB565: {
- ret = _mm_util_crop_rgb565(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ ret = __mm_util_crop_rgb565(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
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: {
- ret = _mm_util_crop_rgba32(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ ret = __mm_util_crop_rgba32(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
case MM_UTIL_IMG_FMT_I420:
debug_log("Image isplay is suceeded when YUV crop height value %d ",*crop_dest_height);
}
- ret = _mm_util_crop_yuv420(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ ret = __mm_util_crop_yuv420(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
default:
return ret;
}
-EXPORT_API int
-mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
+EXPORT_API int mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
{
int ret = MM_ERROR_NONE;
unsigned char x_chroma_shift = 0;
}
static int
-mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, char *pFileName, mm_util_jpeg_yuv_format input_fmt)
+mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
tjhandle dhandle=NULL;
unsigned char *srcBuf=NULL;
int jpegSize;
static int
mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
tjhandle dhandle=NULL;
unsigned char *srcBuf=NULL;
int TD_BU=0;
static int
mm_image_encode_to_jpeg_file_with_libjpeg_turbo(char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
tjhandle chandle=NULL;
unsigned char *dstBuf=NULL;
unsigned long size=0;
static int
mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, int *csize, void *rawdata, int w, int h, mm_util_jpeg_yuv_format fmt,int quality)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
tjhandle chandle=NULL;
int TD_BU=0;
longjmp(myerr->setjmp_buffer, 1); /* Return control to the setjmp point */
}
-static int
-mm_image_encode_to_jpeg_file_with_libjpeg(char *pFileName, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
{
int iErrorCode = MM_ERROR_NONE;
iRowStride = width * 4;
}
+ JSAMPLE *image_buffer = (JSAMPLE *)rawdata;
while (cinfo.next_scanline < cinfo.image_height) {
- row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
+ //row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
+ row_pointer[0] = & image_buffer[cinfo.next_scanline * iRowStride];
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
debug_log("while");
debug_error("We can't encode the IMAGE format");
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
- fsync((int)fpWriter);
+ fsync((int)(fpWriter->_fileno));
debug_log("[fsync] FILE");
fclose(fpWriter);
return iErrorCode;
static int
mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt,int quality)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
JSAMPROW y[16],cb[16],cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
JSAMPARRAY data[3]; /* t[0][2][5] = color sample 0 of row 2 and column 5 */
iRowStride = width * 4;
}
+ JSAMPLE *image_buffer = (JSAMPLE *)rawdata;
while (cinfo.next_scanline < cinfo.image_height) {
- row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
+ //row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
+ row_pointer[0] = & image_buffer[cinfo.next_scanline * iRowStride];
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
debug_log("while");
}
static int
-mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, char *pFileName, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
+mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
{
- int iErrorCode = MM_ERROR_NONE;
- FILE *infile = NULL;
+ int iErrorCode = MM_ERROR_NONE;
+ FILE *infile = NULL;
struct jpeg_decompress_struct dinfo;
struct my_error_mgr_s jerr;
JSAMPARRAY buffer; /* Output row buffer */
- int row_stride = 0, state = 0; /* physical row width in output buffer */
+ int row_stride = 0; /* physical row width in output buffer */
JSAMPROW image, u_image, v_image;
JSAMPROW row; /* point to buffer[0] */
}
}
}else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ int state = 0;
/* while (scan lines remain to be read) jpeg_read_scanlines(...); */
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
static int
mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
{
- int iErrorCode = MM_ERROR_NONE;
+ int iErrorCode = MM_ERROR_NONE;
struct jpeg_decompress_struct dinfo;
struct my_error_mgr_s jerr;
JSAMPARRAY buffer; /* Output row buffer */
- int row_stride = 0, state = 0; /* physical row width in output buffer */
+ int row_stride = 0; /* physical row width in output buffer */
JSAMPROW image, u_image, v_image;
JSAMPROW row; /* point to buffer[0] */
}
}
} else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ int state = 0;
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
jpeg_read_scanlines(&dinfo, buffer, 1);
state += row_stride;
}
debug_log("jpeg_read_scanlines");
-
}
/* Finish decompression */
return iErrorCode;
}
+#if 0
static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag,ExifFormat format, unsigned long components, unsigned char* data)
{
ExifData *ed = (ExifData *)exif;
return 0;
}
+#endif
EXPORT_API int
mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
dst = malloc(dst_size);
if(dst) {
ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
- ret =mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
+ ret = mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
free(dst);
dst=NULL;
} else {
ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
ret = mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
free(dst);
- dst=NULL;
+ dst = NULL;
} else {
TTRACE_END();
return MM_ERROR_IMAGE_NO_FREE_SPACE;
FILE *fp = fopen(filename, "rb");
unsigned char magic[2] = {0};
+ size_t read_size = 0;
if(fp) {
- fread((void *)magic, 1, 2, fp);
+ read_size = fread((void *)magic, 1, 2, fp);
+ if (read_size > 0)
+ debug_log("Success fread");
+
debug_log("%x %x", magic[0], magic[1]);
fclose(fp);
} else {
if (ret == MM_ERROR_NONE) {
int err = MM_ERROR_NONE;
err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ if (err != MM_ERROR_NONE)
+ debug_error("fail mm_util_get_image_size");
+
unsigned char *dst = NULL;
dst = malloc(dst_size);
if(dst) {
if (ret == MM_ERROR_NONE) {
int err = MM_ERROR_NONE;
err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ if (err != MM_ERROR_NONE)
+ debug_error("fail mm_util_get_image_size");
+
dst = malloc(dst_size);
if(dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
FILE *fp = fopen(filename, "rb");
unsigned char magic[2] = {0};
+ size_t read_size = 0;
if(fp) {
- fread((void *)magic, 1, 2, fp);
+ read_size = fread((void *)magic, 1, 2, fp);
+ if (read_size > 0)
+ debug_log("Success fread");
+
debug_log("%x %x", magic[0], magic[1]);
fclose(fp);
}
if (ret == MM_ERROR_NONE) {
int err = MM_ERROR_NONE;
err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ if (err != MM_ERROR_NONE)
+ debug_error("fail mm_util_get_image_size");
+
unsigned char *dst = NULL;
dst = malloc(dst_size);
if(dst) {
if (ret == MM_ERROR_NONE) {
int err = MM_ERROR_NONE;
err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ if (err != MM_ERROR_NONE)
+ debug_error("fail mm_util_get_image_size");
+
dst = malloc(dst_size);
if(dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);