pInfo->imageInfo.imageLen = 0;
}
+static void _mm_file_id3tag_add_bracket_at_genre(char **genre, int genre_len)
+{
+ int int_genre = -1;
+ char tmp_genre[6] = {0, };
+ int tmp_genre_len = 0;
+
+ 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
+ */
+ memset(tmp_genre, 0, sizeof(tmp_genre));
+ snprintf(tmp_genre, sizeof(tmp_genre), "(%d)", int_genre);
+
+ tmp_genre_len = strlen(tmp_genre);
+ if (tmp_genre_len > 0) {
+ *genre = mmfile_realloc(*genre, sizeof(char) * (tmp_genre_len + 1));
+ if (*genre)
+ SAFE_STRLCPY(*genre, tmp_genre, tmp_genre_len + 1);
+ }
+}
+
EXPORT_API
bool mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo, unsigned char *buffer)
{
} else if (strncmp((char *)CompTmp, "TCO", 3) == 0 && pInfo->tagV2Info.bGenreMarked == false) {
pInfo->pGenre = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->genreLen);
debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen);
-
- if ((pInfo->pGenre != NULL) && (pInfo->genreLen > 0)) {
- bool ret = FALSE;
- int int_genre = -1;
-
- ret = is_numeric(pInfo->pGenre, pInfo->genreLen);
-
- if (ret == TRUE) {
- ret = safe_atoi(pInfo->pGenre, &int_genre);
- if (ret == TRUE) {
- debug_msg(RELEASE, "genre information is inteager [%d]\n", int_genre);
-
- /*Change int to string */
- if ((0 <= int_genre) && (int_genre < GENRE_COUNT - 1)) {
- /*save genreinfo like "(123)". mm_file_id3tag_restore_content_info convert it to string*/
- char tmp_genre[6] = {0, }; /*ex. "(123)+NULL"*/
- int tmp_genre_len = 0;
-
- memset(tmp_genre, 0, 6);
- snprintf(tmp_genre, sizeof(tmp_genre), "(%d)", int_genre);
-
- tmp_genre_len = strlen(tmp_genre);
- if (tmp_genre_len > 0) {
- mmfile_free(pInfo->pGenre);
- pInfo->pGenre = mmfile_malloc(sizeof(char) * (tmp_genre_len + 1));
- if (pInfo->pGenre) {
- SAFE_STRLCPY(pInfo->pGenre, tmp_genre, tmp_genre_len + 1);
- }
- }
- }
- } else {
- debug_error(RELEASE, "genre information is wrong inteager [%s]\n", pInfo->pGenre);
- }
- }
- }
-
+ _mm_file_id3tag_add_bracket_at_genre(&pInfo->pGenre, pInfo->genreLen);
pInfo->tagV2Info.bGenreMarked = true;
} else if (strncmp((char *)CompTmp, "TRK", 3) == 0 && pInfo->tagV2Info.bTrackNumMarked == false) {
pInfo->pTrackNum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tracknumLen);
} else if (strncmp((char *)CompTmp, "TCON", 4) == 0 && pInfo->tagV2Info.bGenreMarked == false) {
pInfo->pGenre = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->genreLen);
debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen);
-
- if ((pInfo->pGenre != NULL) && (pInfo->genreLen > 0)) {
- bool ret = FALSE;
- int int_genre = -1;
-
- ret = is_numeric(pInfo->pGenre, pInfo->genreLen);
-
- if (ret == TRUE) {
- ret = safe_atoi(pInfo->pGenre, &int_genre);
- if (ret == TRUE) {
- debug_msg(RELEASE, "genre information is inteager [%d]\n", int_genre);
-
- /*Change int to string */
- if ((0 <= int_genre) && (int_genre < GENRE_COUNT - 1)) {
- /*save genreinfo like "(123)". mm_file_id3tag_restore_content_info convert it to string*/
- char tmp_genre[6] = {0, }; /*ex. "(123)+NULL"*/
- int tmp_genre_len = 0;
-
- memset(tmp_genre, 0, 6);
- snprintf(tmp_genre, sizeof(tmp_genre), "(%d)", int_genre);
-
- tmp_genre_len = strlen(tmp_genre);
- if (tmp_genre_len > 0) {
- mmfile_free(pInfo->pGenre);
- pInfo->pGenre = mmfile_malloc(sizeof(char) * (tmp_genre_len + 1));
- if (pInfo->pGenre) {
- SAFE_STRLCPY(pInfo->pGenre, tmp_genre, tmp_genre_len + 1);
- }
- }
- }
- } else {
- debug_msg(RELEASE, "genre information is wrong inteager [%s]\n", pInfo->pGenre);
- }
- }
- }
-
+ _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) {
pInfo->pTrackNum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tracknumLen);
}
debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen);
-
- if ((pInfo->pGenre != NULL) && (pInfo->genreLen > 0)) {
- bool ret = FALSE;
- int int_genre = -1;
-
- ret = is_numeric(pInfo->pGenre, pInfo->genreLen);
-
- if (ret == TRUE) {
- ret = safe_atoi(pInfo->pGenre, &int_genre);
- if (ret == TRUE) {
- debug_msg(RELEASE, "genre information is inteager [%d]\n", int_genre);
-
- /*Change int to string */
- if ((0 <= int_genre) && (int_genre < GENRE_COUNT - 1)) {
- /*save genreinfo like "(123)". mm_file_id3tag_restore_content_info convert it to string*/
- char tmp_genre[6] = {0, }; /*ex. "(123)+NULL"*/
- int tmp_genre_len = 0;
-
- memset(tmp_genre, 0, 6);
- snprintf(tmp_genre, sizeof(tmp_genre), "(%d)", int_genre);
-
- tmp_genre_len = strlen(tmp_genre);
- if (tmp_genre_len > 0) {
- mmfile_free(pInfo->pGenre);
- pInfo->pGenre = mmfile_malloc(sizeof(char) * (tmp_genre_len + 1));
- if (pInfo->pGenre) {
- SAFE_STRLCPY(pInfo->pGenre, tmp_genre, tmp_genre_len + 1);
- }
- }
- }
- } else {
- debug_msg(RELEASE, "genre information is wrong inteager [%s]\n", pInfo->pGenre);
- }
- }
- }
-
+ _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) {