*/
/**
- * Read data attached to decoding callback
- */
-typedef struct {
- size_t size;
- void *mem;
-} read_data;
-
-/**
- * Write data attached to encoding callback
- */
-typedef struct {
- size_t size;
- void **mem;
-} write_data;
-
-/**
- * format for gif
- */
-typedef enum {
- MM_UTIL_GIF_FMT_RGBA8888, /**< RGBA8888 format */
-} mm_util_gif_format;
-
-/**
* Disposal mode for gif encoding
*/
typedef enum {
MM_UTIL_GIF_DISPOSAL_PREVIOUS = 3, /**< Restore to previous content. */
} mm_util_gif_disposal;
-typedef struct {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
-} mm_util_gif_color_s;
-
-typedef struct {
- unsigned long long delay_time; /**< Pre-display delay in 0.01sec units */
- unsigned long width; /**< Width */
- unsigned long height; /**< Height */
- unsigned long x; /**< X position */
- unsigned long y; /**< Y position */
- void *data; /**< Data */
-} mm_util_gif_frame_data;
-
#define GRAPHIC_EXT_BLOCK_SIZE 4
-#define APP_EXT_BLOCK_SIZE 11
-#define APP_EXT_BLOCK_DATA "NETSCAPE2.0"
-#define SUB_BLOCK_SIZE 3
-#define NETSCAPE_SUB_BLOCK_INDEX 1
typedef void* mm_gif_image_h;
typedef void* mm_gif_file_h;
-typedef struct {
- unsigned long width; /**< Width */
- unsigned long height; /**< Height */
- size_t size; /**< Size */
- void *data; /**< Frames */
-} mm_util_gif_data;
-
-/**
- * This function extracts raw data from gif file
- *
- * @param decoded [out] pointer of mm_util_gif_data.
- * After using it, please free the allocated memory.
- * @param filename [in] input file name, encoded stream file
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_gif_data
- * @since R1, 1.0
- */
-int mm_util_decode_from_gif_file(mm_util_gif_data * decoded, const char *filename);
-
-/**
- * This function extracts raw data from gif memory
- *
- * @param decoded [out] pointer of mm_util_gif_data.
- * After using it, please free the allocated memory.
- * @param memory [in] input file memory, encoded stream file
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_gif_data
- * @since R1, 1.0
- */
-int mm_util_decode_from_gif_memory(mm_util_gif_data * decoded, void *memory);
+int mm_util_decode_from_gif_file(const char *filename, mm_image_info_s * decoded);
+int mm_util_decode_from_gif_memory(void *memory, mm_image_info_s * decoded);
/**
* This function creates the handle of the single image(frame).
#endif
typedef struct {
+ size_t size;
+ void **mem;
+} gif_mem_s;
+
+typedef struct {
/* for giflib, Same as SavedImage */
GifImageDesc image_desc;
void *image_data;
void **enc_buffer; /**< Encoded output data attached to callback */
size_t *enc_buffer_size;
unsigned char *buffer;
- write_data write_data_ptr; /**< Encoded output data attached to callback */
+ gif_mem_s write_data_ptr; /**< Encoded output data attached to callback */
gboolean is_started;
int saved_image_count;
#define RGB_ALLOC(r, g, b, number, size) { r = calloc(1, number * size); g = calloc(1, number * size); b = calloc(1, number * size); }
#define RGB_FREE(r, g, b) { MMUTIL_SAFE_FREE(r); MMUTIL_SAFE_FREE(g); MMUTIL_SAFE_FREE(b); }
-static int __convert_gif_to_rgba(mm_util_gif_data *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height)
+
+static int __convert_gif_to_rgba(mm_image_info_s *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height)
{
unsigned long i, j;
GifRowType gif_row;
static int __read_function(GifFileType *gft, GifByteType *data, int size)
{
- read_data *read_data_ptr = (read_data *) gft->UserData;
+ gif_mem_s *read_data_ptr = (gif_mem_s *) gft->UserData;
if (read_data_ptr->mem && size > 0) {
memcpy(data, read_data_ptr->mem + read_data_ptr->size, size);
return size;
}
-static int __read_gif(mm_util_gif_data *decoded, const char *filename, void *memory)
+static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memory)
{
int ExtCode, i, j, Row, Col, Width, Height;
size_t Size = 0;
GifFileType *GifFile;
unsigned int image_num = 0;
ColorMapObject *ColorMap;
- read_data read_data_ptr;
+ gif_mem_s read_data_ptr;
int ret;
mm_util_debug("mm_util_decode_from_gif");
return ret;
}
-int mm_util_decode_from_gif_file(mm_util_gif_data *decoded, const char *fpath)
+int mm_util_decode_from_gif_file(const char *fpath, mm_image_info_s *decoded)
{
mm_util_fenter();
return __read_gif(decoded, fpath, NULL);
}
-int mm_util_decode_from_gif_memory(mm_util_gif_data *decoded, void *memory)
+int mm_util_decode_from_gif_memory(void *memory, mm_image_info_s *decoded)
{
mm_util_fenter();
static int __write_function(GifFileType *gft, const GifByteType *data, int size)
{
- write_data *write_data_ptr = (write_data *) gft->UserData;
+ gif_mem_s *write_data_ptr = (gif_mem_s *) gft->UserData;
if (size > 0) {
*(write_data_ptr->mem) = (void *)realloc(*(write_data_ptr->mem), (write_data_ptr->size + size));
typedef struct {
char file_name[PATH_MAX];
- mm_util_gif_data decoded;
+ mm_image_info_s decoded;
} gif_test_data_s;
for (i = 0; i < nfiles && i < ANIMATED_FRAME_MAX; i++) {
fprintf(stderr, "\tdecode %s\n", files[i].file_name);
- ret = mm_util_decode_from_gif_file(&files[i].decoded, files[i].file_name);
+ ret = mm_util_decode_from_gif_file(files[i].file_name, &files[i].decoded);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\tERROR is occurred %x to decode %s\n", ret, files[i].file_name);
continue;