tag related code cleanup 78/233878/6
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 20 May 2020 04:18:11 +0000 (13:18 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 28 May 2020 23:20:21 +0000 (23:20 +0000)
Change-Id: Iacd82e62e9771abf872fb6fdb3448db238651e64
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
formats/ffmpeg/mm_file_format_imelody.c
formats/ffmpeg/mm_file_format_midi.c
formats/ffmpeg/mm_file_format_mp3.c
utils/include/mm_file_utils.h
utils/mm_file_util_string.c
utils/mm_file_util_tag.c

index f5ac6466ed24a7812d603bf345096028da0859f6..b284fd335afe420f8b5f086ed0aaae5ea09e5199 100755 (executable)
@@ -1087,8 +1087,6 @@ int mmfile_format_read_frame_imy(MMFileFormatContext *formatContext, unsigned in
 int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
 {
        tMMFileImelodyTagInfo taginfo = {0, };
-       unsigned int tag_len;
-       unsigned int cnv_len;
        const char *locale = MMFileUtilGetLocale();
 
        mm_file_retvm_if_fails(DEBUG, formatContext, MMFILE_FORMAT_FAIL);
@@ -1099,9 +1097,7 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
         * UTF8 convert
         */
        if (taginfo.title) {
-               tag_len = strlen(taginfo.title);
-               cnv_len = 0;
-               formatContext->title = mmfile_string_convert(taginfo.title, tag_len, "UTF-8", locale, NULL, &cnv_len);
+               formatContext->title = mmfile_convert_to_utf8(taginfo.title, -1, locale);
 
                if (formatContext->title == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
@@ -1111,9 +1107,7 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
        }
 
        if (taginfo.composer) {
-               tag_len = strlen(taginfo.composer);
-               cnv_len = 0;
-               formatContext->composer = mmfile_string_convert(taginfo.composer, tag_len, "UTF-8", locale, NULL, &cnv_len);
+               formatContext->composer = mmfile_convert_to_utf8(taginfo.composer, -1, locale);
                if (formatContext->composer == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->composer = g_strdup(taginfo.composer);
@@ -1122,9 +1116,7 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
        }
 
        if (taginfo.copyright) {
-               tag_len = strlen(taginfo.copyright);
-               cnv_len = 0;
-               formatContext->copyright = mmfile_string_convert(taginfo.copyright, tag_len, "UTF-8", locale, NULL, &cnv_len);
+               formatContext->copyright = mmfile_convert_to_utf8(taginfo.copyright, -1, locale);
                if (formatContext->copyright == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->copyright = g_strdup(taginfo.copyright);
index f111b45766ef2c8fec55e0a3ce29fa6a4963525d..6021ce7db5bb2e1d1351828961bca882b6646f8b 100755 (executable)
@@ -907,8 +907,6 @@ int mmfile_format_read_tag_mid(MMFileFormatContext *formatContext)
 {
        MIDI_INFO_SIMPLE *info = NULL;
        const char *locale = MMFileUtilGetLocale();
-       unsigned int tag_len;
-       unsigned int cnv_len;
 
        mm_file_retvm_if_fails(DEBUG, formatContext, MMFILE_FORMAT_FAIL);
 
@@ -919,9 +917,7 @@ int mmfile_format_read_tag_mid(MMFileFormatContext *formatContext)
         * UTF8 converting.
         */
        if (info->title) {
-               tag_len = strlen(info->title);
-               cnv_len = 0;
-               formatContext->title = mmfile_string_convert((const char *)info->title, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
+               formatContext->title = mmfile_convert_to_utf8((const char *)info->title, -1, locale);
                if (formatContext->title == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->title = g_strdup(info->title);
@@ -929,9 +925,7 @@ int mmfile_format_read_tag_mid(MMFileFormatContext *formatContext)
        }
 
        if (info->copyright) {
-               tag_len = strlen(info->copyright);
-               cnv_len = 0;
-               formatContext->copyright = mmfile_string_convert((const char *)info->copyright, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
+               formatContext->copyright = mmfile_convert_to_utf8((const char *)info->copyright, -1, locale);
                if (formatContext->copyright == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->copyright = g_strdup(info->copyright);
@@ -939,9 +933,7 @@ int mmfile_format_read_tag_mid(MMFileFormatContext *formatContext)
        }
 
        if (info->comment) {
-               tag_len = strlen(info->comment);
-               cnv_len = 0;
-               formatContext->comment = mmfile_string_convert((const char *)info->comment, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
+               formatContext->comment = mmfile_convert_to_utf8((const char *)info->comment, -1, locale);
                if (formatContext->comment == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->comment = g_strdup(info->comment);
index f93968f3a470c11a459f7f8a6966cef6140e5f54..1e1fe516a6f1016f13ac147ef530a9cecd97d7bc 100644 (file)
@@ -184,7 +184,7 @@ int mmfile_format_read_tag_mp3(MMFileFormatContext *formatContext)
        formatContext->conductor = g_strdup(privateData->tagInfo[AV_ID3TAG_CONDUCTOR].value);
        formatContext->unsyncLyrics = g_strdup(privateData->tagInfo[AV_ID3TAG_UNSYNCLYRICS].value);
        formatContext->syncLyrics = privateData->pSyncLyrics;
-       formatContext->syncLyricsNum = privateData->tagInfo[AV_ID3TAG_SYNCLYRICS].length;
+       formatContext->syncLyricsNum = g_list_length(formatContext->syncLyrics);
        formatContext->recDate = g_strdup(privateData->tagInfo[AV_ID3TAG_RECDATE].value);
        formatContext->part_of_set = g_strdup(privateData->tagInfo[AV_ID3TAG_PART_OF_SET].value);
 
@@ -1073,7 +1073,6 @@ static int mmf_file_mp3_get_tag_info(char *filename, AvFileContentInfo *pInfo)
        debug_msg(RELEASE, "Conductor   : %s\n", pInfo->tagInfo[AV_ID3TAG_CONDUCTOR].value);
        debug_msg(RELEASE, "Artwork     : mime(%s) addr(%p) size(%d)\n", pInfo->imageInfo.imageMIMEType, pInfo->imageInfo.pImageBuf, pInfo->imageInfo.imageLen);
        debug_msg(RELEASE, "UnsyncLyrics   : %s\n", pInfo->tagInfo[AV_ID3TAG_UNSYNCLYRICS].value);
-       debug_msg(RELEASE, "SyncLyrics size  : %d\n", pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length);
 
        return MMFILE_FORMAT_SUCCESS;
 
index 09e7e6374e91f464a2507d35c497c0a345d506d3..069a167864da70b420222826822c3fda10b34e04 100755 (executable)
@@ -43,6 +43,8 @@ extern "C" {
 
 #define MM_FILE_INI_PATH       "/etc/multimedia/mm_file_config.ini"
 
+#define mmfile_free(ptr)  do { g_free((ptr)); (ptr) = NULL; } while (0)
+
 
 /*////////////////////////////////////////////////////////////////////// */
 /*                     ENDIAN UTIL API                                // */
@@ -159,8 +161,12 @@ void mmfile_format_print_frame(MMFileFormatFrame *in);
 /*////////////////////////////////////////////////////////////////////// */
 /*                            STRING API                              // */
 /*////////////////////////////////////////////////////////////////////// */
+
+#define MMFILE_CODESET_UTF8 "UTF-8"
+#define MMFILE_CODESET_UTF16 "UTF-16"
+
 char *mmfile_get_charset(const char *str);
-char *mmfile_string_convert(const char *str, unsigned int len, const char *to_codeset, const char *from_codeset, gsize *bytes_read, unsigned int *bytes_written);
+char *mmfile_convert_to_utf8(const char *str, gssize len, const char *from_codeset);
 
 
 /*////////////////////////////////////////////////////////////////////// */
@@ -169,23 +175,6 @@ char *mmfile_string_convert(const char *str, unsigned int len, const char *to_co
 char *MMFileUtilGetLocale();
 
 
-#ifdef __MMFILE_MEM_TRACE__
-/*////////////////////////////////////////////////////////////////////// */
-/*                            MEMORY DEBUG API                        // */
-/*////////////////////////////////////////////////////////////////////// */
-char *mmfile_string_convert_debug(const char *str, unsigned int len, const char *to_codeset, const char *from_codeset,
-                                                               int *bytes_read,
-                                                               int *bytes_written,
-                                                               const char *func,
-                                                               unsigned int line);
-
-
-#define mmfile_string_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written) mmfile_string_convert_debug((str), (len), (to_codeset), (from_codeset), (bytes_read), (bytes_written), __func__, __LINE__)
-#endif
-
-#define mmfile_free(ptr)  do { g_free((ptr)); (ptr) = NULL; } while (0)
-
-
 
 /*////////////////////////////////////////////////////////////////////// */
 /*                            TAG API                                 // */
@@ -281,7 +270,6 @@ typedef struct {
        char    imageExt[MP3_ID3_IMAGE_EXT_MAX_LENGTH];
        int             pictureType;
        int             imageLen;
-       int             imgDesLen;
        int             imgMimetypeLen;
        bool    bURLInfo;
 
@@ -317,9 +305,7 @@ typedef struct {
 } AvTagVer2AdditionalData;
 
 typedef struct {
-       int length;
        char *value;
-       bool marked;
 } AvID3TagInfo;
 
 typedef struct {
index f3be389b24fe521ac5140320b17d3c7eb6e1a62a..6e0f4a4ef54042099425d55cb54f2a0f6803ddd6 100755 (executable)
 #include "mm_file_debug.h"
 #include "mm_file_utils.h"
 
-#ifdef __MMFILE_MEM_TRACE__
-
-char *mmfile_string_convert_debug(const char *str, unsigned int len,
-                                                               const char *to_codeset, const char *from_codeset,
-                                                               int *bytes_read,
-                                                               int *bytes_written,
-                                                               const char *func,
-                                                               unsigned int line)
-{
-       char *tmp = g_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written, NULL);
-
-       if (tmp) {
-               debug_msg(RELEASE, "## DEBUG ## %p = g_convert (%p, %u, %p, %p, %p ,%p, %p, %u) by %s() %d\n",
-                               tmp, str, len, to_codeset, from_codeset, bytes_read, bytes_written, func, line);
-       }
-
-       return tmp;
-
-}
-
-#else   /* __MMFILE_MEM_TRACE__ */
-
-
 char *mmfile_get_charset(const char *str)
 {
        UCharsetDetector *ucsd = NULL;
@@ -101,59 +78,36 @@ done:
 }
 
 
-char *mmfile_string_convert(const char *str, unsigned int len,
-                               const char *to_codeset, const char *from_codeset,
-                               gsize *bytes_read,
-                               unsigned int *bytes_written)
+char *mmfile_convert_to_utf8(const char *str, gssize len, const char *from_codeset)
 {
        char *result = NULL;
        GError *err = NULL;
-       /*int i = 0;*/
-       gsize written_len = 0;
+       char **split = NULL;
 
-       if (len == 0) {
-               debug_error(DEBUG, "Invalid len");
-               return NULL;
-       }
+       mm_file_retvm_if_fails(DEBUG, len != 0, NULL);
 
        /*if both to_codeset and from_codeset are same, return duplicated string.*/
-       if (g_strcmp0(to_codeset, from_codeset) == 0) {
-               result = g_strdup(str);
-
-               if (bytes_written != NULL)
-                       *bytes_written = strlen(result);
+       if (g_strcmp0(MMFILE_CODESET_UTF8, from_codeset) == 0)
+               return g_strdup(str);
 
-               return result;
-       }
-
-       result = g_convert(str, len, to_codeset, from_codeset, bytes_read, &written_len, &err);
+       result = g_convert(str, len, MMFILE_CODESET_UTF8, from_codeset, NULL, NULL, &err);
 
        /*if converting failed, return null string.*/
-       if (!result || written_len == 0) {
+       if (!result) {
                debug_warning(RELEASE, "text encoding failed.[%s][%d]\n", str, len);
-
                if (err != NULL) {
                        debug_warning(DEBUG, "Error msg [%s]", err->message);
                        g_error_free(err);
                }
-               mmfile_free(result);
-
-               written_len = 0;
-       } else {
-               /* check carriage return */
-               gsize i = 0;
-               for (i = 0; i < written_len - 1; i++) {
-                       if (result[i] == '\r') {
-                               if (result[i + 1] != '\n')
-                                       result[i] = '\n';
-                       }
-               }
+               return NULL;
        }
 
-       if (bytes_written != NULL)
-               *bytes_written = written_len;
+       /* Remove '\r' */
+       split = g_strsplit(result, "\r", -1);
+       g_free(result);
+
+       result = g_strjoinv(NULL, split);
+       g_strfreev(split);
 
        return result;
 }
-
-#endif  /*__MMFILE_MEM_TRACE__*/
index 52ef680e50c358969380c8ffe01e1079134e6ac9..2172e8fbbcc44b28bd5079bf2206b0ef8385c8e4 100644 (file)
@@ -303,7 +303,7 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
        char *temp_text = NULL;
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -311,13 +311,13 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
 
        readed = mmfile_read(fp, (unsigned char *)&texttag, MMFILE_3GP_TEXT_TAGBOX_LEN);
        if (readed != MMFILE_3GP_TEXT_TAGBOX_LEN) {
-               debug_error(DEBUG, "read text tag header fail\n");
+               debug_error(DEBUG, "read text tag header fail");
                ret = MMFILE_UTIL_FAIL;
                goto exception;
        }
 
        if (textBytes <= 1) { /* there exist only 00(null) */
-               debug_error(DEBUG, "Text is NULL\n");
+               debug_error(DEBUG, "Text is NULL");
                goto exception;
        }
 
@@ -325,7 +325,7 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
 
        readed = mmfile_read(fp, (unsigned char *)texttag.text, textBytes);
        if (readed != textBytes) {
-               debug_error(DEBUG, "read text fail\n");
+               debug_error(DEBUG, "read text fail");
                ret = MMFILE_UTIL_FAIL;
                goto exception;
        }
@@ -333,8 +333,7 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
        /* check BOM char */
        if ((texttag.text[0] == 0xFE) && (texttag.text[1] == 0xFF)) {
                /* this char is UTF-16 */
-               unsigned int bytes_written = 0;
-               temp_text = mmfile_string_convert((const char *)&texttag.text[2], readed - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+               temp_text = mmfile_convert_to_utf8((const char *)&texttag.text[2], readed - 2, MMFILE_CODESET_UTF16);
        } else {
                temp_text = g_strdup((const char *)texttag.text);
        }
@@ -377,7 +376,7 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
                                break;
                        }
                default: {
-                               debug_warning(DEBUG, "Not supported Text Tag type[%d]\n", eTag);
+                               debug_warning(DEBUG, "Not supported Text Tag type[%d]", eTag);
                                break;
                        }
        }
@@ -405,13 +404,13 @@ static int GetYearFromYearTagBox(MMFileFormatContext *formatContext, MMFileIOHan
        char temp_year[MAX_YEAR_BUFFER] = {0, };
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&yearbox, MMFILE_3GP_YEAR_TAGBOX_LEN);
        if (readed != MMFILE_3GP_YEAR_TAGBOX_LEN) {
-               debug_error(DEBUG, "read yeartag header fail\n");
+               debug_error(DEBUG, "read yeartag header fail");
                goto exception;
        }
 
@@ -440,25 +439,25 @@ static int GetAlbumFromAlbumTagBox(MMFileFormatContext *formatContext, MMFileIOH
        MMFILE_3GP_ALBUM_TAGBOX albumbox = {0, };
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&albumbox, MMFILE_3GP_ALBUM_TAGBOX_LEN);
        if (readed != MMFILE_3GP_ALBUM_TAGBOX_LEN) {
-               debug_error(DEBUG, "read albumtag header fail\n");
+               debug_error(DEBUG, "read albumtag header fail");
                goto exception;
        }
 
        albumTitleLen = basic_header->size - MMFILE_MP4_BASIC_BOX_HEADER_LEN - MMFILE_3GP_ALBUM_TAGBOX_LEN - 1; /* 1: track number */
        if (albumTitleLen > 1) { /* there exist only 00(null) */
-               debug_msg(RELEASE, "albumTitleLen=%d\n", albumTitleLen);
+               debug_msg(RELEASE, "albumTitleLen=%d", albumTitleLen);
 
                albumbox.albumtile = g_malloc0(albumTitleLen + 1);  /* 1: for null char */
 
                readed = mmfile_read(fp, (unsigned char *)albumbox.albumtile, albumTitleLen);
                if (readed != albumTitleLen) {
-                       debug_error(DEBUG, "read album title fail\n");
+                       debug_error(DEBUG, "read album title fail");
                        goto exception;
                }
 
@@ -468,7 +467,7 @@ static int GetAlbumFromAlbumTagBox(MMFileFormatContext *formatContext, MMFileIOH
                        trackFlags = 0;
                        readed = mmfile_read(fp, (unsigned char *)&(albumbox.albumtile[albumTitleLen]), 1);
                        if (readed != 1) {
-                               debug_error(DEBUG, "read album title fail\n");
+                               debug_error(DEBUG, "read album title fail");
                                goto exception;
                        }
                        albumbox.albumtile[albumTitleLen] = '\0';
@@ -477,8 +476,7 @@ static int GetAlbumFromAlbumTagBox(MMFileFormatContext *formatContext, MMFileIOH
                /* check BOM char */
                if ((albumbox.albumtile[0] == 0xFE) && (albumbox.albumtile[1] == 0xFF)) {
                        /* this char is UTF-16 */
-                       unsigned int bytes_written = 0;
-                       temp_text = mmfile_string_convert((const char *)&albumbox.albumtile[2], readed - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+                       temp_text = mmfile_convert_to_utf8((const char *)&albumbox.albumtile[2], readed - 2, MMFILE_CODESET_UTF16);
                } else {
                        temp_text = g_strdup((const char *)albumbox.albumtile);
                }
@@ -488,13 +486,13 @@ static int GetAlbumFromAlbumTagBox(MMFileFormatContext *formatContext, MMFileIOH
                else
                        mmfile_free(temp_text);
 
-               debug_msg(RELEASE, "formatContext->album=%s, strlen=%zu\n", formatContext->album, strlen(formatContext->album));
+               debug_msg(RELEASE, "formatContext->album=%s, strlen=%zu", formatContext->album, strlen(formatContext->album));
        }
 
        if (trackFlags) {
                readed = mmfile_read(fp, (unsigned char *)&albumbox.trackNumber, 1);
                if (readed != 1) {
-                       debug_error(DEBUG, "read track number fail\n");
+                       debug_error(DEBUG, "read track number fail");
                        goto exception;
                }
 
@@ -527,20 +525,20 @@ static int GetRatingFromRatingTagBox(MMFileFormatContext *formatContext, MMFileI
        MMFILE_3GP_RATING_TAGBOX ratingTag = {0, };
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&ratingTag, MMFILE_3GP_RATING_TAGBOX_LEN);
        if (readed != MMFILE_3GP_RATING_TAGBOX_LEN) {
-               debug_error(DEBUG, "read rating tag header fail\n");
+               debug_error(DEBUG, "read rating tag header fail");
                goto exception;
        }
 
        ratinginfoLen = basic_header->size - MMFILE_MP4_BASIC_BOX_HEADER_LEN - MMFILE_3GP_RATING_TAGBOX_LEN;
 
        if (ratinginfoLen == 1) {
-               debug_error(DEBUG, "Rating Text is NULL\n");
+               debug_error(DEBUG, "Rating Text is NULL");
                goto exception;
        }
 
@@ -548,15 +546,14 @@ static int GetRatingFromRatingTagBox(MMFileFormatContext *formatContext, MMFileI
 
        readed = mmfile_read(fp, (unsigned char *)ratingTag.ratingInfo, ratinginfoLen);
        if (readed != ratinginfoLen) {
-               debug_error(DEBUG, "read rating info string fail\n");
+               debug_error(DEBUG, "read rating info string fail");
                goto exception;
        }
 
        /* check BOM char */
        if ((ratingTag.ratingInfo[0] == 0xFE) && (ratingTag.ratingInfo[1] == 0xFF)) {
                /* this char is UTF-16 */
-               unsigned int bytes_written = 0;
-               temp_text = mmfile_string_convert((const char *)&ratingTag.ratingInfo[2], readed - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+               temp_text = mmfile_convert_to_utf8((const char *)&ratingTag.ratingInfo[2], readed - 2, MMFILE_CODESET_UTF16);
        } else {
                temp_text = g_strdup((const char *)ratingTag.ratingInfo);
        }
@@ -588,20 +585,20 @@ static int GetClassficationFromClsfTagBox(MMFileFormatContext *formatContext, MM
        MMFILE_3GP_CLASSIFICATION_TAGBOX classTag = {0, };
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&classTag, MMFILE_3GP_CLASS_TAGBOX_LEN);
        if (readed != MMFILE_3GP_CLASS_TAGBOX_LEN) {
-               debug_error(DEBUG, "read classification tag header fail\n");
+               debug_error(DEBUG, "read classification tag header fail");
                goto exception;
        }
 
 
        classinfoLen = basic_header->size - MMFILE_MP4_BASIC_BOX_HEADER_LEN - MMFILE_3GP_CLASS_TAGBOX_LEN;
        if (classinfoLen == 1) {
-               debug_error(DEBUG, "Classification Text is NULL\n");
+               debug_error(DEBUG, "Classification Text is NULL");
                goto exception;
        }
 
@@ -609,15 +606,14 @@ static int GetClassficationFromClsfTagBox(MMFileFormatContext *formatContext, MM
 
        readed = mmfile_read(fp, (unsigned char *)classTag.classificationInfo, classinfoLen);
        if (readed != classinfoLen) {
-               debug_error(DEBUG, "read class info string fail\n");
+               debug_error(DEBUG, "read class info string fail");
                goto exception;
        }
 
        /* check BOM char */
        if ((classTag.classificationInfo[0] == 0xFE) && (classTag.classificationInfo[1] == 0xFF)) {
                /* this char is UTF-16 */
-               unsigned int bytes_written = 0;
-               temp_text = mmfile_string_convert((const char *)&classTag.classificationInfo[2], readed - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+               temp_text = mmfile_convert_to_utf8((const char *)&classTag.classificationInfo[2], readed - 2, MMFILE_CODESET_UTF16);
        } else {
                temp_text = g_strdup((const char *)classTag.classificationInfo);
        }
@@ -682,7 +678,6 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
        unsigned char *buffer = NULL;
        unsigned char *p = NULL;
        int pos = 0;
-       unsigned int bytes_written = 0;
        unsigned int name_sz = 0;
        unsigned int astro_sz = 0;
 
@@ -691,20 +686,20 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
 
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&lociTag, 6);  /*6 = version + flag + pad + language */
        if (readed != 6) {
-               debug_error(DEBUG, "read location tag header fail\n");
+               debug_error(DEBUG, "read location tag header fail");
                goto exception;
        }
 
        /*buffer len = name + role + ... + additional notes length */
        bufferLen = basic_header->size - MMFILE_MP4_BASIC_BOX_HEADER_LEN - 6;
        if (bufferLen < 1) {
-               debug_error(DEBUG, "too small buffer\n");
+               debug_error(DEBUG, "too small buffer");
                goto exception;
        }
 
@@ -712,7 +707,7 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
 
        readed = mmfile_read(fp, (unsigned char *)buffer, bufferLen);
        if (readed != bufferLen) {
-               debug_error(DEBUG, "read location tag fail\n");
+               debug_error(DEBUG, "read location tag fail");
                goto exception;
        }
        p = buffer;
@@ -721,7 +716,7 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
        pos = _get_char_position(p, '\0', readed - (1 + 4 + 4 + 4 + 2));
        if (pos >= 0) {
                if (p[0] == 0xFE && p[1] == 0xFF) {
-                       lociTag.name = (unsigned char *)mmfile_string_convert((const char *)(p + 2), pos - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+                       lociTag.name = (unsigned char *)mmfile_convert_to_utf8((const char *)(p + 2), pos - 2, MMFILE_CODESET_UTF16);
                } else {
                        lociTag.name = (unsigned char *)g_strdup((const char *)p);
                }
@@ -735,9 +730,9 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
        lociTag.role = *p;
        p++;
 
-       debug_msg(RELEASE, "long: 0x%02X 0x%02X 0x%02X 0x%02X \n", *(p + 0), *(p + 1), *(p + 2), *(p + 3));
-       debug_msg(RELEASE, "lati: 0x%02X 0x%02X 0x%02X 0x%02X \n", *(p + 4), *(p + 5), *(p + 6), *(p + 7));
-       debug_msg(RELEASE, "alti: 0x%02X 0x%02X 0x%02X 0x%02X \n", *(p + 8), *(p + 9), *(p + 10), *(p + 11));
+       debug_msg(RELEASE, "long: 0x%02X 0x%02X 0x%02X 0x%02X ", *(p + 0), *(p + 1), *(p + 2), *(p + 3));
+       debug_msg(RELEASE, "lati: 0x%02X 0x%02X 0x%02X 0x%02X ", *(p + 4), *(p + 5), *(p + 6), *(p + 7));
+       debug_msg(RELEASE, "alti: 0x%02X 0x%02X 0x%02X 0x%02X ", *(p + 8), *(p + 9), *(p + 10), *(p + 11));
 
        ilong = mmfile_io_be_uint32(*(unsigned int *)p);
        ilati = mmfile_io_be_uint32(*(unsigned int *)(p + 4));
@@ -760,7 +755,7 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
        pos = _get_char_position(p, '\0', readed - (name_sz + 1 + 4 + 4 + 4 + 1));
        if (pos >= 0) {
                if (p[0] == 0xFE && p[1] == 0xFF) {
-                       lociTag.astronomical_body = (unsigned char *)mmfile_string_convert((const char *)(p + 2), pos - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+                       lociTag.astronomical_body = (unsigned char *)mmfile_convert_to_utf8((const char *)(p + 2), pos - 2, MMFILE_CODESET_UTF16);
                } else {
                        lociTag.astronomical_body = (unsigned char *)g_strdup((const char *)p);
                }
@@ -774,7 +769,7 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
        pos = _get_char_position(p, '\0', readed - (name_sz + 1 + 4 + 4 + 4 + astro_sz));
        if (pos >= 0) {
                if (p[0] == 0xFE && p[1] == 0xFF) {
-                       lociTag.additional_notes = (unsigned char *)mmfile_string_convert((const char *)(p + 2), pos - 2, "UTF-8", "UTF-16", NULL, (unsigned int *)&bytes_written);
+                       lociTag.additional_notes = (unsigned char *)mmfile_convert_to_utf8((const char *)(p + 2), pos - 2, MMFILE_CODESET_UTF16);
                } else {
                        lociTag.additional_notes = (unsigned char *)g_strdup((const char *)p);
                }
@@ -782,14 +777,14 @@ static int GetLocationFromLociTagBox(MMFileFormatContext *formatContext, MMFileI
                goto exception;
        }
 
-       debug_msg(RELEASE, "** Location Information **\n");
-       debug_msg(RELEASE, "Name             : %s\n", lociTag.name);
-       debug_msg(RELEASE, "Role             : %d (0: shooting, 1: real, 2: fictional, other: reserved)\n", lociTag.role);
-       debug_msg(RELEASE, "Longitude        : %16.16f\n", lociTag.longitude);
-       debug_msg(RELEASE, "Latitude         : %16.16f\n", lociTag.latitude);
-       debug_msg(RELEASE, "Altitude         : %16.16f\n", lociTag.altitude);
-       debug_msg(RELEASE, "Astronomical body: %s\n", lociTag.astronomical_body);
-       debug_msg(RELEASE, "Additional notes : %s\n", lociTag.additional_notes);
+       debug_msg(RELEASE, "** Location Information **");
+       debug_msg(RELEASE, "Name             : %s", lociTag.name);
+       debug_msg(RELEASE, "Role             : %d (0: shooting, 1: real, 2: fictional, other: reserved)", lociTag.role);
+       debug_msg(RELEASE, "Longitude        : %16.16f", lociTag.longitude);
+       debug_msg(RELEASE, "Latitude         : %16.16f", lociTag.latitude);
+       debug_msg(RELEASE, "Altitude         : %16.16f", lociTag.altitude);
+       debug_msg(RELEASE, "Astronomical body: %s", lociTag.astronomical_body);
+       debug_msg(RELEASE, "Additional notes : %s", lociTag.additional_notes);
 
        formatContext->longitude = lociTag.longitude;
        formatContext->latitude = lociTag.latitude;
@@ -819,13 +814,13 @@ static int GetSAUTInfoFromSMTATagBox(MMFileFormatContext *formatContext, MMFileI
        int readed = 0;
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&smtaTag, sizeof(MMFILE_M4A_SMTA_TAGBOX));
        if (readed != sizeof(MMFILE_M4A_SMTA_TAGBOX)) {
-               debug_error(DEBUG, "read smta tag header fail\n");
+               debug_error(DEBUG, "read smta tag header fail");
                goto exception;
        }
 
@@ -878,7 +873,7 @@ exception:
 static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileIOHandle *fp, MMFILE_MP4_BASIC_BOX_HEADER *basic_header)
 {
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -902,13 +897,13 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
 
        readed = mmfile_read(fp, buffer, basic_header->size);
        if (readed != (int)basic_header->size) {
-               debug_error(DEBUG, "read mp4a box failed\n");
+               debug_error(DEBUG, "read mp4a box failed");
                goto exception;
        }
 
        for (i = 0; i + 3 < basic_header->size; ++i)
                if (buffer[i] == 'S' && buffer[i + 1] == 'A' && buffer[i + 2] == '3' && buffer[i + 3] == 'D') {
-                       debug_warning(DEBUG, "SA3D data found at offset %d bytes\n", i);
+                       debug_warning(DEBUG, "SA3D data found at offset %d bytes", i);
                        is_SA3D_present = true;
                        break;
                }
@@ -922,7 +917,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
 
        readed = mmfile_read(fp, (unsigned char *)&sa3dTag, sizeof(MMFILE_MP4A_SA3D_TAGBOX));
        if (readed != sizeof(MMFILE_MP4A_SA3D_TAGBOX)) {
-               debug_error(DEBUG, "read SA3D tag header fail\n");
+               debug_error(DEBUG, "read SA3D tag header fail");
                goto exception;
        }
 
@@ -941,7 +936,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
                debug_msg(RELEASE, "sa3dTag.channel_map[%d] = %d", i, sa3dTag.channel_map[i]);
 
        if (sa3dTag.version != RFC_AMBISONIC_SA3DBOX_VERSION_SUPPORTED) {
-               debug_error(DEBUG, "SA3D tag box version is unsupported\n");
+               debug_error(DEBUG, "SA3D tag box version is unsupported");
                goto exception;
        } else {
                if (sa3dTag.ambisonic_type == RFC_AMBISONIC_TYPE_PERIPHONIC)
@@ -968,7 +963,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
                                                                (sa3dTag.channel_map[3] == 2))
                                                        formatContext->ambisonicFormat = MMFILE_AMBISONIC_FORMAT_AMB;
                                        } else {
-                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond\n");
+                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond");
                                                goto exception;
                                        }
 
@@ -1004,7 +999,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
                                                                (sa3dTag.channel_map[8] == 4))
                                                        formatContext->ambisonicFormat = MMFILE_AMBISONIC_FORMAT_AMB;
                                        } else {
-                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond\n");
+                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond");
                                                goto exception;
                                        }
 
@@ -1055,7 +1050,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
                                                                (sa3dTag.channel_map[15] == 9))
                                                        formatContext->ambisonicFormat = MMFILE_AMBISONIC_FORMAT_AMB;
                                        } else {
-                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond\n");
+                                               debug_error(DEBUG, "Incorrect metadata: ambisonic order and channels number do not correspond");
                                                goto exception;
                                        }
 
@@ -1063,7 +1058,7 @@ static int GetSA3DInfoFromMP4ATagBox(MMFileFormatContext *formatContext, MMFileI
                                }
 
                        default: {
-                                       debug_warning(DEBUG, "Ambisonic order or format is not supported: ambix or amb formats up to 3rd order were expected.\n");
+                                       debug_warning(DEBUG, "Ambisonic order or format is not supported: ambix or amb formats up to 3rd order were expected.");
                                        goto exception;
                                        break;
                                }
@@ -1091,7 +1086,7 @@ static int ParseSt3dData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
 
        readed = mmfile_read(fp, (unsigned char *)&stereo_mode, sizeof(uint8_t));
        if (readed != sizeof(uint8_t)) {
-               debug_error(DEBUG, "read st3d tag header fail\n");
+               debug_error(DEBUG, "read st3d tag header fail");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1113,7 +1108,7 @@ static int ParseSvhdData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
        mmfile_seek(fp, start_offset, SEEK_SET);
        readed = mmfile_read(fp, (unsigned char *)formatContext->metadataSourceV2, box_size);
        if (readed != box_size) {
-               debug_error(DEBUG, "read svhd tag header fail\n");
+               debug_error(DEBUG, "read svhd tag header fail");
                if (formatContext->metadataSourceV2)
                        free(formatContext->metadataSourceV2);
                return MMFILE_UTIL_FAIL;
@@ -1172,21 +1167,21 @@ static int ParseProjData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
 
        readed = mmfile_read(fp, (unsigned char *)&proj_data, sizeof(proj_box_data));
        if (readed != sizeof(proj_box_data)) {
-               debug_error(DEBUG, "read of proj box failed\n");
+               debug_error(DEBUG, "read of proj box failed");
                return MMFILE_UTIL_FAIL;
        }
 
        formatContext->projTypeV2 = mmfile_io_be_uint32(proj_data.proj_type);
 
-       debug_error(DEBUG, "formatContext->projTypeV2 = %d\n", formatContext->projTypeV2);
-       debug_error(DEBUG, "proj_data.version = %d\n", proj_data.version);
-       debug_error(DEBUG, "proj_data.flags = %d\n", ((uint32_t)proj_data.flags[0] << 16) +
+       debug_error(DEBUG, "formatContext->projTypeV2 = %d", formatContext->projTypeV2);
+       debug_error(DEBUG, "proj_data.version = %d", proj_data.version);
+       debug_error(DEBUG, "proj_data.flags = %d", ((uint32_t)proj_data.flags[0] << 16) +
                        ((uint32_t)proj_data.flags[1] << 8) + (uint32_t)proj_data.flags[2]);
 
        mmfile_seek(fp, sizeof(proj_box_data), SEEK_CUR);
        readed = mmfile_read(fp, (unsigned char *)&prhd_data, sizeof(prhd_box_data));
        if (readed != sizeof(prhd_box_data)) {
-               debug_error(DEBUG, "read of prhd box failed\n");
+               debug_error(DEBUG, "read of prhd box failed");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1194,16 +1189,16 @@ static int ParseProjData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
        formatContext->posePitchV2 = mmfile_io_be_uint32(prhd_data.projection_pose_pitch);
        formatContext->poseRollV2 = mmfile_io_be_uint32(prhd_data.projection_pose_roll);
 
-       debug_error(DEBUG, "formatContext->poseYawV2 = %d\n", formatContext->poseYawV2);
-       debug_error(DEBUG, "formatContext->posePitchV2 = %d\n", formatContext->posePitchV2);
-       debug_error(DEBUG, "formatContext->poseRollV2 = %d\n", formatContext->poseRollV2);
+       debug_error(DEBUG, "formatContext->poseYawV2 = %d", formatContext->poseYawV2);
+       debug_error(DEBUG, "formatContext->posePitchV2 = %d", formatContext->posePitchV2);
+       debug_error(DEBUG, "formatContext->poseRollV2 = %d", formatContext->poseRollV2);
 
        if (formatContext->projTypeV2 == PROJECTION_TYPE_EQUI) {
                debug_msg(RELEASE, "Projection type is Equirectangular");
                mmfile_seek(fp, 8, SEEK_CUR); /* 8 = 4 (for size) + 4 (fourcc) */
                readed = mmfile_read(fp, (unsigned char *)&equi_data, sizeof(equi_box_data));
                if (readed != sizeof(equi_box_data)) {
-                       debug_error(DEBUG, "read of equi box failed\n");
+                       debug_error(DEBUG, "read of equi box failed");
                        return MMFILE_UTIL_FAIL;
                }
 
@@ -1212,25 +1207,25 @@ static int ParseProjData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
                formatContext->equiBoundsLeftV2 = mmfile_io_be_uint32(equi_data.projection_bounds_left);
                formatContext->equiBoundsRightV2 = mmfile_io_be_uint32(equi_data.projection_bounds_right);
 
-               debug_error(DEBUG, "formatContext->equiBoundsTopV2 = %d\n", formatContext->equiBoundsTopV2);
-               debug_error(DEBUG, "formatContext->equiBoundsBottomV2 = %d\n", formatContext->equiBoundsBottomV2);
-               debug_error(DEBUG, "formatContext->equiBoundsLeftV2 = %d\n", formatContext->equiBoundsLeftV2);
-               debug_error(DEBUG, "formatContext->equiBoundsRightV2 = %d\n", formatContext->equiBoundsRightV2);
+               debug_error(DEBUG, "formatContext->equiBoundsTopV2 = %d", formatContext->equiBoundsTopV2);
+               debug_error(DEBUG, "formatContext->equiBoundsBottomV2 = %d", formatContext->equiBoundsBottomV2);
+               debug_error(DEBUG, "formatContext->equiBoundsLeftV2 = %d", formatContext->equiBoundsLeftV2);
+               debug_error(DEBUG, "formatContext->equiBoundsRightV2 = %d", formatContext->equiBoundsRightV2);
 
        } else if (formatContext->projTypeV2 == PROJECTION_TYPE_CBMP) {
                debug_msg(RELEASE, "Projection type is Cubemap");
                mmfile_seek(fp, 8, SEEK_CUR); /* 8 = 4 (for size) + 4 (fourcc) */
                readed = mmfile_read(fp, (unsigned char *)&cbmp_data, sizeof(cbmp_box_data));
                if (readed != sizeof(cbmp_box_data)) {
-                       debug_error(DEBUG, "read of cbmp box failed\n");
+                       debug_error(DEBUG, "read of cbmp box failed");
                        return MMFILE_UTIL_FAIL;
                }
 
                formatContext->cbmpLayoutV2 = mmfile_io_be_uint32(cbmp_data.layout);
                formatContext->cbmpPaddingV2 = mmfile_io_be_uint32(cbmp_data.padding);
 
-               debug_error(DEBUG, "formatContext->cbmpLayoutV2 = %d\n", formatContext->cbmpLayoutV2);
-               debug_error(DEBUG, "formatContext->cbmpPaddingV2 = %d\n", formatContext->cbmpPaddingV2);
+               debug_error(DEBUG, "formatContext->cbmpLayoutV2 = %d", formatContext->cbmpLayoutV2);
+               debug_error(DEBUG, "formatContext->cbmpPaddingV2 = %d", formatContext->cbmpPaddingV2);
 
        } else {
                debug_msg(RELEASE, "Projection type is %d (unknown)", proj_data.proj_type);
@@ -1243,7 +1238,7 @@ static int ParseProjData(MMFileFormatContext *formatContext, MMFileIOHandle *fp,
 static int GetVideoV2MetadataFromAvc1TagBox(MMFileFormatContext *formatContext, MMFileIOHandle *fp, MMFILE_MP4_BASIC_BOX_HEADER *basic_header)
 {
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1274,27 +1269,27 @@ static int GetVideoV2MetadataFromAvc1TagBox(MMFileFormatContext *formatContext,
 
        readed = mmfile_read(fp, buffer, basic_header->size);
        if (readed != (int)basic_header->size) {
-               debug_error(DEBUG, "read st3d box failed\n");
+               debug_error(DEBUG, "read st3d box failed");
                goto exception;
        }
 
        for (i = 0; i + 3 < basic_header->size; ++i) {
                if ((buffer[i] == 's' && buffer[i + 1] == 't' && buffer[i + 2] == '3' && buffer[i + 3] == 'd') && (formatContext->stereoModeV2 == INVALID_UINT_VALUE)) {
-                       debug_warning(DEBUG, "st3d data found at offset %lld\n", basic_header->start_offset + i);
+                       debug_warning(DEBUG, "st3d data found at offset %lld", basic_header->start_offset + i);
                        ParseSt3dData(formatContext, fp, basic_header->start_offset + i + 4);
                        debug_msg(RELEASE, "formatContext->stereoModeV2 = %d", formatContext->stereoModeV2);
                }
                if (buffer[i] == 's' && buffer[i + 1] == 'v' && buffer[i + 2] == '3' && buffer[i + 3] == 'd') {
-                       debug_warning(DEBUG, "sv3d data found at offset %lld\n", basic_header->start_offset + i);
+                       debug_warning(DEBUG, "sv3d data found at offset %lld", basic_header->start_offset + i);
                        formatContext->isSpherical = true;
                }
                if (buffer[i] == 's' && buffer[i + 1] == 'v' && buffer[i + 2] == 'h' && buffer[i + 3] == 'd') {
-                       debug_warning(DEBUG, "svhd data found at offset %lld\n", basic_header->start_offset + i);
+                       debug_warning(DEBUG, "svhd data found at offset %lld", basic_header->start_offset + i);
                        ParseSvhdData(formatContext, fp, basic_header->start_offset + i + 4, mmfile_io_be_uint32(*((uint32_t*)(buffer - 4 + i))));
                        debug_msg(RELEASE, "formatContext->metadataSourceV2 = %s (length = %zu)", formatContext->metadataSourceV2, strlen(formatContext->metadataSourceV2));
                }
                if (buffer[i] == 'p' && buffer[i + 1] == 'r' && buffer[i + 2] == 'o' && buffer[i + 3] == 'j') {
-                       debug_warning(DEBUG, "proj data found at offset %lld\n", basic_header->start_offset + i);
+                       debug_warning(DEBUG, "proj data found at offset %lld", basic_header->start_offset + i);
                        ParseProjData(formatContext, fp, basic_header->start_offset + i + 4);
                }
        }
@@ -1313,13 +1308,13 @@ static int GetValueFromCDISTagBox(MMFileFormatContext *formatContext, MMFileIOHa
        int readed = 0;
 
        if (!formatContext || !fp || !basic_header) {
-               debug_error(DEBUG, "invalid param\n");
+               debug_error(DEBUG, "invalid param");
                return MMFILE_UTIL_FAIL;
        }
 
        readed = mmfile_read(fp, (unsigned char *)&value, sizeof(unsigned int));
        if (readed != sizeof(unsigned int)) {
-               debug_error(DEBUG, "read cdis tag header fail\n");
+               debug_error(DEBUG, "read cdis tag header fail");
                goto exception;
        }
 
@@ -1364,19 +1359,19 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
        /* meta box */
        readed = mmfile_read(fp, (unsigned char *)&meta_version, 4);
        if (readed != 4) {
-               debug_error(DEBUG, "read meta box version\n");
+               debug_error(DEBUG, "read meta box version");
                goto exception;
        }
 
        /* hdlr box */
        readed = mmfile_read(fp, (unsigned char *)&hdlrBoxHeader, MMFILE_MP4_BASIC_BOX_HEADER_LEN);
        if (readed != MMFILE_MP4_BASIC_BOX_HEADER_LEN) {
-               debug_error(DEBUG, "read hdlr box header\n");
+               debug_error(DEBUG, "read hdlr box header");
                goto exception;
        }
 
        if (hdlrBoxHeader.type != FOURCC('h', 'd', 'l', 'r')) {
-               debug_warning(DEBUG, "meta type is not hdlr\n");
+               debug_warning(DEBUG, "meta type is not hdlr");
                goto exception;
        }
 
@@ -1385,7 +1380,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
 
        readed = mmfile_read(fp, (unsigned char *)&hdlrBox, MMFILE_3GP_HANDLER_BOX_LEN);
        if (readed != MMFILE_3GP_HANDLER_BOX_LEN) {
-               debug_error(DEBUG, "read hdlr box\n");
+               debug_error(DEBUG, "read hdlr box");
                goto exception;
        }
 
@@ -1395,7 +1390,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
         * check tag type (ID3v2 or iTunes)
         */
        if (hdlrBox.handler_type == FOURCC('I', 'D', '3', '2')) {
-               debug_msg(RELEASE, "ID3v2 tag detected.\n");
+               debug_msg(RELEASE, "ID3v2 tag detected.");
 
                id3_meta = 1;
 #ifdef ENABLE_ITUNES_META
@@ -1404,13 +1399,13 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
        } else if (hdlrBox.handler_type == FOURCC('m', 'd', 'i', 'r') &&
                                mmfile_io_le_uint32(hdlrBox.reserved[0]) == FOURCC('a', 'p', 'p', 'l')) {
 
-               debug_msg(RELEASE, "Apple iTunes tag detected by mdir.\n");
+               debug_msg(RELEASE, "Apple iTunes tag detected by mdir.");
 
 #ifdef ENABLE_ITUNES_META
                iTunes_meta = 1;
 #endif
        } else {
-               debug_warning(DEBUG, "unknown meta type. 4CC:[%c%c%c%c]\n", ((char *)&hdlrBox.handler_type)[0],
+               debug_warning(DEBUG, "unknown meta type. 4CC:[%c%c%c%c]", ((char *)&hdlrBox.handler_type)[0],
                                        ((char *)&hdlrBox.handler_type)[1],
                                        ((char *)&hdlrBox.handler_type)[2],
                                        ((char *)&hdlrBox.handler_type)[3]);
@@ -1435,12 +1430,12 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
 
                readed = mmfile_read(fp, read_buf, buf_size);   /* to find 'ilst' */
                if (readed != buf_size) {
-                       debug_error(DEBUG, "read fail [%d]\n", readed);
+                       debug_error(DEBUG, "read fail [%d]", readed);
                        goto exception;
                }
 
                if (read_buf[0] == 'i' && read_buf[1] == 'l' && read_buf[2] == 's' && read_buf[3] == 't') {
-                       debug_msg(RELEASE, "Apple iTunes tag detected by ilst.\n");
+                       debug_msg(RELEASE, "Apple iTunes tag detected by ilst.");
                        iTunes_meta = 1;
                }
        }
@@ -1493,7 +1488,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                artist_offset = mmfile_tell(fp);
                                artist_sz = mmfile_io_be_uint32(*(int *)(read_buf + 4)) - 16; /* atom len(4)+data(4)+atom verion(1)+flag(3)+null(4) = 16 */
 
-                               debug_msg(RELEASE, "----------------------------------- artist found, offset=[%lld], size=[%d]\n", artist_offset, artist_sz);
+                               debug_msg(RELEASE, "----------------------------------- artist found, offset=[%lld], size=[%d]", artist_offset, artist_sz);
                        }
 
                        /**
@@ -1506,7 +1501,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                track_found = 1;
                                track_offset = mmfile_tell(fp);
 
-                               debug_msg(RELEASE, "----------------------------------- Track found, offset=[%lld]\n", track_offset);
+                               debug_msg(RELEASE, "----------------------------------- Track found, offset=[%lld]", track_offset);
                        }
 
                        /**
@@ -1520,7 +1515,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                genre_found = 1;
                                genre_offset = mmfile_tell(fp);
 
-                               debug_msg(RELEASE, "----------------------------------- genre found, offset=[%lld]\n", genre_offset);
+                               debug_msg(RELEASE, "----------------------------------- genre found, offset=[%lld]", genre_offset);
                        }
 #endif
 
@@ -1538,7 +1533,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
 
                                cover_offset = mmfile_tell(fp);
 
-                               debug_msg(RELEASE, "----------------------------------- cover_found found,  offset=[%lld]\n", cover_offset);
+                               debug_msg(RELEASE, "----------------------------------- cover_found found,  offset=[%lld]", cover_offset);
                        }
 
                        mmfile_seek(fp, -(_ITUNES_READ_BUF_SZ - 1), SEEK_CUR);  /*FIXME: poor search*/
@@ -1551,21 +1546,21 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                mmfile_seek(fp, artist_offset, SEEK_SET);
 
                                if (formatContext->artist) {
-                                       debug_msg(RELEASE, "----------------------------------- previous artist was [%s] \n", formatContext->artist);
+                                       debug_msg(RELEASE, "----------------------------------- previous artist was [%s] ", formatContext->artist);
                                        free(formatContext->artist);
                                }
 
-                               debug_msg(RELEASE, "----------------------------------- new artist will be allocated with size (len+1) [%d] \n", artist_sz + 1);
+                               debug_msg(RELEASE, "----------------------------------- new artist will be allocated with size (len+1) [%d] ", artist_sz + 1);
                                formatContext->artist = g_malloc0(artist_sz + 1);
 
                                if (formatContext->artist) {
                                        readed = mmfile_read(fp, (unsigned char *)formatContext->artist, artist_sz);
                                        formatContext->artist[artist_sz] = '\0';
 
-                                       debug_msg(RELEASE, "----------------------------------- new artist is [%s] \n", formatContext->artist);
+                                       debug_msg(RELEASE, "----------------------------------- new artist is [%s] ", formatContext->artist);
 
                                        if (readed != artist_sz) {
-                                               debug_error(DEBUG, "failed to read. ret = %d, in = %d\n", readed, artist_sz);
+                                               debug_error(DEBUG, "failed to read. ret = %d, in = %d", readed, artist_sz);
                                                mmfile_free(formatContext->artist);
                                        }
                                }
@@ -1576,7 +1571,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                        mmfile_seek(fp, track_offset, SEEK_SET);
                        readed = mmfile_read(fp, read_buf, _ITUNES_TRACK_NUM_SZ);
                        if (readed != _ITUNES_TRACK_NUM_SZ) {
-                               debug_error(DEBUG, "failed to read. ret = %d, in = %d\n", readed, _ITUNES_TRACK_NUM_SZ);
+                               debug_error(DEBUG, "failed to read. ret = %d, in = %d", readed, _ITUNES_TRACK_NUM_SZ);
                        } else {
                                track_num = mmfile_io_be_uint32(*(int *)read_buf);
                                if (!formatContext->tagTrackNum) {
@@ -1591,16 +1586,16 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                        mmfile_seek(fp, genre_offset, SEEK_SET);
                        readed = mmfile_read(fp, read_buf, _ITUNES_GENRE_NUM_SZ);
                        if (readed != _ITUNES_GENRE_NUM_SZ) {
-                               debug_error(DEBUG, "failed to read. ret = %d, in = %d\n", readed, _ITUNES_GENRE_NUM_SZ);
+                               debug_error(DEBUG, "failed to read. ret = %d, in = %d", readed, _ITUNES_GENRE_NUM_SZ);
                        } else {
                                genre_index = mmfile_io_be_uint16(*(int *)read_buf);
-                               debug_msg(RELEASE, "genre index=[%d] \n", genre_index);
+                               debug_msg(RELEASE, "genre index=[%d] ", genre_index);
 
                                if (genre_index > 0 && genre_index < GENRE_COUNT)       {
                                        if (!formatContext->genre) {
                                                memset(read_buf, 0x00, _ITUNES_READ_BUF_SZ);
                                                snprintf((char *)read_buf, sizeof(read_buf), "%s", MpegAudio_Genre[genre_index - 1]);
-                                               debug_msg(RELEASE, "genre string=[%s] \n", read_buf);
+                                               debug_msg(RELEASE, "genre string=[%s] ", read_buf);
                                                formatContext->genre = g_strdup((const char *)read_buf);
                                        }
                                }
@@ -1641,7 +1636,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                if (formatContext->artwork) {
                                        readed = mmfile_read(fp, formatContext->artwork, cover_sz);
                                        if (readed != cover_sz) {
-                                               debug_error(DEBUG, "failed to read. ret = %d, in = %d\n", readed, cover_sz);
+                                               debug_error(DEBUG, "failed to read. ret = %d, in = %d", readed, cover_sz);
                                                mmfile_free(formatContext->artwork);
                                                formatContext->artworkSize = 0;
                                                mmfile_free(formatContext->artworkMime);
@@ -1667,7 +1662,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                        /* id3 tag box */
                        readed = mmfile_read(fp, (unsigned char *)&id3v2BoxHeader, MMFILE_MP4_BASIC_BOX_HEADER_LEN);
                        if (readed != MMFILE_MP4_BASIC_BOX_HEADER_LEN) {
-                               debug_error(DEBUG, "read id3v2 box header\n");
+                               debug_error(DEBUG, "read id3v2 box header");
                                goto exception;
                        }
 
@@ -1675,13 +1670,13 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                        id3v2BoxHeader.type = mmfile_io_le_uint32(id3v2BoxHeader.type);
 
                        if (id3v2BoxHeader.type != FOURCC('I', 'D', '3', '2')) {
-                               debug_warning(DEBUG, "meta type is not id3v2\n");
+                               debug_warning(DEBUG, "meta type is not id3v2");
                                goto exception;
                        }
 
                        readed = mmfile_read(fp, (unsigned char *)&id3v2Box, MMFILE_3GP_ID3V2_BOX_LEN);
                        if (readed != MMFILE_3GP_ID3V2_BOX_LEN) {
-                               debug_error(DEBUG, "read id3v2 box\n");
+                               debug_error(DEBUG, "read id3v2 box");
                                goto exception;
                        }
 
@@ -1691,26 +1686,26 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
 
                        readed = mmfile_read(fp, (unsigned char *)id3v2Box.id3v2Data, id3v2Len);
                        if (readed != id3v2Len) {
-                               debug_error(DEBUG, "read id3tag data error\n");
+                               debug_error(DEBUG, "read id3tag data error");
                                goto exception;
                        }
 
                        /* check id3v2 */
                        if (!IS_ID3V2_TAG(id3v2Box.id3v2Data)) {
-                               debug_error(DEBUG, "it is not id3tag\n");
+                               debug_error(DEBUG, "it is not id3tag");
                                goto exception;
                        }
 
                        if (id3v2Box.id3v2Data[3] == 0xFF ||  id3v2Box.id3v2Data[4] == 0xFF ||
                            id3v2Box.id3v2Data[6] >= 0x80 ||  id3v2Box.id3v2Data[7] >= 0x80 ||
                            id3v2Box.id3v2Data[8] >= 0x80 ||  id3v2Box.id3v2Data[9] >= 0x80) {
-                               debug_error(DEBUG, "it is not valid id3tag\n");
+                               debug_error(DEBUG, "it is not valid id3tag");
                                goto exception;
                        }
 
                        tagVersion = id3v2Box.id3v2Data[3];
                        if (tagVersion > 4) {
-                               debug_error(DEBUG, "tag vesion is too high\n");
+                               debug_error(DEBUG, "tag vesion is too high");
                                goto exception;
                        }
 
@@ -1736,14 +1731,14 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                }
                        case 1:
                        default: {
-                                       debug_error(DEBUG, "tag vesion is not support\n");
+                                       debug_error(DEBUG, "tag vesion is not support");
                                        versionCheck = false;
                                        break;
                                }
                        }
 
                        if (versionCheck == false) {
-                               debug_error(DEBUG, "tag parsing is fail\n");
+                               debug_error(DEBUG, "tag parsing is fail");
                                goto exception;
                        }
 
@@ -1792,7 +1787,7 @@ int mm_file_get_int_value_from_xml_string(const char* xml_str, const char* param
        int value_length = 0;
 
        if (!xml_str || !param_name || !strstr(xml_str, param_name)) {
-               debug_error(DEBUG, "error: incorrect or non-existing parameter\n");
+               debug_error(DEBUG, "error: incorrect or non-existing parameter");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1802,7 +1797,7 @@ int mm_file_get_int_value_from_xml_string(const char* xml_str, const char* param
 
        value_end = strchr(value_start, '<');
        if (!value_end) {
-               debug_error(DEBUG, "error: incorrect XML\n");
+               debug_error(DEBUG, "error: incorrect XML");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1815,14 +1810,14 @@ int mm_file_get_int_value_from_xml_string(const char* xml_str, const char* param
                        i++;
        while (i < value_length) {
                if (value_start[i] < '0' || value_start[i] > '9') {
-                       debug_error(DEBUG, "error: incorrect value, integer was expected\n");
+                       debug_error(DEBUG, "error: incorrect value, integer was expected");
                        return MMFILE_UTIL_FAIL;
                }
                i++;
        }
 
        if (value_length >= value_length_max || value_length < 1) {
-               debug_error(DEBUG, "error: empty XML value or incorrect range\n");
+               debug_error(DEBUG, "error: empty XML value or incorrect range");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1831,7 +1826,7 @@ int mm_file_get_int_value_from_xml_string(const char* xml_str, const char* param
 
        *value = strtol(init_view_ret, &endptr, 10);
        if (endptr == init_view_ret) {
-               debug_error(DEBUG, "error: no digits were found\n");
+               debug_error(DEBUG, "error: no digits were found");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1845,7 +1840,7 @@ int mm_file_get_string_value_from_xml_string(const char* xml_str, const char* pa
        int value_length = 0;
 
        if (!xml_str || !param_name || !strstr(xml_str, param_name)) {
-               debug_error(DEBUG, "error: incorrect or non-existing parameter\n");
+               debug_error(DEBUG, "error: incorrect or non-existing parameter");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1855,7 +1850,7 @@ int mm_file_get_string_value_from_xml_string(const char* xml_str, const char* pa
 
        value_end = strchr(value_start, '<');
        if (!value_end) {
-               debug_error(DEBUG, "error: incorrect XML\n");
+               debug_error(DEBUG, "error: incorrect XML");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1864,13 +1859,13 @@ int mm_file_get_string_value_from_xml_string(const char* xml_str, const char* pa
                value_length--;
 
        if (value_length >= value_length_max || value_length < 1) {
-               debug_error(DEBUG, "error: empty XML value or incorrect range\n");
+               debug_error(DEBUG, "error: empty XML value or incorrect range");
                return MMFILE_UTIL_FAIL;
        }
 
        *value = (char*)calloc(value_length, sizeof(char));
        if (*value == NULL) {
-               debug_error(DEBUG, "error: calloc failed\n");
+               debug_error(DEBUG, "error: calloc failed");
                return MMFILE_UTIL_FAIL;
        }
        strncpy(*value, value_start, value_length);
@@ -1885,7 +1880,7 @@ int mm_file_get_bool_value_from_xml_string(const char* xml_str, const char* para
        int value_length = 0;
 
        if (!xml_str || !param_name || !strstr(xml_str, param_name)) {
-               debug_error(DEBUG, "error: incorrect or non-existing parameter\n");
+               debug_error(DEBUG, "error: incorrect or non-existing parameter");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -1904,7 +1899,7 @@ int mm_file_get_bool_value_from_xml_string(const char* xml_str, const char* para
                value_length--;
 
        if (value_length < 1) {
-               debug_error(DEBUG, "error: empty XML value or incorrect range\n");
+               debug_error(DEBUG, "error: empty XML value or incorrect range");
                return MMFILE_UTIL_FAIL;
        }
 
@@ -2011,32 +2006,32 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
 
        ret = mmfile_open(&fp, formatContext->uriFileName, MMFILE_RDONLY);
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "error: mmfile_open\n");
+               debug_error(DEBUG, "error: mmfile_open");
                goto exit;
        }
 
        file_size = mmfile_seek(fp, 0, SEEK_END);
        if (file_size == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "mmfile operation failed\n");
+               debug_error(DEBUG, "mmfile operation failed");
                goto exit;
        }
 
        probe_size = (file_size > probe_size) ? probe_size : file_size;
        buffer = (unsigned char *)malloc(probe_size * sizeof(unsigned char));
        if (!buffer) {
-               debug_error(DEBUG, "malloc failed\n");
+               debug_error(DEBUG, "malloc failed");
                goto exit;
        }
 
        ret = mmfile_seek(fp, 0, SEEK_SET);
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "mmfile operation failed\n");
+               debug_error(DEBUG, "mmfile operation failed");
                goto exit;
        }
 
        ret = mmfile_read(fp, buffer, probe_size * sizeof(unsigned char));
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "mmfile operation failed\n");
+               debug_error(DEBUG, "mmfile operation failed");
                goto exit;
        }
 
@@ -2044,41 +2039,41 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
        for (i = 0; i + 3 < probe_size; ++i) {
                if (*(unsigned int *)(buffer + i) == FOURCC('e', 'q', 'u', 'i') ||
                                *(unsigned int *)(buffer + i) == FOURCC('c', 'b', 'm', 'p')) {
-                       debug_msg(DEBUG, "projection data found at offset %d bytes\n", i);
+                       debug_msg(DEBUG, "projection data found at offset %d bytes", i);
                        break;
                }
        }
 
        if (i + 3 == probe_size) {
-               debug_msg(DEBUG, "projection info wasn't found\n");
+               debug_msg(DEBUG, "projection info wasn't found");
                ret = MMFILE_UTIL_SUCCESS;
                goto exit;
        }
 
        if ((i - (int)sizeof(MMFILE_WEBM_PROJ_V2_BOX)) < 0) {
-               debug_error(DEBUG, "error: invalid supposed projection info location\n");
+               debug_error(DEBUG, "error: invalid supposed projection info location");
                ret = MMFILE_UTIL_FAIL;
                goto exit;
        }
 
        ret = mmfile_seek(fp, i - sizeof(MMFILE_WEBM_PROJ_V2_BOX), SEEK_SET);
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "error: failed to seek to the supposed projection info location\n");
+               debug_error(DEBUG, "error: failed to seek to the supposed projection info location");
                goto exit;
        }
 
        ret = mmfile_read(fp, (unsigned char *)&v2box, sizeof(MMFILE_WEBM_PROJ_V2_BOX));
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "mmfile operation failed\n");
+               debug_error(DEBUG, "mmfile operation failed");
                goto exit;
        }
 
        if (v2box.proj_type_box_value == PROJECTION_TYPE_EQUI) {
-               debug_msg(DEBUG, "Equirectangular projection is used\n");
+               debug_msg(DEBUG, "Equirectangular projection is used");
 
                ret = mmfile_read(fp, (unsigned char *)&equi, sizeof(MMFILE_WEBM_EQUI_PROJ_V2_BOX));
                if (ret == MMFILE_UTIL_FAIL) {
-                       debug_error(DEBUG, "error: failed to read equirectangular element\n");
+                       debug_error(DEBUG, "error: failed to read equirectangular element");
                        goto exit;
                }
                if (strncmp((char *)equi.proj_priv_box_name, "equi", 4) == 0) {
@@ -2087,24 +2082,24 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
                        formatContext->equiBoundsLeftV2 = mmfile_io_be_uint32(equi.equi_projection_bounds_left);
                        formatContext->equiBoundsRightV2 = mmfile_io_be_uint32(equi.equi_projection_bounds_right);
                } else {
-                       debug_error(DEBUG, "error: failed to read equirectangular element\n");
+                       debug_error(DEBUG, "error: failed to read equirectangular element");
                        ret = MMFILE_UTIL_SUCCESS;
                        goto exit;
                }
        }
        if (v2box.proj_type_box_value == PROJECTION_TYPE_CBMP) {
-               debug_msg(DEBUG, "Cubemap projection is used\n");
+               debug_msg(DEBUG, "Cubemap projection is used");
 
                ret = mmfile_read(fp, (unsigned char *)&cbmp, sizeof(MMFILE_WEBM_CBMP_PROJ_V2_BOX));
                if (ret == MMFILE_UTIL_FAIL) {
-                       debug_error(DEBUG, "error: failed to read cubemap element\n");
+                       debug_error(DEBUG, "error: failed to read cubemap element");
                        goto exit;
                }
                if (strncmp((char *)cbmp.proj_priv_box_name, "cbmp", 4) == 0) {
                        formatContext->cbmpLayoutV2 = mmfile_io_be_uint32(cbmp.cbmp_projection_layout);
                        formatContext->cbmpPaddingV2 = mmfile_io_be_uint32(cbmp.cbmp_projection_padding);
                } else {
-                       debug_error(DEBUG, "error: failed to read cubemap element\n");
+                       debug_error(DEBUG, "error: failed to read cubemap element");
                        ret = MMFILE_UTIL_FAIL;
                        goto exit;
                }
@@ -2112,28 +2107,28 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
 
        ret = mmfile_read(fp, (unsigned char *)&pose, sizeof(MMFILE_WEBM_POSE_ELEMENT_V2_BOX));
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "error: failed to read pose info\n");
+               debug_error(DEBUG, "error: failed to read pose info");
                goto exit;
        }
 
        if (pose.pose_yaw_element_id == POSE_YAW_ELEMENT_ID) {
                formatContext->poseYawV2 = (uint)mmfile_io_be_float32(pose.pose_yaw_element_value);
        } else {
-               debug_error(DEBUG, "error: failed to pose yaw element\n");
+               debug_error(DEBUG, "error: failed to pose yaw element");
                ret = MMFILE_UTIL_FAIL;
                goto exit;
        }
        if (pose.pose_pitch_element_id == POSE_PITCH_ELEMENT_ID) {
                formatContext->posePitchV2 = (uint)mmfile_io_be_float32(pose.pose_pitch_element_value);
        } else {
-               debug_error(DEBUG, "error: failed to pose pitch element\n");
+               debug_error(DEBUG, "error: failed to pose pitch element");
                ret = MMFILE_UTIL_FAIL;
                goto exit;
        }
        if (pose.pose_roll_element_id == POSE_ROLL_ELEMENT_ID) {
                formatContext->poseRollV2 = (uint)mmfile_io_be_float32(pose.pose_roll_element_value);
        } else {
-               debug_error(DEBUG, "error: failed to pose roll element\n");
+               debug_error(DEBUG, "error: failed to pose roll element");
                ret = MMFILE_UTIL_FAIL;
                goto exit;
        }
@@ -2159,7 +2154,7 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
 
        ret = mmfile_open(&fp, formatContext->uriFileName, MMFILE_RDONLY);
        if (ret == MMFILE_UTIL_FAIL) {
-               debug_error(DEBUG, "error: mmfile_open\n");
+               debug_error(DEBUG, "error: mmfile_open");
                goto exit;
        }
 
@@ -2173,7 +2168,7 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                basic_header.type = mmfile_io_le_uint32(basic_header.type);
 
                if (basic_header.size == 0) {
-                       debug_warning(DEBUG, "header is invalid.\n");
+                       debug_warning(DEBUG, "header is invalid.");
                        basic_header.size = readed;
                        basic_header.type = 0;
                        chunk_size = basic_header.size;
@@ -2207,86 +2202,86 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
 
                switch (basic_header.type) {
                        case FOURCC('m', 'o', 'o', 'v'): {
-                                       debug_msg(RELEASE, "MPEG4: [moov] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [moov] SIZE: [%lld]Byte", chunk_size);
                                        moov_end = basic_header.start_offset + chunk_size;
                                        break;
                                }
                        case FOURCC('u', 'd', 't', 'a'): {
-                                       debug_msg(RELEASE, "MPEG4: [udat] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [udat] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                                /*/////////////////////////////////////////////////////////////// */
                                /*                  Extracting Tag Data                        // */
                                /*/////////////////////////////////////////////////////////////// */
                        case FOURCC('t', 'i', 't', 'l'): {
-                                       debug_msg(RELEASE, "MPEG4: [titl] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [titl] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_TITLE);
                                        break;
                                }
                        case FOURCC('d', 's', 'c', 'p'): {
-                                       debug_msg(RELEASE, "MPEG4: [dscp] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [dscp] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_CAPTION);
                                        break;
                                }
                        case FOURCC('c', 'p', 'r', 't'): {
-                                       debug_msg(RELEASE, "MPEG4: [cprt] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [cprt] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_COPYRIGHT);
                                        break;
                                }
                        case FOURCC('p', 'e', 'r', 'f'): {
-                                       debug_msg(RELEASE, "MPEG4: [perf] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [perf] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_PERFORMER);
                                        break;
                                }
                        case FOURCC('a', 'u', 't', 'h'): {
-                                       debug_msg(RELEASE, "MPEG4: [auth] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [auth] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_AUTHOR);
                                        break;
                                }
                        case FOURCC('g', 'n', 'r', 'e'): {
-                                       debug_msg(RELEASE, "MPEG4: [gnre] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [gnre] SIZE: [%lld]Byte", chunk_size);
                                        GetStringFromTextTagBox(formatContext, fp, &basic_header, eMMFILE_3GP_TAG_GENRE);
                                        break;
                                }
                        case FOURCC('a', 'l', 'b', 'm'): {
-                                       debug_msg(RELEASE, "MPEG4: [albm] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [albm] SIZE: [%lld]Byte", chunk_size);
                                        GetAlbumFromAlbumTagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                        case FOURCC('y', 'r', 'r', 'c'): {
-                                       debug_msg(RELEASE, "MPEG4: [yrrc] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [yrrc] SIZE: [%lld]Byte", chunk_size);
                                        GetYearFromYearTagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                        case FOURCC('r', 't', 'n', 'g'): {
-                                       debug_msg(RELEASE, "MPEG4: [rtng] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [rtng] SIZE: [%lld]Byte", chunk_size);
                                        GetRatingFromRatingTagBox(formatContext, fp, &basic_header);  /* not use */
                                        break;
                                }
                        case FOURCC('c', 'l', 's', 'f'): {
-                                       debug_msg(RELEASE, "MPEG4: [clsf] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [clsf] SIZE: [%lld]Byte", chunk_size);
                                        GetClassficationFromClsfTagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                        case FOURCC('k', 'y', 'w', 'd'): {
-                                       debug_msg(RELEASE, "MPEG4: [kywd] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [kywd] SIZE: [%lld]Byte", chunk_size);
                                        ret = mmfile_seek(fp, basic_header.start_offset + chunk_size, SEEK_SET);
                                        break;
                                }
                        case FOURCC('l', 'o', 'c', 'i'): {
-                                       debug_msg(RELEASE, "MPEG4: [loci] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [loci] SIZE: [%lld]Byte", chunk_size);
                                        GetLocationFromLociTagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                                /* Check smta in user data field (moov) to be compatible with android */
                        case FOURCC('s', 'm', 't', 'a'): {
-                                       debug_msg(RELEASE, "MPEG4: [smta] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [smta] SIZE: [%lld]Byte", chunk_size);
                                        GetSAUTInfoFromSMTATagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                                /* Check cdis in user data field (moov) to be compatible with android */
                        case FOURCC('c', 'd', 'i', 's'): {
-                                       debug_msg(RELEASE, "MPEG4: [smta] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [smta] SIZE: [%lld]Byte", chunk_size);
                                        GetValueFromCDISTagBox(formatContext, fp, &basic_header);
                                        break;
                                }
@@ -2294,19 +2289,19 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                                /*                  Extracting ID3 Tag Data                    // */
                                /*/////////////////////////////////////////////////////////////// */
                        case FOURCC('m', 'e', 't', 'a'): {
-                                       debug_msg(RELEASE, "MPEG4: [meta] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [meta] SIZE: [%lld]Byte", chunk_size);
                                        GetTagFromMetaBox(formatContext, fp, &basic_header);
                                        break;
                                }
 
                        case FOURCC('t', 'r', 'a', 'k'): {
-                                       debug_msg(RELEASE, "MPEG4: [trak] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [trak] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                        case FOURCC('u', 'u', 'i', 'd'): {
                                        unsigned long uuid[4] = {0, };
 
-                                       debug_msg(RELEASE, "MPEG4: [uuid] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [uuid] SIZE: [%lld]Byte", chunk_size);
 
                                        mmfile_read(fp, (unsigned char *)uuid, sizeof(uuid));
 
@@ -2338,7 +2333,7 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                                                        }
 #endif
 
-                                                       debug_msg(RELEASE, "Extracting tags from UUID XML string %s\n", str);
+                                                       debug_msg(RELEASE, "Extracting tags from UUID XML string %s", str);
 
                                                        ParseSpatialVideoMetadataFromXMLString(str, formatContext);
                                                }
@@ -2348,34 +2343,34 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                                        break;
                                }
                        case FOURCC('m', 'd', 'i', 'a'): {
-                                       debug_msg(RELEASE, "MPEG4: [mdia] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [mdia] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                        case FOURCC('m', 'i', 'n', 'f'): {
-                                       debug_msg(RELEASE, "MPEG4: [minf] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [minf] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                        case FOURCC('s', 't', 'b', 'l'): {
-                                       debug_msg(RELEASE, "MPEG4: [stbl] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [stbl] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                        case FOURCC('s', 't', 's', 'd'): {
-                                       debug_msg(RELEASE, "MPEG4: [stsd] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [stsd] SIZE: [%lld]Byte", chunk_size);
                                        break;
                                }
                        case FOURCC('m', 'p', '4', 'a'): {
-                                       debug_msg(RELEASE, "MPEG4: [mp4a] SIZE: [%lld]Byte\n", chunk_size);
+                                       debug_msg(RELEASE, "MPEG4: [mp4a] SIZE: [%lld]Byte", chunk_size);
                                        GetSA3DInfoFromMP4ATagBox(formatContext, fp, &basic_header);
                                        ret = mmfile_seek(fp, basic_header.start_offset + chunk_size, SEEK_SET);
                                        break;
                                }
                        case FOURCC('a', 'v', 'c', '1'): {
-                                       debug_msg(RELEASE, "MPEG4: [avc1] SIZE: [%lld]Byte (offset: %lld)\n", chunk_size, basic_header.start_offset);
+                                       debug_msg(RELEASE, "MPEG4: [avc1] SIZE: [%lld]Byte (offset: %lld)", chunk_size, basic_header.start_offset);
                                        GetVideoV2MetadataFromAvc1TagBox(formatContext, fp, &basic_header);
                                        break;
                                }
                        default: {
-                                       debug_msg(RELEASE, "4CC: Not Support [%c%c%c%c]. So skip it. Size [%lld Byte]\n",
+                                       debug_msg(RELEASE, "4CC: Not Support [%c%c%c%c]. So skip it. Size [%lld Byte]",
                                                                ((char *)&basic_header.type)[0], ((char *)&basic_header.type)[1],
                                                                ((char *)&basic_header.type)[2], ((char *)&basic_header.type)[3], chunk_size);
                                        ret = mmfile_seek(fp, basic_header.start_offset + chunk_size, SEEK_SET);
@@ -2384,7 +2379,7 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                }
 
                if (ret == MMFILE_UTIL_FAIL) {
-                       debug_error(DEBUG, "mmfile operation is error\n");
+                       debug_error(DEBUG, "mmfile operation is error");
                        ret = -1;
                        goto exit;
                }
@@ -2405,73 +2400,32 @@ exit:
        return ret;
 }
 
-static char *get_string(const char *buf, int buf_size, int *bytes_written)
+static bool __get_genre_num(const char *buffer, int *si)
 {
-       int i = 0, c = 0;
-       char *q = NULL;
-       char str[512] = {0, };
-
-       q = str;
-       for (i = 0; i < buf_size; i++) {
-               c = buf[i];
-               if (c == '\0')
-                       break;
-               if ((q - str) >= (int)sizeof(str) - 1)
-                       break;
-               *q++ = c;
-       }
-       *q = '\0';
+       int len = strlen(buffer);
+       char *tmp_genre = NULL;
 
-       if (strlen(str) > 0) {
-               *bytes_written = strlen(str);
-               return strdup(str);
-       } else {
-               *bytes_written = 0;
-               return NULL;
-       }
-}
+       /* Genre format: (###), ### */
+       if (len > 6 || len == 0)
+               return false;
 
-char *rtrimN(char *pStr)
-{
-       int pos = 0;
-       pos = strlen(pStr) - 1;
-       for (; pos >= 0; pos--) {
-               if (pStr[pos] == 0x20) {
-                       pStr[pos] = 0x00;
-               } else {
-                       break;
-               }
+       /* Check fisrt c */
+       if (len == 1) {
+               if (!g_ascii_isdigit(buffer[0]))
+                       return false;
+       } else {
+               if (!g_ascii_isdigit(buffer[1]))
+                       return false;
        }
 
-       return strdup(pStr);
-}
-
-bool safe_atoi(char *buffer, int *si)
+       /* Remove bind () if exist */
+       tmp_genre = g_strdup(buffer);
+       if (g_str_has_prefix(tmp_genre, "(") && g_str_has_suffix(tmp_genre, ")"))
+               tmp_genre[0] = '0';
 
-{
-       char *end;
-       errno = 0;
-
-       const long sl = strtol(buffer, &end, 10);
+       *si = atoi(tmp_genre);
+       g_free(tmp_genre);
 
-       if (end == buffer) {
-               debug_error(RELEASE, "not a decimal number");
-               return false;
-       } else if ('\0' != *end) {
-               debug_error(RELEASE, "extra characters at end of input: %s", end);
-               return false;
-       } else if ((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno)) {
-               debug_error(RELEASE, "out of range of type long");
-               return false;
-       } else if (sl > INT_MAX) {
-               debug_error(RELEASE, "greater than INT_MAX");
-               return false;
-       } else if (sl < INT_MIN) {
-               debug_error(RELEASE, "less than INT_MIN");
-               return false;
-       } else {
-               *si = (int)sl;
-       }
        return true;
 }
 
@@ -2497,7 +2451,7 @@ static bool make_characterset_array(char ***charset_array)
 
        (*charset_array)[AV_ID3V2_UTF16] = strdup("UCS2");
        (*charset_array)[AV_ID3V2_UTF16_BE] = strdup("UTF16-BE");
-       (*charset_array)[AV_ID3V2_UTF8] = strdup("UTF-8");
+       (*charset_array)[AV_ID3V2_UTF8] = strdup(MMFILE_CODESET_UTF8);
 
        return true;
 }
@@ -2525,42 +2479,14 @@ static void init_content_info(AvFileContentInfo *pInfo)
 {
        int i=0;
 
-       for(i = 0; i < AV_ID3TAG_MAX; i++) {
-               pInfo->tagInfo[i].length = 0;
+       for(i = 0; i < AV_ID3TAG_MAX; i++)
                pInfo->tagInfo[i].value = NULL;
-               pInfo->tagInfo[i].marked = false;
-       }
 
        pInfo->imageInfo.bURLInfo = false;
        pInfo->imageInfo.pImageBuf = NULL;
        pInfo->imageInfo.imageLen = 0;
 }
 
-static void _mm_file_id3tag_add_bracket_at_genre(char **genre, int genre_len)
-{
-       int int_genre = -1;
-
-       if (!genre || !(*genre) || genre_len <= 0)
-               return;
-
-       if (!safe_atoi(*genre, &int_genre)) {
-               debug_log(RELEASE, "genre information is not integer [%s]", *genre);
-               return;
-       }
-
-       debug_msg(RELEASE, "genre information is integer [%d]", int_genre);
-
-       /* if the value is not kinds of genre, exit */
-       if (int_genre < 0 || int_genre >= GENRE_COUNT)
-               return;
-
-       /* Change int to string with bracket like "(123)"
-        * mm_file_id3tag_restore_content_info convert it to string
-        */
-       mmfile_free(*genre);
-       *genre = g_strdup_printf("(%d)", int_genre);
-}
-
 static void __id3tag_skip_newline(unsigned char *pTagVal, int *nTagLen, int *offset)
 {
        /* skip newline in text encoding of ID3 tag frame */
@@ -2600,7 +2526,7 @@ static int __id3tag_get_text_encoding_v223(unsigned char *pTagVal, int *npTagLen
                        *offset += 3;
                        return AV_ID3V2_UTF16_BE;
                } else {
-                       debug_msg(RELEASE, "id3tag never get here!!\n");
+                       debug_msg(RELEASE, "id3tag never get here!!");
                        return nTextEnc;        /* default bypass */
                }
        } else {
@@ -2622,7 +2548,7 @@ static int __id3tag_get_text_encoding_v224(unsigned char *pTagVal, int *npTagLen
                        *offset += 2;
                        return AV_ID3V2_UTF16;
                } else {
-                       debug_msg(RELEASE, "id3tag never get here!!\n");
+                       debug_msg(RELEASE, "id3tag never get here!!");
                        return nTextEnc;        /* default bypass */
                }
        } else if (nTextEnc == AV_ID3V2_UTF8) {
@@ -2649,13 +2575,12 @@ static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal
        GList *synclyrics_info_list = NULL;
 
        if (nTagLen < MMFILE_SYNC_LYRIC_INFO_MIN_LEN) {
-               debug_msg(RELEASE, "failed to get Synchronised lyrics Info realCpyFramNum(%d)\n", nTagLen);
-               pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length = 0;
+               debug_msg(RELEASE, "failed to get Synchronised lyrics Info realCpyFramNum(%d)", nTagLen);
                return;
        }
 
        if ((textEncodingType == AV_ID3V2_UTF16) || (textEncodingType == AV_ID3V2_UTF16_BE)) {
-               debug_warning(DEBUG, "[%d] not implemented\n", textEncodingType);
+               debug_warning(DEBUG, "[%d] not implemented", textEncodingType);
                return;
        }
 
@@ -2665,7 +2590,7 @@ static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal
                        if (textEncodingType == AV_ID3V2_UTF8)
                                synclyrics_info->lyric_info = g_memdup(pTagVal + copy_start_pos, copy_len + 1);
                        else
-                               synclyrics_info->lyric_info = mmfile_string_convert((const char *)&pTagVal[copy_start_pos], copy_len, "UTF-8", pCharSet, NULL, NULL);
+                               synclyrics_info->lyric_info = mmfile_convert_to_utf8((const char *)&pTagVal[copy_start_pos], copy_len, pCharSet);
 
                        synclyrics_info->time_info = (unsigned long)pTagVal[offset + idx + 1] << 24 | (unsigned long)pTagVal[offset + idx + 2] << 16 | (unsigned long)pTagVal[offset + idx + 3] << 8  | (unsigned long)pTagVal[offset + idx + 4];
                        idx += 4;
@@ -2678,7 +2603,6 @@ static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal
        }
 
        pInfo->pSyncLyrics = synclyrics_info_list;
-       pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length = g_list_length(pInfo->pSyncLyrics);
 }
 
 static bool __id3tag_parse_PIC_format(AvFileContentInfo *pInfo, unsigned char *pTagVal, int *offset)
@@ -2688,7 +2612,7 @@ static bool __id3tag_parse_PIC_format(AvFileContentInfo *pInfo, unsigned char *p
        /* get the mime type of Attached PICture, it is text string */
 
        if (pTagVal[*offset] == '\0') {
-               debug_msg(RELEASE, "The picture format of PIC is not included\n");
+               debug_msg(RELEASE, "The picture format of PIC is not included");
                return false;
        }
 
@@ -2714,7 +2638,7 @@ static bool __id3tag_parse_APIC_mimetype(AvFileContentInfo *pInfo, unsigned char
 
        if (pTagVal[*offset] == '\0') {
                pInfo->imageInfo.imgMimetypeLen = 0;
-               debug_msg(RELEASE, "The MIME type of APIC is not included\n");
+               debug_msg(RELEASE, "The MIME type of APIC is not included");
                return false;
        }
 
@@ -2736,13 +2660,13 @@ static bool __id3tag_parse_APIC_mimetype(AvFileContentInfo *pInfo, unsigned char
        }
 
        if ((pTagVal[*offset] != '\0') || (nTagLen <= *offset)) {
-               debug_msg(RELEASE, "pTagVal[offset](%d) mimetype is not NULL terminated! realCpyFrameNum - offset(%d)\n",
+               debug_msg(RELEASE, "pTagVal[offset](%d) mimetype is not NULL terminated! realCpyFrameNum - offset(%d)",
                                        pTagVal[*offset], nTagLen - *offset);
                return true;
        }
 
        (*offset)++;/* end of MIME('\0', 1byte) */
-       debug_msg(RELEASE, "after scaning Mime type offset(%d) value!\n", *offset);
+       debug_msg(RELEASE, "after scaning Mime type offset(%d) value!", *offset);
 
        return true;
 }
@@ -2754,10 +2678,10 @@ static void __id3tag_parse_APIC_pictype(AvFileContentInfo *pInfo, unsigned char
        if (pTagVal[*offset] < MP3_ID3V2_PICTURE_TYPE_MAX)
                pInfo->imageInfo.pictureType = pTagVal[*offset];
        else
-               debug_msg(RELEASE, "APIC image has invalid picture type(0x%x)\n", pTagVal[*offset]);
+               debug_msg(RELEASE, "APIC image has invalid picture type(0x%x)", pTagVal[*offset]);
 
        (*offset)++;/* PictureType(1byte) */
-       debug_msg(RELEASE, "after scaning PictureType(%d) offset(%d) value!\n", pInfo->imageInfo.pictureType, *offset);
+       debug_msg(RELEASE, "after scaning PictureType(%d) offset(%d) value!", pInfo->imageInfo.pictureType, *offset);
 }
 
 static void __id3tag_parse_APIC_desc(AvFileContentInfo *pInfo, unsigned char *pTagVal, int nTagLen, const char *pCharSet, int *offset)
@@ -2766,19 +2690,17 @@ static void __id3tag_parse_APIC_desc(AvFileContentInfo *pInfo, unsigned char *pT
 
        int idx = 0;
        unsigned int tag_len = 0;
-       unsigned int desc_len = 0;
        char *tmp_desc = NULL;
 
        if (pTagVal[*offset] == 0x0) {
-               pInfo->imageInfo.imgDesLen = 0;
-               debug_msg(RELEASE, "The description of APIC is not included!!!\n");
+               debug_msg(RELEASE, "The description of APIC is not included!!!");
                return;
        }
 
        while (1) {
                if (pTagVal[*offset + idx] == '\0') {
                        if (nTagLen < (*offset + idx)) {
-                               debug_error(DEBUG, "End of APIC Tag %d %d %d\n", nTagLen, *offset, idx);
+                               debug_error(DEBUG, "End of APIC Tag %d %d %d", nTagLen, *offset, idx);
                                break;
                        }
                        /* check end of image description */
@@ -2796,14 +2718,13 @@ static void __id3tag_parse_APIC_desc(AvFileContentInfo *pInfo, unsigned char *pT
        tmp_desc = g_memdup(pTagVal + *offset, tag_len);
 
        /* convert description */
-       pInfo->imageInfo.imageDescription = mmfile_string_convert(tmp_desc, tag_len, "UTF-8", pCharSet, NULL, &desc_len);
-       pInfo->imageInfo.imgDesLen = (int)desc_len;
+       pInfo->imageInfo.imageDescription = mmfile_convert_to_utf8(tmp_desc, tag_len, pCharSet);
        mmfile_free(tmp_desc);
-       debug_msg(RELEASE, "new_desc %s(%d)\n", pInfo->imageInfo.imageDescription, pInfo->imageInfo.imgDesLen);
+       debug_msg(RELEASE, "new_desc %s", pInfo->imageInfo.imageDescription);
 
        *offset += idx;
        if ((pTagVal[*offset] != '\0') || (nTagLen <= *offset)) {
-               debug_msg(RELEASE, "pTagVal[offset](%d) description is not NULL terminated! realCpyFrameNum - offset(%d)\n",
+               debug_msg(RELEASE, "pTagVal[offset](%d) description is not NULL terminated! realCpyFrameNum - offset(%d)",
                                        pTagVal[*offset], nTagLen - *offset);
                return;
        }
@@ -2819,10 +2740,10 @@ static void __id3tag_parse_APIC_picture(AvFileContentInfo *pInfo, unsigned char
                (*offset)++;
        }
 
-       debug_msg(RELEASE, "after scaning APIC description offset(%d) value!\n", *offset);
+       debug_msg(RELEASE, "after scaning APIC description offset(%d) value!", *offset);
 
        if (nTagLen <= *offset) {
-               debug_msg(RELEASE, "No APIC image!! realCpyFrameNum(%d) - offset(%d)\n", nTagLen, *offset);
+               debug_msg(RELEASE, "No APIC image!! realCpyFrameNum(%d) - offset(%d)", nTagLen, *offset);
                return;
        }
 
@@ -2842,7 +2763,7 @@ static bool _mm_file_id3tag_parse_PIC(AvFileContentInfo *pInfo, unsigned char *p
        debug_fenter(RELEASE);
 
        if (!__id3tag_parse_PIC_format(pInfo, pTagVal, &offset)) {
-               debug_msg(RELEASE, "PIC is not valid\n");
+               debug_msg(RELEASE, "PIC is not valid");
                return false;
        }
 
@@ -2862,7 +2783,7 @@ static bool _mm_file_id3tag_parse_APIC(AvFileContentInfo *pInfo, unsigned char *
        debug_fenter(RELEASE);
 
        if (!__id3tag_parse_APIC_mimetype(pInfo, pTagVal, nTagLen, &offset)) {
-               debug_msg(RELEASE, "APIC is not valid\n");
+               debug_msg(RELEASE, "APIC is not valid");
                return false;
        }
 
@@ -2879,75 +2800,50 @@ static bool _mm_file_id3tag_parse_APIC(AvFileContentInfo *pInfo, unsigned char *
 bool mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo,  unsigned char *buffer)
 {
        const char *locale = MMFileUtilGetLocale();
-       char *pFullStr = NULL;
 
-       debug_msg(RELEASE, "ID3tag v110--------------------------------------------------------------\n");
+       debug_msg(RELEASE, "ID3tag v110--------------------------------------------------------------");
 
-       if (pInfo->tagInfo[AV_ID3TAG_TITLE].marked == false) {
-               pFullStr = mmfile_string_convert((const char *)&buffer[3], MP3_ID3_TITLE_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_TITLE].length);
-               if (pFullStr != NULL) {
-                       pInfo->tagInfo[AV_ID3TAG_TITLE].value = rtrimN(pFullStr);
-                       free(pFullStr);
-               }
+       if (!pInfo->tagInfo[AV_ID3TAG_TITLE].value) {
+               pInfo->tagInfo[AV_ID3TAG_TITLE].value = mmfile_convert_to_utf8((const char *)&buffer[3], MP3_ID3_TITLE_LENGTH, locale);
 
-               debug_msg(RELEASE, "pInfo->pTitle returned =(%s), pInfo->titleLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_TITLE].value, pInfo->tagInfo[AV_ID3TAG_TITLE].length);
+               debug_msg(RELEASE, "pInfo->pTitle returned =(%s)", pInfo->tagInfo[AV_ID3TAG_TITLE].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_ARTIST].marked == false) {
-               pFullStr = mmfile_string_convert((const char *)&buffer[33], MP3_ID3_ARTIST_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_ARTIST].length);
-               if (pFullStr != NULL) {
-                       pInfo->tagInfo[AV_ID3TAG_ARTIST].value = rtrimN(pFullStr);
-                       free(pFullStr);
-               }
+       if (!pInfo->tagInfo[AV_ID3TAG_ARTIST].value) {
+               pInfo->tagInfo[AV_ID3TAG_ARTIST].value = mmfile_convert_to_utf8((const char *)&buffer[33], MP3_ID3_ARTIST_LENGTH, locale);
 
-               debug_msg(RELEASE, "pInfo->pArtist returned =(%s), pInfo->artistLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_ARTIST].value, pInfo->tagInfo[AV_ID3TAG_ARTIST].length);
+               debug_msg(RELEASE, "pInfo->pArtist returned =(%s)", pInfo->tagInfo[AV_ID3TAG_ARTIST].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_ALBUM].marked == false) {
-               pFullStr = mmfile_string_convert((const char *)&buffer[63], MP3_ID3_ALBUM_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_ALBUM].length);
-               if (pFullStr != NULL) {
-                       pInfo->tagInfo[AV_ID3TAG_ALBUM].value = rtrimN(pFullStr);
-                       free(pFullStr);
-               }
+       if (!pInfo->tagInfo[AV_ID3TAG_ALBUM].value) {
+               pInfo->tagInfo[AV_ID3TAG_ALBUM].value = mmfile_convert_to_utf8((const char *)&buffer[63], MP3_ID3_ALBUM_LENGTH, locale);
 
-               debug_msg(RELEASE, "pInfo->pAlbum returned =(%s), pInfo->albumLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_ALBUM].value, pInfo->tagInfo[AV_ID3TAG_ALBUM].length);
+               debug_msg(RELEASE, "pInfo->pAlbum returned =(%s)", pInfo->tagInfo[AV_ID3TAG_ALBUM].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_YEAR].marked == false) {
-
-               pInfo->tagInfo[AV_ID3TAG_YEAR].value = mmfile_string_convert((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_YEAR].length);
-
-               debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_YEAR].value, pInfo->tagInfo[AV_ID3TAG_YEAR].length);
+       if (!pInfo->tagInfo[AV_ID3TAG_YEAR].value) {
+               pInfo->tagInfo[AV_ID3TAG_YEAR].value = mmfile_convert_to_utf8((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, locale);
 
-               if (pInfo->tagInfo[AV_ID3TAG_YEAR].value == NULL) {     /*Use same logic with ffmpeg*/
-                       pInfo->tagInfo[AV_ID3TAG_YEAR].value = get_string((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, (int *)&pInfo->tagInfo[AV_ID3TAG_YEAR].length);
-                       debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_YEAR].value, pInfo->tagInfo[AV_ID3TAG_YEAR].length);
-               }
+               debug_msg(RELEASE, "pInfo->pYear returned =(%s)", pInfo->tagInfo[AV_ID3TAG_YEAR].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_COMMENT].marked == false) {
-               pInfo->tagInfo[AV_ID3TAG_COMMENT].value = mmfile_string_convert((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_COMMENT].length);
-               debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_COMMENT].value, pInfo->tagInfo[AV_ID3TAG_COMMENT].length);
-
-               if (pInfo->tagInfo[AV_ID3TAG_COMMENT].value == NULL) {  /*Use same logic with ffmpeg*/
-                       pInfo->tagInfo[AV_ID3TAG_COMMENT].value = get_string((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, (int *)&pInfo->tagInfo[AV_ID3TAG_COMMENT]);
-                       debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_COMMENT].value, pInfo->tagInfo[AV_ID3TAG_COMMENT].length);
-               }
+       if (!pInfo->tagInfo[AV_ID3TAG_COMMENT].value) {
+               pInfo->tagInfo[AV_ID3TAG_COMMENT].value = mmfile_convert_to_utf8((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, locale);
+               debug_msg(RELEASE, "pInfo->pComment returned =(%s)", pInfo->tagInfo[AV_ID3TAG_COMMENT].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_TRACKNUM].marked == false) {
+       if (!pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value) {
                pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value = g_malloc0(ID3TAG_V110_TRACK_NUM_DIGIT);
                pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value[ID3TAG_V110_TRACK_NUM_DIGIT - 1] = 0;
                snprintf(pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value, ID3TAG_V110_TRACK_NUM_DIGIT, "%04d", (int)buffer[126]);
-               pInfo->tagInfo[AV_ID3TAG_TRACKNUM].length = strlen(pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value);
 
-               debug_msg(RELEASE, "pInfo->pTrackNum returned =(%s), pInfo->tracknumLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value, pInfo->tagInfo[AV_ID3TAG_TRACKNUM].length);
+               debug_msg(RELEASE, "pInfo->pTrackNum returned =(%s)", pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value);
        }
 
-       if (pInfo->tagInfo[AV_ID3TAG_GENRE].marked == false) {
-               pInfo->genre = buffer[127];
-               debug_msg(RELEASE, "pInfo->genre returned genre number (%d)\n", pInfo->genre);
-       }
+       /*ID3V2 genre is stored in pInfo->tagInfo[AV_ID3TAG_GENRE].value */
+       /*pInfo->genre is used when ID3V2 genre is invalid, or empty. */
+       pInfo->genre = buffer[127];
+       debug_msg(RELEASE, "pInfo->genre returned genre number (%d)", pInfo->genre);
 
        return true;
 }
@@ -2969,7 +2865,7 @@ static AvID3TagList __get_tag_info_v222(const char *tag)
                }
        }
 
-       debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!\n", tag);
+       debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!", tag);
 
        return AV_ID3TAG_MAX;
 }
@@ -2991,7 +2887,7 @@ static AvID3TagList __get_tag_info_v223(const char *tag)
                }
        }
 
-       debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!\n", tag);
+       debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!", tag);
 
        return AV_ID3TAG_MAX;
 }
@@ -3020,7 +2916,7 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer)
        needToloopv2taglen = taglen - MP3_TAGv2_HEADER_LEN;
        curPos = MP3_TAGv2_HEADER_LEN;
 
-       debug_msg(RELEASE, "ID3tag v222--------------------------------------------------------------\n");
+       debug_msg(RELEASE, "ID3tag v222--------------------------------------------------------------");
 
        while (needToloopv2taglen > MP3_TAGv2_22_TXT_HEADER_LEN) {
                if ((buffer[curPos] < '0' || buffer[curPos] > 'Z') || (buffer[curPos + 1] < '0' || buffer[curPos + 1] > 'Z')
@@ -3041,7 +2937,7 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer)
                curPos += oneFrameLen;
 
                tag_id = __get_tag_info_v222(CompTmp);
-               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) {
+               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].value && purelyFramelen > 0) {
                        if (buffer[curPos - purelyFramelen] == 0x00) {
                                encodingOffSet = 1;
                                textEncodingType = AV_ID3V2_ISO_8859;
@@ -3055,7 +2951,7 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer)
                                encodingOffSet++;
 
                        if (purelyFramelen - encodingOffSet <= 0) {
-                               debug_warning(DEBUG, "warning: wrong frame length\n");
+                               debug_warning(DEBUG, "warning: wrong frame length");
                                continue;
                        }
 
@@ -3075,13 +2971,12 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer)
                                        /*pExtContent[tmp+1] value should't have encoding value */
                                        if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) {
                                                textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp);
-                                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                               pInfo->tagInfo[tag_id].marked = true;
+                                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                        } else {
-                                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get Comment Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet);
+                                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get Comment: tmp(%d), purelyFramelen - encodingOffSet(%lu)", tmp, purelyFramelen - encodingOffSet);
                                        }
                                } else {
-                                       debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                       debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: Description info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                }
                                break;
 
@@ -3095,33 +2990,28 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer)
                                        if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) {
                                                textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp);
 
-                                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                               pInfo->tagInfo[tag_id].marked = true;
+                                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                        } else {
-                                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get URL Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet);
+                                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get URL Info tmp(%d), purelyFramelen - encodingOffSet(%lu)", tmp, purelyFramelen - encodingOffSet);
                                        }
                                } else {
-                                       debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: URL info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                       debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: URL info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                }
                                break;
 
 
                        case AV_ID3TAG_PICTURE:
-                               if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_PIC(pInfo, pExtContent, realCpyFrameNum, (const char*)charset_array[textEncodingType]))
-                                               pInfo->tagInfo[tag_id].marked = true;
+                               if (realCpyFrameNum <= 2000000)
+                                       _mm_file_id3tag_parse_PIC(pInfo, pExtContent, realCpyFrameNum, (const char*)charset_array[textEncodingType]);
                                break;
 
                        default:
-                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                               pInfo->tagInfo[tag_id].marked = true;
-
-                               if (tag_id == AV_ID3TAG_GENRE)
-                                       _mm_file_id3tag_add_bracket_at_genre(&pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length);
+                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                break;
                        }
 
                        if (pInfo->tagInfo[tag_id].value)
-                               debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length);
+                               debug_msg(RELEASE, "[%d] returned = (%s)", tag_id, pInfo->tagInfo[tag_id].value);
                }
 
                mmfile_free(pExtContent);
@@ -3174,17 +3064,17 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
        needToloopv2taglen = taglen - MP3_TAGv2_HEADER_LEN;
        curPos = MP3_TAGv2_HEADER_LEN;
 
-       debug_msg(RELEASE, "ID3tag v223--------------------------------------------------------------\n");
+       debug_msg(RELEASE, "ID3tag v223--------------------------------------------------------------");
 
        /* check Extended Header */
        if (buffer[5] & 0x40) {
                /* if extended header exists, skip it*/
                int extendedHeaderLen = (unsigned long)buffer[10] << 21 | (unsigned long)buffer[11] << 14 | (unsigned long)buffer[12] << 7  | (unsigned long)buffer[13];
 
-               debug_msg(RELEASE, "--------------- extendedHeaderLen = %d\n", extendedHeaderLen);
+               debug_msg(RELEASE, "--------------- extendedHeaderLen = %d", extendedHeaderLen);
 
                if (extendedHeaderLen > (int)(taglen - curPos)) {
-                       debug_error(DEBUG, "extended header too long.\n");
+                       debug_error(DEBUG, "extended header too long.");
                } else {
                        curPos += extendedHeaderLen;
                        curPos += 4;
@@ -3203,7 +3093,7 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                oneFrameLen += (unsigned long)buffer[4 + curPos] << 24 | (unsigned long)buffer[5 + curPos] << 16
                                        | (unsigned long)buffer[6 + curPos] << 8 | (unsigned long)buffer[7 + curPos];
 
-               debug_msg(RELEASE, "----------------------------------------------------------------------------------------------------\n");
+               debug_msg(RELEASE, "----------------------------------------------------------------------------------------------------");
 
                if (oneFrameLen > taglen - curPos)
                        break;
@@ -3212,35 +3102,35 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                curPos += oneFrameLen;
 
                tag_id = __get_tag_info_v223(CompTmp);
-               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) {
+               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].value && purelyFramelen > 0) {
                        if (IS_ENCODEDBY_UTF16(buffer + (curPos - purelyFramelen))) {
                                encodingOffSet = 2;
-                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
+                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)", CompTmp, encodingOffSet);
                                textEncodingType = AV_ID3V2_UTF16;
                        } else if (IS_ENCODEDBY_UTF16_R(buffer + (curPos - purelyFramelen))) {
                                encodingOffSet = 2;
-                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
+                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)", CompTmp, encodingOffSet);
                                textEncodingType = AV_ID3V2_UTF16_BE;
                        } else if (IS_ENCODEDBY_UTF16(buffer + (curPos - purelyFramelen + 1))) {
                                encodingOffSet = 3;
-                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
+                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)", CompTmp, encodingOffSet);
                                textEncodingType = AV_ID3V2_UTF16;
                        } else if (IS_ENCODEDBY_UTF16_R(buffer + (curPos - purelyFramelen + 1))) {
                                encodingOffSet = 3;
-                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
+                               debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)", CompTmp, encodingOffSet);
                                textEncodingType = AV_ID3V2_UTF16_BE;
                        } else {
                                if (buffer[curPos - purelyFramelen + encodingOffSet] == 0x00) {
-                                       debug_msg(RELEASE, "encodingOffset will be set to 1\n");
+                                       debug_msg(RELEASE, "encodingOffset will be set to 1");
                                        encodingOffSet = 1;
                                } else {
-                                       debug_msg(RELEASE, "Finding encodingOffset\n");
+                                       debug_msg(RELEASE, "Finding encodingOffset");
 
                                        while ((buffer[curPos - purelyFramelen + encodingOffSet] < 0x20) && (encodingOffSet < purelyFramelen)) /* text string encoded by ISO-8859-1 */
                                                encodingOffSet++;
                                }
                                textEncodingType = AV_ID3V2_ISO_8859;
-                               debug_msg(RELEASE, "this text string(%s) encoded by ISO-8859-1 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
+                               debug_msg(RELEASE, "this text string(%s) encoded by ISO-8859-1 encodingOffSet(%d)", CompTmp, encodingOffSet);
                        }
 
                        mmfile_free(pExtContent);
@@ -3251,13 +3141,13 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                if (textEncodingType != AV_ID3V2_UTF16 && textEncodingType != AV_ID3V2_UTF16_BE) {
                                        if (CompTmp[0] == 'T' || (strcmp(CompTmp, "APIC") == 0)) {
-                                               debug_msg(RELEASE, "get the new text ecoding type\n");
+                                               debug_msg(RELEASE, "get the new text ecoding type");
                                                textEncodingType = buffer[curPos - purelyFramelen + encodingOffSet - 1];
                                        }
                                }
 
                                if (textEncodingType > AV_ID3V2_MAX) {
-                                       debug_msg(DEBUG, "WRONG ENCOIDNG TYPE [%d], FRAME[%s]\n", textEncodingType, (char *)CompTmp);
+                                       debug_msg(DEBUG, "WRONG ENCOIDNG TYPE [%d], FRAME[%s]", textEncodingType, (char *)CompTmp);
                                        continue;
                                }
 
@@ -3273,14 +3163,13 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
                                                                textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
 
-                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
-                                                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                                               pInfo->tagInfo[tag_id].marked= true;
+                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
+                                                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)&pExtContent[tmp], realCpyFrameNum, charset_array[textEncodingType]);
                                                        } else {
-                                                               debug_msg(RELEASE, "failed to get Comment Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet);
+                                                               debug_msg(RELEASE, "failed to get Comment: tmp(%d), purelyFramelen - encodingOffSet(%lu)", tmp, purelyFramelen - encodingOffSet);
                                                        }
                                                } else {
-                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                break;
 
@@ -3293,15 +3182,14 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
                                                                textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
 
-                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
+                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
 
                                                                __id3tag_parse_SYLT(pInfo, pExtContent, realCpyFrameNum, charset_array[textEncodingType], textEncodingType, tmp);
-                                                               pInfo->tagInfo[tag_id].marked= true;
                                                        } else {
-                                                               debug_msg(RELEASE, "failed to get Synchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet);
+                                                               debug_msg(RELEASE, "failed to get Synchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)", tmp, purelyFramelen - encodingOffSet);
                                                        }
                                                } else {
-                                                       debug_msg(RELEASE, "Synchronised lyrics too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "Synchronised lyrics too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                break;
 
@@ -3327,14 +3215,14 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        }
 
                                                        /*pExtContent[tmp+1] value should't have encoding value */
-                                                       debug_msg(RELEASE, "tpExtContent[%d] %x\n", tmp, pExtContent[tmp]);
+                                                       debug_msg(RELEASE, "tpExtContent[%d] %x", tmp, pExtContent[tmp]);
 
                                                        if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
                                                                textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
 
                                                                char *char_set = NULL;
 
-                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
+                                                               debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
 
                                                                if (textEncodingType == AV_ID3V2_ISO_8859) {
                                                                        if (lang_info != NULL && !g_ascii_strcasecmp(lang_info, "KOR")) {
@@ -3346,38 +3234,36 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                                }
 
                                                                if (char_set == NULL) {
-                                                                       pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
+                                                                       pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)&pExtContent[tmp], realCpyFrameNum, charset_array[textEncodingType]);
                                                                } else {
-                                                                       pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", char_set, NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
+                                                                       pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)&pExtContent[tmp], realCpyFrameNum, char_set);
                                                                        mmfile_free(char_set);
                                                                }
-                                                               pInfo->tagInfo[tag_id].marked= true;
                                                        } else {
-                                                               debug_msg(RELEASE, "failed to get Unsynchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet);
+                                                               debug_msg(RELEASE, "failed to get Unsynchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)", tmp, purelyFramelen - encodingOffSet);
                                                        }
                                                } else {
-                                                       debug_msg(RELEASE, "Unsynchronised lyrics too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "Unsynchronised lyrics too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                mmfile_free(lang_info);
                                                break;
 
                                        case AV_ID3TAG_PICTURE:
-                                               if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]))
-                                                       pInfo->tagInfo[tag_id].marked= true;
+                                               if (realCpyFrameNum <= 2000000)
+                                                       _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                                break;
 
                                        default:
-                                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                               pInfo->tagInfo[tag_id].marked= true;
+                                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                                break;
                                        }
 
                                        if (pInfo->tagInfo[tag_id].value)
-                                               debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length);
+                                               debug_msg(RELEASE, "[%d] returned = (%s)", tag_id, pInfo->tagInfo[tag_id].value);
                                }
 
                        } else {
-                               debug_msg(RELEASE, "All of the pExtContent Values are NULL\n");
+                               debug_msg(RELEASE, "All of the pExtContent Values are NULL");
                        }
                }
 
@@ -3430,17 +3316,17 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
        needToloopv2taglen = taglen - MP3_TAGv2_HEADER_LEN;
        curPos = MP3_TAGv2_HEADER_LEN;
 
-       debug_msg(RELEASE, "ID3tag v224--------------------------------------------------------------\n");
+       debug_msg(RELEASE, "ID3tag v224--------------------------------------------------------------");
 
        /* check Extended Header */
        if (buffer[5] & 0x40) {
                /* if extended header exists, skip it*/
                int extendedHeaderLen = (unsigned long)buffer[10] << 21 | (unsigned long)buffer[11] << 14 | (unsigned long)buffer[12] << 7  | (unsigned long)buffer[13];
 
-               debug_msg(RELEASE, "--------------- extendedHeaderLen = %d\n", extendedHeaderLen);
+               debug_msg(RELEASE, "--------------- extendedHeaderLen = %d", extendedHeaderLen);
 
                if (extendedHeaderLen > (int)(taglen - curPos)) {
-                       debug_error(DEBUG, "extended header too long.\n");
+                       debug_error(DEBUG, "extended header too long.");
                } else {
                        curPos += extendedHeaderLen;
                }
@@ -3463,10 +3349,10 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                purelyFramelen = oneFrameLen - MP3_TAGv2_23_TXT_HEADER_LEN;
                curPos += oneFrameLen;
 
-               debug_msg(RELEASE, "-----------------------------------------------------------------------------------\n");
+               debug_msg(RELEASE, "-----------------------------------------------------------------------------------");
 
                tag_id = __get_tag_info_v223(CompTmp);
-               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) {
+               if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].value && purelyFramelen > 0) {
                        /*in case of UTF 16 encoding */
                        /*buffer+(curPos-purelyFramelen) data should '0x01' but in order to expansion, we don't accurately check the value. */
                        if (IS_ENCODEDBY_UTF16(buffer + (curPos - purelyFramelen))) {
@@ -3514,13 +3400,13 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                if (textEncodingType != AV_ID3V2_UTF16 && textEncodingType != AV_ID3V2_UTF16_BE) {
                                        if (CompTmp[0] == 'T' || (strcmp(CompTmp, "APIC") == 0)) {
-                                               debug_msg(RELEASE, "get the new text ecoding type\n");
+                                               debug_msg(RELEASE, "get the new text ecoding type");
                                                textEncodingType = buffer[curPos - purelyFramelen + encodingOffSet - 1];
                                        }
                                }
 
                                if (textEncodingType > AV_ID3V2_MAX) {
-                                       debug_msg(DEBUG, "WRONG ENCOIDNG TYPE [%d], FRAME[%s]\n", textEncodingType, (char *)CompTmp);
+                                       debug_msg(DEBUG, "WRONG ENCOIDNG TYPE [%d], FRAME[%s]", textEncodingType, (char *)CompTmp);
                                        continue;
                                }
 
@@ -3534,12 +3420,11 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        tmp = 3;
 
                                                        textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
-                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
+                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
 
-                                                       pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                                       pInfo->tagInfo[tag_id].marked= true;
+                                                       pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)&pExtContent[tmp], realCpyFrameNum, charset_array[textEncodingType]);
                                                } else {
-                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                break;
 
@@ -3549,12 +3434,11 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        tmp = 5;
 
                                                        textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
-                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
+                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
 
                                                        __id3tag_parse_SYLT(pInfo, pExtContent, realCpyFrameNum, charset_array[textEncodingType], textEncodingType, tmp);
-                                                       pInfo->tagInfo[tag_id].marked= true;
                                                } else {
-                                                       debug_msg(RELEASE, "SyncLyrics info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "SyncLyrics info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                break;
 
@@ -3564,32 +3448,30 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        tmp = 3;
 
                                                        textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
-                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
+                                                       debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)", tmp, textEncodingType, realCpyFrameNum);
 
-                                                       pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                                       pInfo->tagInfo[tag_id].marked= true;
+                                                       pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)&pExtContent[tmp], realCpyFrameNum, charset_array[textEncodingType]);
                                                } else {
-                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
+                                                       debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)", realCpyFrameNum);
                                                }
                                                break;
 
                                        case AV_ID3TAG_PICTURE:
-                                               if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]))
-                                                       pInfo->tagInfo[tag_id].marked= true;
+                                               if (realCpyFrameNum <= 2000000)
+                                                       _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                                break;
 
                                        default:
-                                               pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length);
-                                               pInfo->tagInfo[tag_id].marked= true;
+                                               pInfo->tagInfo[tag_id].value = mmfile_convert_to_utf8((const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]);
                                                break;
                                        }
 
                                        if (pInfo->tagInfo[tag_id].value)
-                                               debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length);
+                                               debug_msg(RELEASE, "[%d] returned = (%s)", tag_id, pInfo->tagInfo[tag_id].value);
                                }
 
                        } else {
-                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v224: All of the pExtContent Values are NULL\n");
+                               debug_msg(RELEASE, "mmf_file_id3tag_parse_v224: All of the pExtContent Values are NULL");
                        }
 
                }
@@ -3622,88 +3504,39 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
 void mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo)
 {
-       char    *mpegAudioGenre = NULL/*, *tmpGenreForV1Tag = NULL*/;
-       bool    bAdditionGenre = false /*, bMpegAudioFrame = false*/;
-       int mpegAudioFileLen = 0, idv2IntGenre = GENRE_COUNT - 1/*, tmpinx = 0, tmpinx2=0*/;
+       int genre_id = 0;
 
        /* for Genre Info */
-       if (pInfo->tagInfo[AV_ID3TAG_GENRE].marked == false) {
-               if (pInfo->bV1tagFound == true) {
-                       debug_msg(RELEASE, "Genre: %d\n", pInfo->genre);
-
-                       if (pInfo->genre > GENRE_COUNT - 1)
-                               pInfo->genre = GENRE_COUNT - 1;
-
-                       pInfo->tagInfo[AV_ID3TAG_GENRE].value = g_strdup(MpegAudio_Genre[pInfo->genre]);
-                       if (pInfo->tagInfo[AV_ID3TAG_GENRE].value)
-                               pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-                       else
-                               debug_error(RELEASE, "Genre: memory allocation failed.\n");
-               } else {
-                       debug_msg(RELEASE, "Genre was not Found.\n");
-               }
-       } else {
-               debug_msg(RELEASE, "genre size is Zero Or not UTF16 code! genreLen[%d] genre[%s]\n", pInfo->tagInfo[AV_ID3TAG_GENRE].length, pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-
-               if (pInfo->tagInfo[AV_ID3TAG_GENRE].value)
-                       mpegAudioGenre = g_strdup(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-               else
-                       pInfo->tagInfo[AV_ID3TAG_GENRE].length = 0;
-
-               mmfile_free(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-
-               /*tmpinx = 0;*/
-               if (!mpegAudioGenre)
+       if (pInfo->tagInfo[AV_ID3TAG_GENRE].value) {
+               /* Check integer */
+               if (!__get_genre_num(pInfo->tagInfo[AV_ID3TAG_GENRE].value, &genre_id)) {
+                       debug_log(RELEASE, "genre information is not integer [%s]", pInfo->tagInfo[AV_ID3TAG_GENRE].value);
                        return;
-
-               /**
-                *Genre number
-                * (XXX)        XXX is 0 - 148
-                */
-               pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(mpegAudioGenre);
-               if (pInfo->tagInfo[AV_ID3TAG_GENRE].length >= 3 &&
-                   mpegAudioGenre[0] == '(' && mpegAudioGenre[pInfo->tagInfo[AV_ID3TAG_GENRE].length - 1] == ')') {
-                       bAdditionGenre = true;
-                       for (mpegAudioFileLen = 1; mpegAudioFileLen <= pInfo->tagInfo[AV_ID3TAG_GENRE].length - 2; mpegAudioFileLen++) {
-                               if (mpegAudioGenre[mpegAudioFileLen] < '0' || mpegAudioGenre[mpegAudioFileLen] > '9') {
-                                       bAdditionGenre = false;
-                                       break;
-                               }
-                       }
                }
 
-               if (bAdditionGenre == true) {
-                       idv2IntGenre = atoi(mpegAudioGenre + 1);
+               /* If integer, check genre code. */
+               /* If out of range, set UNKNOWN */
+               if (genre_id < 0 || genre_id >= GENRE_COUNT)
+                       genre_id = GENRE_COUNT - 1;
 
-                       if (idv2IntGenre > GENRE_COUNT - 1 || idv2IntGenre < 0)
-                               idv2IntGenre = GENRE_COUNT - 1;
-
-                       pInfo->tagInfo[AV_ID3TAG_GENRE].value = g_strdup(MpegAudio_Genre[idv2IntGenre]);
-                       if (pInfo->tagInfo[AV_ID3TAG_GENRE].value)
-                               pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-                       else
-                               debug_error(RELEASE, "Genre: memory allocation failed.\n");
+               debug_msg(RELEASE, "genre information is integer [%d]", genre_id);
 
-                       debug_msg(RELEASE, "pInfo->tagInfo[AV_ID3TAG_GENRE].value = %s\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-               } else if (bAdditionGenre == false && pInfo->tagInfo[AV_ID3TAG_GENRE].length > 0) {
-                       /**
-                        * Genre string.
-                        */
+               g_free(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
+               pInfo->tagInfo[AV_ID3TAG_GENRE].value = g_strdup(MpegAudio_Genre[genre_id]);
+       } else {
+               /* No genre in ID3V2.. So check V1 */
+               if (pInfo->bV1tagFound == true) {
+                       debug_msg(RELEASE, "Genre: %d", pInfo->genre);
 
-                       /* Give space for NULL character. Hence added "+1" */
-                       pInfo->tagInfo[AV_ID3TAG_GENRE].value = g_strdup(mpegAudioGenre);
-                       if (pInfo->tagInfo[AV_ID3TAG_GENRE].value)
-                               pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value);
-                       else
-                               debug_error(RELEASE, "Genre: memory allocation failed.\n");
+                       /* If out of range, set UNKNOWN */
+                       if (pInfo->genre > GENRE_COUNT - 1)
+                               pInfo->genre = GENRE_COUNT - 1;
 
-                       debug_msg(RELEASE, "pInfo->tagInfo[AV_ID3TAG_GENRE].value = %s, pInfo->tagInfo[AV_ID3TAG_GENRE].length = %d\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value, pInfo->tagInfo[AV_ID3TAG_GENRE].length);
+                       pInfo->tagInfo[AV_ID3TAG_GENRE].value = g_strdup(MpegAudio_Genre[pInfo->genre]);
                } else {
-                       debug_msg(RELEASE, "Failed to \"(...)\" value to genre = %s\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value);
+                       debug_msg(RELEASE, "Genre was not Found.");
                }
-               mmfile_free(mpegAudioGenre);
        }
-
 }
 
 void mm_file_free_synclyrics_list(GList *synclyrics_list)