--- /dev/null
+/*
+* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __MM_UTIL_OPTION_H__
+#define __MM_UTIL_OPTION_H__
+
+#include <stdbool.h>
+
+#include "mm_util_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *mm_util_enc_opt_h;
+
+/*
+ * these functions are to set the optional values for each encoder
+ */
+int mm_util_enc_opt_create(mm_util_enc_opt_h *enc_opt);
+int mm_util_enc_opt_set_codec(mm_util_enc_opt_h enc_opt, mm_util_img_codec_type codec);
+int mm_util_enc_opt_set_png_compression(mm_util_enc_opt_h enc_opt, unsigned int compression);
+int mm_util_enc_opt_set_webp_lossless(mm_util_enc_opt_h enc_opt, bool lossless);
+void mm_util_enc_opt_destroy(mm_util_enc_opt_h enc_opt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTIL_OPTION_H__*/
ANIM_ENC_DESTROY destroy;
} anim_enc_module_t;
+typedef struct {
+ mm_util_img_codec_type codec;
+ unsigned int compression;
+ bool lossless;
+} mm_util_enc_opt_t;
+
gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp);
--- /dev/null
+/*
+* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <glib.h>
+
+#include "mm_util_private.h"
+#include "mm_util_option.h"
+
+#define DEFAULT_PNG_COMPRESSION 6
+
+int mm_util_enc_opt_create(mm_util_enc_opt_h *enc_opt)
+{
+ mm_util_enc_opt_t *enc_option = NULL;
+
+ mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
+
+ enc_option = g_new0(mm_util_enc_opt_t, 1);
+ enc_option->codec = IMG_CODEC_UNKNOWN_TYPE;
+ enc_option->compression = DEFAULT_PNG_COMPRESSION;
+ enc_option->lossless = false;
+
+ *enc_opt = enc_option;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_util_enc_opt_set_codec(mm_util_enc_opt_h enc_opt, mm_util_img_codec_type codec)
+{
+ mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
+
+ mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
+ mm_util_retvm_if(codec >= IMG_CODEC_WBMP, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid codec [%d]", codec);
+
+ enc_option->codec = codec;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_util_enc_opt_set_png_compression(mm_util_enc_opt_h enc_opt, unsigned int compression)
+{
+ mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
+
+ mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
+ mm_util_retvm_if(compression > 9, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid compression [%d]", compression);
+ mm_util_retvm_if(enc_option->codec != IMG_CODEC_PNG, MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format [%d]", enc_option->codec);
+
+ enc_option->compression = compression;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_util_enc_opt_set_webp_lossless(mm_util_enc_opt_h enc_opt, bool lossless)
+{
+ mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
+
+ mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
+ mm_util_retvm_if(enc_option->codec != IMG_CODEC_WEBP, MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format [%d]", enc_option->codec);
+
+ enc_option->lossless = lossless;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+void mm_util_enc_opt_destroy(mm_util_enc_opt_h enc_opt)
+{
+ g_free(enc_opt);
+}
#include "mm_util_type.h"
#include "mm_util_image.h"
-
-typedef void *mm_util_enc_opt_h;
+#include "mm_util_option.h"
int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, mm_util_image_h *dst_handle);
int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, const char *dst_path);
int mm_util_encode_image_to_file(mm_util_image_h decoded_image, mm_util_enc_opt_h opt, const char *path);
int mm_util_encode_image_to_buffer(mm_util_image_h decoded_image, mm_util_enc_opt_h opt, void **buf, size_t *buf_size);
-int mm_util_enc_opt_create(mm_util_enc_opt_h *enc_opt);
-int mm_util_enc_opt_set_codec(mm_util_enc_opt_h enc_opt, mm_util_img_codec_type codec);
-int mm_util_enc_opt_set_png_compression(mm_util_enc_opt_h enc_opt, unsigned int compression);
-int mm_util_enc_opt_set_webp_lossless(mm_util_enc_opt_h enc_opt, bool lossless);
-void mm_util_enc_opt_destroy(mm_util_enc_opt_h enc_opt);
-
#ifdef __cplusplus
}
#endif
#include "mm_util_private.h"
#include "mm_util_magick.h"
-#define DEFAULT_PNG_COMPRESSION 6
-
-typedef struct {
- mm_util_img_codec_type codec;
- unsigned int compression;
- bool lossless;
-} mm_util_enc_opt_t;
-
static bool __mm_util_check_rotation(mm_util_rotate_type_e rotation);
static void __mm_util_magick_fatal_error_handler(const ExceptionType excep, const char *reason, const char *message) MAGICK_FUNC_NORETURN;
return ret;
}
-
-int mm_util_enc_opt_create(mm_util_enc_opt_h *enc_opt)
-{
- mm_util_enc_opt_t *enc_option = NULL;
-
- mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
-
- enc_option = g_new0(mm_util_enc_opt_t, 1);
- enc_option->codec = IMG_CODEC_UNKNOWN_TYPE;
- enc_option->compression = DEFAULT_PNG_COMPRESSION;
- enc_option->lossless = false;
-
- *enc_opt = enc_option;
-
- return MM_UTIL_ERROR_NONE;
-}
-
-int mm_util_enc_opt_set_codec(mm_util_enc_opt_h enc_opt, mm_util_img_codec_type codec)
-{
- mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
-
- mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
-
- enc_option->codec = codec;
-
- return MM_UTIL_ERROR_NONE;
-}
-
-int mm_util_enc_opt_set_png_compression(mm_util_enc_opt_h enc_opt, unsigned int compression)
-{
- mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
-
- mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
- mm_util_retvm_if(compression > 9, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid compression [%d]", compression);
- mm_util_retvm_if(enc_option->codec != IMG_CODEC_PNG, MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported [%d]", enc_option->codec);
-
- enc_option->compression = compression;
-
- return MM_UTIL_ERROR_NONE;
-}
-
-int mm_util_enc_opt_set_webp_lossless(mm_util_enc_opt_h enc_opt, bool lossless)
-{
- mm_util_enc_opt_t *enc_option = (mm_util_enc_opt_t *)enc_opt;
-
- mm_util_retvm_if(!enc_opt, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid enc_opt");
- mm_util_retvm_if(enc_option->codec != IMG_CODEC_WEBP, MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported [%d]", enc_option->codec);
-
- enc_option->lossless = lossless;
-
- return MM_UTIL_ERROR_NONE;
-}
-
-void mm_util_enc_opt_destroy(mm_util_enc_opt_h enc_opt)
-{
- g_free(enc_opt);
-}