{
int headFlags;
int hId, hMode, hSrIndex;
- int mp3SampleRateTable[4] = { 44100, 48000, 32000, 99999 };
+ int mp3SampleRateTable[4] = { 44100, 48000, 32000, 99999 };
/* get Xing header data */
headData->flags = 0;
return true;
}
-static void __AvGetID3v1Tags(unsigned char *buf, int offset, AvFileContentInfo *pInfo)
-{
- unsigned char TmpBuff[MP3TAGINFO_SIZE] = {0, };
-
- if (!buf || !pInfo || offset < 0) {
- debug_error(DEBUG, "Invalid parameters!");
- return;
- }
-
- if (pInfo->tagV2Info.tagLen != 0 || offset != TAGV1_SEEK_GAP) {
- debug_msg(RELEASE, "No need to check id3v1");
- return;
- }
-
- memcpy(TmpBuff, buf, MP3TAGINFO_SIZE);
-
- if (!mm_file_id3tag_parse_v110(pInfo, TmpBuff))
- debug_msg(RELEASE, "mm_file_id3tag_parse_v110 fails");
-}
-
-static void __AvGetID3v2Tags(unsigned char *buf, AvFileContentInfo *pInfo)
-{
- if (!buf || !pInfo || pInfo->tagV2Info.tagLen == 0) {
- debug_error(DEBUG, "Invalid parameters!");
- return;
- }
-
- if (pInfo->tagV2Info.tagVersion == 0x02)
- mm_file_id3tag_parse_v222(pInfo, buf);
- else if (pInfo->tagV2Info.tagVersion == 0x03)
- mm_file_id3tag_parse_v223(pInfo, buf);
- else if (pInfo->tagV2Info.tagVersion == 0x04)
- mm_file_id3tag_parse_v224(pInfo, buf); /* currently 2.4 ver pased by 2.3 routine */
- else
- debug_msg(RELEASE, "Invalid tag version(%d)", pInfo->tagV2Info.tagVersion);
-}
-
/*
* This fuction retrieves the start position of header.
* Param _pFile [in] Specifies the file pointer of mp3 file.
{
MMFileIOHandle *hFile;
unsigned char *buf = NULL;
- unsigned char *v2TagExistCheck = NULL;
- unsigned char TagBuff[MP3TAGINFO_SIZE + TAGV1_SEEK_GAP];
+ unsigned char tagBuf[MP3TAGINFO_SIZE + TAGV1_SEEK_GAP] = {0, };
int tagHeaderPos = 0;
debug_fenter(RELEASE);
}
/* read file to check ID3v2 header */
- v2TagExistCheck = g_malloc0(MP3_TAGv2_HEADER_LEN);
-
- if (mmfile_read(hFile, v2TagExistCheck, MP3_TAGv2_HEADER_LEN) != MP3_TAGv2_HEADER_LEN) {
- debug_error(DEBUG, "v2TagExistCheck value read fail!");
- mmfile_free(v2TagExistCheck);
+ if (mmfile_read(hFile, tagBuf, MP3_TAGv2_HEADER_LEN) != MP3_TAGv2_HEADER_LEN) {
+ debug_error(DEBUG, "ID3v2 check fail!");
goto EXCEPTION;
}
/* check ID3v2 header */
- __AvGetID3v2Header(v2TagExistCheck, MP3_TAGv2_HEADER_LEN, &pInfo->tagV2Info);
- mmfile_free(v2TagExistCheck);
+ __AvGetID3v2Header(tagBuf, MP3_TAGv2_HEADER_LEN, &pInfo->tagV2Info);
if (mmfile_seek(hFile, 0L, SEEK_SET) < 0)
goto EXCEPTION;
goto EXCEPTION;
}
- /* get ID3v2 information */
- __AvGetID3v2Tags(buf, pInfo);
+ if (pInfo->tagV2Info.tagVersion == 0x02)
+ mm_file_id3tag_parse_v222(pInfo, buf);
+ else if (pInfo->tagV2Info.tagVersion == 0x03)
+ mm_file_id3tag_parse_v223(pInfo, buf);
+ else if (pInfo->tagV2Info.tagVersion == 0x04)
+ mm_file_id3tag_parse_v224(pInfo, buf); /* currently 2.4 ver pased by 2.3 routine */
+ else
+ debug_msg(RELEASE, "Invalid tag version(%d)", pInfo->tagV2Info.tagVersion);
+
mmfile_free(buf);
/* locate fp to read TAG(ID3v1) information */
goto EXCEPTION;
pInfo->bV1tagFound = false;
+ memset(tagBuf, 0x00, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP);
+
/* read with TAG(ID3v1) length */
- if (mmfile_read(hFile, TagBuff, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP) != MP3TAGINFO_SIZE + TAGV1_SEEK_GAP)
+ if (mmfile_read(hFile, tagBuf, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP) != MP3TAGINFO_SIZE + TAGV1_SEEK_GAP)
goto EXCEPTION;
/* check and get TAG(ID3v1) information */
- if (__AvGetID3v1Header(TagBuff, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP, &tagHeaderPos)) {
+ if (__AvGetID3v1Header(tagBuf, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP, &tagHeaderPos)) {
pInfo->bV1tagFound = true;
- __AvGetID3v1Tags((TagBuff + tagHeaderPos), tagHeaderPos, pInfo);
+ if (tagHeaderPos == TAGV1_SEEK_GAP) {
+ if (!mm_file_id3tag_parse_v110(pInfo, tagBuf + tagHeaderPos))
+ debug_msg(RELEASE, "mm_file_id3tag_parse_v110 fails");
+ }
}
mm_file_id3tag_restore_content_info(pInfo);
*/
static bool __get_stream_info(char *filename, AvFileContentInfo *pInfo)
{
- MMFileIOHandle *hFile;
- unsigned char header[256];
- unsigned long frameSamples = 0;
- unsigned char *buf = NULL;
- unsigned long bufLen = 0;
- unsigned char TagBuff[MP3TAGINFO_SIZE + TAGV1_SEEK_GAP];
+ MMFileIOHandle *hFile;
+ unsigned char header[256] = {0, };
+ unsigned long frameSamples = 0;
+ unsigned char *buf = NULL;
+ unsigned long bufLen = 0;
debug_fenter(RELEASE);
pInfo->headerPos = 0;
pInfo->genre = 148;
- /*open*/
mm_file_retvm_if_fails(DEBUG, mmfile_open(&hFile, filename, MMFILE_RDONLY) == MMFILE_UTIL_SUCCESS, false);
pInfo->fileLen = mmfile_get_size(hFile);
debug_msg(RELEASE, "Mp3 File FrameSize (%d) pInfo->headerPos(%ld)", pInfo->frameSize, pInfo->headerPos);
}
- if (pInfo->mpegVersion == 1) {
- if (pInfo->layer == 1)
- frameSamples = MPEG_1_SIZE_LAYER_1;
- else
- frameSamples = MPEG_1_SIZE_LAYER_2_3;
- } else {
- if (pInfo->layer == 1)
- frameSamples = MPEG_2_SIZE_LAYER_1;
- else
- frameSamples = MPEG_2_SIZE_LAYER_2_3;
- }
+ if (pInfo->mpegVersion == 1)
+ frameSamples = (pInfo->layer == 1) ? MPEG_1_SIZE_LAYER_1 : MPEG_1_SIZE_LAYER_2_3;
+ else
+ frameSamples = (pInfo->layer == 1) ? MPEG_2_SIZE_LAYER_1 : MPEG_2_SIZE_LAYER_2_3;
/* check TAG(ID3v1) exist due to duration */
if (mmfile_seek(hFile, -(MP3TAGINFO_SIZE + TAGV1_SEEK_GAP), SEEK_END) < 0)
goto EXCEPTION;
pInfo->bV1tagFound = false;
+ /* Reuse header for check if ID3v1 tag exists */
+ memset(header, 0x00, 256);
- if (mmfile_read(hFile, TagBuff, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP) != MP3TAGINFO_SIZE + TAGV1_SEEK_GAP)
+ if (mmfile_read(hFile, header, TAGV1_SEEK_GAP + 5) != TAGV1_SEEK_GAP + 5)
goto EXCEPTION;
- if (__AvGetID3v1Header(TagBuff, MP3TAGINFO_SIZE + TAGV1_SEEK_GAP, NULL))
+ mmfile_close(hFile);
+
+ /* Check if id3v1 tag exists for duration calculation. */
+ if (__AvGetID3v1Header(header, TAGV1_SEEK_GAP + 5, NULL))
pInfo->bV1tagFound = true;
/* get MP3 duration */
debug_msg(DEBUG, "duration from new algorithm : %lld", pInfo->duration);
}
- mmfile_close(hFile);
-
/*debug print*/
debug_msg(RELEASE, "Mp3 File pInfo->duration (%lld) ", pInfo->duration);
debug_msg(RELEASE, "** MP3 **");