}
}
+static int __id3tag_get_text_encoding_v222(unsigned char *pTagVal, int offset)
+{
+ if (pTagVal[offset - 1] == 0x00)
+ return AV_ID3V2_ISO_8859;
+
+ return AV_ID3V2_UTF16;
+}
+
+static int __id3tag_get_text_encoding_v223(unsigned char *pTagVal, int *npTagLen, int nTextEnc, int *offset)
+{
+ if ((IS_ENCODEDBY_UTF16(pTagVal + *offset) || IS_ENCODEDBY_UTF16_R(pTagVal + *offset)) && *npTagLen > 2) {
+ __id3tag_skip_newline(pTagVal, npTagLen, offset);
+
+ if (IS_ENCODEDBY_UTF16(pTagVal + *offset) && (*npTagLen > 2)) {
+ *npTagLen -= 2;
+ *offset += 2;
+ return AV_ID3V2_UTF16;
+ } else if (IS_ENCODEDBY_UTF16_R(pTagVal + *offset) && (*npTagLen > 2)) {
+ *npTagLen -= 2;
+ *offset += 2;
+ return AV_ID3V2_UTF16_BE;
+ } else if (IS_ENCODEDBY_UTF16(pTagVal + *offset + 1) && (*npTagLen > 3)) {
+ *npTagLen -= 3;
+ *offset += 3;
+ return AV_ID3V2_UTF16;
+ } else if (IS_ENCODEDBY_UTF16_R(pTagVal + *offset + 1) && (*npTagLen > 3)) {
+ *npTagLen -= 3;
+ *offset += 3;
+ return AV_ID3V2_UTF16_BE;
+ } else {
+ debug_msg(RELEASE, "id3tag never get here!!\n");
+ return nTextEnc; /* default bypass */
+ }
+ } else {
+ while ((pTagVal[*offset] < 0x20) && (*offset < *npTagLen)) { /* text string encoded by ISO-8859-1 */
+ (*npTagLen)--;
+ (*offset)++;
+ }
+ return AV_ID3V2_ISO_8859;
+ }
+}
+
+static int __id3tag_get_text_encoding_v224(unsigned char *pTagVal, int *npTagLen, int nTextEnc, int *offset)
+{
+ if (nTextEnc == AV_ID3V2_UTF16 || nTextEnc == AV_ID3V2_UTF16_BE) {
+ __id3tag_skip_newline(pTagVal, npTagLen, offset);
+
+ if ((IS_ENCODEDBY_UTF16(pTagVal + *offset) || IS_ENCODEDBY_UTF16_R(pTagVal + *offset)) && *npTagLen > 2) {
+ *npTagLen -= 2;
+ *offset += 2;
+ return AV_ID3V2_UTF16;
+ } else {
+ debug_msg(RELEASE, "id3tag never get here!!\n");
+ return nTextEnc; /* default bypass */
+ }
+ } else if (nTextEnc == AV_ID3V2_UTF8) {
+ while (pTagVal[*offset] < 0x20 && (*offset < *npTagLen)) { /* text string encoded by UTF-8 */
+ (*npTagLen)--;
+ (*offset)++;
+ }
+ return AV_ID3V2_UTF8;
+ } else {
+ while (pTagVal[*offset] < 0x20 && (*offset < *npTagLen)) { /* text string encoded by ISO-8859-1 */
+ (*npTagLen)--;
+ (*offset)++;
+ }
+ return AV_ID3V2_ISO_8859;
+ }
+}
+
static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal, int nTagLen, const char *pCharSet, int textEncodingType, int offset)
{
int idx = 0;
/*pExtContent[tmp+1] value should't have encoding value */
if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) {
- if (pExtContent[tmp - 1] == 0x00)
- textEncodingType = AV_ID3V2_ISO_8859;
- else
- textEncodingType = AV_ID3V2_UTF16;
+ textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp);
pInfo->pComment = mmfile_string_convert((char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen);
debug_msg(RELEASE, "pInfo->pComment returned = (%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen);
/*pExtContent[tmp+1] value should't have null value */
if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) {
- if (pExtContent[tmp - 1] == 0x00)
- textEncodingType = AV_ID3V2_ISO_8859;
- else
- textEncodingType = AV_ID3V2_UTF16;
+ textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp);
pInfo->pURL = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->urlLen);
debug_msg(RELEASE, "pInfo->pURL returned = (%s), pInfo->urlLen(%d)\n", pInfo->pURL, pInfo->urlLen);
/*pExtContent[tmp+1] value should't have encoding value */
if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if (IS_ENCODEDBY_UTF16(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else if (IS_ENCODEDBY_UTF16(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else {
- debug_msg(RELEASE, "pInfo->pComment Never Get Here!!\n");
- }
- } else {
- while ((pExtContent[tmp] < 0x20) && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
+ textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
pInfo->pComment = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen);
/*pExtContent[tmp+1] value should't have encoding value */
if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if (IS_ENCODEDBY_UTF16(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else if (IS_ENCODEDBY_UTF16(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else {
- debug_msg(RELEASE, "pInfo->pSyncLyrics Never Get Here!!\n");
- }
- } else {
- while ((pExtContent[tmp] < 0x20) && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
+ 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, "tpExtContent[%d] %x\n", tmp, pExtContent[tmp]);
if (pExtContent[tmp] == 0x00 || pExtContent[tmp] == 0xFF || pExtContent[tmp] == 0xFE) {
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if (IS_ENCODEDBY_UTF16(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp) && (realCpyFrameNum > 2)) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else if (IS_ENCODEDBY_UTF16(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16;
- } else if (IS_ENCODEDBY_UTF16_R(pExtContent + tmp + 1) && (realCpyFrameNum > 3)) {
- realCpyFrameNum -= 3;
- tmp += 3;
- textEncodingType = AV_ID3V2_UTF16_BE;
- } else {
- debug_msg(RELEASE, "pInfo->pUnsyncLyrics Never Get Here!!\n");
- }
- } else {
- while ((pExtContent[tmp] < 0x20) && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
+ textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
char *char_set = NULL;
realCpyFrameNum -= 3;
tmp = 3;
- if (textEncodingType == AV_ID3V2_UTF16 || textEncodingType == AV_ID3V2_UTF16_BE) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else {
- debug_msg(RELEASE, "pInfo->pComment Never Get Here!!\n");
- }
- } else if (textEncodingType == AV_ID3V2_UTF8) {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_UTF8;
- } else {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
-
+ textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
pInfo->pComment = _mm_file_string_convert_v224((const char *)&pExtContent[tmp], realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->commentLen);
realCpyFrameNum -= 5;
tmp = 5;
- if (textEncodingType == AV_ID3V2_UTF16 || textEncodingType == AV_ID3V2_UTF16_BE) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else {
- debug_msg(RELEASE, "pInfo->pSyncLyrics Never Get Here!!\n");
- }
- } else if (textEncodingType == AV_ID3V2_UTF8) {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_UTF8;
- } else {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
-
+ textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
__id3tag_parse_SYLT(pInfo, pExtContent, realCpyFrameNum, charset_array[textEncodingType], textEncodingType, tmp);
realCpyFrameNum -= 3;
tmp = 3;
- if (textEncodingType == AV_ID3V2_UTF16 || textEncodingType == AV_ID3V2_UTF16_BE) {
- __id3tag_skip_newline(pExtContent, &realCpyFrameNum, &tmp);
-
- if ((IS_ENCODEDBY_UTF16(pExtContent + tmp) || IS_ENCODEDBY_UTF16_R(pExtContent + tmp)) && realCpyFrameNum > 2) {
- realCpyFrameNum -= 2;
- tmp += 2;
- textEncodingType = AV_ID3V2_UTF16;
- } else {
- debug_msg(RELEASE, "pInfo->pUnsyncLyrics Never Get Here!!\n");
- }
- } else if (textEncodingType == AV_ID3V2_UTF8) {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_UTF8;
- } else {
- while (pExtContent[tmp] < 0x20 && (tmp < realCpyFrameNum)) { /* text string encoded by ISO-8859-1 */
- realCpyFrameNum--;
- tmp++;
- }
- textEncodingType = AV_ID3V2_ISO_8859;
- }
-
+ textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp);
debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum);
pInfo->pUnsyncLyrics = _mm_file_string_convert_v224((const char *)&pExtContent[tmp], realCpyFrameNum, textEncodingType, charset_array[textEncodingType], &pInfo->unsynclyricsLen);