Improve 'mm_file_id3tag_parse_v224' function to reduce Cyclomatic Complexity 87/214087/7
authorjiyong.min <jiyong.min@samsung.com>
Wed, 18 Sep 2019 02:20:12 +0000 (11:20 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Wed, 18 Sep 2019 07:46:40 +0000 (16:46 +0900)
 - It needs below UTC changes.
  https://review.tizen.org/gerrit/#/c/test/tct/native/api/+/214107/

Change-Id: Ie9ab72aa8d663ff759d12f2219edfa07c32c2f4c

utils/mm_file_util_tag.c

index b52f0d2..71b4136 100644 (file)
@@ -2760,6 +2760,25 @@ static bool _mm_file_id3tag_parse_APIC(AvFileContentInfo *pInfo, unsigned char *
        return true;
 }
 
+static char *_mm_file_string_convert_v224(const char *strTag, int nTagLen, const int nEncodingType, const char *strCharSet, int *npStrLen)
+{
+       char *new_tag = NULL;
+
+       *npStrLen = 0;
+
+       if (nEncodingType == AV_ID3V2_UTF8) {
+               new_tag = g_strdup(strTag);
+               if (!new_tag)
+                       return NULL;
+
+               *npStrLen = strlen(new_tag);
+       } else {
+               new_tag = mmfile_string_convert((const char *)strTag, nTagLen, "UTF-8", strCharSet, NULL, (unsigned int *)npStrLen);
+       }
+
+       return new_tag;
+}
+
 EXPORT_API
 bool mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo,  unsigned char *buffer)
 {
@@ -3662,101 +3681,28 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                        if (realCpyFrameNum > 0) {
                                                if (strncmp((char *)CompTmp, "TIT2", 4) == 0 && pInfo->tagV2Info.bTitleMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pTitle = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pTitle) {
-                                                                       memcpy(pInfo->pTitle, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pTitle[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->titleLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pTitle, pExtContent, pInfo->titleLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pTitle = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->titleLen);
-                                                       }
-
+                                                       pInfo->pTitle = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->titleLen);
                                                        debug_msg(RELEASE, "pInfo->pTitle returned = (%s), pInfo->titleLen(%d)\n", pInfo->pTitle, pInfo->titleLen);
                                                        pInfo->tagV2Info.bTitleMarked = true;
 
                                                } else if (strncmp((char *)CompTmp, "TPE1", 4) == 0 && pInfo->tagV2Info.bArtistMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pArtist = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pArtist) {
-                                                                       memcpy(pInfo->pArtist, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pArtist[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->artistLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pArtist, pExtContent, pInfo->artistLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->artistLen);
-                                                       }
-
-
+                                                       pInfo->pArtist = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->artistLen);
                                                        debug_msg(RELEASE, "pInfo->pArtist returned = (%s), pInfo->artistLen(%d)\n", pInfo->pArtist, pInfo->artistLen);
                                                        pInfo->tagV2Info.bArtistMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TPE2", 4) == 0 && pInfo->tagV2Info.bAlbum_ArtistMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pAlbum_Artist = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pAlbum_Artist) {
-                                                                       memcpy(pInfo->pAlbum_Artist, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pAlbum_Artist[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->album_artistLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pAlbum_Artist, pExtContent, pInfo->album_artistLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pAlbum_Artist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->album_artistLen);
-                                                       }
-
+                                                       pInfo->pAlbum_Artist = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->album_artistLen);
                                                        debug_msg(RELEASE, "pInfo->pAlbum_Artist returned = (%s), pInfo->album_artistLen(%d)\n", pInfo->pAlbum_Artist, pInfo->album_artistLen);
                                                        pInfo->tagV2Info.bAlbum_ArtistMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TPE3", 4) == 0 && pInfo->tagV2Info.bConductorMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pConductor = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pConductor) {
-                                                                       memcpy(pInfo->pConductor, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pConductor[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->conductorLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pConductor, pExtContent, pInfo->conductorLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pConductor = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->conductorLen);
-                                                       }
-
+                                                       pInfo->pConductor = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->conductorLen);
                                                        debug_msg(RELEASE, "pInfo->pConductor returned = (%s), pInfo->conductorLen(%d)\n", pInfo->pConductor, pInfo->conductorLen);
                                                        pInfo->tagV2Info.bConductorMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TALB", 4) == 0 && pInfo->tagV2Info.bAlbumMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pAlbum = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pAlbum) {
-                                                                       memcpy(pInfo->pAlbum, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pAlbum[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->albumLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pAlbum, pExtContent, pInfo->albumLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pAlbum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->albumLen);
-                                                       }
-
+                                                       pInfo->pAlbum = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->albumLen);
                                                        debug_msg(RELEASE, "pInfo->pAlbum returned = (%s), pInfo->albumLen(%d)\n", pInfo->pAlbum, pInfo->albumLen);
                                                        pInfo->tagV2Info.bAlbumMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TYER", 4) == 0 && pInfo->tagV2Info.bYearMarked == false) { /*TODO. TYER is replaced by the TDRC. but many files use TYER in v2.4 */
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pYear = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pYear) {
-                                                                       memcpy(pInfo->pYear, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pYear[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->yearLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pYear, pExtContent, pInfo->yearLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pYear = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->yearLen);
-                                                       }
-
+                                                       pInfo->pYear = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->yearLen);
                                                        debug_msg(RELEASE, "pInfo->pYear returned = (%s), pInfo->yearLen(%d)\n", pInfo->pYear, pInfo->yearLen);
                                                        pInfo->tagV2Info.bYearMarked = true;
                                                } else if (strncmp((char *)CompTmp, "COMM", 4) == 0 && pInfo->tagV2Info.bDescriptionMarked == false) {
@@ -3793,19 +3739,7 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                                                debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
 
-                                                               if (textEncodingType == AV_ID3V2_UTF8) {
-                                                                       pInfo->pComment = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                                       if (pInfo->pComment) {
-                                                                               memset(pInfo->pComment, 0, (realCpyFrameNum + 2));
-                                                                               memcpy(pInfo->pComment, pExtContent + tmp, realCpyFrameNum);
-                                                                               pInfo->pComment[realCpyFrameNum] = '\0';
-                                                                               /*string copy with '\0'*/
-                                                                               pInfo->commentLen = realCpyFrameNum;
-                                                                               _STRNCPY_EX(pInfo->pComment, pExtContent, pInfo->commentLen);
-                                                                       }
-                                                               } else {
-                                                                       pInfo->pComment = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen);
-                                                               }
+                                                               pInfo->pComment = _mm_file_string_convert_v224((const char *)&pExtContent[tmp], realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->commentLen);
                                                        } else {
                                                                debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
                                                        }
@@ -3932,22 +3866,7 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                                                debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
 
-                                                               if (textEncodingType == AV_ID3V2_UTF8) {
-                                                                       pInfo->pUnsyncLyrics = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-
-                                                                       if (pInfo->pUnsyncLyrics != NULL) {
-                                                                               memset(pInfo->pUnsyncLyrics, 0, (realCpyFrameNum + 2));
-                                                                               memcpy(pInfo->pUnsyncLyrics, pExtContent + tmp, realCpyFrameNum);
-                                                                               pInfo->pUnsyncLyrics[realCpyFrameNum] = '\0';
-                                                                               /*string copy with '\0'*/
-                                                                               pInfo->unsynclyricsLen = realCpyFrameNum;
-                                                                               _STRNCPY_EX(pInfo->pUnsyncLyrics, pExtContent, pInfo->unsynclyricsLen);
-                                                                       } else {
-                                                                               debug_error(DEBUG, "out of memoryu for SyncLyrics\n");
-                                                                       }
-                                                               } else {
-                                                                       pInfo->pUnsyncLyrics = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->unsynclyricsLen);
-                                                               }
+                                                               pInfo->pUnsyncLyrics = _mm_file_string_convert_v224((const char *)&pExtContent[tmp], realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->unsynclyricsLen);
                                                        } else {
                                                                debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum);
                                                        }
@@ -3957,164 +3876,44 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        debug_msg(RELEASE, "pInfo->pUnsyncLyrics returned = (%s), pInfo->unsynclyricsLen(%d)\n", pInfo->pUnsyncLyrics, pInfo->unsynclyricsLen);
                                                        pInfo->tagV2Info.bDescriptionMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TCON", 4) == 0 && pInfo->tagV2Info.bGenreMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pGenre = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pGenre) {
-                                                                       memcpy(pInfo->pGenre, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pGenre[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->genreLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pGenre, pExtContent, pInfo->genreLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pGenre = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->genreLen);
-                                                       }
-
+                                                       pInfo->pGenre = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->genreLen);
                                                        debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen);
                                                        _mm_file_id3tag_add_bracket_at_genre(&pInfo->pGenre, pInfo->genreLen);
                                                        pInfo->tagV2Info.bGenreMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TRCK", 4) == 0 && pInfo->tagV2Info.bTrackNumMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pTrackNum = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pTrackNum != NULL) {
-                                                                       memcpy(pInfo->pTrackNum, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pTrackNum[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->tracknumLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pTrackNum, pExtContent, pInfo->tracknumLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pTrackNum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tracknumLen);
-                                                       }
-
+                                                       pInfo->pTrackNum = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->tracknumLen);
                                                        debug_msg(RELEASE, "pInfo->pTrackNum returned = (%s), pInfo->tracknumLen(%d)\n", pInfo->pTrackNum, pInfo->tracknumLen);
                                                        pInfo->tagV2Info.bTrackNumMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TPOS", 4) == 0 && pInfo->tagV2Info.bPartOfASetMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pPartOfASet = mmfile_malloc(realCpyFrameNum+2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pPartOfASet != NULL) {
-                                                                       memcpy(pInfo->pPartOfASet, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pPartOfASet[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->partofsetLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pPartOfASet, pExtContent, pInfo->partofsetLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pPartOfASet = mmfile_string_convert((const char*)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int*)&pInfo->partofsetLen);
-                                                       }
-
+                                                       pInfo->pPartOfASet = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->partofsetLen);
                                                        debug_msg(RELEASE,  "pInfo->pPartOfASet returned = (%s), pInfo->partofsetLen(%d)\n", pInfo->pPartOfASet, pInfo->partofsetLen);
                                                        pInfo->tagV2Info.bPartOfASetMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TENC", 4) == 0 && pInfo->tagV2Info.bEncByMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pEncBy = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pEncBy != NULL) {
-                                                                       memcpy(pInfo->pEncBy, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pEncBy[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->encbyLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pEncBy, pExtContent, pInfo->encbyLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pEncBy = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->encbyLen);
-                                                       }
-
+                                                       pInfo->pEncBy = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->encbyLen);
                                                        debug_msg(RELEASE, "pInfo->pEncBy returned = (%s), pInfo->encbyLen(%d)\n", pInfo->pEncBy, pInfo->encbyLen);
                                                        pInfo->tagV2Info.bEncByMarked = true;
                                                } else if (strncmp((char *)CompTmp, "WXXX", 4) == 0 && pInfo->tagV2Info.bURLMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pURL = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pURL != NULL) {
-                                                                       memcpy(pInfo->pURL, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pURL[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->urlLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pURL, pExtContent, pInfo->urlLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pURL = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->urlLen);
-                                                       }
-
+                                                       pInfo->pURL = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->urlLen);
                                                        debug_msg(RELEASE, "pInfo->pURL returned = (%s), pInfo->urlLen(%d)\n", pInfo->pURL, pInfo->urlLen);
                                                        pInfo->tagV2Info.bURLMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TCOP", 4) == 0 && pInfo->tagV2Info.bCopyRightMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pCopyright = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pCopyright != NULL) {
-                                                                       memcpy(pInfo->pCopyright, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pCopyright[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->copyrightLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pCopyright, pExtContent, pInfo->copyrightLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pCopyright = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->copyrightLen);
-                                                       }
-
+                                                       pInfo->pCopyright = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->copyrightLen);
                                                        debug_msg(RELEASE, "pInfo->pCopyright returned = (%s), pInfo->copyrightLen(%d)\n", pInfo->pCopyright, pInfo->copyrightLen);
                                                        pInfo->tagV2Info.bCopyRightMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TOPE", 4) == 0 && pInfo->tagV2Info.bOriginArtistMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pOriginArtist = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pOriginArtist != NULL) {
-                                                                       memcpy(pInfo->pOriginArtist, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pOriginArtist[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->originartistLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pOriginArtist, pExtContent, pInfo->originartistLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pOriginArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->originartistLen);
-                                                       }
-
+                                                       pInfo->pOriginArtist = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->originartistLen);
                                                        debug_msg(RELEASE, "pInfo->pOriginArtist returned = (%s), pInfo->originartistLen(%d)\n", pInfo->pOriginArtist, pInfo->originartistLen);
                                                        pInfo->tagV2Info.bOriginArtistMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TCOM", 4) == 0 && pInfo->tagV2Info.bComposerMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pComposer = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pComposer != NULL) {
-                                                                       memcpy(pInfo->pComposer, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pComposer[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->composerLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pComposer, pExtContent, pInfo->composerLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pComposer = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->composerLen);
-                                                       }
-
+                                                       pInfo->pComposer = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->composerLen);
                                                        debug_msg(RELEASE, "pInfo->pComposer returned = (%s), pInfo->originartistLen(%d)\n", pInfo->pComposer, pInfo->composerLen);
                                                        pInfo->tagV2Info.bComposerMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TDRC", 4) == 0 && pInfo->tagV2Info.bRecDateMarked == false) {      /*TYER(year) and TRDA are replaced by the TDRC */
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pRecDate = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pRecDate != NULL) {
-                                                                       memcpy(pInfo->pRecDate, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pRecDate[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->recdateLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pRecDate, pExtContent, pInfo->recdateLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pRecDate = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->recdateLen);
-                                                       }
-
+                                                       pInfo->pRecDate = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->recdateLen);
                                                        debug_msg(RELEASE, "pInfo->pRecDate returned = (%s), pInfo->recdateLen(%d)\n", pInfo->pRecDate, pInfo->recdateLen);
                                                        pInfo->tagV2Info.bRecDateMarked = true;
                                                } else if (strncmp((char *)CompTmp, "TIT1", 4) == 0 && pInfo->tagV2Info.bContentGroupMarked == false) {
-                                                       if (textEncodingType == AV_ID3V2_UTF8) {
-                                                               pInfo->pContentGroup = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */
-                                                               if (pInfo->pContentGroup != NULL) {
-                                                                       memcpy(pInfo->pContentGroup, pExtContent, realCpyFrameNum);
-                                                                       pInfo->pContentGroup[realCpyFrameNum] = '\0';
-                                                                       /*string copy with '\0'*/
-                                                                       pInfo->contentGroupLen = realCpyFrameNum;
-                                                                       _STRNCPY_EX(pInfo->pContentGroup, pExtContent, pInfo->contentGroupLen);
-                                                               }
-                                                       } else {
-                                                               pInfo->pContentGroup = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->contentGroupLen);
-                                                       }
-
+                                                       pInfo->pContentGroup = _mm_file_string_convert_v224((const char *)pExtContent, realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->contentGroupLen);
                                                        debug_msg(RELEASE, "pInfo->pContentGroup returned = (%s), pInfo->contentGroupLen(%d)\n", pInfo->pContentGroup, pInfo->contentGroupLen);
                                                        pInfo->tagV2Info.bContentGroupMarked = true;
                                                } else if (strncmp((char *)CompTmp, "APIC", 4) == 0 && pInfo->tagV2Info.bImageMarked == false && realCpyFrameNum <= 2000000) {