Apply tizen coding rule 41/147341/1 accepted/tizen/unified/20170906.060715 submit/tizen/20170904.081106 submit/tizen/20170905.045152
authorHaejeong Kim <backto.kim@samsung.com>
Mon, 4 Sep 2017 05:10:24 +0000 (14:10 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Mon, 4 Sep 2017 05:10:24 +0000 (14:10 +0900)
Change-Id: I8fa2ede20e3dbb42a76d1e0a374f010750cd0e94

22 files changed:
formats/ffmpeg/include/mm_file_format_aac.h
formats/ffmpeg/include/mm_file_format_id3tag.h
formats/ffmpeg/mm_file_format_aac.c
formats/ffmpeg/mm_file_format_amr.c
formats/ffmpeg/mm_file_format_ffmpeg.c
formats/ffmpeg/mm_file_format_frame.c
formats/ffmpeg/mm_file_format_imelody.c
formats/ffmpeg/mm_file_format_midi.c
formats/ffmpeg/mm_file_format_mmf.c
formats/ffmpeg/mm_file_format_mp3.c
formats/ffmpeg/mm_file_format_tag_id3.c
formats/ffmpeg/mm_file_format_wav.c
formats/ffmpeg/mm_file_formats.c
include/mm_file.h
include/mm_file_debug.h
include/mm_file_formats.h
mm_file.c
tests/mm_file_test.c
utils/include/mm_file_utils.h
utils/mm_file_util_io_mem.c
utils/mm_file_util_io_mmap.c
utils/mm_file_util_validity.c

index fbc7a77..355b227 100755 (executable)
@@ -38,7 +38,7 @@ typedef enum _mmfile_aac_profile_type {
        AAC_PROFILE_SSR,
        AAC_PROFILE_LTP,
        AAC_PROFILE_UNKNOWN
-}TAacProfileType;
+} TAacProfileType;
 
 typedef void* MMFileAACHandle;
 
index 0bcae37..1f22a66 100755 (executable)
@@ -106,7 +106,7 @@ typedef enum {
 } AvID3v2EncodingType;
 
 
-typedef struct{
+typedef struct {
        char    *pImageBuf;
        char    imageDescription[MP3_ID3_IMAGE_DESCRIPTION_MAX_LENGTH];
        char    imageMIMEType[MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH];
@@ -114,11 +114,11 @@ typedef struct{
        int             pictureType;
        int             imageLen;
        int             imgDesLen;
-       int     imgMimetypeLen;
-       bool    bURLInfo;
+       int             imgMimetypeLen;
+       bool            bURLInfo;
 } AvTagVer2ImageInfo;
 
- typedef struct{
+typedef struct {
        int             tagLen;
        char    tagVersion;
 
@@ -162,7 +162,7 @@ typedef struct {
        int             recdateLen;
 
 /* for PC Studio Podcast */
-       int     contentGroupLen;
+       int             contentGroupLen;
 
 /* for ID3V2 Tag */
        int             encbyLen;
@@ -171,8 +171,8 @@ typedef struct {
        int             composerLen;
 
 /* To send resolution info to appl from OEM */
-       int     width;
-       int     height;
+       int             width;
+       int             height;
 
        unsigned int    bitRate;
        unsigned int    sampleRate;
@@ -208,7 +208,7 @@ typedef struct {
        char                    *pYear;
        char                    *pGenre;
        char                    *pTrackNum;             /*Track number/Position in set */
-       char                    *pRecDate;              /*Recording dates */
+       char                    *pRecDate;              /*Recording dates */
 
 /* for PC Studio Podcast */
        char                    *pContentGroup;
@@ -229,8 +229,8 @@ typedef struct {
 typedef struct {
        int             videocodec;
        int             audiocodec;
-       int     width;
-       int     height;
+       int             width;
+       int             height;
 } AvExtraInfo;
 
 inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo)
index 9617245..d2bfa58 100755 (executable)
 
 /* Array to Number conversions */
 #define GET_INT_NUMBER(buff) (int)((((int)(buff)[0]) << 24) | \
-                                    (((int)(buff)[1]) << 16) | \
-                                    (((int)(buff)[2]) << 8) | \
-                                    (((int)(buff)[3])))
+                                                       (((int)(buff)[1]) << 16) | \
+                                                       (((int)(buff)[2]) << 8) | \
+                                                       (((int)(buff)[3])))
 
 #define GET_SHORT_NUMBER(buff) (short)(((short)(buff)[0] << 8) | \
-                                        ((short)(buff)[1]))
+                                                       ((short)(buff)[1]))
 
 
 
@@ -87,10 +87,10 @@ typedef struct _mmfile_aac_handle {
 
 /*Index table for Sampling frequency */
 const int Sampling_freq_table[16] = { 96000, 88200,  64000, 48000,
-                                      44100, 32000,  24000, 22050,
-                                      16000, 12000,  11025, 8000,
-                                      0,     0,      0,     0
-                                    };
+                                                               44100, 32000,  24000, 22050,
+                                                               16000, 12000,  11025, 8000,
+                                                               0,     0,      0,     0
+                                                               };
 
 /* internal APIs */
 void _aac_init_handle(tMMFILE_AAC_HANDLE *privateData);
@@ -175,7 +175,7 @@ int _search_id3tag(tMMFILE_AAC_HANDLE *pData)
        pData->tagInfoSize = MP3_TAGv2_HEADER_LEN;
 
        pData->tagInfoSize += (((encSize & 0x0000007F) >> 0) | ((encSize & 0x00007F00) >> 1) |  \
-                              ((encSize & 0x007F0000) >> 2) | ((encSize & 0x7F000000) >> 3));
+                                               ((encSize & 0x007F0000) >> 2) | ((encSize & 0x7F000000) >> 3));
 
        if (pData->tagInfoSize > pData->streamInfo.fileSize) {
                debug_msg(RELEASE, "Invalid size");
@@ -219,21 +219,21 @@ int _parse_id3_tag(tMMFILE_AAC_HANDLE *pData)
        }
 
        switch (hTag->tagV2Info.tagVersion) {
-               case 1:
-                       ret = mm_file_id3tag_parse_v110(hTag, tagBuff);
-                       break;
-               case 2:
-                       ret = mm_file_id3tag_parse_v222(hTag, tagBuff);
-                       break;
-               case 3:
-                       ret = mm_file_id3tag_parse_v223(hTag, tagBuff);
-                       break;
-               case 4:
-                       ret = mm_file_id3tag_parse_v224(hTag, tagBuff);
-                       break;
-               default:
-                       debug_error(DEBUG, "Invalid Tag version [%d]\n", hTag->tagV2Info.tagVersion);
-                       break;
+       case 1:
+               ret = mm_file_id3tag_parse_v110(hTag, tagBuff);
+               break;
+       case 2:
+               ret = mm_file_id3tag_parse_v222(hTag, tagBuff);
+               break;
+       case 3:
+               ret = mm_file_id3tag_parse_v223(hTag, tagBuff);
+               break;
+       case 4:
+               ret = mm_file_id3tag_parse_v224(hTag, tagBuff);
+               break;
+       default:
+               debug_error(DEBUG, "Invalid Tag version [%d]\n", hTag->tagV2Info.tagVersion);
+               break;
        }
 
        if (ret == FALSE) {
@@ -489,7 +489,7 @@ int _get_next_adts_frame_length(tMMFILE_AAC_HANDLE *pData, int *frameLen)
 
        debug_msg(RELEASE, "\nFILE POS: %lld\n", filePosBefore);
        debug_msg(RELEASE, "\nADTS HEADER: [%2x] [%2x] [%2x] [%2x] [%2x] [%2x]\n",
-                 adtsHeader[0], adtsHeader[1], adtsHeader[2], adtsHeader[3], adtsHeader[4], adtsHeader[5]);
+                                       adtsHeader[0], adtsHeader[1], adtsHeader[2], adtsHeader[3], adtsHeader[4], adtsHeader[5]);
 
        if (mmfile_tell(pData->hFile) >= pData->streamInfo.fileSize) {
                *frameLen = 0;
@@ -895,8 +895,7 @@ exception:
 
 
 EXPORT_API
-int mmfile_format_read_frame_aac(MMFileFormatContext *formatContext,
-                                 unsigned int timestamp, MMFileFormatFrame *frame)
+int mmfile_format_read_frame_aac(MMFileFormatContext *formatContext, unsigned int timestamp, MMFileFormatFrame *frame)
 {
        debug_error(DEBUG, "error: mmfile_format_read_frame_aac, no handling\n");
 
index 478f4a3..9cc5139 100755 (executable)
@@ -135,11 +135,11 @@ int _parse_amr_header(tMMFILE_AMR_HANDLE *pData)
        }
 
        debug_msg(RELEASE, "\nAMR HEADER: [%2x] [%2x] [%2x] [%2x] [%2x]\n   \
-         [%2x] [%2x] [%2x] [%2x] [%2x]\n   \
-         [%2x] [%2x] [%2x] [%2x] [%2x]\n",
-                 header[0], header[1], header[2], header[3], header[4],
-                 header[5], header[6], header[7], header[8], header[9],
-                 header[10], header[11], header[12], header[13], header[14]);
+                               [%2x] [%2x] [%2x] [%2x] [%2x]\n   \
+                               [%2x] [%2x] [%2x] [%2x] [%2x]\n",
+                               header[0], header[1], header[2], header[3], header[4],
+                               header[5], header[6], header[7], header[8], header[9],
+                               header[10], header[11], header[12], header[13], header[14]);
 
        if (!(memcmp(header, MMFILE_AMR_SINGLE_CH_HEADER, MMFILE_AMR_SINGLE_CH_HEADER_SIZE))) {
                pData->amrFormat = AMR_FORMAT_NB;
@@ -273,8 +273,7 @@ int mmfile_amrparser_open(MMFileAMRHandle *handle, const char *filenamec)
                goto exception;
        }
 
-       debug_msg(RELEASE, "AMR Format Type: %s\n", \
-                 privateData->amrFormat == AMR_FORMAT_NB ? "AMR-NB" : "AMR-WB");
+       debug_msg(RELEASE, "AMR Format Type: %s\n", privateData->amrFormat == AMR_FORMAT_NB ? "AMR-NB" : "AMR-WB");
 
        *handle = privateData;
 
@@ -448,8 +447,7 @@ int mmfile_format_read_tag_amr(MMFileFormatContext *formatContext)
 
 
 EXPORT_API
-int mmfile_format_read_frame_amr(MMFileFormatContext *formatContext,
-                                 unsigned int timestamp, MMFileFormatFrame *frame)
+int mmfile_format_read_frame_amr(MMFileFormatContext *formatContext, unsigned int timestamp, MMFileFormatFrame *frame)
 {
        debug_error(DEBUG, "error: mmfile_format_read_frame_amr, no handling\n");
 
index 2a44750..493ab7a 100755 (executable)
@@ -172,19 +172,19 @@ static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence)
        memHandle = opaque;
 
        switch (whence) {
-               case SEEK_SET:
-                       tmp_offset = 0 + pos;
-                       break;
-               case SEEK_CUR:
-                       tmp_offset = memHandle->offset + pos;
-                       break;
-               case SEEK_END:
-                       tmp_offset = memHandle->size + pos;
-                       break;
-               case AVSEEK_SIZE:       /*FFMPEG specific*/
-                       return memHandle->size;
-               default:
-                       return MMFILE_UTIL_FAIL;
+       case SEEK_SET:
+               tmp_offset = 0 + pos;
+               break;
+       case SEEK_CUR:
+               tmp_offset = memHandle->offset + pos;
+               break;
+       case SEEK_END:
+               tmp_offset = memHandle->size + pos;
+               break;
+       case AVSEEK_SIZE:       /*FFMPEG specific*/
+               return memHandle->size;
+       default:
+               return MMFILE_UTIL_FAIL;
        }
 
        /*check validation*/
@@ -476,8 +476,7 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
                                        videoStream->bitRate            = pVideoCodecCtx->bit_rate;
                                }
                        }
-               }
-               else if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+               }               else if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                        if (formatContext->audioStreamId == -1) {
                                audioStream = mmfile_malloc(sizeof(MMFileFormatStream));
                                if (NULL == audioStream) {
@@ -1117,8 +1116,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
                } else {
                        if (avcodec_get_type(pFormatCtx->streams[pkt.stream_index]->codecpar->codec_id) == AVMEDIA_TYPE_VIDEO) {
                                v++;
-                               if ((pkt.flags & AV_PKT_FLAG_KEY) || (key_detected == 1))
-                               {
+                               if ((pkt.flags & AV_PKT_FLAG_KEY) || (key_detected == 1)) {
                                        debug_msg(RELEASE, "video frame: %d, %d, %d\n", retry, i, v);
 #ifdef __MMFILE_TEST_MODE__
                                        _dump_av_packet(&pkt);
@@ -1224,89 +1222,89 @@ static int ConvertVideoCodecEnum(int AVVideoCodecID)
        int ret_codecid = 0;
 
        switch (AVVideoCodecID) {
-               case AV_CODEC_ID_NONE:
-                       ret_codecid = MM_VIDEO_CODEC_NONE;
-                       break;
-               case AV_CODEC_ID_MPEG1VIDEO:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG1;
-                       break;
-               case AV_CODEC_ID_MPEG2VIDEO:  /*/< preferred ID for MPEG-1/2 video decoding */
-               case AV_CODEC_ID_MPEG2VIDEO_XVMC:
-               case AV_CODEC_ID_MPEG2TS:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG2;
-                       break;
-               case AV_CODEC_ID_H261:
-                       ret_codecid = MM_VIDEO_CODEC_H261;
-                       break;
-               case AV_CODEC_ID_H263:
-                       ret_codecid = MM_VIDEO_CODEC_H263;
-                       break;
-               case AV_CODEC_ID_MPEG4:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG4;
-                       break;
-               case AV_CODEC_ID_MSMPEG4V1:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG4;
-                       break;
-               case AV_CODEC_ID_MSMPEG4V2:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG4;
-                       break;
-               case AV_CODEC_ID_MSMPEG4V3:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG4;
-                       break;
-               case AV_CODEC_ID_WMV1:
-                       ret_codecid = MM_VIDEO_CODEC_WMV;
-                       break;
-               case AV_CODEC_ID_WMV2:
-                       ret_codecid = MM_VIDEO_CODEC_WMV;
-                       break;
-               case AV_CODEC_ID_H263P:
-                       ret_codecid = MM_VIDEO_CODEC_H263;
-                       break;
-               case AV_CODEC_ID_H263I:
-                       ret_codecid = MM_VIDEO_CODEC_H263;
-                       break;
-               case AV_CODEC_ID_FLV1:
-                       ret_codecid = MM_VIDEO_CODEC_FLV;
-                       break;
-               case AV_CODEC_ID_H264:
-                       ret_codecid = MM_VIDEO_CODEC_H264;
-                       break;
-               case AV_CODEC_ID_INDEO2:
-               case AV_CODEC_ID_INDEO3:
-               case AV_CODEC_ID_INDEO4:
-               case AV_CODEC_ID_INDEO5:
-                       ret_codecid = MM_VIDEO_CODEC_INDEO;
-                       break;
-               case AV_CODEC_ID_THEORA:
-                       ret_codecid = MM_VIDEO_CODEC_THEORA;
-                       break;
-               case AV_CODEC_ID_CINEPAK:
-                       ret_codecid = MM_VIDEO_CODEC_CINEPAK;
-                       break;
-               case AV_CODEC_ID_VC1:
-                       ret_codecid = MM_VIDEO_CODEC_VC1;
-                       break;
-               case AV_CODEC_ID_WMV3:
-                       ret_codecid = MM_VIDEO_CODEC_WMV;
-                       break;
-               case AV_CODEC_ID_AVS:
-                       ret_codecid = MM_VIDEO_CODEC_AVS;
-                       break;
-               case AV_CODEC_ID_RL2:
-               case AV_CODEC_ID_RV10:  /* RealVideo 1 */
-               case AV_CODEC_ID_RV20:  /* RealVideo 2 */
-               case AV_CODEC_ID_RV30:  /* RealVideo 3 */
-               case AV_CODEC_ID_RV40:  /* RealVideo 4 */
-                       ret_codecid = MM_VIDEO_CODEC_REAL;
-                       break;
+       case AV_CODEC_ID_NONE:
+               ret_codecid = MM_VIDEO_CODEC_NONE;
+               break;
+       case AV_CODEC_ID_MPEG1VIDEO:
+               ret_codecid = MM_VIDEO_CODEC_MPEG1;
+               break;
+       case AV_CODEC_ID_MPEG2VIDEO:  /*/< preferred ID for MPEG-1/2 video decoding */
+       case AV_CODEC_ID_MPEG2VIDEO_XVMC:
+       case AV_CODEC_ID_MPEG2TS:
+               ret_codecid = MM_VIDEO_CODEC_MPEG2;
+               break;
+       case AV_CODEC_ID_H261:
+               ret_codecid = MM_VIDEO_CODEC_H261;
+               break;
+       case AV_CODEC_ID_H263:
+               ret_codecid = MM_VIDEO_CODEC_H263;
+               break;
+       case AV_CODEC_ID_MPEG4:
+               ret_codecid = MM_VIDEO_CODEC_MPEG4;
+               break;
+       case AV_CODEC_ID_MSMPEG4V1:
+               ret_codecid = MM_VIDEO_CODEC_MPEG4;
+               break;
+       case AV_CODEC_ID_MSMPEG4V2:
+               ret_codecid = MM_VIDEO_CODEC_MPEG4;
+               break;
+       case AV_CODEC_ID_MSMPEG4V3:
+               ret_codecid = MM_VIDEO_CODEC_MPEG4;
+               break;
+       case AV_CODEC_ID_WMV1:
+               ret_codecid = MM_VIDEO_CODEC_WMV;
+               break;
+       case AV_CODEC_ID_WMV2:
+               ret_codecid = MM_VIDEO_CODEC_WMV;
+               break;
+       case AV_CODEC_ID_H263P:
+               ret_codecid = MM_VIDEO_CODEC_H263;
+               break;
+       case AV_CODEC_ID_H263I:
+               ret_codecid = MM_VIDEO_CODEC_H263;
+               break;
+       case AV_CODEC_ID_FLV1:
+               ret_codecid = MM_VIDEO_CODEC_FLV;
+               break;
+       case AV_CODEC_ID_H264:
+               ret_codecid = MM_VIDEO_CODEC_H264;
+               break;
+       case AV_CODEC_ID_INDEO2:
+       case AV_CODEC_ID_INDEO3:
+       case AV_CODEC_ID_INDEO4:
+       case AV_CODEC_ID_INDEO5:
+               ret_codecid = MM_VIDEO_CODEC_INDEO;
+               break;
+       case AV_CODEC_ID_THEORA:
+               ret_codecid = MM_VIDEO_CODEC_THEORA;
+               break;
+       case AV_CODEC_ID_CINEPAK:
+               ret_codecid = MM_VIDEO_CODEC_CINEPAK;
+               break;
+       case AV_CODEC_ID_VC1:
+               ret_codecid = MM_VIDEO_CODEC_VC1;
+               break;
+       case AV_CODEC_ID_WMV3:
+               ret_codecid = MM_VIDEO_CODEC_WMV;
+               break;
+       case AV_CODEC_ID_AVS:
+               ret_codecid = MM_VIDEO_CODEC_AVS;
+               break;
+       case AV_CODEC_ID_RL2:
+       case AV_CODEC_ID_RV10:  /* RealVideo 1 */
+       case AV_CODEC_ID_RV20:  /* RealVideo 2 */
+       case AV_CODEC_ID_RV30:  /* RealVideo 3 */
+       case AV_CODEC_ID_RV40:  /* RealVideo 4 */
+               ret_codecid = MM_VIDEO_CODEC_REAL;
+               break;
 #ifdef __MMFILE_LIBAV_VERSION__
-               case AV_CODEC_ID_HEVC:
-                       ret_codecid = MM_VIDEO_CODEC_MPEG4;
-                       break;
+       case AV_CODEC_ID_HEVC:
+               ret_codecid = MM_VIDEO_CODEC_MPEG4;
+               break;
 #endif
-               default:
-                       ret_codecid = MM_VIDEO_CODEC_NONE;
-                       break;
+       default:
+               ret_codecid = MM_VIDEO_CODEC_NONE;
+               break;
        }
 
        return ret_codecid;
@@ -1318,63 +1316,63 @@ static int ConvertAudioCodecEnum(int AVAudioCodecID)
        int ret_codecid = 0;
 
        switch (AVAudioCodecID) {
-               case AV_CODEC_ID_AMR_NB:
-               case AV_CODEC_ID_AMR_WB:
-                       ret_codecid = MM_AUDIO_CODEC_AMR;
-                       break;
-               /* RealAudio codecs*/
-               case AV_CODEC_ID_RA_144:        /* RealAudio 1 */
-               case AV_CODEC_ID_RA_288:        /* RealAudio 2 */
-               case AV_CODEC_ID_COOK:          /* RealAudio 6 */
-                       ret_codecid = MM_AUDIO_CODEC_REAL;
-                       break;
-               case AV_CODEC_ID_MP2:
-                       ret_codecid = MM_AUDIO_CODEC_MP2;
-                       break;
-               case AV_CODEC_ID_MP3:
-               case AV_CODEC_ID_MP3ADU:
-               case AV_CODEC_ID_MP3ON4:
-                       ret_codecid = MM_AUDIO_CODEC_MP3;
-                       break;
-               case AV_CODEC_ID_AAC:
-                       ret_codecid = MM_AUDIO_CODEC_AAC;
-                       break;
-               case AV_CODEC_ID_AC3:
-                       ret_codecid = MM_AUDIO_CODEC_AC3;
-                       break;
-               case AV_CODEC_ID_VORBIS:
-                       ret_codecid = MM_AUDIO_CODEC_VORBIS;
-                       break;
-               case AV_CODEC_ID_WMAV1:
-               case AV_CODEC_ID_WMAV2:
-               case AV_CODEC_ID_WMAVOICE:
-               case AV_CODEC_ID_WMAPRO:
-               case AV_CODEC_ID_WMALOSSLESS:
-                       ret_codecid = MM_AUDIO_CODEC_WMA;
-                       break;
-               case AV_CODEC_ID_FLAC:
-                       ret_codecid = MM_AUDIO_CODEC_FLAC;
-                       break;
-               case AV_CODEC_ID_ALAC:
-                       ret_codecid = MM_AUDIO_CODEC_ALAC;
-                       break;
-               case AV_CODEC_ID_WAVPACK:
-                       ret_codecid = MM_AUDIO_CODEC_WAVE;
-                       break;
-               case AV_CODEC_ID_ATRAC3:
-               case AV_CODEC_ID_ATRAC3P:
-               case AV_CODEC_ID_EAC3:
-                       ret_codecid = MM_AUDIO_CODEC_AC3;
-                       break;
-               case AV_CODEC_ID_PCM_S8:
-               case AV_CODEC_ID_PCM_S16BE:
-               case AV_CODEC_ID_PCM_S24BE:
-               case AV_CODEC_ID_PCM_S32BE:
-                       ret_codecid = MM_AUDIO_CODEC_PCM;
-                       break;
-               default:
-                       ret_codecid = MM_AUDIO_CODEC_NONE;
-                       break;
+       case AV_CODEC_ID_AMR_NB:
+       case AV_CODEC_ID_AMR_WB:
+               ret_codecid = MM_AUDIO_CODEC_AMR;
+               break;
+       /* RealAudio codecs*/
+       case AV_CODEC_ID_RA_144:        /* RealAudio 1 */
+       case AV_CODEC_ID_RA_288:        /* RealAudio 2 */
+       case AV_CODEC_ID_COOK:          /* RealAudio 6 */
+               ret_codecid = MM_AUDIO_CODEC_REAL;
+               break;
+       case AV_CODEC_ID_MP2:
+               ret_codecid = MM_AUDIO_CODEC_MP2;
+               break;
+       case AV_CODEC_ID_MP3:
+       case AV_CODEC_ID_MP3ADU:
+       case AV_CODEC_ID_MP3ON4:
+               ret_codecid = MM_AUDIO_CODEC_MP3;
+               break;
+       case AV_CODEC_ID_AAC:
+               ret_codecid = MM_AUDIO_CODEC_AAC;
+               break;
+       case AV_CODEC_ID_AC3:
+               ret_codecid = MM_AUDIO_CODEC_AC3;
+               break;
+       case AV_CODEC_ID_VORBIS:
+               ret_codecid = MM_AUDIO_CODEC_VORBIS;
+               break;
+       case AV_CODEC_ID_WMAV1:
+       case AV_CODEC_ID_WMAV2:
+       case AV_CODEC_ID_WMAVOICE:
+       case AV_CODEC_ID_WMAPRO:
+       case AV_CODEC_ID_WMALOSSLESS:
+               ret_codecid = MM_AUDIO_CODEC_WMA;
+               break;
+       case AV_CODEC_ID_FLAC:
+               ret_codecid = MM_AUDIO_CODEC_FLAC;
+               break;
+       case AV_CODEC_ID_ALAC:
+               ret_codecid = MM_AUDIO_CODEC_ALAC;
+               break;
+       case AV_CODEC_ID_WAVPACK:
+               ret_codecid = MM_AUDIO_CODEC_WAVE;
+               break;
+       case AV_CODEC_ID_ATRAC3:
+       case AV_CODEC_ID_ATRAC3P:
+       case AV_CODEC_ID_EAC3:
+               ret_codecid = MM_AUDIO_CODEC_AC3;
+               break;
+       case AV_CODEC_ID_PCM_S8:
+       case AV_CODEC_ID_PCM_S16BE:
+       case AV_CODEC_ID_PCM_S24BE:
+       case AV_CODEC_ID_PCM_S32BE:
+               ret_codecid = MM_AUDIO_CODEC_PCM;
+               break;
+       default:
+               ret_codecid = MM_AUDIO_CODEC_NONE;
+               break;
        }
 
        return ret_codecid;
@@ -1387,84 +1385,84 @@ static int getMimeType(int formatId, char *mimeType, int buf_size)
        int ret = 0;    /*default: success*/
 
        switch (formatId) {
-               case MM_FILE_FORMAT_3GP:
-               case MM_FILE_FORMAT_MP4:
-                       snprintf(mimeType, buf_size, "video/3gpp");
-                       break;
-               case MM_FILE_FORMAT_ASF:
-               case MM_FILE_FORMAT_WMA:
-               case MM_FILE_FORMAT_WMV:
-                       snprintf(mimeType, buf_size, "video/x-ms-asf");
-                       break;
-               case  MM_FILE_FORMAT_AVI:
-                       snprintf(mimeType, buf_size, "video/avi");
-                       break;
-               case MM_FILE_FORMAT_OGG:
-                       snprintf(mimeType, buf_size, "video/ogg");
-                       break;
-               case MM_FILE_FORMAT_REAL:
-                       snprintf(mimeType, buf_size, "video/vnd.rn-realmedia");
-                       break;
-               case MM_FILE_FORMAT_AMR:
-                       snprintf(mimeType, buf_size, "audio/AMR");
-                       break;
-               case MM_FILE_FORMAT_AAC:
-                       snprintf(mimeType, buf_size, "audio/aac");
-                       break;
-               case MM_FILE_FORMAT_MP3:
-                       snprintf(mimeType, buf_size, "audio/mp3");
-                       break;
-               case MM_FILE_FORMAT_AIFF:
-               case MM_FILE_FORMAT_WAV:
-                       snprintf(mimeType, buf_size, "audio/wave");
-                       break;
-               case MM_FILE_FORMAT_MID:
-                       snprintf(mimeType, buf_size, "audio/midi");
-                       break;
-               case MM_FILE_FORMAT_MMF:
-                       snprintf(mimeType, buf_size, "audio/mmf");
-                       break;
-               case MM_FILE_FORMAT_DIVX:
-                       snprintf(mimeType, buf_size, "video/divx");
-                       break;
-               case MM_FILE_FORMAT_IMELODY:
-                       snprintf(mimeType, buf_size, "audio/iMelody");
-                       break;
-               case MM_FILE_FORMAT_JPG:
-                       snprintf(mimeType, buf_size, "image/jpeg");
-                       break;
-               case MM_FILE_FORMAT_AU:
-                       snprintf(mimeType, buf_size, "audio/basic");
-                       break;
-               case MM_FILE_FORMAT_VOB:
-                       snprintf(mimeType, buf_size, "video/dvd");
-                       break;
-               case MM_FILE_FORMAT_FLV:
-                       snprintf(mimeType, buf_size, "video/x-flv");
-                       break;
-               case MM_FILE_FORMAT_QT:
-                       snprintf(mimeType, buf_size, "video/quicktime");
-                       break;
-               case MM_FILE_FORMAT_MATROSKA:
-                       snprintf(mimeType, buf_size, "video/x-matroska");
-                       break;
-               case MM_FILE_FORMAT_FLAC:
-                       snprintf(mimeType, buf_size, "audio/x-flac");
-                       break;
-               case MM_FILE_FORMAT_M2TS:
-                       snprintf(mimeType, buf_size, "video/MP2T");
-                       break;
-               case MM_FILE_FORMAT_M2PS:
-                       snprintf(mimeType, buf_size, "video/MP2P");
-                       break;
-               case MM_FILE_FORMAT_M1AUDIO:
-                       snprintf(mimeType, buf_size, "audio/x-mpegaudio");
-                       break;
-               case MM_FILE_FORMAT_M1VIDEO:
-                       snprintf(mimeType, buf_size, "video/mpeg");
-                       break;
-               default:
-                       ret = -1;
+       case MM_FILE_FORMAT_3GP:
+       case MM_FILE_FORMAT_MP4:
+               snprintf(mimeType, buf_size, "video/3gpp");
+               break;
+       case MM_FILE_FORMAT_ASF:
+       case MM_FILE_FORMAT_WMA:
+       case MM_FILE_FORMAT_WMV:
+               snprintf(mimeType, buf_size, "video/x-ms-asf");
+               break;
+       case  MM_FILE_FORMAT_AVI:
+               snprintf(mimeType, buf_size, "video/avi");
+               break;
+       case MM_FILE_FORMAT_OGG:
+               snprintf(mimeType, buf_size, "video/ogg");
+               break;
+       case MM_FILE_FORMAT_REAL:
+               snprintf(mimeType, buf_size, "video/vnd.rn-realmedia");
+               break;
+       case MM_FILE_FORMAT_AMR:
+               snprintf(mimeType, buf_size, "audio/AMR");
+               break;
+       case MM_FILE_FORMAT_AAC:
+               snprintf(mimeType, buf_size, "audio/aac");
+               break;
+       case MM_FILE_FORMAT_MP3:
+               snprintf(mimeType, buf_size, "audio/mp3");
+               break;
+       case MM_FILE_FORMAT_AIFF:
+       case MM_FILE_FORMAT_WAV:
+               snprintf(mimeType, buf_size, "audio/wave");
+               break;
+       case MM_FILE_FORMAT_MID:
+               snprintf(mimeType, buf_size, "audio/midi");
+               break;
+       case MM_FILE_FORMAT_MMF:
+               snprintf(mimeType, buf_size, "audio/mmf");
+               break;
+       case MM_FILE_FORMAT_DIVX:
+               snprintf(mimeType, buf_size, "video/divx");
+               break;
+       case MM_FILE_FORMAT_IMELODY:
+               snprintf(mimeType, buf_size, "audio/iMelody");
+               break;
+       case MM_FILE_FORMAT_JPG:
+               snprintf(mimeType, buf_size, "image/jpeg");
+               break;
+       case MM_FILE_FORMAT_AU:
+               snprintf(mimeType, buf_size, "audio/basic");
+               break;
+       case MM_FILE_FORMAT_VOB:
+               snprintf(mimeType, buf_size, "video/dvd");
+               break;
+       case MM_FILE_FORMAT_FLV:
+               snprintf(mimeType, buf_size, "video/x-flv");
+               break;
+       case MM_FILE_FORMAT_QT:
+               snprintf(mimeType, buf_size, "video/quicktime");
+               break;
+       case MM_FILE_FORMAT_MATROSKA:
+               snprintf(mimeType, buf_size, "video/x-matroska");
+               break;
+       case MM_FILE_FORMAT_FLAC:
+               snprintf(mimeType, buf_size, "audio/x-flac");
+               break;
+       case MM_FILE_FORMAT_M2TS:
+               snprintf(mimeType, buf_size, "video/MP2T");
+               break;
+       case MM_FILE_FORMAT_M2PS:
+               snprintf(mimeType, buf_size, "video/MP2P");
+               break;
+       case MM_FILE_FORMAT_M1AUDIO:
+               snprintf(mimeType, buf_size, "audio/x-mpegaudio");
+               break;
+       case MM_FILE_FORMAT_M1VIDEO:
+               snprintf(mimeType, buf_size, "video/mpeg");
+               break;
+       default:
+               ret = -1;
        }
 
        debug_msg(RELEASE, "id: %d, mimetype: %s\n", formatId, mimeType);
index e79ffe9..931eb77 100755 (executable)
@@ -172,19 +172,19 @@ static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence)
        memHandle = opaque;
 
        switch (whence) {
-               case SEEK_SET:
-                       tmp_offset = 0 + pos;
-                       break;
-               case SEEK_CUR:
-                       tmp_offset = memHandle->offset + pos;
-                       break;
-               case SEEK_END:
-                       tmp_offset = memHandle->size + pos;
-                       break;
-               case AVSEEK_SIZE:       /*FFMPEG specific*/
-                       return memHandle->size;
-               default:
-                       return MMFILE_UTIL_FAIL;
+       case SEEK_SET:
+               tmp_offset = 0 + pos;
+               break;
+       case SEEK_CUR:
+               tmp_offset = memHandle->offset + pos;
+               break;
+       case SEEK_END:
+               tmp_offset = memHandle->size + pos;
+               break;
+       case AVSEEK_SIZE:       /*FFMPEG specific*/
+               return memHandle->size;
+       default:
+               return MMFILE_UTIL_FAIL;
        }
 
        /*check validation*/
@@ -205,85 +205,85 @@ static int __getMimeType(int formatId, char *mimeType, int buf_size)
        int ret = 0;    /*default: success*/
 
        switch (formatId) {
-               case MM_FILE_FORMAT_3GP:
-               case MM_FILE_FORMAT_MP4:
-                       snprintf(mimeType, buf_size, "video/3gpp");
-                       break;
-               case MM_FILE_FORMAT_ASF:
-               case MM_FILE_FORMAT_WMA:
-               case MM_FILE_FORMAT_WMV:
-                       snprintf(mimeType, buf_size, "video/x-ms-asf");
-                       break;
-               case  MM_FILE_FORMAT_AVI:
-                       snprintf(mimeType, buf_size, "video/avi");
-                       break;
-               case MM_FILE_FORMAT_OGG:
-                       snprintf(mimeType, buf_size, "video/ogg");
-                       break;
-               case MM_FILE_FORMAT_REAL:
-                       snprintf(mimeType, buf_size, "video/vnd.rn-realmedia");
-                       break;
-               case MM_FILE_FORMAT_AMR:
-                       snprintf(mimeType, buf_size, "audio/AMR");
-                       break;
-               case MM_FILE_FORMAT_AAC:
-                       snprintf(mimeType, buf_size, "audio/aac");
-                       break;
-               case MM_FILE_FORMAT_MP3:
-                       snprintf(mimeType, buf_size, "audio/mp3");
-                       break;
-               case MM_FILE_FORMAT_AIFF:
-               case MM_FILE_FORMAT_WAV:
-                       snprintf(mimeType, buf_size, "audio/wave");
-                       break;
-               case MM_FILE_FORMAT_MID:
-                       snprintf(mimeType, buf_size, "audio/midi");
-                       break;
-               case MM_FILE_FORMAT_MMF:
-                       snprintf(mimeType, buf_size, "audio/mmf");
-                       break;
-               case MM_FILE_FORMAT_DIVX:
-                       snprintf(mimeType, buf_size, "video/divx");
-                       break;
-               case MM_FILE_FORMAT_IMELODY:
-                       snprintf(mimeType, buf_size, "audio/iMelody");
-                       break;
-               case MM_FILE_FORMAT_JPG:
-                       snprintf(mimeType, buf_size, "image/jpeg");
-                       break;
-               case MM_FILE_FORMAT_AU:
-                       snprintf(mimeType, buf_size, "audio/basic");
-                       break;
-               case MM_FILE_FORMAT_VOB:
-                       snprintf(mimeType, buf_size, "video/dvd");
-                       break;
-               case MM_FILE_FORMAT_FLV:
-                       snprintf(mimeType, buf_size, "video/x-flv");
-                       break;
-               case MM_FILE_FORMAT_QT:
-                       snprintf(mimeType, buf_size, "video/quicktime");
-                       break;
-               case MM_FILE_FORMAT_MATROSKA:
-                       snprintf(mimeType, buf_size, "video/x-matroska");
-                       break;
-               case MM_FILE_FORMAT_FLAC:
-                       snprintf(mimeType, buf_size, "audio/x-flac");
-                       break;
-               case MM_FILE_FORMAT_M2TS:
-                       snprintf(mimeType, buf_size, "video/MP2T");
-                       break;
-               case MM_FILE_FORMAT_M2PS:
-                       snprintf(mimeType, buf_size, "video/MP2P");
-                       break;
-               case MM_FILE_FORMAT_M1VIDEO:
-                       snprintf(mimeType, buf_size, "video/mpeg");
-                       break;
-               case MM_FILE_FORMAT_M1AUDIO:
-                       snprintf(mimeType, buf_size, "audio/x-mpegaudio");
-                       break;
-               default:
-                       ret = -1;
-                       break;
+       case MM_FILE_FORMAT_3GP:
+       case MM_FILE_FORMAT_MP4:
+               snprintf(mimeType, buf_size, "video/3gpp");
+               break;
+       case MM_FILE_FORMAT_ASF:
+       case MM_FILE_FORMAT_WMA:
+       case MM_FILE_FORMAT_WMV:
+               snprintf(mimeType, buf_size, "video/x-ms-asf");
+               break;
+       case  MM_FILE_FORMAT_AVI:
+               snprintf(mimeType, buf_size, "video/avi");
+               break;
+       case MM_FILE_FORMAT_OGG:
+               snprintf(mimeType, buf_size, "video/ogg");
+               break;
+       case MM_FILE_FORMAT_REAL:
+               snprintf(mimeType, buf_size, "video/vnd.rn-realmedia");
+               break;
+       case MM_FILE_FORMAT_AMR:
+               snprintf(mimeType, buf_size, "audio/AMR");
+               break;
+       case MM_FILE_FORMAT_AAC:
+               snprintf(mimeType, buf_size, "audio/aac");
+               break;
+       case MM_FILE_FORMAT_MP3:
+               snprintf(mimeType, buf_size, "audio/mp3");
+               break;
+       case MM_FILE_FORMAT_AIFF:
+       case MM_FILE_FORMAT_WAV:
+               snprintf(mimeType, buf_size, "audio/wave");
+               break;
+       case MM_FILE_FORMAT_MID:
+               snprintf(mimeType, buf_size, "audio/midi");
+               break;
+       case MM_FILE_FORMAT_MMF:
+               snprintf(mimeType, buf_size, "audio/mmf");
+               break;
+       case MM_FILE_FORMAT_DIVX:
+               snprintf(mimeType, buf_size, "video/divx");
+               break;
+       case MM_FILE_FORMAT_IMELODY:
+               snprintf(mimeType, buf_size, "audio/iMelody");
+               break;
+       case MM_FILE_FORMAT_JPG:
+               snprintf(mimeType, buf_size, "image/jpeg");
+               break;
+       case MM_FILE_FORMAT_AU:
+               snprintf(mimeType, buf_size, "audio/basic");
+               break;
+       case MM_FILE_FORMAT_VOB:
+               snprintf(mimeType, buf_size, "video/dvd");
+               break;
+       case MM_FILE_FORMAT_FLV:
+               snprintf(mimeType, buf_size, "video/x-flv");
+               break;
+       case MM_FILE_FORMAT_QT:
+               snprintf(mimeType, buf_size, "video/quicktime");
+               break;
+       case MM_FILE_FORMAT_MATROSKA:
+               snprintf(mimeType, buf_size, "video/x-matroska");
+               break;
+       case MM_FILE_FORMAT_FLAC:
+               snprintf(mimeType, buf_size, "audio/x-flac");
+               break;
+       case MM_FILE_FORMAT_M2TS:
+               snprintf(mimeType, buf_size, "video/MP2T");
+               break;
+       case MM_FILE_FORMAT_M2PS:
+               snprintf(mimeType, buf_size, "video/MP2P");
+               break;
+       case MM_FILE_FORMAT_M1VIDEO:
+               snprintf(mimeType, buf_size, "video/mpeg");
+               break;
+       case MM_FILE_FORMAT_M1AUDIO:
+               snprintf(mimeType, buf_size, "audio/x-mpegaudio");
+               break;
+       default:
+               ret = -1;
+               break;
        }
 
        debug_msg(RELEASE, "id: %d, mimetype: %s\n", formatId, mimeType);
@@ -316,41 +316,41 @@ static int __get_fileformat(const char *urifilename, int *format)
                debug_msg(RELEASE, "search index = [%d]\n", index);
 
                switch (index) {
-                       case MM_FILE_FORMAT_QT:
-                       case MM_FILE_FORMAT_3GP:
-                       case MM_FILE_FORMAT_MP4:
-                               *format = MM_FILE_FORMAT_3GP;
-                               break;
+               case MM_FILE_FORMAT_QT:
+               case MM_FILE_FORMAT_3GP:
+               case MM_FILE_FORMAT_MP4:
+                       *format = MM_FILE_FORMAT_3GP;
+                       break;
 
-                       case MM_FILE_FORMAT_ASF:
-                       case MM_FILE_FORMAT_WMA:
-                       case MM_FILE_FORMAT_WMV:
-                               *format = MM_FILE_FORMAT_ASF;
-                               break;
+               case MM_FILE_FORMAT_ASF:
+               case MM_FILE_FORMAT_WMA:
+               case MM_FILE_FORMAT_WMV:
+                       *format = MM_FILE_FORMAT_ASF;
+                       break;
 
-                       case MM_FILE_FORMAT_DIVX:
-                       case MM_FILE_FORMAT_AVI:
-                               *format = MM_FILE_FORMAT_AVI;
-                               break;
+               case MM_FILE_FORMAT_DIVX:
+               case MM_FILE_FORMAT_AVI:
+                       *format = MM_FILE_FORMAT_AVI;
+                       break;
 
-                       case MM_FILE_FORMAT_MATROSKA:
-                       case MM_FILE_FORMAT_FLV:
-                       case MM_FILE_FORMAT_M2TS:
-                       case MM_FILE_FORMAT_M2PS:
-                       case MM_FILE_FORMAT_REAL:
-                       case MM_FILE_FORMAT_M1AUDIO:
-                       case MM_FILE_FORMAT_M1VIDEO:
-                               *format = index;
-                               break;
+               case MM_FILE_FORMAT_MATROSKA:
+               case MM_FILE_FORMAT_FLV:
+               case MM_FILE_FORMAT_M2TS:
+               case MM_FILE_FORMAT_M2PS:
+               case MM_FILE_FORMAT_REAL:
+               case MM_FILE_FORMAT_M1AUDIO:
+               case MM_FILE_FORMAT_M1VIDEO:
+                       *format = index;
+                       break;
 
-                       default: {
-                               *format = MM_FILE_FORMAT_NUM;
-                               debug_error(DEBUG, "error: not supported or invaild format enum[%d]\n", index);
-                               break;
-                       }
+               default: {
+                       *format = MM_FILE_FORMAT_NUM;
+                       debug_error(DEBUG, "error: not supported or invaild format enum[%d]\n", index);
+                       break;
+               }
                }
 
-               if (MMFileFunc[*format].Valid!= NULL && MMFileFunc[*format].Valid(fp, NULL, 0)) {
+               if (MMFileFunc[*format].Valid != NULL && MMFileFunc[*format].Valid(fp, NULL, 0)) {
                        goto FILE_FORMAT_SUCCESS;
                }
        }
@@ -517,7 +517,7 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bo
                        if (len < 0 && len != AVERROR(EAGAIN) && len != AVERROR_EOF) {
                                debug_warning(DEBUG, "Error while avcodec_receive_frame");
                        } else if (len >= 0) {
-                               if ((packet.flags & AV_PKT_FLAG_KEY) ) {
+                               if ((packet.flags & AV_PKT_FLAG_KEY)) {
 
                                        if (first_seek || !is_accurate) {
                                                /* This is first seeking or not accurate mode.
@@ -693,7 +693,7 @@ int mmfile_format_get_frame_from_memory(const void *data, unsigned int datasize,
        char *urifilename = NULL;
        AVFormatContext *pFormatCtx = NULL;
        AVInputFormat *grab_iformat = NULL;
-       AVIOContext              *pIOCtx = NULL;
+       AVIOContext *pIOCtx = NULL;
        MMFmemIOHandle *handle = NULL;
        uint8_t *avio_ctx_buffer = NULL;
 
@@ -748,7 +748,7 @@ int mmfile_format_get_frame_from_memory(const void *data, unsigned int datasize,
        }
 
        ret = _mmf_mem_open(&handle, urifilename);
-       if (ret !=MMFILE_IO_SUCCESS) {
+       if (ret != MMFILE_IO_SUCCESS) {
                debug_warning(DEBUG, "failed to _mmf_mem_open.\n");
                av_free(avio_ctx_buffer);
                ret = MMFILE_FORMAT_FAIL;
index 2a88348..1460753 100755 (executable)
 
 static unsigned char midiData[AV_MIDI_COUNT_MAX] ;
 static unsigned char midiHeader[MIDI_HEADER_LENGTH] = {0x4d, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x30, 0x4d, 0x54,
-                                                       0x72, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xff,
-                                                       0x59, 0x02, 0x00, 0x00, 0x00, 0xff, 0x51, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0xb0,
-                                                       0x07, 0x00, 0x00, 0x90
-                                                      };
+                                                                                                       0x72, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xff,
+                                                                                                       0x59, 0x02, 0x00, 0x00, 0x00, 0xff, 0x51, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0xb0,
+                                                                                                       0x07, 0x00, 0x00, 0x90
+                                                                                                       };
 
 
 static unsigned char noteTotal[AV_MIDI_COUNT_MAX];
@@ -55,7 +55,7 @@ static char octave[AV_MIDI_NOTE_MAX];
 static int durationSpec[AV_MIDI_NOTE_MAX];
 static int restSpec[AV_MIDI_NOTE_MAX];
 
-static         struct {
+static struct {
        char flat_sharp;
        char note;
        char duration;
@@ -245,11 +245,11 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
                tag_len = strlen(taginfo.title);
                cnv_len = 0;
                formatContext->title = mmfile_string_convert((const char *)taginfo.title,
-                                                            tag_len,
-                                                            "UTF-8",
-                                                            locale,
-                                                            NULL,
-                                                            (unsigned int *)&cnv_len);
+                                                                                               tag_len,
+                                                                                               "UTF-8",
+                                                                                               locale,
+                                                                                               NULL,
+                                                                                               (unsigned int *)&cnv_len);
 
                if (formatContext->title == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
@@ -262,11 +262,11 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
                tag_len = strlen(taginfo.composer);
                cnv_len = 0;
                formatContext->composer = mmfile_string_convert((const char *)taginfo.composer,
-                                                               tag_len,
-                                                               "UTF-8",
-                                                               locale,
-                                                               NULL,
-                                                               (unsigned int *)&cnv_len);
+                                                                                               tag_len,
+                                                                                               "UTF-8",
+                                                                                               locale,
+                                                                                               NULL,
+                                                                                               (unsigned int *)&cnv_len);
                if (formatContext->composer == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->composer = mmfile_strdup(taginfo.composer);
@@ -278,11 +278,11 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
                tag_len = strlen(taginfo.comment);
                cnv_len = 0;
                formatContext->comment = mmfile_string_convert((const char *)taginfo.comment,
-                                                              tag_len,
-                                                              "UTF-8",
-                                                              locale,
-                                                              NULL,
-                                                              (unsigned int *)&cnv_len);
+                                                                                               tag_len,
+                                                                                               "UTF-8",
+                                                                                               locale,
+                                                                                               NULL,
+                                                                                               (unsigned int *)&cnv_len);
                if (formatContext->comment == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->comment = mmfile_strdup(taginfo.comment);
@@ -294,11 +294,11 @@ int mmfile_format_read_tag_imy(MMFileFormatContext *formatContext)
                tag_len = strlen(taginfo.copyright);
                cnv_len = 0;
                formatContext->copyright = mmfile_string_convert((const char *)taginfo.copyright,
-                                                                tag_len,
-                                                                "UTF-8",
-                                                                locale,
-                                                                NULL,
-                                                                (unsigned int *)&cnv_len);
+                                                                                               tag_len,
+                                                                                               "UTF-8",
+                                                                                               locale,
+                                                                                               NULL,
+                                                                                               (unsigned int *)&cnv_len);
                if (formatContext->copyright == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->copyright = mmfile_strdup(taginfo.copyright);
@@ -677,73 +677,73 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
 
                if (Melody[number].flat_sharp == '#') {
                        switch (Melody[number].note) {
-                               case 'c':
-                                       noteData[number].note = octaveValue + 1;
-                                       break;
-                               case 'd':
-                                       noteData[number].note = octaveValue + 3;
-                                       break;
-                               case 'f':
-                                       noteData[number].note = octaveValue + 6;
-                                       break;
-                               case 'g':
-                                       noteData[number].note = octaveValue + 8;
-                                       break;
-                               case 'a':
-                                       noteData[number].note = octaveValue + 10;
-                                       break;
-                               default:
-                                       break;
+                       case 'c':
+                               noteData[number].note = octaveValue + 1;
+                               break;
+                       case 'd':
+                               noteData[number].note = octaveValue + 3;
+                               break;
+                       case 'f':
+                               noteData[number].note = octaveValue + 6;
+                               break;
+                       case 'g':
+                               noteData[number].note = octaveValue + 8;
+                               break;
+                       case 'a':
+                               noteData[number].note = octaveValue + 10;
+                               break;
+                       default:
+                               break;
                        }
                }
 
                else if (Melody[number].flat_sharp == '&') {
                        switch (Melody[number].note) {
-                               case 'd':
-                                       noteData[number].note = octaveValue + 1;
-                                       break;
-                               case 'e':
-                                       noteData[number].note = octaveValue + 3;
-                                       break;
-                               case 'g':
-                                       noteData[number].note = octaveValue + 6;
-                                       break;
-                               case 'a':
-                                       noteData[number].note = octaveValue + 8;
-                                       break;
-                               case 'b':
-                                       noteData[number].note = octaveValue + 10;
-                                       break;
-                               default:
-                                       break;
+                       case 'd':
+                               noteData[number].note = octaveValue + 1;
+                               break;
+                       case 'e':
+                               noteData[number].note = octaveValue + 3;
+                               break;
+                       case 'g':
+                               noteData[number].note = octaveValue + 6;
+                               break;
+                       case 'a':
+                               noteData[number].note = octaveValue + 8;
+                               break;
+                       case 'b':
+                               noteData[number].note = octaveValue + 10;
+                               break;
+                       default:
+                               break;
                        }
                }
 
                else {
                        switch (Melody[number].note) {
-                               case 'c':
-                                       noteData[number].note = octaveValue;
-                                       break;
-                               case 'd':
-                                       noteData[number].note = octaveValue + 2;
-                                       break;
-                               case 'e':
-                                       noteData[number].note = octaveValue + 4;
-                                       break;
-                               case 'f':
-                                       noteData[number].note = octaveValue + 5;
-                                       break;
-                               case 'g':
-                                       noteData[number].note = octaveValue + 7;
-                                       break;
-                               case 'a':
-                                       noteData[number].note = octaveValue + 9;
-                                       break;
-                               case 'b':
-                                       noteData[number].note = octaveValue + 11;
-                                       break;
-                               default:
-                                       break;
+                       case 'c':
+                               noteData[number].note = octaveValue;
+                               break;
+                       case 'd':
+                               noteData[number].note = octaveValue + 2;
+                               break;
+                       case 'e':
+                               noteData[number].note = octaveValue + 4;
+                               break;
+                       case 'f':
+                               noteData[number].note = octaveValue + 5;
+                               break;
+                       case 'g':
+                               noteData[number].note = octaveValue + 7;
+                               break;
+                       case 'a':
+                               noteData[number].note = octaveValue + 9;
+                               break;
+                       case 'b':
+                               noteData[number].note = octaveValue + 11;
+                               break;
+                       default:
+                               break;
                        }
                }
        }
@@ -755,133 +755,133 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
        for (number = 0; number < noteCount; number++) {
                if (style == '0') {
                        switch (Melody[number].duration) {
-                               case '0':
-                                       noteData[number].duration_on = 183;
-                                       noteData[number].duration_off = 9;
-                                       break;
-                               case '1':
-                                       noteData[number].duration_on = 91;
-                                       noteData[number].duration_off = 5;
-                                       break;
-                               case '2':
-                                       noteData[number].duration_on = 46;
-                                       noteData[number].duration_off = 2;
-                                       break;
-                               case '3':
-                                       noteData[number].duration_on = 23;
-                                       noteData[number].duration_off = 1;
-                                       break;
-                               case '4':
-                                       noteData[number].duration_on = 11;
-                                       noteData[number].duration_off = 1;
-                                       break;
-                               case '5':
-                                       noteData[number].duration_on = 5;
-                                       noteData[number].duration_off = 1;
-                                       break;
-                               default:
-                                       break;
+                       case '0':
+                               noteData[number].duration_on = 183;
+                               noteData[number].duration_off = 9;
+                               break;
+                       case '1':
+                               noteData[number].duration_on = 91;
+                               noteData[number].duration_off = 5;
+                               break;
+                       case '2':
+                               noteData[number].duration_on = 46;
+                               noteData[number].duration_off = 2;
+                               break;
+                       case '3':
+                               noteData[number].duration_on = 23;
+                               noteData[number].duration_off = 1;
+                               break;
+                       case '4':
+                               noteData[number].duration_on = 11;
+                               noteData[number].duration_off = 1;
+                               break;
+                       case '5':
+                               noteData[number].duration_on = 5;
+                               noteData[number].duration_off = 1;
+                               break;
+                       default:
+                               break;
                        }
                }
 
                else if (style == '1') {
                        switch (Melody[number].duration) {
-                               case '0':
-                                       noteData[number].duration_on = 192;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               case '1':
-                                       noteData[number].duration_on = 96;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               case '2':
-                                       noteData[number].duration_on = 48;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               case '3':
-                                       noteData[number].duration_on = 24;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               case '4':
-                                       noteData[number].duration_on = 12;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               case '5':
-                                       noteData[number].duration_on = 6;
-                                       noteData[number].duration_off = 0;
-                                       break;
-                               default:
-                                       break;
+                       case '0':
+                               noteData[number].duration_on = 192;
+                               noteData[number].duration_off = 0;
+                               break;
+                       case '1':
+                               noteData[number].duration_on = 96;
+                               noteData[number].duration_off = 0;
+                               break;
+                       case '2':
+                               noteData[number].duration_on = 48;
+                               noteData[number].duration_off = 0;
+                               break;
+                       case '3':
+                               noteData[number].duration_on = 24;
+                               noteData[number].duration_off = 0;
+                               break;
+                       case '4':
+                               noteData[number].duration_on = 12;
+                               noteData[number].duration_off = 0;
+                               break;
+                       case '5':
+                               noteData[number].duration_on = 6;
+                               noteData[number].duration_off = 0;
+                               break;
+                       default:
+                               break;
                        }
                }
 
                else {
                        switch (Melody[number].duration) {
-                               case '0':
-                                       noteData[number].duration_on = 96;
-                                       noteData[number].duration_off = 96;
-                                       break;
-                               case '1':
-                                       noteData[number].duration_on = 48;
-                                       noteData[number].duration_off = 48;
-                                       break;
-                               case '2':
-                                       noteData[number].duration_on = 24;
-                                       noteData[number].duration_off = 24;
-                                       break;
-                               case '3':
-                                       noteData[number].duration_on = 12;
-                                       noteData[number].duration_off = 12;
-                                       break;
-                               case '4':
-                                       noteData[number].duration_on = 6;
-                                       noteData[number].duration_off = 6;
-                                       break;
-                               case '5':
-                                       noteData[number].duration_on = 3;
-                                       noteData[number].duration_off = 3;
-                                       break;
-                               default:
-                                       break;
-                       }
-               }
-
-               switch (Melody[number].duration) {
                        case '0':
-                               durationSpec[number] = 192;
+                               noteData[number].duration_on = 96;
+                               noteData[number].duration_off = 96;
                                break;
                        case '1':
-                               durationSpec[number] = 96;
+                               noteData[number].duration_on = 48;
+                               noteData[number].duration_off = 48;
                                break;
                        case '2':
-                               durationSpec[number] = 48;
+                               noteData[number].duration_on = 24;
+                               noteData[number].duration_off = 24;
                                break;
                        case '3':
-                               durationSpec[number] = 24;
+                               noteData[number].duration_on = 12;
+                               noteData[number].duration_off = 12;
                                break;
                        case '4':
-                               durationSpec[number] = 12;
+                               noteData[number].duration_on = 6;
+                               noteData[number].duration_off = 6;
                                break;
                        case '5':
-                               durationSpec[number] = 6;
+                               noteData[number].duration_on = 3;
+                               noteData[number].duration_off = 3;
                                break;
                        default:
                                break;
+                       }
+               }
+
+               switch (Melody[number].duration) {
+               case '0':
+                       durationSpec[number] = 192;
+                       break;
+               case '1':
+                       durationSpec[number] = 96;
+                       break;
+               case '2':
+                       durationSpec[number] = 48;
+                       break;
+               case '3':
+                       durationSpec[number] = 24;
+                       break;
+               case '4':
+                       durationSpec[number] = 12;
+                       break;
+               case '5':
+                       durationSpec[number] = 6;
+                       break;
+               default:
+                       break;
                }
 
                if (Melody[number].duration_specifier != '%') {
                        switch (Melody[number].duration_specifier) {
-                               case '.':
-                                       noteData[number].duration_on += (durationSpec[number] / 2);
-                                       break;
-                               case ':':
-                                       noteData[number].duration_on += durationSpec[number];
-                                       break;
-                               case ';':
-                                       noteData[number].duration_on -= (durationSpec[number] / 3);
-                                       break;
-                               default:
-                                       break;
+                       case '.':
+                               noteData[number].duration_on += (durationSpec[number] / 2);
+                               break;
+                       case ':':
+                               noteData[number].duration_on += durationSpec[number];
+                               break;
+                       case ';':
+                               noteData[number].duration_on -= (durationSpec[number] / 3);
+                               break;
+                       default:
+                               break;
                        }
 
                        if (noteData[number].duration_on > MIDI_MAX)
@@ -892,101 +892,101 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
        for (number = 1; number < noteCount; number++) {
                if (Melody[number].rest >= '0' && Melody[number].rest <= '5') {
                        switch (Melody[number].rest) {
-                               case '0':
-                                       noteData[number - 1].duration_off += 192;
-                                       restSpec[number] = 192;
-                                       break;
-                               case '1':
-                                       noteData[number - 1].duration_off += 96;
-                                       restSpec[number] = 96;
-                                       break;
-                               case '2':
-                                       noteData[number - 1].duration_off += 48;
-                                       restSpec[number] = 48;
-                                       break;
-                               case '3':
-                                       noteData[number - 1].duration_off += 24;
-                                       restSpec[number] = 24;
-                                       break;
-                               case '4':
-                                       noteData[number - 1].duration_off += 12;
-                                       restSpec[number] = 12;
-                                       break;
-                               case '5':
-                                       noteData[number - 1].duration_off += 6;
-                                       restSpec[number] = 6;
-                                       break;
-                               default:
-                                       break;
-                       }
-
-                       if (noteData[number - 1].duration_off > MIDI_MAX && Melody[number].rest_specifier == '%')
-                               noteData[number - 1].duration_off = MIDI_LIMIT;
-               }
-
-               if (Melody[number].rest_specifier != '%') {
-                       switch (Melody[number].rest_specifier) {
-                               case '.':
-                                       noteData[number - 1].duration_off += (restSpec[number] / 2);
-                                       break;
-                               case ':':
-                                       noteData[number - 1].duration_off += restSpec[number];
-                                       break;
-                               case ';':
-                                       noteData[number - 1].duration_off -= (restSpec[number] / 3);
-                                       break;
-                               default:
-                                       break;
-                       }
-
-                       if (noteData[number - 1].duration_off > MIDI_MAX)
-                               noteData[number - 1].duration_off = MIDI_LIMIT;
-               }
-       }
-
-       if (Melody[0].rest >= '0' && Melody[0].rest <= '5') {
-               switch (Melody[0].rest) {
                        case '0':
-                               midiData[50] += 192;
-                               restSpec[0] = 192;
+                               noteData[number - 1].duration_off += 192;
+                               restSpec[number] = 192;
                                break;
                        case '1':
-                               midiData[50] += 96;
-                               restSpec[0] = 96;
+                               noteData[number - 1].duration_off += 96;
+                               restSpec[number] = 96;
                                break;
                        case '2':
-                               midiData[50] += 48;
-                               restSpec[0] = 48;
+                               noteData[number - 1].duration_off += 48;
+                               restSpec[number] = 48;
                                break;
                        case '3':
-                               midiData[50] += 24;
-                               restSpec[0] = 24;
+                               noteData[number - 1].duration_off += 24;
+                               restSpec[number] = 24;
                                break;
                        case '4':
-                               midiData[50] += 12;
-                               restSpec[0] = 12;
+                               noteData[number - 1].duration_off += 12;
+                               restSpec[number] = 12;
                                break;
                        case '5':
-                               midiData[50] += 6;
-                               restSpec[0] = 6;
+                               noteData[number - 1].duration_off += 6;
+                               restSpec[number] = 6;
+                               break;
+                       default:
+                               break;
+                       }
+
+                       if (noteData[number - 1].duration_off > MIDI_MAX && Melody[number].rest_specifier == '%')
+                               noteData[number - 1].duration_off = MIDI_LIMIT;
+               }
+
+               if (Melody[number].rest_specifier != '%') {
+                       switch (Melody[number].rest_specifier) {
+                       case '.':
+                               noteData[number - 1].duration_off += (restSpec[number] / 2);
+                               break;
+                       case ':':
+                               noteData[number - 1].duration_off += restSpec[number];
+                               break;
+                       case ';':
+                               noteData[number - 1].duration_off -= (restSpec[number] / 3);
                                break;
                        default:
                                break;
+                       }
+
+                       if (noteData[number - 1].duration_off > MIDI_MAX)
+                               noteData[number - 1].duration_off = MIDI_LIMIT;
+               }
+       }
+
+       if (Melody[0].rest >= '0' && Melody[0].rest <= '5') {
+               switch (Melody[0].rest) {
+               case '0':
+                       midiData[50] += 192;
+                       restSpec[0] = 192;
+                       break;
+               case '1':
+                       midiData[50] += 96;
+                       restSpec[0] = 96;
+                       break;
+               case '2':
+                       midiData[50] += 48;
+                       restSpec[0] = 48;
+                       break;
+               case '3':
+                       midiData[50] += 24;
+                       restSpec[0] = 24;
+                       break;
+               case '4':
+                       midiData[50] += 12;
+                       restSpec[0] = 12;
+                       break;
+               case '5':
+                       midiData[50] += 6;
+                       restSpec[0] = 6;
+                       break;
+               default:
+                       break;
                }
 
                if (Melody[0].rest_specifier != '%') {
                        switch (Melody[0].rest_specifier) {
-                               case '.':
-                                       midiData[50] += (restSpec[0] / 2);
-                                       break;
-                               case ':':
-                                       midiData[50] += restSpec[0];
-                                       break;
-                               case ';':
-                                       midiData[50] -= (restSpec[0] / 3);
-                                       break;
-                               default:
-                                       break;
+                       case '.':
+                               midiData[50] += (restSpec[0] / 2);
+                               break;
+                       case ':':
+                               midiData[50] += restSpec[0];
+                               break;
+                       case ';':
+                               midiData[50] -= (restSpec[0] / 3);
+                               break;
+                       default:
+                               break;
                        }
                }
 
@@ -1026,14 +1026,14 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
                        noteTotal[1] = 84 - VOL_INTERVAL;
 
                switch (Melody[number].vol) {
-                       case '+':
-                               noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] + VOL_INTERVAL;
-                               break;
-                       case '-':
-                               noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] - VOL_INTERVAL;
-                               break;
-                       default:
-                               break;
+               case '+':
+                       noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] + VOL_INTERVAL;
+                       break;
+               case '-':
+                       noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] - VOL_INTERVAL;
+                       break;
+               default:
+                       break;
                }
 
                if (noteTotal[6 * number + 1] > MIDI_LIMIT)
@@ -1137,206 +1137,206 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
 
                        if (Melody[number].flat_sharp == '#') {
                                switch (Melody[number].note) {
-                                       case 'c':
-                                               noteData[number].note = octaveValue + 1;
-                                               break;
-                                       case 'd':
-                                               noteData[number].note = octaveValue + 3;
-                                               break;
-                                       case 'f':
-                                               noteData[number].note = octaveValue + 6;
-                                               break;
-                                       case 'g':
-                                               noteData[number].note = octaveValue + 8;
-                                               break;
-                                       case 'a':
-                                               noteData[number].note = octaveValue + 10;
-                                               break;
-                                       default:
-                                               break;
+                               case 'c':
+                                       noteData[number].note = octaveValue + 1;
+                                       break;
+                               case 'd':
+                                       noteData[number].note = octaveValue + 3;
+                                       break;
+                               case 'f':
+                                       noteData[number].note = octaveValue + 6;
+                                       break;
+                               case 'g':
+                                       noteData[number].note = octaveValue + 8;
+                                       break;
+                               case 'a':
+                                       noteData[number].note = octaveValue + 10;
+                                       break;
+                               default:
+                                       break;
                                }
                        }
 
                        else if (Melody[number].flat_sharp == '&') {
                                switch (Melody[number].note) {
-                                       case 'd':
-                                               noteData[number].note = octaveValue + 1;
-                                               break;
-                                       case 'e':
-                                               noteData[number].note = octaveValue + 3;
-                                               break;
-                                       case 'g':
-                                               noteData[number].note = octaveValue + 6;
-                                               break;
-                                       case 'a':
-                                               noteData[number].note = octaveValue + 8;
-                                               break;
-                                       case 'b':
-                                               noteData[number].note = octaveValue + 10;
-                                               break;
-                                       default:
-                                               break;
+                               case 'd':
+                                       noteData[number].note = octaveValue + 1;
+                                       break;
+                               case 'e':
+                                       noteData[number].note = octaveValue + 3;
+                                       break;
+                               case 'g':
+                                       noteData[number].note = octaveValue + 6;
+                                       break;
+                               case 'a':
+                                       noteData[number].note = octaveValue + 8;
+                                       break;
+                               case 'b':
+                                       noteData[number].note = octaveValue + 10;
+                                       break;
+                               default:
+                                       break;
                                }
                        }
 
                        else {
                                switch (Melody[number].note) {
-                                       case 'c':
-                                               noteData[number].note = octaveValue;
-                                               break;
-                                       case 'd':
-                                               noteData[number].note = octaveValue + 2;
-                                               break;
-                                       case 'e':
-                                               noteData[number].note = octaveValue + 4;
-                                               break;
-                                       case 'f':
-                                               noteData[number].note = octaveValue + 5;
-                                               break;
-                                       case 'g':
-                                               noteData[number].note = octaveValue + 7;
-                                               break;
-                                       case 'a':
-                                               noteData[number].note = octaveValue + 9;
-                                               break;
-                                       case 'b':
-                                               noteData[number].note = octaveValue + 11;
-                                               break;
-                                       default:
-                                               break;
+                               case 'c':
+                                       noteData[number].note = octaveValue;
+                                       break;
+                               case 'd':
+                                       noteData[number].note = octaveValue + 2;
+                                       break;
+                               case 'e':
+                                       noteData[number].note = octaveValue + 4;
+                                       break;
+                               case 'f':
+                                       noteData[number].note = octaveValue + 5;
+                                       break;
+                               case 'g':
+                                       noteData[number].note = octaveValue + 7;
+                                       break;
+                               case 'a':
+                                       noteData[number].note = octaveValue + 9;
+                                       break;
+                               case 'b':
+                                       noteData[number].note = octaveValue + 11;
+                                       break;
+                               default:
+                                       break;
                                }
                        }
 
 
                        if (style == '0') {
                                switch (Melody[number].duration) {
-                                       case '0':
-                                               noteData[number].duration_on = 183;
-                                               noteData[number].duration_off = 9;
-                                               break;
-                                       case '1':
-                                               noteData[number].duration_on = 91;
-                                               noteData[number].duration_off = 5;
-                                               break;
-                                       case '2':
-                                               noteData[number].duration_on = 46;
-                                               noteData[number].duration_off = 2;
-                                               break;
-                                       case '3':
-                                               noteData[number].duration_on = 23;
-                                               noteData[number].duration_off = 1;
-                                               break;
-                                       case '4':
-                                               noteData[number].duration_on = 11;
-                                               noteData[number].duration_off = 1;
-                                               break;
-                                       case '5':
-                                               noteData[number].duration_on = 5;
-                                               noteData[number].duration_off = 1;
-                                               break;
-                                       default:
-                                               break;
+                               case '0':
+                                       noteData[number].duration_on = 183;
+                                       noteData[number].duration_off = 9;
+                                       break;
+                               case '1':
+                                       noteData[number].duration_on = 91;
+                                       noteData[number].duration_off = 5;
+                                       break;
+                               case '2':
+                                       noteData[number].duration_on = 46;
+                                       noteData[number].duration_off = 2;
+                                       break;
+                               case '3':
+                                       noteData[number].duration_on = 23;
+                                       noteData[number].duration_off = 1;
+                                       break;
+                               case '4':
+                                       noteData[number].duration_on = 11;
+                                       noteData[number].duration_off = 1;
+                                       break;
+                               case '5':
+                                       noteData[number].duration_on = 5;
+                                       noteData[number].duration_off = 1;
+                                       break;
+                               default:
+                                       break;
                                }
                        }
 
                        else if (style == '1') {
                                switch (Melody[number].duration) {
-                                       case '0':
-                                               noteData[number].duration_on = 192;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       case '1':
-                                               noteData[number].duration_on = 96;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       case '2':
-                                               noteData[number].duration_on = 48;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       case '3':
-                                               noteData[number].duration_on = 24;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       case '4':
-                                               noteData[number].duration_on = 12;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       case '5':
-                                               noteData[number].duration_on = 6;
-                                               noteData[number].duration_off = 0;
-                                               break;
-                                       default:
-                                               break;
+                               case '0':
+                                       noteData[number].duration_on = 192;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               case '1':
+                                       noteData[number].duration_on = 96;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               case '2':
+                                       noteData[number].duration_on = 48;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               case '3':
+                                       noteData[number].duration_on = 24;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               case '4':
+                                       noteData[number].duration_on = 12;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               case '5':
+                                       noteData[number].duration_on = 6;
+                                       noteData[number].duration_off = 0;
+                                       break;
+                               default:
+                                       break;
                                }
                        }
 
                        else {
                                switch (Melody[number].duration) {
-                                       case '0':
-                                               noteData[number].duration_on = 96;
-                                               noteData[number].duration_off = 96;
-                                               break;
-                                       case '1':
-                                               noteData[number].duration_on = 48;
-                                               noteData[number].duration_off = 48;
-                                               break;
-                                       case '2':
-                                               noteData[number].duration_on = 24;
-                                               noteData[number].duration_off = 24;
-                                               break;
-                                       case '3':
-                                               noteData[number].duration_on = 12;
-                                               noteData[number].duration_off = 12;
-                                               break;
-                                       case '4':
-                                               noteData[number].duration_on = 6;
-                                               noteData[number].duration_off = 6;
-                                               break;
-                                       case '5':
-                                               noteData[number].duration_on = 3;
-                                               noteData[number].duration_off = 3;
-                                               break;
-                                       default:
-                                               break;
-                               }
-                       }
-
-                       switch (Melody[number].duration) {
                                case '0':
-                                       durationSpec[number] = 192;
+                                       noteData[number].duration_on = 96;
+                                       noteData[number].duration_off = 96;
                                        break;
                                case '1':
-                                       durationSpec[number] = 96;
+                                       noteData[number].duration_on = 48;
+                                       noteData[number].duration_off = 48;
                                        break;
                                case '2':
-                                       durationSpec[number] = 48;
+                                       noteData[number].duration_on = 24;
+                                       noteData[number].duration_off = 24;
                                        break;
                                case '3':
-                                       durationSpec[number] = 24;
+                                       noteData[number].duration_on = 12;
+                                       noteData[number].duration_off = 12;
                                        break;
                                case '4':
-                                       durationSpec[number] = 12;
+                                       noteData[number].duration_on = 6;
+                                       noteData[number].duration_off = 6;
                                        break;
                                case '5':
-                                       durationSpec[number] = 6;
+                                       noteData[number].duration_on = 3;
+                                       noteData[number].duration_off = 3;
                                        break;
                                default:
                                        break;
+                               }
+                       }
+
+                       switch (Melody[number].duration) {
+                       case '0':
+                               durationSpec[number] = 192;
+                               break;
+                       case '1':
+                               durationSpec[number] = 96;
+                               break;
+                       case '2':
+                               durationSpec[number] = 48;
+                               break;
+                       case '3':
+                               durationSpec[number] = 24;
+                               break;
+                       case '4':
+                               durationSpec[number] = 12;
+                               break;
+                       case '5':
+                               durationSpec[number] = 6;
+                               break;
+                       default:
+                               break;
                        }
 
                        if (Melody[number].duration_specifier != '%') {
                                switch (Melody[number].duration_specifier) {
-                                       case '.':
-                                               noteData[number].duration_on += (durationSpec[number] / 2);
-                                               break;
-                                       case ':':
-                                               noteData[number].duration_on += durationSpec[number];
-                                               break;
-                                       case ';':
-                                               noteData[number].duration_on -= (durationSpec[number] / 3);
-                                               break;
-                                       default:
-                                               break;
+                               case '.':
+                                       noteData[number].duration_on += (durationSpec[number] / 2);
+                                       break;
+                               case ':':
+                                       noteData[number].duration_on += durationSpec[number];
+                                       break;
+                               case ';':
+                                       noteData[number].duration_on -= (durationSpec[number] / 3);
+                                       break;
+                               default:
+                                       break;
                                }
 
                                if (noteData[number].duration_on > MIDI_MAX)
@@ -1347,32 +1347,32 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
                for (number = count + 1; number < noteCount && number < AV_MIDI_NOTE_MAX; number++) {
                        if (Melody[number].rest >= '0' && Melody[number].rest <= '5') {
                                switch (Melody[number].rest) {
-                                       case '0':
-                                               noteData[number - 1].duration_off += 192;
-                                               restSpec[number] = 192;
-                                               break;
-                                       case '1':
-                                               noteData[number - 1].duration_off += 96;
-                                               restSpec[number] = 96;
-                                               break;
-                                       case '2':
-                                               noteData[number - 1].duration_off += 48;
-                                               restSpec[number] = 48;
-                                               break;
-                                       case '3':
-                                               noteData[number - 1].duration_off += 24;
-                                               restSpec[number] = 24;
-                                               break;
-                                       case '4':
-                                               noteData[number - 1].duration_off += 12;
-                                               restSpec[number] = 12;
-                                               break;
-                                       case '5':
-                                               noteData[number - 1].duration_off += 6;
-                                               restSpec[number] = 6;
-                                               break;
-                                       default:
-                                               break;
+                               case '0':
+                                       noteData[number - 1].duration_off += 192;
+                                       restSpec[number] = 192;
+                                       break;
+                               case '1':
+                                       noteData[number - 1].duration_off += 96;
+                                       restSpec[number] = 96;
+                                       break;
+                               case '2':
+                                       noteData[number - 1].duration_off += 48;
+                                       restSpec[number] = 48;
+                                       break;
+                               case '3':
+                                       noteData[number - 1].duration_off += 24;
+                                       restSpec[number] = 24;
+                                       break;
+                               case '4':
+                                       noteData[number - 1].duration_off += 12;
+                                       restSpec[number] = 12;
+                                       break;
+                               case '5':
+                                       noteData[number - 1].duration_off += 6;
+                                       restSpec[number] = 6;
+                                       break;
+                               default:
+                                       break;
                                }
 
                                if (noteData[number - 1].duration_off > MIDI_MAX && Melody[number].rest_specifier == '%')
@@ -1381,17 +1381,17 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
 
                        if (Melody[number].rest_specifier != '%') {
                                switch (Melody[number].rest_specifier) {
-                                       case '.':
-                                               noteData[number - 1].duration_off += (restSpec[number] / 2);
-                                               break;
-                                       case ':':
-                                               noteData[number - 1].duration_off += restSpec[number];
-                                               break;
-                                       case ';':
-                                               noteData[number - 1].duration_off -= (restSpec[number] / 3);
-                                               break;
-                                       default:
-                                               break;
+                               case '.':
+                                       noteData[number - 1].duration_off += (restSpec[number] / 2);
+                                       break;
+                               case ':':
+                                       noteData[number - 1].duration_off += restSpec[number];
+                                       break;
+                               case ';':
+                                       noteData[number - 1].duration_off -= (restSpec[number] / 3);
+                                       break;
+                               default:
+                                       break;
                                }
 
                                if (noteData[number - 1].duration_off > MIDI_MAX)
@@ -1401,47 +1401,47 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
 
                if (Melody[count].rest >= '0' && Melody[count].rest <= '5') {
                        switch (Melody[count].rest) {
-                               case '0':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 192;
-                                       restSpec[count] = 192;
-                                       break;
-                               case '1':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 96;
-                                       restSpec[count] = 96;
-                                       break;
-                               case '2':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 48;
-                                       restSpec[count] = 48;
-                                       break;
-                               case '3':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 24;
-                                       restSpec[count] = 24;
+                       case '0':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 192;
+                               restSpec[count] = 192;
+                               break;
+                       case '1':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 96;
+                               restSpec[count] = 96;
+                               break;
+                       case '2':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 48;
+                               restSpec[count] = 48;
+                               break;
+                       case '3':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 24;
+                               restSpec[count] = 24;
+                               break;
+                       case '4':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 12;
+                               restSpec[count] = 12;
+                               break;
+                       case '5':
+                               midiData[52 + (6 * count * (repeat + 1) - 1)] += 6;
+                               restSpec[count] = 6;
+                               break;
+                       default:
+                               break;
+                       }
+
+                       if (Melody[count].rest_specifier != '%') {
+                               switch (Melody[count].rest_specifier) {
+                               case '.':
+                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += (restSpec[count] / 2);
                                        break;
-                               case '4':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 12;
-                                       restSpec[count] = 12;
+                               case ':':
+                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += restSpec[count];
                                        break;
-                               case '5':
-                                       midiData[52 + (6 * count * (repeat + 1) - 1)] += 6;
-                                       restSpec[count] = 6;
+                               case ';':
+                                       midiData[52 + (6 * count * (repeat + 1) - 1)] -= (restSpec[count] / 3);
                                        break;
                                default:
                                        break;
-                       }
-
-                       if (Melody[count].rest_specifier != '%') {
-                               switch (Melody[count].rest_specifier) {
-                                       case '.':
-                                               midiData[52 + (6 * count * (repeat + 1) - 1)] += (restSpec[count] / 2);
-                                               break;
-                                       case ':':
-                                               midiData[52 + (6 * count * (repeat + 1) - 1)] += restSpec[count];
-                                               break;
-                                       case ';':
-                                               midiData[52 + (6 * count * (repeat + 1) - 1)] -= (restSpec[count] / 3);
-                                               break;
-                                       default:
-                                               break;
                                }
                        }
 
@@ -1487,14 +1487,14 @@ __AvConvertIMelody2MIDI(char *pMelodyBuf, unsigned int *pBufLen)
                                noteTotal[6 * count + 1] = MIDI_LIMIT;
 
                        switch (Melody[number].vol) {
-                               case '+':
-                                       noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] + VOL_INTERVAL;
-                                       break;
-                               case '-':
-                                       noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] - VOL_INTERVAL;
-                                       break;
-                               default:
-                                       break;
+                       case '+':
+                               noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] + VOL_INTERVAL;
+                               break;
+                       case '-':
+                               noteTotal[6 * number + 1] = noteTotal[6 * (number - 1) + 1] - VOL_INTERVAL;
+                               break;
+                       default:
+                               break;
                        }
 
                        if (noteTotal[6 * number + 1] > MIDI_LIMIT)
@@ -1568,62 +1568,62 @@ __AvMIDISetVolume(char *pMelodyBuf)
                        pMelodyBuf++;
 
                        switch (*pMelodyBuf) {
-                               case '0':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '1':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '2':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '3':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '4':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '5':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               default:
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
+                       case '0':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '1':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '2':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '3':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '4':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '5':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       default:
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
                        }
                }
 
                else
                        switch (*pMelodyBuf) {
-                               case '0':
-                                       midiVol = 0;
-                                       break;
-                               case '2':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '3':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '4':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '5':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '6':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '7':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '8':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               case '9':
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
-                               default:
-                                       midiVol = AV_MIDI_VOL_MAX;
-                                       break;
+                       case '0':
+                               midiVol = 0;
+                               break;
+                       case '2':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '3':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '4':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '5':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '6':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '7':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '8':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       case '9':
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
+                       default:
+                               midiVol = AV_MIDI_VOL_MAX;
+                               break;
                        }
        }
 
index fafc988..bc944f5 100755 (executable)
@@ -50,12 +50,12 @@ enum {
 #define        AvSMW_CNVID_HVS                         (9)             /* HV Script */
 #define        AvSMW_CNVID_WAV                         (11)    /* WAVE */
 
-#define AvSMW_SUCCESS                          (0)             /* success                                                              */
+#define AvSMW_SUCCESS                          (0)             /* success                                                              */
 #define AvSMW_ERROR                                    (-1)    /* error                                                                */
 #define AvSMW_ERROR_ARGUMENT           (-2)    /* error of arguments                                   */
 #define AvSMW_ERROR_RESOURCE_OVER      (-3)    /* over specified resources                             */
-#define AvSMW_ERROR_ID                         (-4)    /* error id number                                              */
-#define AvSMW_ERROR_TIMEOUT                    (-5)    /* timeout                                                              */
+#define AvSMW_ERROR_ID                         (-4)    /* error id number                                              */
+#define AvSMW_ERROR_TIMEOUT                    (-5)    /* timeout                                                              */
 #define AvSMW_ERROR_SOFTRESET          (-6)    /* error of soft reset for MA-5                 */
 
 #define AvSMW_ERROR_FILE                       (-16)   /* file error                                                   */
@@ -63,9 +63,9 @@ enum {
 #define AvSMW_ERROR_CONTENTS_TYPE      (-18)   /* SMAF Contents Type shows can't play  */
 #define AvSMW_ERROR_CHUNK_SIZE         (-19)   /* illegal SAvF Chunk Size value                */
 #define AvSMW_ERROR_CHUNK                      (-20)   /* illegal SAvF Track Chunk value               */
-#define AvSMW_ERROR_UNMATCHED_TAG      (-21)   /* unmathced specified TAG                              */
-#define AvSMW_ERROR_SHORT_LENGTH       (-22)   /* short sequence                                               */
-#define AvSMW_ERROR_LONG_LENGTH                (-23)   /* long sequence                                                */
+#define AvSMW_ERROR_UNMATCHED_TAG      (-21)   /* unmathced specified TAG                              */
+#define AvSMW_ERROR_SHORT_LENGTH       (-22)   /* short sequence                                               */
+#define AvSMW_ERROR_LONG_LENGTH                (-23)   /* long sequence                                                */
 #define        AvSMW_ERROR_UNSUPPORTED         (-24)   /* unsupported format                                   */
 #define AvSMW_ERROR_NO_INFORMATION     (-25)   /* no specified information                             */
 #define AvSMW_ERROR_HV_CONFLICT                (-26)   /* conflict about HV resource                   */
@@ -78,13 +78,13 @@ enum {
 
 #define SINT   signed int
 #define SINT8  signed char
-#define SINT16         signed short
-#define SINT32         signed long
+#define SINT16 signed short
+#define SINT32 signed long
 #define UINT   unsigned int
-#define UINT8  unsigned char
+#define UINT8  unsigned char
 #define UINT16 unsigned short
-#define UINT32         unsigned long
-#define ULONG  unsigned long
+#define UINT32 unsigned long
+#define ULONG  unsigned long
 
 /*--------------------------------------------------------------------------*/
 /*   Defines                                                                */
@@ -365,12 +365,7 @@ int mmfile_format_read_tag_mid(MMFileFormatContext *formatContext)
        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_string_convert((const char *)info->title, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
                if (formatContext->title == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->title = mmfile_strdup(info->title);
@@ -380,12 +375,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_string_convert((const char *)info->copyright, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
                if (formatContext->copyright == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->copyright = mmfile_strdup(info->copyright);
@@ -395,12 +385,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_string_convert((const char *)info->comment, tag_len, "UTF-8", locale, NULL, (unsigned int *)&cnv_len);
                if (formatContext->comment == NULL) {
                        debug_warning(DEBUG, "failed to UTF8 convert.\n");
                        formatContext->comment = mmfile_strdup(info->comment);
@@ -562,8 +547,8 @@ __AvGetMidiDuration(char *szFileName, MIDI_INFO_SIMPLE *info)
 
        /*check format*/
        if (!(memcmp(pbFile, MMFILE_XMF_100, 8)) ||
-           !(memcmp(pbFile, MMFILE_XMF_101, 8)) ||
-           !(memcmp(pbFile, MMFILE_MXMF_200, 8))) {
+               !(memcmp(pbFile, MMFILE_XMF_101, 8)) ||
+               !(memcmp(pbFile, MMFILE_MXMF_200, 8))) {
 
                is_xmf = 1;
                codecType = AV_DEC_AUDIO_XMF;
@@ -970,7 +955,7 @@ __AvGetSizeOfFileInfo(PMIDINFO pI)
        UINT32          sdTotalTicks;
        SINT32          sdCurrentTime;
        SINT32          sdDelta;
-       PMIDCHINFO      pCh;
+       PMIDCHINFO      pCh;
        UINT32          dCh;
 
        UINT32          dSetup;                 /* bit0:beat@0, bit1:tempo@0, bit2:GmOn@0, bit3:tempo@1 */
@@ -1058,197 +1043,197 @@ __AvGetSizeOfFileInfo(PMIDINFO pI)
                        dCh = dCmd & 0x0f;
 
                        switch (dCmd & 0xf0) {
-                               case 0x90:      /* NoteOn */
-                                       /* Conductor Track Note Check */
-                                       if (sdTr == 0) dConductorNote |= 1;
-                                       switch (dCurrBank[dCh] >> 8) {
-                                               case 0x79:
-                                                       /* Melody */
-                                                       break;
-
-                                               case 0x78:
-                                                       /* Drum */
-                                                       pI->bVoiceMap[DRUM_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
-                                                       break;
-
-                                               default:
-                                                       if (dCh == 9) {
-                                                               /* Unknown: default GM Drum */
-                                                               pI->bVoiceMap[DRUM_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
-                                                       }
-                                       }
-                                       pMt->dOffset += 2;
+                       case 0x90:      /* NoteOn */
+                               /* Conductor Track Note Check */
+                               if (sdTr == 0) dConductorNote |= 1;
+                               switch (dCurrBank[dCh] >> 8) {
+                               case 0x79:
+                                       /* Melody */
                                        break;
 
-                               case 0xC0:      /* Program change */
-                                       switch (dBank[dCh] >> 8) {
-                                               case 0x79:
-                                                       if (dBank[dCh] != 0x7906) {
-                                                               /* Melody */
-                                                               pI->bVoiceMap[MELODY_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
-                                                       } else {
-                                                               /* Vibration Note */
-                                                               pI->dVibNoteVoice = 1;
-                                                       }
-                                                       break;
-
-                                               case 0x78:
-                                                       /* Drum */
-                                                       break;
+                               case 0x78:
+                                       /* Drum */
+                                       pI->bVoiceMap[DRUM_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
+                                       break;
 
-                                               default:
-                                                       /* default GM Melody */
-                                                       if (dCh != 9) {
-                                                               pI->bVoiceMap[MELODY_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
-                                                       }
+                               default:
+                                       if (dCh == 9) {
+                                               /* Unknown: default GM Drum */
+                                               pI->bVoiceMap[DRUM_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
+                                       }
+                               }
+                               pMt->dOffset += 2;
+                               break;
+
+                       case 0xC0:      /* Program change */
+                               switch (dBank[dCh] >> 8) {
+                               case 0x79:
+                                       if (dBank[dCh] != 0x7906) {
+                                               /* Melody */
+                                               pI->bVoiceMap[MELODY_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
+                                       } else {
+                                               /* Vibration Note */
+                                               pI->dVibNoteVoice = 1;
                                        }
-
-                                       dCurrBank[dCh] = dBank[dCh];
-                                       pMt->dOffset++;
                                        break;
 
-                               case 0xD0:      /* Channel pressure */
-                                       pMt->dOffset++;
+                               case 0x78:
+                                       /* Drum */
                                        break;
 
-                               case 0xB0:      /* Control Change */
-                                       switch (pMt->pbBase[pMt->dOffset]) {
-                                               case 0x00:      /* Bank select(MSB) */
-                                                       dBank[dCh] = (dBank[dCh] & 0x00FF) | (pMt->pbBase[pMt->dOffset + 1] << 8);
-                                                       break;
-
-                                               case 0x20:      /* Bank select (LSB) */
-                                                       dBank[dCh] = (dBank[dCh] & 0xFF00) | pMt->pbBase[pMt->dOffset + 1];
-                                                       break;
-                                               default:
-                                                       break;
+                               default:
+                                       /* default GM Melody */
+                                       if (dCh != 9) {
+                                               pI->bVoiceMap[MELODY_MAP][pMt->pbBase[pMt->dOffset] & 0x7F] = 1;
                                        }
-                                       pMt->dOffset += 2;
+                               }
+
+                               dCurrBank[dCh] = dBank[dCh];
+                               pMt->dOffset++;
+                               break;
+
+                       case 0xD0:      /* Channel pressure */
+                               pMt->dOffset++;
+                               break;
+
+                       case 0xB0:      /* Control Change */
+                               switch (pMt->pbBase[pMt->dOffset]) {
+                               case 0x00:      /* Bank select(MSB) */
+                                       dBank[dCh] = (dBank[dCh] & 0x00FF) | (pMt->pbBase[pMt->dOffset + 1] << 8);
                                        break;
 
+                               case 0x20:      /* Bank select (LSB) */
+                                       dBank[dCh] = (dBank[dCh] & 0xFF00) | pMt->pbBase[pMt->dOffset + 1];
+                                       break;
                                default:
-                                       pMt->dOffset += 2;
                                        break;
+                               }
+                               pMt->dOffset += 2;
+                               break;
+
+                       default:
+                               pMt->dOffset += 2;
+                               break;
                        }
                } else {
                        switch (dCmd) {
-                               case 0xF0:                      /* SysEx */
-                               case 0xF7:                      /* SysEx */
-                                       pMt->dSmfCmd = 0;
-                                       dSize = 0;
-                                       do {
-                                               dTemp = (UINT32)pMt->pbBase[pMt->dOffset++];
-                                               dSize = (dSize << 7) + (dTemp & 0x7f);
-                                       } while (dTemp >= 0x80);
-
-                                       if ((dSize == 5) &&
-                                           (pMt->pbBase[pMt->dOffset] == 0x7e) &&
-                                           (pMt->pbBase[pMt->dOffset + 1] == 0x7f) &&
-                                           (pMt->pbBase[pMt->dOffset + 2] == 0x09) &&
-                                           (pMt->pbBase[pMt->dOffset + 3] == 0x01)) {
-                                               /* System On */
-                                               if (sdTotalTicks == 0) {
-                                                       dSetup |= 0x04;
-                                               }
-                                       } else {
-                                               if (pI->dSetupBar == 0) {
-                                                       if ((dSize == 22) &&
-                                                           (pMt->pbBase[pMt->dOffset] == 0x43) &&
-                                                           (pMt->pbBase[pMt->dOffset + 1] == 0x79) &&
-                                                           (pMt->pbBase[pMt->dOffset + 2] == 0x06) &&
-                                                           (pMt->pbBase[pMt->dOffset + 3] == 0x7C) &&
-                                                           (pMt->pbBase[pMt->dOffset + 4] == 0x02)) {
-                                                               /* Channel status */
-                                                               for (dCh = 0; dCh < 16; dCh++) {
-                                                                       pCh = &pI->ChInfo[dCh];
-                                                                       dTemp = pMt->pbBase[pMt->dOffset + 5 + dCh];
-                                                                       pCh->dKeyCon = (dTemp >> 2) & 0x03;
-                                                                       pCh->dVibSync = (dTemp >> 1) & 0x01;
-                                                                       pCh->dLedSync = dTemp & 0x01;
-                                                               }
+                       case 0xF0:                      /* SysEx */
+                       case 0xF7:                      /* SysEx */
+                               pMt->dSmfCmd = 0;
+                               dSize = 0;
+                               do {
+                                       dTemp = (UINT32)pMt->pbBase[pMt->dOffset++];
+                                       dSize = (dSize << 7) + (dTemp & 0x7f);
+                               } while (dTemp >= 0x80);
+
+                               if ((dSize == 5) &&
+                                       (pMt->pbBase[pMt->dOffset] == 0x7e) &&
+                                       (pMt->pbBase[pMt->dOffset + 1] == 0x7f) &&
+                                       (pMt->pbBase[pMt->dOffset + 2] == 0x09) &&
+                                       (pMt->pbBase[pMt->dOffset + 3] == 0x01)) {
+                                       /* System On */
+                                       if (sdTotalTicks == 0) {
+                                               dSetup |= 0x04;
+                                       }
+                               } else {
+                                       if (pI->dSetupBar == 0) {
+                                               if ((dSize == 22) &&
+                                                       (pMt->pbBase[pMt->dOffset] == 0x43) &&
+                                                       (pMt->pbBase[pMt->dOffset + 1] == 0x79) &&
+                                                       (pMt->pbBase[pMt->dOffset + 2] == 0x06) &&
+                                                       (pMt->pbBase[pMt->dOffset + 3] == 0x7C) &&
+                                                       (pMt->pbBase[pMt->dOffset + 4] == 0x02)) {
+                                                       /* Channel status */
+                                                       for (dCh = 0; dCh < 16; dCh++) {
+                                                               pCh = &pI->ChInfo[dCh];
+                                                               dTemp = pMt->pbBase[pMt->dOffset + 5 + dCh];
+                                                               pCh->dKeyCon = (dTemp >> 2) & 0x03;
+                                                               pCh->dVibSync = (dTemp >> 1) & 0x01;
+                                                               pCh->dLedSync = dTemp & 0x01;
                                                        }
                                                }
                                        }
+                               }
+
+                               pMt->dOffset += dSize;
+                               break;
+
+                       case 0xF1:                      /* System Msg */
+                       case 0xF3:                      /* System Msg */
+                               pMt->dOffset++;
+                               break;
+
+                       case 0xF2:                      /* System Msg */
+                               pMt->dOffset += 2;
+                               break;
+
+                       case 0xFF:                                                                                      /* Meta          */
+                               dCmd2 = (UINT32)pMt->pbBase[pMt->dOffset++];    /* Meta Command  */
+                               dSize = 0;                                                                              /* Size          */
+                               do {
+                                       dTemp = (UINT32)pMt->pbBase[pMt->dOffset++];
+                                       dSize = (dSize << 7) + (dTemp & 0x7f);
+                               } while (dTemp >= 0x80);
+
+                               switch (dCmd2) {
+                               case 0x01:      /* Text */
+                                       if (pI->pbText == NULL) {
+                                               pI->pbText = &pMt->pbBase[pMt->dOffset];
+                                               pI->dSizeText = dSize;
+                                       }
+                                       break;
 
-                                       pMt->dOffset += dSize;
+                               case 0x02:      /* Copyright */
+                                       if (pI->pbCopyright == NULL) {
+                                               pI->pbCopyright = &pMt->pbBase[pMt->dOffset];
+                                               pI->dSizeCopyright = dSize;
+                                       }
                                        break;
 
-                               case 0xF1:                      /* System Msg */
-                               case 0xF3:                      /* System Msg */
-                                       pMt->dOffset++;
+                               case 0x06:      /* Title */
+                                       if (pI->pbTitle == NULL) {
+                                               pI->pbTitle = &pMt->pbBase[pMt->dOffset];
+                                               pI->dSizeTitle = dSize;
+                                       }
                                        break;
 
-                               case 0xF2:                      /* System Msg */
-                                       pMt->dOffset += 2;
+                               case 0x2f:              /* End */
+                                       pI->dEndFlag &= ~(1L << sdTr);
                                        break;
 
-                               case 0xFF:                                                                                      /* Meta          */
-                                       dCmd2 = (UINT32)pMt->pbBase[pMt->dOffset++];    /* Meta Command  */
-                                       dSize = 0;                                                                              /* Size          */
-                                       do {
-                                               dTemp = (UINT32)pMt->pbBase[pMt->dOffset++];
-                                               dSize = (dSize << 7) + (dTemp & 0x7f);
-                                       } while (dTemp >= 0x80);
-
-                                       switch (dCmd2) {
-                                               case 0x01:      /* Text */
-                                                       if (pI->pbText == NULL) {
-                                                               pI->pbText = &pMt->pbBase[pMt->dOffset];
-                                                               pI->dSizeText = dSize;
-                                                       }
-                                                       break;
+                               case 0x51:              /* Set Tempo */
+                                       switch (dSize) {
+                                       case 3:
+                                       case 4:
+                                               dTime = ((UINT32)pMt->pbBase[pMt->dOffset] << 16) +
+                                                               ((UINT32)pMt->pbBase[pMt->dOffset + 1] << 8) +
+                                                               (UINT32)pMt->pbBase[pMt->dOffset + 2];
+                                               if ((sdTotalTicks == 0) && (dTime == 250000)) dSetup |= 0x02;
+                                               if (sdTotalTicks == (UINT32)pI->dTimeResolution) dSetup |= 0x08;
 
-                                               case 0x02:      /* Copyright */
-                                                       if (pI->pbCopyright == NULL) {
-                                                               pI->pbCopyright = &pMt->pbBase[pMt->dOffset];
-                                                               pI->dSizeCopyright = dSize;
-                                                       }
-                                                       break;
+                                               /*<== I Think that Below Code is Trash!! and Erase it! (Actually I Don Know ^^)
+                                               dTime = (dTime << 7) / 125; */
 
-                                               case 0x06:      /* Title */
-                                                       if (pI->pbTitle == NULL) {
-                                                               pI->pbTitle = &pMt->pbBase[pMt->dOffset];
-                                                               pI->dSizeTitle = dSize;
-                                                       }
-                                                       break;
-
-                                               case 0x2f:              /* End */
-                                                       pI->dEndFlag &= ~(1L << sdTr);
-                                                       break;
-
-                                               case 0x51:              /* Set Tempo */
-                                                       switch (dSize) {
-                                                               case 3:
-                                                               case 4:
-                                                                       dTime = ((UINT32)pMt->pbBase[pMt->dOffset] << 16) +
-                                                                               ((UINT32)pMt->pbBase[pMt->dOffset + 1] << 8) +
-                                                                               (UINT32)pMt->pbBase[pMt->dOffset + 2];
-                                                                       if ((sdTotalTicks == 0) && (dTime == 250000)) dSetup |= 0x02;
-                                                                       if (sdTotalTicks == (UINT32)pI->dTimeResolution) dSetup |= 0x08;
-
-                                                                       /*<== I Think that Below Code is Trash!! and Erase it! (Actually I Don Know ^^)
-                                                                       dTime = (dTime << 7) / 125; */
-
-                                                                       sdDelta = (UINT32)(dTime / (pI->dTimeResolution > 0 ? pI->dTimeResolution : 1));
-                                                                       break;
-
-                                                               default:
-                                                                       break;
-                                                       }
-                                                       break;
-
-                                               case 0x58:              /* Set TimeSignature */
-                                                       if ((sdTotalTicks == 0) &&
-                                                           (pMt->pbBase[pMt->dOffset] == 1) &&
-                                                           (pMt->pbBase[pMt->dOffset + 1] == 2)) dSetup |= 0x01;
-                                                       break;
-                                               default:
-                                                       break;
+                                               sdDelta = (UINT32)(dTime / (pI->dTimeResolution > 0 ? pI->dTimeResolution : 1));
+                                               break;
+
+                                       default:
+                                               break;
                                        }
-                                       pMt->dOffset += dSize;
+                                       break;
+
+                               case 0x58:              /* Set TimeSignature */
+                                       if ((sdTotalTicks == 0) &&
+                                               (pMt->pbBase[pMt->dOffset] == 1) &&
+                                               (pMt->pbBase[pMt->dOffset + 1] == 2)) dSetup |= 0x01;
                                        break;
                                default:
                                        break;
+                               }
+                               pMt->dOffset += dSize;
+                               break;
+                       default:
+                               break;
                        }
                }
 
@@ -1314,8 +1299,7 @@ __AvCheckSizeOfMidFile(UINT8 *src_fp, UINT32 dFsize)
        UINT8 *fp = src_fp;
        /* debug_msg(DEBUG, "input param: %p, %d\n", fp, dFsize); */
        while (dFsize >= 22) {
-               dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) +
-                       ((UINT32)fp[2] << 8) + (UINT32)fp[3];
+               dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) + ((UINT32)fp[2] << 8) + (UINT32)fp[3];
                if (dTemp == 0x4D546864)        break;          /* 'MThd' */
                fp++;
                dFsize--;
@@ -1332,8 +1316,7 @@ __AvCheckSizeOfMidFile(UINT8 *src_fp, UINT32 dFsize)
        dFsize -= 4;
 
        /*--- Check size ----------------------------------------------------*/
-       dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) +
-               ((UINT32)fp[2] << 8) + (UINT32)fp[3];
+       dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) + ((UINT32)fp[2] << 8) + (UINT32)fp[3];
 
        if (dTemp != 6) {
                debug_error(DEBUG, "__AvCheckSizeOfMidFile Error / Size != 6\n");
@@ -1384,8 +1367,7 @@ __AvCheckSizeOfMidFile(UINT8 *src_fp, UINT32 dFsize)
        for (i = 0; i < dNumOfTracks; i++) {
                /*--- Check chunk name --------------------------------------------*/
                while (dFsize >= 8) {
-                       dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) +
-                               ((UINT32)fp[2] << 8) + (UINT32)fp[3];
+                       dTemp = ((UINT32)fp[0] << 24) + ((UINT32)fp[1] << 16) + ((UINT32)fp[2] << 8) + (UINT32)fp[3];
                        if (dTemp == 0x4D54726B)        break;  /* 'MTrk' */
                        fp++;
                        dFsize--;
@@ -1397,8 +1379,7 @@ __AvCheckSizeOfMidFile(UINT8 *src_fp, UINT32 dFsize)
                }
 
                /*--- Check size ----------------------------------------------------*/
-               dSize = ((UINT32)fp[4] << 24) + ((UINT32)fp[5] << 16) +
-                       ((UINT32)fp[6] << 8) + (UINT32)fp[7];
+               dSize = ((UINT32)fp[4] << 24) + ((UINT32)fp[5] << 16) + ((UINT32)fp[6] << 8) + (UINT32)fp[7];
 
                if (dFsize < (dSize + 8)) {
                        debug_error(DEBUG, "__AvCheckSizeOfMidFile Error/ Bad size [%ld] vs [%ld]\n", dFsize, dSize + 22);
index 695bb94..10f458d 100755 (executable)
 #define        AV_MMF_CONTENTS_TYPE_5                          0x50
 
 
-#define AVMASMW_SUCCESS                                (0)             /* success                                                              */
+#define AVMASMW_SUCCESS                                (0)             /* success                                                              */
 #define AVMASMW_ERROR                          (-1)    /* error                                                                */
 #define AVMASMW_ERROR_ARGUMENT         (-2)    /* error of arguments                                   */
 #define AVMASMW_ERROR_RESOURCE_OVER    (-3)    /* over specified resources                             */
-#define AVMASMW_ERROR_ID                       (-4)    /* error id number                                              */
-#define AVMASMW_ERROR_TIMEOUT          (-5)    /* timeout                                                              */
+#define AVMASMW_ERROR_ID                       (-4)    /* error id number                                              */
+#define AVMASMW_ERROR_TIMEOUT          (-5)    /* timeout                                                              */
 #define AVMASMW_ERROR_SOFTRESET                (-6)    /* error of soft reset for MA-5                 */
 
 #define AVMASMW_ERROR_FILE                             (-16)   /* file error                                                   */
 #define AVMASMW_ERROR_CONTENTS_TYPE            (-18)   /* SAVMAF Contents Type shows can't play        */
 #define AVMASMW_ERROR_CHUNK_SIZE               (-19)   /* illegal SMAF Chunk Size value                */
 #define AVMASMW_ERROR_CHUNK                            (-20)   /* illegal SMAF Track Chunk value               */
-#define AVMASMW_ERROR_UNMATCHED_TAG            (-21)   /* unmathced specified TAG                              */
-#define AVMASMW_ERROR_SHORT_LENGTH             (-22)   /* short sequence                                               */
-#define AVMASMW_ERROR_LONG_LENGTH              (-23)   /* long sequence                                                */
+#define AVMASMW_ERROR_UNMATCHED_TAG            (-21)   /* unmathced specified TAG                              */
+#define AVMASMW_ERROR_SHORT_LENGTH             (-22)   /* short sequence                                               */
+#define AVMASMW_ERROR_LONG_LENGTH              (-23)   /* long sequence                                                */
 #define AVMASMW_ERROR_UNSUPPORTED              (-24)   /* unsupported format                                   */
 #define AVMASMW_ERROR_NO_INFORMATION   (-25)   /* no specified information                             */
 #define AVMASMW_ERROR_HV_CONFLICT              (-26)   /* conflict about HV resource                   */
 
 #define        AVMALIB_MAKEDWORD(a, b, c, d)   (unsigned int)(((unsigned int)(a) << 24) | \
-                                                       ((unsigned int)(b) << 16) | ((unsigned int)(c) << 8) | (unsigned int)(d))
+                                                                       ((unsigned int)(b) << 16) | ((unsigned int)(c) << 8) | (unsigned int)(d))
 
 /****************************************************************************
  *     define
@@ -378,7 +378,7 @@ typedef struct AvTagPhraseInfo {
 typedef struct AvTagHuffmanInfo {
        unsigned int    dMtsqSize;                              /* size of Mtsq(Atsq) Body                      */
        unsigned int    dSeqSize;                               /* size of sequence data                        */
-       unsigned int    dReadSize;                              /* read data size                                       */
+       unsigned int    dReadSize;                              /* read data size                                       */
        short                   swLeft[512];                    /* Huffman Tree (Left)                          */
        short                   swRight[512];                   /* Huffman Tree (Right)                         */
        unsigned char   *psBuffer;                              /* pointer to reference area            */
@@ -491,7 +491,7 @@ typedef struct AvTagEventBlock {
        unsigned char   *pbSeq;                                 /* pointer to next event data           */
        unsigned int    dIndex;                                 /* index of next event                          */
        unsigned int    dTrackNo;                               /* track no.                                            */
-       void                    *pvNext;                                        /* pointer to next event block          */
+       void                    *pvNext;                                        /* pointer to next event block          */
 } EVENTBLOCK, *PEVENTBLOCK;
 
 /* Note OFF information structure      */
@@ -501,7 +501,7 @@ typedef struct AvTagNoteOffBlock {
        unsigned int    dCmd;                                   /* command ID (sound driver)            */
        unsigned int    dCh;                                    /* channel no.                                          */
        unsigned int    dKey;                                   /* key no.                                                      */
-       void                    *pvNext;                                        /* pointer to next note off block       */
+       void                    *pvNext;                                        /* pointer to next note off block       */
 } OFFBLOCK, *POFFBLOCK;
 
 /* Playback information structure      */
@@ -665,9 +665,9 @@ static unsigned int
 _mmf_Get4Byte(unsigned char *pbBuf)
 {
        return (unsigned int)((((unsigned int)pbBuf[0]) << 24) +
-                             (((unsigned int)pbBuf[1]) << 16) +
-                             (((unsigned int)pbBuf[2]) <<  8) +
-                             ((unsigned int)pbBuf[3]));
+                                       (((unsigned int)pbBuf[1]) << 16) +
+                                       (((unsigned int)pbBuf[2]) <<  8) +
+                                       ((unsigned int)pbBuf[3]));
 }
 
 
@@ -752,20 +752,20 @@ static int
 _mmf_GetTimebase(unsigned char bData)
 {
        switch (bData) {
-               case 0x02:
-                       return  4;                                              /*  4[msec/tick]                        */
-               case 0x03:
-                       return  5;                                              /*  5[msec/tick]                        */
-               case 0x10:
-                       return 10;                                              /* 10[msec/tick]                        */
-               case 0x11:
-                       return 20;                                              /* 20[msec/tick]                        */
-               case 0x12:
-                       return 40;                                              /* 40[msec/tick]                        */
-               case 0x13:
-                       return 50;                                              /* 50[msec/tick]                        */
-               default:
-                       return AV_MMF_FUNC_ERROR;                       /* Time Base Error                      */
+       case 0x02:
+               return  4;                                              /*  4[msec/tick]                        */
+       case 0x03:
+               return  5;                                              /*  5[msec/tick]                        */
+       case 0x10:
+               return 10;                                              /* 10[msec/tick]                        */
+       case 0x11:
+               return 20;                                              /* 20[msec/tick]                        */
+       case 0x12:
+               return 40;                                              /* 40[msec/tick]                        */
+       case 0x13:
+               return 50;                                              /* 50[msec/tick]                        */
+       default:
+               return AV_MMF_FUNC_ERROR;                       /* Time Base Error                      */
        }
 }
 
@@ -781,121 +781,121 @@ _mmf_MalibNextChunk(unsigned char *pbFile, unsigned int dSize, unsigned int dSta
        dChunkSize      = AVMALIB_MAKEDWORD(pbFile[4], pbFile[5], pbFile[6], pbFile[7]);
 
        switch (dChunkID) {
-               case AVMALIB_CHUNKID_MMMD:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MMMD;
-                       if (dState != AVMALIB_CHUNK_PHASE_MMMD)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_CNTI:
-                       *pdChunkID = AVMALIB_CHUNKCODE_CNTI;
-                       if (dState != AVMALIB_CHUNK_PHASE_CNTI)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_OPDA:
-                       *pdChunkID = AVMALIB_CHUNKCODE_OPDA;
+       case AVMALIB_CHUNKID_MMMD:
+               *pdChunkID = AVMALIB_CHUNKCODE_MMMD;
+               if (dState != AVMALIB_CHUNK_PHASE_MMMD)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_CNTI:
+               *pdChunkID = AVMALIB_CHUNKCODE_CNTI;
+               if (dState != AVMALIB_CHUNK_PHASE_CNTI)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_OPDA:
+               *pdChunkID = AVMALIB_CHUNKCODE_OPDA;
+               if (dState != AVMALIB_CHUNK_PHASE_MMMDSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MSPI:
+               *pdChunkID = AVMALIB_CHUNKCODE_MSPI;
+               if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MTSU:
+               *pdChunkID = AVMALIB_CHUNKCODE_MTSU;
+               if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MTSQ:
+               *pdChunkID = AVMALIB_CHUNKCODE_MTSQ;
+               if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MTSP:
+               *pdChunkID = AVMALIB_CHUNKCODE_MTSP;
+               if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_ASPI:
+               *pdChunkID = AVMALIB_CHUNKCODE_ASPI;
+               if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_ATSU:
+               *pdChunkID = AVMALIB_CHUNKCODE_ATSU;
+               if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_ATSQ:
+               *pdChunkID = AVMALIB_CHUNKCODE_ATSQ;
+               if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+
+       case AVMALIB_CHUNKID_MTHV:
+               *pdChunkID = AVMALIB_CHUNKCODE_MTHV;
+               if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MHVS:
+               *pdChunkID = AVMALIB_CHUNKCODE_MHVS;
+               if (dState != AVMALIB_CHUNK_PHASE_MTHVSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+       case AVMALIB_CHUNKID_MHSC:
+               *pdChunkID = AVMALIB_CHUNKCODE_MHSC;
+               if (dState != AVMALIB_CHUNK_PHASE_MTHVSUB)
+                       return AVMALIB_CHUNK_ID_ERROR;
+               break;
+
+       default:
+               *pdChunkNo = (unsigned char)(dChunkID & 0x000000FF);
+               switch (dChunkID & 0xFFFFFF00) {
+               case AVMALIB_CHUNKID_MTR:
+                       *pdChunkID = AVMALIB_CHUNKCODE_MTR;
                        if (dState != AVMALIB_CHUNK_PHASE_MMMDSUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
-               case AVMALIB_CHUNKID_MSPI:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MSPI;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_MTSU:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MTSU;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_MTSQ:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MTSQ;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+               case AVMALIB_CHUNKID_ATR:
+                       *pdChunkID = AVMALIB_CHUNKCODE_ATR;
+                       if (dState != AVMALIB_CHUNK_PHASE_MMMDSUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
-               case AVMALIB_CHUNKID_MTSP:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MTSP;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
+
+               case AVMALIB_CHUNKID_DCH:
+                       *pdChunkID = AVMALIB_CHUNKCODE_DCH;
+                       if (dState != AVMALIB_CHUNK_PHASE_OPDASUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
-               case AVMALIB_CHUNKID_ASPI:
-                       *pdChunkID = AVMALIB_CHUNKCODE_ASPI;
-                       if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
+               case AVMALIB_CHUNKID_M5P:
+                       *pdChunkID = AVMALIB_CHUNKCODE_M5P;
+                       if (dState != AVMALIB_CHUNK_PHASE_OPDASUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
-               case AVMALIB_CHUNKID_ATSU:
-                       *pdChunkID = AVMALIB_CHUNKCODE_ATSU;
-                       if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
+
+               case AVMALIB_CHUNKID_MWA:
+                       *pdChunkID = AVMALIB_CHUNKCODE_MWA;
+                       if (dState != AVMALIB_CHUNK_PHASE_MTSPSUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
-               case AVMALIB_CHUNKID_ATSQ:
-                       *pdChunkID = AVMALIB_CHUNKCODE_ATSQ;
+
+               case AVMALIB_CHUNKID_AWA:
+                       *pdChunkID = AVMALIB_CHUNKCODE_AWA;
                        if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
 
-               case AVMALIB_CHUNKID_MTHV:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MTHV;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTRSUB)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_MHVS:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MHVS;
-                       if (dState != AVMALIB_CHUNK_PHASE_MTHVSUB)
-                               return AVMALIB_CHUNK_ID_ERROR;
-                       break;
-               case AVMALIB_CHUNKID_MHSC:
-                       *pdChunkID = AVMALIB_CHUNKCODE_MHSC;
+               case AVMALIB_CHUNKID_HVP:
+                       *pdChunkID = AVMALIB_CHUNKCODE_HVP;
                        if (dState != AVMALIB_CHUNK_PHASE_MTHVSUB)
                                return AVMALIB_CHUNK_ID_ERROR;
                        break;
 
                default:
-                       *pdChunkNo = (unsigned char)(dChunkID & 0x000000FF);
-                       switch (dChunkID & 0xFFFFFF00) {
-                               case AVMALIB_CHUNKID_MTR:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_MTR;
-                                       if (dState != AVMALIB_CHUNK_PHASE_MMMDSUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-                               case AVMALIB_CHUNKID_ATR:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_ATR;
-                                       if (dState != AVMALIB_CHUNK_PHASE_MMMDSUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-
-                               case AVMALIB_CHUNKID_DCH:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_DCH;
-                                       if (dState != AVMALIB_CHUNK_PHASE_OPDASUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-                               case AVMALIB_CHUNKID_M5P:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_M5P;
-                                       if (dState != AVMALIB_CHUNK_PHASE_OPDASUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-
-                               case AVMALIB_CHUNKID_MWA:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_MWA;
-                                       if (dState != AVMALIB_CHUNK_PHASE_MTSPSUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-
-                               case AVMALIB_CHUNKID_AWA:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_AWA;
-                                       if (dState != AVMALIB_CHUNK_PHASE_ATRSUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-
-                               case AVMALIB_CHUNKID_HVP:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_HVP;
-                                       if (dState != AVMALIB_CHUNK_PHASE_MTHVSUB)
-                                               return AVMALIB_CHUNK_ID_ERROR;
-                                       break;
-
-                               default:
-                                       *pdChunkID = AVMALIB_CHUNKCODE_UNKNOWN;
-                                       break;
-                       }
+                       *pdChunkID = AVMALIB_CHUNKCODE_UNKNOWN;
                        break;
+               }
+               break;
        }
 
        if (dChunkSize > (dSize - AVMALIB_SIZE_OF_CHUNKHEADER))
@@ -928,24 +928,24 @@ _mmf_MTRCheck(PTRACKINFO psTrack, unsigned char   bSmafType)
 
        /* Check Format Type                            */
        switch (bSmafType) {
-               case AV_MMF_SMAF_TYPE_MA1:
-               case AV_MMF_SMAF_TYPE_MA2:
-                       if (psTrack->pbMtr[0] != 0x00) {
-                               return AV_MMF_ERR_CHUNK;
-                       }
-                       break;
-               case AV_MMF_SMAF_TYPE_MA3:
-                       if ((psTrack->pbMtr[0] != 0x01) && (psTrack->pbMtr[0] != 0x02)) {
-                               return AV_MMF_ERR_CHUNK;
-                       }
-                       break;
-               case AV_MMF_SMAF_TYPE_MA5:
-                       if (psTrack->pbMtr[0] != 0x02) {
-                               return AV_MMF_ERR_CHUNK;
-                       }
-                       break;
-               default:
-                       break;
+       case AV_MMF_SMAF_TYPE_MA1:
+       case AV_MMF_SMAF_TYPE_MA2:
+               if (psTrack->pbMtr[0] != 0x00) {
+                       return AV_MMF_ERR_CHUNK;
+               }
+               break;
+       case AV_MMF_SMAF_TYPE_MA3:
+               if ((psTrack->pbMtr[0] != 0x01) && (psTrack->pbMtr[0] != 0x02)) {
+                       return AV_MMF_ERR_CHUNK;
+               }
+               break;
+       case AV_MMF_SMAF_TYPE_MA5:
+               if (psTrack->pbMtr[0] != 0x02) {
+                       return AV_MMF_ERR_CHUNK;
+               }
+               break;
+       default:
+               break;
        }
 
        /* Check Sequence Type          */
@@ -971,35 +971,34 @@ _mmf_MTRCheck(PTRACKINFO psTrack, unsigned char   bSmafType)
        pbBuf = psTrack->pbMtr;
        dSize = psTrack->dMtrSize;
        while (dSize > (dIndex + AV_MMF_CHUNK_HEADER_SIZE)) {
-               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_MTRSUB, &dChunkID, &dChunkNo);
+               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex), AVMALIB_CHUNK_PHASE_MTRSUB, &dChunkID, &dChunkNo);
                if (sdChunkSize < 0) {
                        return AV_MMF_ERR_CHUNK;
                }
                dIndex += AV_MMF_CHUNK_HEADER_SIZE;
                switch (dChunkID) {
-                       case AVMALIB_CHUNKCODE_MSPI:
-                               psTrack->pbMspi         = &(pbBuf[dIndex]);
-                               psTrack->dMspiSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_MTSU:
-                               psTrack->pbMtsu         = &(pbBuf[dIndex]);
-                               psTrack->dMtsuSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_MTSQ:
-                               psTrack->pbMtsq         = &(pbBuf[dIndex]);
-                               psTrack->dMtsqSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_MTSP:
-                               psTrack->pbMtsp         = &(pbBuf[dIndex]);
-                               psTrack->dMtspSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_MTHV:
-                               psTrack->pbMthv         = &(pbBuf[dIndex]);
-                               psTrack->dMthvSize      = sdChunkSize;
-                               break;
-                       default:
-                               break;
+               case AVMALIB_CHUNKCODE_MSPI:
+                       psTrack->pbMspi         = &(pbBuf[dIndex]);
+                       psTrack->dMspiSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_MTSU:
+                       psTrack->pbMtsu         = &(pbBuf[dIndex]);
+                       psTrack->dMtsuSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_MTSQ:
+                       psTrack->pbMtsq         = &(pbBuf[dIndex]);
+                       psTrack->dMtsqSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_MTSP:
+                       psTrack->pbMtsp         = &(pbBuf[dIndex]);
+                       psTrack->dMtspSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_MTHV:
+                       psTrack->pbMthv         = &(pbBuf[dIndex]);
+                       psTrack->dMthvSize      = sdChunkSize;
+                       break;
+               default:
+                       break;
                }
                dIndex += sdChunkSize;
        }
@@ -1042,8 +1041,7 @@ _mmf_ATRCheck(PTRACKINFO psTrack)
        }
 
        /* Check Wave Type                      */
-       if (((psTrack->pbMtr[2] != 0x10) && (psTrack->pbMtr[2] != 0x11)) ||
-           ((psTrack->pbMtr[3] & 0xF0) != 0x00)) {
+       if (((psTrack->pbMtr[2] != 0x10) && (psTrack->pbMtr[2] != 0x11)) || ((psTrack->pbMtr[3] & 0xF0) != 0x00)) {
                return AV_MMF_ERR_CHUNK;
        }
 
@@ -1064,27 +1062,26 @@ _mmf_ATRCheck(PTRACKINFO psTrack)
 
        /* Check sub chunk disposition  */
        while (dSize > (dIndex + AV_MMF_CHUNK_HEADER_SIZE)) {
-               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_ATRSUB, &dChunkID, &dChunkNo);
+               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex), AVMALIB_CHUNK_PHASE_ATRSUB, &dChunkID, &dChunkNo);
                if (sdChunkSize < 0) {
                        return AV_MMF_ERR_CHUNK;
                }
                dIndex += AV_MMF_CHUNK_HEADER_SIZE;
                switch (dChunkID) {
-                       case AVMALIB_CHUNKCODE_ASPI:
-                               psTrack->pbMspi         = &(pbBuf[dIndex]);
-                               psTrack->dMspiSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_ATSQ:
-                               psTrack->pbMtsq         = &(pbBuf[dIndex]);
-                               psTrack->dMtsqSize      = sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_AWA:
-                               if ((0x01 <= dChunkNo) && (dChunkNo <= 0x3E))
-                                       fbWave = AV_MMF_MA2_VOICE_FOUND;
-                               break;
-                       default:
-                               break;
+               case AVMALIB_CHUNKCODE_ASPI:
+                       psTrack->pbMspi         = &(pbBuf[dIndex]);
+                       psTrack->dMspiSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_ATSQ:
+                       psTrack->pbMtsq         = &(pbBuf[dIndex]);
+                       psTrack->dMtsqSize      = sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_AWA:
+                       if ((0x01 <= dChunkNo) && (dChunkNo <= 0x3E))
+                               fbWave = AV_MMF_MA2_VOICE_FOUND;
+                       break;
+               default:
+                       break;
                }
                dIndex += sdChunkSize;
        }
@@ -1125,65 +1122,65 @@ _mmf_MspICheck(PTRACKINFO psTrack, PPHRASEINFO psPhrase)
        while (dSize >= dIndex + AV_MMF_PHRAZE_SIZE_A) {
                wTag = (unsigned short)((((unsigned short)pbBuf[dIndex]) << 8) + (unsigned short)pbBuf[dIndex + 1]);
                switch (wTag) {
-                       case AV_MMF_TAG_STARTPOINT:                             /* start point                                  */
-                               psTrack->dStartPoint    = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_A;
-                               break;
-                       case AV_MMF_TAG_STOPPOINT:                              /* stop point                                   */
-                               psTrack->dStopPoint             = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_A;
-                               break;
-                       case AV_MMF_TAG_PHRASE_A:                                       /* A melody                                             */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[0].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[0].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_B:                                       /* B melody                                             */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[1].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[1].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_E:                                       /* Ending                                               */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[2].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[2].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_I:                                       /* Intro                                                */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[3].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[3].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_K:                                       /* Interlude                                    */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[4].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[4].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_R:                                       /* Refrain                                              */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[5].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[5].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       case AV_MMF_TAG_PHRASE_S:                                       /* Bridge                                               */
-                               if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
-                                       return;
-                               psPhrase[6].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
-                               psPhrase[6].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
-                               dIndex += AV_MMF_PHRAZE_SIZE_B;
-                               break;
-                       default:
+               case AV_MMF_TAG_STARTPOINT:                             /* start point                                  */
+                       psTrack->dStartPoint    = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_A;
+                       break;
+               case AV_MMF_TAG_STOPPOINT:                              /* stop point                                   */
+                       psTrack->dStopPoint             = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_A;
+                       break;
+               case AV_MMF_TAG_PHRASE_A:                                       /* A melody                                             */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[0].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[0].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_B:                                       /* B melody                                             */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
                                return;
+                       psPhrase[1].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[1].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_E:                                       /* Ending                                               */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[2].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[2].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_I:                                       /* Intro                                                */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[3].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[3].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_K:                                       /* Interlude                                    */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[4].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[4].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_R:                                       /* Refrain                                              */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[5].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[5].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               case AV_MMF_TAG_PHRASE_S:                                       /* Bridge                                               */
+                       if (dSize < dIndex + AV_MMF_PHRAZE_SIZE_B)
+                               return;
+                       psPhrase[6].dStartPoint = _mmf_Get4Byte(&(pbBuf[dIndex + 3]));
+                       psPhrase[6].dStopPoint  = _mmf_Get4Byte(&(pbBuf[dIndex + 7]));
+                       dIndex += AV_MMF_PHRAZE_SIZE_B;
+                       break;
+               default:
+                       return;
                }
        }
        return;
@@ -1294,8 +1291,7 @@ _mmf_GetFlex2L(unsigned char *pbBuf, unsigned int dSize, unsigned int *pbRead)
                        return AV_MMF_FUNC_ERROR;
        }
        if (pbBuf[0] >= 0x80) {
-               sdTemp = (int)((((int)(pbBuf[0] & 0x7F)) << 7) +
-                              ((int)(pbBuf[1] & 0x7F)) + 128);
+               sdTemp = (int)((((int)(pbBuf[0] & 0x7F)) << 7) + ((int)(pbBuf[1] & 0x7F)) + 128);
                *pbRead = 2;
        } else {
                sdTemp = (int)(pbBuf[0] & 0x7F);
@@ -1377,42 +1373,42 @@ _mmf_SeqDataCheck2(PTRACKINFO psTrack, unsigned char bSmafType)
                }
 
                switch (pbBuf[dIndex]) {
+               case 0x00:
+                       if ((pbBuf[dIndex + 1] & 0x30) != 0x30)
+                               dIndex += 2;
+                       else
+                               dIndex += 3;
+                       break;
+               case 0xFF:
+                       switch (pbBuf[dIndex + 1]) {
                        case 0x00:
-                               if ((pbBuf[dIndex + 1] & 0x30) != 0x30)
-                                       dIndex += 2;
-                               else
-                                       dIndex += 3;
+                               dIndex += 2;
                                break;
-                       case 0xFF:
-                               switch (pbBuf[dIndex + 1]) {
-                                       case 0x00:
-                                               dIndex += 2;
-                                               break;
-                                       case 0xF0:
-                                               if (dSize < dIndex + 3) {
-                                                       return AV_MMF_ERR_CHUNK;
-                                               }
-                                               dIndex += (pbBuf[dIndex + 2] + 3);
-                                               if (dSize < dIndex) {
-                                                       return AV_MMF_ERR_CHUNK;
-                                               }
-                                               if (pbBuf[dIndex - 1] != 0xF7) {
-                                                       return AV_MMF_ERR_CHUNK;
-                                               }
-                                               break;
-                                       default:
-                                               return AV_MMF_ERR_CHUNK;
+                       case 0xF0:
+                               if (dSize < dIndex + 3) {
+                                       return AV_MMF_ERR_CHUNK;
                                }
-                               break;
-                       default:
-                               sdTemp = _mmf_GetFlex2L(&pbBuf[dIndex + 1], (dSize - dIndex - 1), &dFlexSize);
-                               if (sdTemp < 0) {
+                               dIndex += (pbBuf[dIndex + 2] + 3);
+                               if (dSize < dIndex) {
+                                       return AV_MMF_ERR_CHUNK;
+                               }
+                               if (pbBuf[dIndex - 1] != 0xF7) {
                                        return AV_MMF_ERR_CHUNK;
                                }
-                               if (dGate < (unsigned int)sdTemp)
-                                       dGate = (unsigned int)sdTemp;
-                               dIndex += (1 + dFlexSize);
                                break;
+                       default:
+                               return AV_MMF_ERR_CHUNK;
+                       }
+                       break;
+               default:
+                       sdTemp = _mmf_GetFlex2L(&pbBuf[dIndex + 1], (dSize - dIndex - 1), &dFlexSize);
+                       if (sdTemp < 0) {
+                               return AV_MMF_ERR_CHUNK;
+                       }
+                       if (dGate < (unsigned int)sdTemp)
+                               dGate = (unsigned int)sdTemp;
+                       dIndex += (1 + dFlexSize);
+                       break;
                }
                if (dSize < dIndex) {
                        return AV_MMF_ERR_CHUNK;
@@ -1743,81 +1739,81 @@ _mmf_SeqDataCheck3(PLOADINFO psLoad, unsigned char bSmafType)
                dIndex++;
 
                switch (bTemp & 0xF0) {
-                       case 0x90:
-                               psLoad->pfnGetByte(psHuf);      /*Note number*/
-                               dIndex++;
-                               psLoad->pfnGetByte(psHuf);      /*Key Velocity*/
-                               dIndex++;
+               case 0x90:
+                       psLoad->pfnGetByte(psHuf);      /*Note number*/
+                       dIndex++;
+                       psLoad->pfnGetByte(psHuf);      /*Key Velocity*/
+                       dIndex++;
+                       sdTemp = _mmf_GetFlex3L(psLoad, &dReadSize);
+                       if (sdTemp < 0) {
+                               return AV_MMF_ERR_CHUNK;
+                       }
+                       dIndex += dReadSize;
+                       if ((unsigned int)sdTemp > dGate)
+                               dGate = sdTemp;
+                       break;
+               case 0x80:
+                       psLoad->pfnGetByte(psHuf);      /*Note number*/
+                       dIndex++;
+                       sdTemp = _mmf_GetFlex3L(psLoad, &dReadSize);
+                       if (sdTemp < 0) {
+                               return AV_MMF_ERR_CHUNK;
+                       }
+                       dIndex += dReadSize;
+                       if ((unsigned int)sdTemp > dGate)
+                               dGate = sdTemp;
+                       break;
+               case 0xA0:
+               case 0xB0:
+               case 0xE0:
+                       bTemp = psLoad->pfnGetByte(psHuf);      /*B0: Conrol number, E0:Pitch Bend Change LSB*/
+                       dIndex++;
+                       bTemp = psLoad->pfnGetByte(psHuf);      /*B0: Conrol value, E0:Pitch Bend Change MSB*/
+                       dIndex++;
+                       break;
+               case 0xC0:
+               case 0xD0:
+                       bTemp = psLoad->pfnGetByte(psHuf);
+                       dIndex++;
+                       break;
+               default:
+                       switch (bTemp) {
+                       case 0xF0:
                                sdTemp = _mmf_GetFlex3L(psLoad, &dReadSize);
                                if (sdTemp < 0) {
                                        return AV_MMF_ERR_CHUNK;
                                }
-                               dIndex += dReadSize;
-                               if ((unsigned int)sdTemp > dGate)
-                                       dGate = sdTemp;
-                               break;
-                       case 0x80:
-                               psLoad->pfnGetByte(psHuf);      /*Note number*/
-                               dIndex++;
-                               sdTemp = _mmf_GetFlex3L(psLoad, &dReadSize);
-                               if (sdTemp < 0) {
+                               for (i = 0; i < (unsigned int)sdTemp; i++)
+                                       bTemp = psLoad->pfnGetByte(psHuf);
+                               if (bTemp != 0xF7) {
                                        return AV_MMF_ERR_CHUNK;
                                }
-                               dIndex += dReadSize;
-                               if ((unsigned int)sdTemp > dGate)
-                                       dGate = sdTemp;
+                               dIndex += (unsigned int)sdTemp + dReadSize;
                                break;
-                       case 0xA0:
-                       case 0xB0:
-                       case 0xE0:
-                               bTemp = psLoad->pfnGetByte(psHuf);      /*B0: Conrol number, E0:Pitch Bend Change LSB*/
-                               dIndex++;
-                               bTemp = psLoad->pfnGetByte(psHuf);      /*B0: Conrol value, E0:Pitch Bend Change MSB*/
-                               dIndex++;
-                               break;
-                       case 0xC0:
-                       case 0xD0:
+                       case 0xFF:
                                bTemp = psLoad->pfnGetByte(psHuf);
                                dIndex++;
-                               break;
-                       default:
                                switch (bTemp) {
-                                       case 0xF0:
-                                               sdTemp = _mmf_GetFlex3L(psLoad, &dReadSize);
-                                               if (sdTemp < 0) {
-                                                       return AV_MMF_ERR_CHUNK;
-                                               }
-                                               for (i = 0; i < (unsigned int)sdTemp; i++)
-                                                       bTemp = psLoad->pfnGetByte(psHuf);
-                                               if (bTemp != 0xF7) {
-                                                       return AV_MMF_ERR_CHUNK;
-                                               }
-                                               dIndex += (unsigned int)sdTemp + dReadSize;
-                                               break;
-                                       case 0xFF:
-                                               bTemp = psLoad->pfnGetByte(psHuf);
-                                               dIndex++;
-                                               switch (bTemp) {
-                                                       case 0x00:
-                                                               break;
-                                                       case 0x2F:
-                                                               bTemp = psLoad->pfnGetByte(psHuf);
-                                                               dIndex++;
-                                                               if (bTemp != 0x00) {
-                                                                       return AV_MMF_ERR_CHUNK;
-                                                               }
-                                                               dGate = 0;
-                                                               psTrk->dStopTick = dPast;
-                                                               dIndex = dSize;
-                                                               break;
-                                                       default:
-                                                               return AV_MMF_ERR_CHUNK;
-                                               }
-                                               break;
-                                       default:
+                               case 0x00:
+                                       break;
+                               case 0x2F:
+                                       bTemp = psLoad->pfnGetByte(psHuf);
+                                       dIndex++;
+                                       if (bTemp != 0x00) {
                                                return AV_MMF_ERR_CHUNK;
+                                       }
+                                       dGate = 0;
+                                       psTrk->dStopTick = dPast;
+                                       dIndex = dSize;
+                                       break;
+                               default:
+                                       return AV_MMF_ERR_CHUNK;
                                }
                                break;
+                       default:
+                               return AV_MMF_ERR_CHUNK;
+                       }
+                       break;
                }
                if ((dSize < dIndex) || (psHuf->dReadSize > psHuf->dMtsqSize)) {
                        return AV_MMF_ERR_CHUNK;
@@ -2181,8 +2177,7 @@ _mmf_CheckM5P(PLOADINFO psLoad)
 
        /* search Pro5 Chunk    */
        while (dOSize > (dIndex + AV_MMF_CHUNK_HEADER_SIZE)) {
-               sdChunkSize = _mmf_MalibNextChunk(&pbOpda[dIndex], (dOSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_OPDASUB, &dChunkID, &dChunkNo);
+               sdChunkSize = _mmf_MalibNextChunk(&pbOpda[dIndex], (dOSize - dIndex), AVMALIB_CHUNK_PHASE_OPDASUB, &dChunkID, &dChunkNo);
                if (sdChunkSize < AVMASMW_SUCCESS)              return AVMASMW_ERROR;
                dIndex += AV_MMF_CHUNK_HEADER_SIZE;
                if ((dChunkID == AVMALIB_CHUNKCODE_M5P) && (dChunkNo == 0x05)) {
@@ -2322,26 +2317,25 @@ _mmf_GetHvData(PLOADINFO psLoad, unsigned char bCType)
        dIndex          = 0;
 
        while (dHvDataSize > (dIndex + AV_MMF_CHUNK_HEADER_SIZE)) {
-               sdChunkSize     = _mmf_MalibNextChunk(&(pbHvData[dIndex]), (dHvDataSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_MTHVSUB, &dChunkID, &dChunkNo);
+               sdChunkSize     = _mmf_MalibNextChunk(&(pbHvData[dIndex]), (dHvDataSize - dIndex), AVMALIB_CHUNK_PHASE_MTHVSUB, &dChunkID, &dChunkNo);
                if (sdChunkSize < 0)            return;
                dIndex  += AV_MMF_CHUNK_HEADER_SIZE;
                switch (dChunkID) {
-                       case AVMALIB_CHUNKCODE_MHVS:
-                               pbSetup         = &(pbHvData[dIndex]);
-                               dSetupSize      = (unsigned int)sdChunkSize;
-                               break;
-                       case AVMALIB_CHUNKCODE_HVP:
-                               if (dChunkNo != 0)              break;
-                               pbVoice         = &(pbHvData[dIndex - AV_MMF_CHUNK_HEADER_SIZE]);
-                               dVoiceSize      = (unsigned int)(sdChunkSize + AV_MMF_CHUNK_HEADER_SIZE);
-                               break;
-                       case AVMALIB_CHUNKCODE_MHSC:
-                               pbScript        = &(pbHvData[dIndex]);
-                               dScriptSize     = (unsigned int)sdChunkSize;
-                               break;
-                       default:
-                               break;
+               case AVMALIB_CHUNKCODE_MHVS:
+                       pbSetup         = &(pbHvData[dIndex]);
+                       dSetupSize      = (unsigned int)sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_HVP:
+                       if (dChunkNo != 0)              break;
+                       pbVoice         = &(pbHvData[dIndex - AV_MMF_CHUNK_HEADER_SIZE]);
+                       dVoiceSize      = (unsigned int)(sdChunkSize + AV_MMF_CHUNK_HEADER_SIZE);
+                       break;
+               case AVMALIB_CHUNKCODE_MHSC:
+                       pbScript        = &(pbHvData[dIndex]);
+                       dScriptSize     = (unsigned int)sdChunkSize;
+                       break;
+               default:
+                       break;
                }
                dIndex  += sdChunkSize;
        }
@@ -2429,8 +2423,7 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
        _mmf_CheckInitial(psLoad_Info);
 
        /* check File Chunk(ID/Size)    */
-       sdChunkSize = _mmf_MalibNextChunk(pbBuf, dSize, AVMALIB_CHUNK_PHASE_MMMD,
-                                         &dChunkID, &dChunkNo);
+       sdChunkSize = _mmf_MalibNextChunk(pbBuf, dSize, AVMALIB_CHUNK_PHASE_MMMD, &dChunkID, &dChunkNo);
        if ((sdChunkSize < 0) || (dChunkID != AVMALIB_CHUNKCODE_MMMD)) {
                return AV_MMF_ERR_FILE;
        }
@@ -2446,46 +2439,45 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
 
        /* check Contents Info Chunk                            */
        dIndex = AV_MMF_CHUNK_HEADER_SIZE;
-       sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex),
-                                         AVMALIB_CHUNK_PHASE_CNTI, &dChunkID, &dChunkNo);
+       sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex), AVMALIB_CHUNK_PHASE_CNTI, &dChunkID, &dChunkNo);
        if ((sdChunkSize < 5) || (dChunkID != AVMALIB_CHUNKCODE_CNTI)) {
                return AV_MMF_ERR_FILE;
        }
 
        /* check Contents Class         */
        if ((pbBuf[AV_MMF_POSITION_OF_CCLASS] != AV_MMF_CONTENTS_CLASS_0) &&
-           (pbBuf[AV_MMF_POSITION_OF_CCLASS] != AV_MMF_CONTENTS_CLASS_1) &&
-           (pbBuf[AV_MMF_POSITION_OF_CCLASS] != AV_MMF_CONTENTS_CLASS_2)) {
+               (pbBuf[AV_MMF_POSITION_OF_CCLASS] != AV_MMF_CONTENTS_CLASS_1) &&
+               (pbBuf[AV_MMF_POSITION_OF_CCLASS] != AV_MMF_CONTENTS_CLASS_2)) {
                return AV_MMF_ERR_CLASS;
        }
 
        /* check Contents Type          */
        dIndex += AV_MMF_CHUNK_HEADER_SIZE;
        if (((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_0) ||
-           ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_1) ||
-           ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_2)) {
+               ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_1) ||
+               ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_2)) {
                psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA2;
        } else if (((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_3) ||
-                  ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_4) ||
-                  ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_5)) {
+                       ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_4) ||
+                       ((pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0xF0) == AV_MMF_CONTENTS_TYPE_5)) {
                switch (pbBuf[AV_MMF_POSITION_OF_CTYPE] & 0x0F) {
-                       case 0x00:
-                       case 0x01:
-                               psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA2;
-                               break;
-                       case 0x02:
-                       case 0x03:
-                               psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA3;
-                               break;
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                               psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA5;
-                               break;
-                       default:
-                               return AV_MMF_ERR_TYPE;
+               case 0x00:
+               case 0x01:
+                       psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA2;
+                       break;
+               case 0x02:
+               case 0x03:
+                       psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA3;
+                       break;
+               case 0x04:
+               case 0x05:
+               case 0x06:
+               case 0x07:
+               case 0x08:
+                       psLoad_Info->dSmafType = AV_MMF_SMAF_TYPE_MA5;
+                       break;
+               default:
+                       return AV_MMF_ERR_TYPE;
                }
        } else {
                return AV_MMF_ERR_TYPE;
@@ -2497,8 +2489,7 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
        dIndex += sdChunkSize;
 
        if (pbBuf[AV_MMF_POSITION_OF_CTYPE] >= 0x30) {
-               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_MMMDSUB, &dChunkID, &dChunkNo);
+               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex), AVMALIB_CHUNK_PHASE_MMMDSUB, &dChunkID, &dChunkNo);
                if ((sdChunkSize >= 12) && (dChunkID == AVMALIB_CHUNKCODE_OPDA)) {
                        dIndex += AV_MMF_CHUNK_HEADER_SIZE;
                        psLoad_Info->sOption_Info.pbOpda                = &pbBuf[dIndex];
@@ -2509,8 +2500,7 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
 
        /* get Track Chunk information  */
        while (dSize > (dIndex + AV_MMF_CHUNK_HEADER_SIZE + AV_MMF_FILE_CRC_SIZE)) {
-               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex),
-                                                 AVMALIB_CHUNK_PHASE_MMMDSUB, &dChunkID, &dChunkNo);
+               sdChunkSize = _mmf_MalibNextChunk(&pbBuf[dIndex], (dSize - dIndex), AVMALIB_CHUNK_PHASE_MMMDSUB, &dChunkID, &dChunkNo);
                if (sdChunkSize < 0) {
                        if (sdChunkSize == AVMALIB_CHUNK_ID_ERROR) {
                                return AV_MMF_ERR_FILE;
@@ -2520,20 +2510,20 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
                }
                dIndex += AV_MMF_CHUNK_HEADER_SIZE;
                switch (dChunkID) {
-                       case AVMALIB_CHUNKCODE_MTR:
-                               if (dChunkNo > 6)
-                                       break;
-                               psLoad_Info->sTrack_Info[dChunkNo].pbMtr        = &(pbBuf[dIndex]);
-                               psLoad_Info->sTrack_Info[dChunkNo].dMtrSize     = (unsigned int)sdChunkSize;
+               case AVMALIB_CHUNKCODE_MTR:
+                       if (dChunkNo > 6)
                                break;
-                       case AVMALIB_CHUNKCODE_ATR:
-                               if (dChunkNo != 0)
-                                       break;
-                               psLoad_Info->sTrack_Info[AV_MMF_ATR_TRACK_NO].pbMtr     = &(pbBuf[dIndex]);
-                               psLoad_Info->sTrack_Info[AV_MMF_ATR_TRACK_NO].dMtrSize  = (unsigned int)sdChunkSize;
-                               break;
-                       default:
+                       psLoad_Info->sTrack_Info[dChunkNo].pbMtr        = &(pbBuf[dIndex]);
+                       psLoad_Info->sTrack_Info[dChunkNo].dMtrSize     = (unsigned int)sdChunkSize;
+                       break;
+               case AVMALIB_CHUNKCODE_ATR:
+                       if (dChunkNo != 0)
                                break;
+                       psLoad_Info->sTrack_Info[AV_MMF_ATR_TRACK_NO].pbMtr     = &(pbBuf[dIndex]);
+                       psLoad_Info->sTrack_Info[AV_MMF_ATR_TRACK_NO].dMtrSize  = (unsigned int)sdChunkSize;
+                       break;
+               default:
+                       break;
                }
                dIndex += sdChunkSize;
        }
@@ -2542,16 +2532,16 @@ _mmf_MALoad(unsigned char *pbFile, unsigned int dFSize)
 
        /* Error Check of Track Chunk   */
        switch (psLoad_Info->dSmafType) {
-               case AV_MMF_SMAF_TYPE_MA2:
-                       sdResult = _mmf_TrackChunkCheck2(psLoad_Info);
-                       break;
-               case AV_MMF_SMAF_TYPE_MA3:
-                       sdResult = _mmf_TrackChunkCheck3(psLoad_Info);
-                       break;
-               default:
-                       if (_mmf_CheckM5P(psLoad_Info) != AV_MMF_FUNC_SUCCESS)  return AV_MMF_ERR_CHUNK;
-                       sdResult = _mmf_TrackChunkCheck5(psLoad_Info);
-                       break;
+       case AV_MMF_SMAF_TYPE_MA2:
+               sdResult = _mmf_TrackChunkCheck2(psLoad_Info);
+               break;
+       case AV_MMF_SMAF_TYPE_MA3:
+               sdResult = _mmf_TrackChunkCheck3(psLoad_Info);
+               break;
+       default:
+               if (_mmf_CheckM5P(psLoad_Info) != AV_MMF_FUNC_SUCCESS)  return AV_MMF_ERR_CHUNK;
+               sdResult = _mmf_TrackChunkCheck5(psLoad_Info);
+               break;
        }
 
        /* check playback time                  */
index 4da5c2b..4ab9299 100755 (executable)
@@ -69,9 +69,9 @@ static const int mp3SamRateTable[3][3] = {
 
 #define IS_VALID_FRAME_MP3(x) \
        ((((x)[0] & mp3FrameMasking[0]) == mp3FrameDataValid[0]) && \
-        (((x)[1] & mp3FrameMasking[1]) == mp3FrameDataValid[1]) && \
-        (((x)[2] & mp3FrameMasking[2]) == mp3FrameDataValid[2]) && \
-        (((x)[3] & mp3FrameMasking[3]) == mp3FrameDataValid[3]))
+       (((x)[1] & mp3FrameMasking[1]) == mp3FrameDataValid[1]) && \
+       (((x)[2] & mp3FrameMasking[2]) == mp3FrameDataValid[2]) && \
+       (((x)[3] & mp3FrameMasking[3]) == mp3FrameDataValid[3]))
 
 
 
@@ -351,7 +351,7 @@ __AvGetXingHeader(AvXHeadData *headData,  unsigned char *buf)
        }
 
        debug_msg(RELEASE, "Xing header: sampling-rate:%d, stream-size:%d, frame-number:%d\n",
-                 headData->sampRate, headData->bytes, headData->frames);
+                                               headData->sampRate, headData->bytes, headData->frames);
 
        return 1;       /* success */
 }
@@ -398,8 +398,7 @@ __AvGetVBRIHeader(AvVBRIHeadData *headData,  unsigned char *buf)
        buf += 2;
        headData->framesPerTable = __AvExtractI2(buf);
 
-       debug_msg(RELEASE, "Vbri header: sampling-rate:%d, stream-size:%d, frame-number:%d\n",
-                 headData->sampRate, headData->bytes, headData->frames);
+       debug_msg(RELEASE, "Vbri header: sampling-rate:%d, stream-size:%d, frame-number:%d\n", headData->sampRate, headData->bytes, headData->frames);
 
        return true;       /* success */
 }
@@ -410,44 +409,39 @@ __AvIsValidHeader(AvFileContentInfo *pInfo, unsigned char *buf)
 
        if (VALID_SYNC(buf)) {
                mp3FrameDataValid[0] = (0xFF) & (mp3FrameMasking[0]);
-               mp3FrameDataValid[1] = (0xE0 | (buf[AV_MP3HDR_VERSION_OFS] & AV_MP3HDR_VERSION_M)
-                                       | (buf[AV_MP3HDR_LAYER_OFS] & AV_MP3HDR_LAYER_M)) & (mp3FrameMasking[1]);
-               mp3FrameDataValid[2] = (buf[AV_MP3HDR_SAMPLERATE_OFS] & AV_MP3HDR_SAMPLERATE_M) &
-                                      (mp3FrameMasking[2]);
-               mp3FrameDataValid[3] = (buf[AV_MP3HDR_CHANNEL_OFS] & AV_MP3HDR_CHANNEL_M) &
-                                      (mp3FrameMasking[3]);
+               mp3FrameDataValid[1] = (0xE0 | (buf[AV_MP3HDR_VERSION_OFS] & AV_MP3HDR_VERSION_M) | (buf[AV_MP3HDR_LAYER_OFS] & AV_MP3HDR_LAYER_M)) & (mp3FrameMasking[1]);
+               mp3FrameDataValid[2] = (buf[AV_MP3HDR_SAMPLERATE_OFS] & AV_MP3HDR_SAMPLERATE_M) & (mp3FrameMasking[2]);
+               mp3FrameDataValid[3] = (buf[AV_MP3HDR_CHANNEL_OFS] & AV_MP3HDR_CHANNEL_M) & (mp3FrameMasking[3]);
 
-               debug_msg(RELEASE, "*** [%02x][%02x][%02x][%02x] : [%02x][%02x][%02x][%02x]",
-                         buf[0], buf[1], buf[2], buf[3],
-                         mp3FrameDataValid[0], mp3FrameDataValid[1], mp3FrameDataValid[2], mp3FrameDataValid[3]);
+               debug_msg(RELEASE, "*** [%02x][%02x][%02x][%02x] : [%02x][%02x][%02x][%02x]", buf[0], buf[1], buf[2], buf[3], mp3FrameDataValid[0], mp3FrameDataValid[1], mp3FrameDataValid[2], mp3FrameDataValid[3]);
 
                /*
-                * MPEG Audio Layer I/II/III frame header
-                * from : http://www.mp3-tech.org/programmer/frame_header.html           *
-                *
-                * AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
-                *
-                * A    11      (31-21)         Frame sync (all bits must be set)
-                * B    2       (20,19)         MPEG Audio version ID
-                * C    2       (18,17)         Layer description
-                * D    1       (16)    Protection bit
-                * E    4       (15,12)         Bitrate index
-                * F    2       (11,10)         Sampling rate frequency index
-                * G    1       (9)     Padding bit
-                * H    1       (8)     Private bit. This one is only informative.
-                * I    2       (7,6)   Channel Mode
-                * J    2       (5,4)   Mode extension (Only used in Joint stereo)
-                * K    1       (3)     Copyright
-                * L    1       (2)     Original
-                * M    2       (1,0)   Emphasis
-                *
-                */
+               * MPEG Audio Layer I/II/III frame header
+               * from : http://www.mp3-tech.org/programmer/frame_header.html           *
+               *
+               * AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
+               *
+               * A             11      (31-21) Frame sync (all bits must be set)
+               * B             2       (20,19) MPEG Audio version ID
+               * C             2       (18,17) Layer description
+               * D             1       (16)            Protection bit
+               * E             4       (15,12) Bitrate index
+               * F     2       (11,10) Sampling rate frequency index
+               * G     1       (9)             Padding bit
+               * H     1       (8)             Private bit. This one is only informative.
+               * I     2       (7,6)           Channel Mode
+               * J     2       (5,4)           Mode extension (Only used in Joint stereo)
+               * K     1       (3)             Copyright
+               * L     1       (2)             Original
+               * M     2       (1,0)   Emphasis
+               *
+               */
 
                /* Simple check for version, layer, bitrate, samplerate */
                if ((buf[1] & 0x18) != 0x08 &&  /* 000XX000 : MPEG Audio version ID, XX=01 - reserved => 00001000(0x08) */
-                   (buf[1] & 0x06) != 0x00 && /* 00000XX0 : Layer description, XX=00 - reserved => 00000000(0x00) */
-                   (buf[2] & 0xF0) != 0xF0 && /* XXXX0000 : Bitrate index, XX=1111 - bad => 11110000(0xF0) */
-                   (buf[2] & 0x0C) != 0x0C) { /* 0000XX00 : Sampling rate frequency index, XX=11 -reserved => 00001100(0x0C) */
+                       (buf[1] & 0x06) != 0x00 && /* 00000XX0 : Layer description, XX=00 - reserved => 00000000(0x00) */
+                       (buf[2] & 0xF0) != 0xF0 && /* XXXX0000 : Bitrate index, XX=1111 - bad => 11110000(0xF0) */
+                       (buf[2] & 0x0C) != 0x0C) { /* 0000XX00 : Sampling rate frequency index, XX=11 -reserved => 00001100(0x0C) */
                        bSync = true;
                }
                debug_msg(RELEASE, "=> %s\n", bSync ? "Good!" : "Bad...");
@@ -469,33 +463,33 @@ __AvParseMp3Header(AvFileContentInfo *pInfo,  unsigned char *header)
        /* 1. Check the version of mp3 */
        result = header[1] & MASK_MPEG;
        switch (result) {
-               case MASK_MPEG_1:
-                       pInfo->mpegVersion = AV_MPEG_VER_1;
-                       break;
-               case MASK_MPEG_2:
-                       pInfo->mpegVersion = AV_MPEG_VER_2;
-                       break;
-               case MASK_MPEG_25:
-                       pInfo->mpegVersion = AV_MPEG_VER_25;
-                       break;
-               default:
-                       return false;
+       case MASK_MPEG_1:
+               pInfo->mpegVersion = AV_MPEG_VER_1;
+               break;
+       case MASK_MPEG_2:
+               pInfo->mpegVersion = AV_MPEG_VER_2;
+               break;
+       case MASK_MPEG_25:
+               pInfo->mpegVersion = AV_MPEG_VER_25;
+               break;
+       default:
+               return false;
        }
 
        /* 2. Get a layer */
        result = header[1] & MASK_LAYER;
        switch (result) {
-               case MASK_LAYER_1:
-                       pInfo->layer = AV_MP3_LAYER_1;
-                       break;
-               case MASK_LAYER_2:
-                       pInfo->layer = AV_MP3_LAYER_2;
-                       break;
-               case MASK_LAYER_3:
-                       pInfo->layer = AV_MP3_LAYER_3;
-                       break;
-               default:
-                       return false;
+       case MASK_LAYER_1:
+               pInfo->layer = AV_MP3_LAYER_1;
+               break;
+       case MASK_LAYER_2:
+               pInfo->layer = AV_MP3_LAYER_2;
+               break;
+       case MASK_LAYER_3:
+               pInfo->layer = AV_MP3_LAYER_3;
+               break;
+       default:
+               return false;
        }
 
        /* 3. bitrate */
@@ -515,24 +509,24 @@ __AvParseMp3Header(AvFileContentInfo *pInfo,  unsigned char *header)
        /* 5. channel */
        result = header[3] & MASK_CHANNEL;
        switch (result) {
-               case MASK_CHANNEL_ST:
-                       pInfo->channelIndex = 0;
-                       pInfo->channels = 2;
-                       break;
-               case MASK_CHANNEL_JS:
-                       pInfo->channelIndex = 1;
-                       pInfo->channels = 2;
-                       break;
-               case MASK_CHANNEL_DC:
-                       pInfo->channelIndex = 2;
-                       pInfo->channels = 2;
-                       break;
-               case MASK_CHANNEL_MN:
-                       pInfo->channelIndex = 3;;
-                       pInfo->channels = 1;
-                       break;
-               default:
-                       return false;
+       case MASK_CHANNEL_ST:
+               pInfo->channelIndex = 0;
+               pInfo->channels = 2;
+               break;
+       case MASK_CHANNEL_JS:
+               pInfo->channelIndex = 1;
+               pInfo->channels = 2;
+               break;
+       case MASK_CHANNEL_DC:
+               pInfo->channelIndex = 2;
+               pInfo->channels = 2;
+               break;
+       case MASK_CHANNEL_MN:
+               pInfo->channelIndex = 3;;
+               pInfo->channels = 1;
+               break;
+       default:
+               return false;
        }
 
        /*      6. padding */
@@ -542,8 +536,7 @@ __AvParseMp3Header(AvFileContentInfo *pInfo,  unsigned char *header)
        else
                pInfo->bPadding = false;
 
-       debug_msg(RELEASE, "=> samplerate=%d, bitrate=%d, layer=%d, version=%d, channel=%d, padding=%d",
-                 pInfo->sampleRate, pInfo->bitRate, pInfo->layer, pInfo->mpegVersion, pInfo->channels, pInfo->bPadding);
+       debug_msg(RELEASE, "=> samplerate=%d, bitrate=%d, layer=%d, version=%d, channel=%d, padding=%d", pInfo->sampleRate, pInfo->bitRate, pInfo->layer, pInfo->mpegVersion, pInfo->channels, pInfo->bPadding);
 
        return true;
 }
@@ -673,16 +666,14 @@ __AvGetMp3FrameSize(AvFileContentInfo *pInfo)
                        pInfo->bitRate = frameSize * pInfo->sampleRate / 48000;
                } else {
                        frameSize += 0/* FIXME: possible_free_framelen*/;
-                       pInfo->bitRate = frameSize * pInfo->sampleRate /
-                                        ((pInfo->layer == AV_MP3_LAYER_3 && pInfo->mpegVersion != AV_MPEG_VER_1) ? 72000 : 144000);
+                       pInfo->bitRate = frameSize * pInfo->sampleRate / ((pInfo->layer == AV_MP3_LAYER_3 && pInfo->mpegVersion != AV_MPEG_VER_1) ? 72000 : 144000);
                }
        } else {
                /* calculating */
                if (pInfo->layer == 1) {
                        frameSize = ((12000 * pInfo->bitRate / pInfo->sampleRate) + frameSize) * 4;
                } else {
-                       frameSize += ((pInfo->layer == AV_MP3_LAYER_3
-                                      && pInfo->mpegVersion != AV_MPEG_VER_1) ? 72000 : 144000) * pInfo->bitRate / pInfo->sampleRate;
+                       frameSize += ((pInfo->layer == AV_MP3_LAYER_3 && pInfo->mpegVersion != AV_MPEG_VER_1) ? 72000 : 144000) * pInfo->bitRate / pInfo->sampleRate;
                }
        }
 
@@ -793,8 +784,8 @@ _START_TAG_SEARCH:
 
        /**@note weak id3v2 tag checking*/
        if (tagHeader[3] != 0xFF && tagHeader[4] != 0xFF &&
-           (tagHeader[6] & 0x80) == 0 && (tagHeader[7] & 0x80) == 0 &&
-           (tagHeader[8] & 0x80) == 0 && (tagHeader[9] & 0x80) == 0) {
+               (tagHeader[6] & 0x80) == 0 && (tagHeader[7] & 0x80) == 0 &&
+               (tagHeader[8] & 0x80) == 0 && (tagHeader[9] & 0x80) == 0) {
                debug_msg(RELEASE, "good ID3V2 tag.\n");
        } else {
                debug_warning(DEBUG, "It's bad ID3V2 tag.\n");
@@ -1033,7 +1024,7 @@ static int mmf_file_mp3_get_infomation(char *filename, AvFileContentInfo *pInfo)
        unsigned long   frameSamples = 0;
        unsigned char   *buf = NULL;
        unsigned char   *v2TagExistCheck = NULL;
-       int     readAmount = 0, readedDataLen = 0;
+       int     readAmount = 0, readedDataLen = 0;
        unsigned char   TagBuff[MP3TAGINFO_SIZE + TAGV1_SEEK_GAP];
        unsigned char           TagV1ID[4] = { 0x54, 0x41, 0x47}; /*TAG */
        int             tagHeaderPos = 0;
@@ -1117,8 +1108,7 @@ static int mmf_file_mp3_get_infomation(char *filename, AvFileContentInfo *pInfo)
 
                while (readAmount > 0) {
                        if (readAmount >= AV_MP3_HEADER_READ_MAX) {
-                               if ((readedDataLen <= _AV_MP3_HEADER_POSITION_MAX + pInfo->tagV2Info.tagLen)
-                                   && (mmfile_read(hFile, buf + readedDataLen, AV_MP3_HEADER_READ_MAX) <= 0)) {
+                               if ((readedDataLen <= _AV_MP3_HEADER_POSITION_MAX + pInfo->tagV2Info.tagLen) && (mmfile_read(hFile, buf + readedDataLen, AV_MP3_HEADER_READ_MAX) <= 0)) {
                                        if (buf)
                                                _FREE_EX(buf);
 
@@ -1127,8 +1117,7 @@ static int mmf_file_mp3_get_infomation(char *filename, AvFileContentInfo *pInfo)
                                        debug_msg(RELEASE, "Reading buf readedDataLen(%d) readAmount (%d)\n", readedDataLen, readAmount);
                                }
                        } else {
-                               if ((readedDataLen <= _AV_MP3_HEADER_POSITION_MAX + pInfo->tagV2Info.tagLen)
-                                   && (mmfile_read(hFile, buf + readedDataLen, readAmount) <= 0)) {
+                               if ((readedDataLen <= _AV_MP3_HEADER_POSITION_MAX + pInfo->tagV2Info.tagLen) && (mmfile_read(hFile, buf + readedDataLen, readAmount) <= 0)) {
                                        if (buf)
                                                _FREE_EX(buf);
 
@@ -1231,14 +1220,13 @@ static int mmf_file_mp3_get_infomation(char *filename, AvFileContentInfo *pInfo)
 
 #if 0
        unsigned long   numOfFrames = 0;
-       unsigned long long      tempduration = 0;
-       unsigned int            tempNumFrames = 0;
+       unsigned long long      tempduration = 0;
+       unsigned int            tempNumFrames = 0;
 
        if (pInfo->bVbr)
                numOfFrames = pInfo->frameNum * 10;
        else {
-               numOfFrames = ((pInfo->fileLen
-                               - (pInfo->headerPos + (pInfo->bV1tagFound ? MP3TAGINFO_SIZE : 0))) * 10) / pInfo->frameSize;
+               numOfFrames = ((pInfo->fileLen - (pInfo->headerPos + (pInfo->bV1tagFound ? MP3TAGINFO_SIZE : 0))) * 10) / pInfo->frameSize;
        }
        tempNumFrames = (unsigned int)(numOfFrames / 10);
 
index 9a39e2d..ad421eb 100755 (executable)
@@ -129,21 +129,21 @@ int MMFileID3V2TagFind(MMFileIOHandle *fp, unsigned char bAppended, unsigned int
 
                /*version check */
                switch (header[index]) {
-                       case 0:
-                               out->version = MMFILE_ID3TAG_V2_0;
-                               break;
-                       case 2:
-                               out->version = MMFILE_ID3TAG_V2_2;
-                               break;
-                       case 3:
-                               out->version = MMFILE_ID3TAG_V2_3;
-                               break;
-                       case 4:
-                               out->version = MMFILE_ID3TAG_V2_4;
-                               break;
-                       default:
-                               debug_warning(DEBUG, "unknown version of id3v2\n");
-                               break;
+               case 0:
+                       out->version = MMFILE_ID3TAG_V2_0;
+                       break;
+               case 2:
+                       out->version = MMFILE_ID3TAG_V2_2;
+                       break;
+               case 3:
+                       out->version = MMFILE_ID3TAG_V2_3;
+                       break;
+               case 4:
+                       out->version = MMFILE_ID3TAG_V2_4;
+                       break;
+               default:
+                       debug_warning(DEBUG, "unknown version of id3v2\n");
+                       break;
                }
 
                index += 2;
index 765f7c0..cf694ee 100755 (executable)
@@ -299,24 +299,24 @@ int mmfile_format_read_stream_wav(MMFileFormatContext *formatContext)
        formatContext->streams[MMFILE_AUDIO_STREAM]->streamType = MMFILE_AUDIO_STREAM;
 
        switch (waveinfo->format) {
-               case 0x0001:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_PCM;
-                       break;
-               case 0x0002:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_MS_ADPCM;
-                       break;
-               case 0x0006:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_ALAW;
-                       break;
-               case 0x0007:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_MULAW;
-                       break;
-               case 0x0011:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_ADPCM;
-                       break;
-               default:
-                       formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_INVALID;
-                       break;
+       case 0x0001:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_PCM;
+               break;
+       case 0x0002:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_MS_ADPCM;
+               break;
+       case 0x0006:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_ALAW;
+               break;
+       case 0x0007:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_MULAW;
+               break;
+       case 0x0011:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_ADPCM;
+               break;
+       default:
+               formatContext->streams[MMFILE_AUDIO_STREAM]->codecId = MM_AUDIO_CODEC_INVALID;
+               break;
        }
 
        formatContext->streams[MMFILE_AUDIO_STREAM]->bitRate = waveinfo->byte_rate * 8;
index 18282d6..38e5c24 100755 (executable)
@@ -185,104 +185,104 @@ static int _CleanupFrameContext(MMFileFormatContext *formatContext, bool clean_a
 
 int fileExtToFormatType(unsigned long long fileExt)
 {
-       switch(fileExt) {
-               case MMFILE_EXT_MP4:
-               case MMFILE_EXT_MPEG4:
-               case MMFILE_EXT_M4A:
-               case MMFILE_EXT_MPG:
-               case MMFILE_EXT_MPG4:
-               case MMFILE_EXT_M4V:
-               case MMFILE_EXT_TTS:
-               case MMFILE_EXT_TRP:
-               case MMFILE_EXT_3M:
-               case MMFILE_EXT_26L:
-               case MMFILE_EXT_264:
-                       return MM_FILE_FORMAT_MP4;
+       switch (fileExt) {
+       case MMFILE_EXT_MP4:
+       case MMFILE_EXT_MPEG4:
+       case MMFILE_EXT_M4A:
+       case MMFILE_EXT_MPG:
+       case MMFILE_EXT_MPG4:
+       case MMFILE_EXT_M4V:
+       case MMFILE_EXT_TTS:
+       case MMFILE_EXT_TRP:
+       case MMFILE_EXT_3M:
+       case MMFILE_EXT_26L:
+       case MMFILE_EXT_264:
+               return MM_FILE_FORMAT_MP4;
 
-               case MMFILE_EXT_3GP:
-                       return MM_FILE_FORMAT_3GP;
+       case MMFILE_EXT_3GP:
+               return MM_FILE_FORMAT_3GP;
 
-               case MMFILE_EXT_AMR:
-               case MMFILE_EXT_AWB:
-                       return MM_FILE_FORMAT_AMR;
+       case MMFILE_EXT_AMR:
+       case MMFILE_EXT_AWB:
+               return MM_FILE_FORMAT_AMR;
 
-               case MMFILE_EXT_WAV:
-                       return MM_FILE_FORMAT_WAV;
+       case MMFILE_EXT_WAV:
+               return MM_FILE_FORMAT_WAV;
 
-               case MMFILE_EXT_MID:
-               case MMFILE_EXT_MIDI:
-               case MMFILE_EXT_SPM:
-                       return MM_FILE_FORMAT_MID;
+       case MMFILE_EXT_MID:
+       case MMFILE_EXT_MIDI:
+       case MMFILE_EXT_SPM:
+               return MM_FILE_FORMAT_MID;
 
-               case MMFILE_EXT_MP3:
-                       return MM_FILE_FORMAT_MP3;
+       case MMFILE_EXT_MP3:
+               return MM_FILE_FORMAT_MP3;
 
-               case MMFILE_EXT_AAC:
-                       return MM_FILE_FORMAT_AAC;
+       case MMFILE_EXT_AAC:
+               return MM_FILE_FORMAT_AAC;
 
-               case MMFILE_EXT_XMF:
-               case MMFILE_EXT_MXMF:
-                       return MM_FILE_FORMAT_MID;
+       case MMFILE_EXT_XMF:
+       case MMFILE_EXT_MXMF:
+               return MM_FILE_FORMAT_MID;
 
-               case MMFILE_EXT_MMF:
-               case MMFILE_EXT_MA2:
-                       return MM_FILE_FORMAT_MMF;
+       case MMFILE_EXT_MMF:
+       case MMFILE_EXT_MA2:
+               return MM_FILE_FORMAT_MMF;
 
-               case MMFILE_EXT_IMY:
-                       return MM_FILE_FORMAT_IMELODY;
+       case MMFILE_EXT_IMY:
+               return MM_FILE_FORMAT_IMELODY;
 
-               case MMFILE_EXT_AVI:
-                       return MM_FILE_FORMAT_AVI;
+       case MMFILE_EXT_AVI:
+               return MM_FILE_FORMAT_AVI;
 
-               case MMFILE_EXT_DIVX:
-                       return MM_FILE_FORMAT_DIVX;
+       case MMFILE_EXT_DIVX:
+               return MM_FILE_FORMAT_DIVX;
 
-               case MMFILE_EXT_ASF:
-               case MMFILE_EXT_ASX:
-                       return MM_FILE_FORMAT_ASF;
+       case MMFILE_EXT_ASF:
+       case MMFILE_EXT_ASX:
+               return MM_FILE_FORMAT_ASF;
 
-               case MMFILE_EXT_WMA:
-                       return MM_FILE_FORMAT_WMA;
+       case MMFILE_EXT_WMA:
+               return MM_FILE_FORMAT_WMA;
 
-               case MMFILE_EXT_WMV:
-                       return MM_FILE_FORMAT_WMV;
+       case MMFILE_EXT_WMV:
+               return MM_FILE_FORMAT_WMV;
 
-               case MMFILE_EXT_OGG:
-                       return MM_FILE_FORMAT_OGG;
+       case MMFILE_EXT_OGG:
+               return MM_FILE_FORMAT_OGG;
 
-               case MMFILE_EXT_MKV:
-               case MMFILE_EXT_MKA:
-               case MMFILE_EXT_WEBM:
-                       return MM_FILE_FORMAT_MATROSKA;
+       case MMFILE_EXT_MKV:
+       case MMFILE_EXT_MKA:
+       case MMFILE_EXT_WEBM:
+               return MM_FILE_FORMAT_MATROSKA;
 
-               case MMFILE_EXT_MOV:
-                       return MM_FILE_FORMAT_QT;
+       case MMFILE_EXT_MOV:
+               return MM_FILE_FORMAT_QT;
 
-               case MMFILE_EXT_FLAC:
-                       return MM_FILE_FORMAT_FLAC;
+       case MMFILE_EXT_FLAC:
+               return MM_FILE_FORMAT_FLAC;
 
-               case MMFILE_EXT_FLV:
-                       return MM_FILE_FORMAT_FLV;
+       case MMFILE_EXT_FLV:
+               return MM_FILE_FORMAT_FLV;
 
-               case MMFILE_EXT_RM:
-               case MMFILE_EXT_RMVB:
-                       return MM_FILE_FORMAT_REAL;
+       case MMFILE_EXT_RM:
+       case MMFILE_EXT_RMVB:
+               return MM_FILE_FORMAT_REAL;
 
-               case MMFILE_EXT_M2TS:
-               case MMFILE_EXT_MTS:
-               case MMFILE_EXT_TP:
-               case MMFILE_EXT_TS:
-                       return MM_FILE_FORMAT_M2TS;
+       case MMFILE_EXT_M2TS:
+       case MMFILE_EXT_MTS:
+       case MMFILE_EXT_TP:
+       case MMFILE_EXT_TS:
+               return MM_FILE_FORMAT_M2TS;
 
-               case MMFILE_EXT_MPEG:
-                       return MM_FILE_FORMAT_M2PS;
+       case MMFILE_EXT_MPEG:
+               return MM_FILE_FORMAT_M2PS;
 
-               case MMFILE_EXT_AIF:
-               case MMFILE_EXT_AIFF:
-                       return MM_FILE_FORMAT_AIFF;
+       case MMFILE_EXT_AIF:
+       case MMFILE_EXT_AIFF:
+               return MM_FILE_FORMAT_AIFF;
 
-               default:
-                       return MM_FILE_FORMAT_NUM;
+       default:
+               return MM_FILE_FORMAT_NUM;
        }
 }
 
@@ -362,7 +362,7 @@ _PreprocessFile(MMFileSourceType *fileSrc, char **urifilename, int *formatEnum)
                goto FILE_FORMAT_FAIL;
        }
 
-       if(MMFileFunc[skip_index].Valid!= NULL && MMFileFunc[skip_index].Valid(fp, NULL, 5)) {  // 3rd argument only mp3
+       if (MMFileFunc[skip_index].Valid != NULL && MMFileFunc[skip_index].Valid(fp, NULL, 5)) {        // 3rd argument only mp3
                *formatEnum = skip_index;
                goto FILE_FORMAT_SUCCESS;
        } else {
@@ -383,39 +383,39 @@ PROBE_PROPER_FILE_TYPE:
                debug_msg(RELEASE, "search index = [%d]\n", index);
 
                switch (index) {
-                       case MM_FILE_FORMAT_QT:
-                       case MM_FILE_FORMAT_3GP:
-                       case MM_FILE_FORMAT_MP4:
-                               *formatEnum = (skip_index == MM_FILE_FORMAT_QT || skip_index == MM_FILE_FORMAT_3GP || skip_index == MM_FILE_FORMAT_MP4) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_3GP;
-                               break;
-
-                       case MM_FILE_FORMAT_ASF:
-                       case MM_FILE_FORMAT_WMA:
-                       case MM_FILE_FORMAT_WMV:
-                               *formatEnum = (skip_index == MM_FILE_FORMAT_ASF || skip_index == MM_FILE_FORMAT_WMA || skip_index == MM_FILE_FORMAT_WMV) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_ASF;
-                               break;
-
-                       case MM_FILE_FORMAT_DIVX:
-                       case MM_FILE_FORMAT_AVI:
-                               *formatEnum = (skip_index == MM_FILE_FORMAT_DIVX || skip_index == MM_FILE_FORMAT_AVI) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_AVI;
-                               break;
-
-                       /* not supported file */
-                       case MM_FILE_FORMAT_NUT:
-                       case MM_FILE_FORMAT_AIFF:
-                       case MM_FILE_FORMAT_AU:
-                       case MM_FILE_FORMAT_VOB:
-                       case MM_FILE_FORMAT_JPG:
-                               *formatEnum = MM_FILE_FORMAT_NUM;
-                               break;
+               case MM_FILE_FORMAT_QT:
+               case MM_FILE_FORMAT_3GP:
+               case MM_FILE_FORMAT_MP4:
+                       *formatEnum = (skip_index == MM_FILE_FORMAT_QT || skip_index == MM_FILE_FORMAT_3GP || skip_index == MM_FILE_FORMAT_MP4) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_3GP;
+                       break;
+
+               case MM_FILE_FORMAT_ASF:
+               case MM_FILE_FORMAT_WMA:
+               case MM_FILE_FORMAT_WMV:
+                       *formatEnum = (skip_index == MM_FILE_FORMAT_ASF || skip_index == MM_FILE_FORMAT_WMA || skip_index == MM_FILE_FORMAT_WMV) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_ASF;
+                       break;
+
+               case MM_FILE_FORMAT_DIVX:
+               case MM_FILE_FORMAT_AVI:
+                       *formatEnum = (skip_index == MM_FILE_FORMAT_DIVX || skip_index == MM_FILE_FORMAT_AVI) ? MM_FILE_FORMAT_NUM : MM_FILE_FORMAT_AVI;
+                       break;
+
+               /* not supported file */
+               case MM_FILE_FORMAT_NUT:
+               case MM_FILE_FORMAT_AIFF:
+               case MM_FILE_FORMAT_AU:
+               case MM_FILE_FORMAT_VOB:
+               case MM_FILE_FORMAT_JPG:
+                       *formatEnum = MM_FILE_FORMAT_NUM;
+                       break;
 
-                       default:
-                               *formatEnum = index;
-                               //debug_error(RELEASE, "error: invaild format enum[%d]\n", index);
-                               break;
+               default:
+                       *formatEnum = index;
+                       //debug_error(RELEASE, "error: invaild format enum[%d]\n", index);
+                       break;
                }
 
-               if (MMFileFunc[*formatEnum].Valid!= NULL && MMFileFunc[*formatEnum].Valid(fp, NULL, 50)) {
+               if (MMFileFunc[*formatEnum].Valid != NULL && MMFileFunc[*formatEnum].Valid(fp, NULL, 50)) {
                        if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = *formatEnum;
                        goto FILE_FORMAT_SUCCESS;
                }
index b4686c3..4c0963e 100755 (executable)
@@ -24,7 +24,7 @@
  *
  * @file               mm_file.h
  * @author
- * @version            1.0
+ * @version            1.0
  * @brief              This file declares data structures and functions of flie
  *                             library.
  */
@@ -102,19 +102,19 @@ typedef enum {
 /**
  * content attributes.
  */
-#define MM_FILE_CONTENT_DURATION                       "content-duration"              /**< Duration of media */
+#define MM_FILE_CONTENT_DURATION                       "content-duration"              /**< Duration of media */
 #define MM_FILE_CONTENT_VIDEO_CODEC                    "content-video-codec"           /**< Used video codec */
 #define MM_FILE_CONTENT_VIDEO_FORMAT           "content-video-format"          /**< Used video format */
 #define MM_FILE_CONTENT_VIDEO_BITRATE          "content-video-bitrate"         /**< Bitrate of video stream */
-#define MM_FILE_CONTENT_VIDEO_FPS                      "content-video-fps"             /**< Frames per second of video stream */
-#define MM_FILE_CONTENT_VIDEO_WIDTH                    "content-video-width"           /**< Width of video stream */
+#define MM_FILE_CONTENT_VIDEO_FPS                      "content-video-fps"             /**< Frames per second of video stream */
+#define MM_FILE_CONTENT_VIDEO_WIDTH                    "content-video-width"           /**< Width of video stream */
 #define MM_FILE_CONTENT_VIDEO_HEIGHT           "content-video-height"          /**< Height of video stream */
 #define MM_FILE_CONTENT_VIDEO_THUMBNAIL                "content-video-thumbnail"       /**< Thumbnail of video stream */
 #define MM_FILE_CONTENT_VIDEO_TRACK_INDEX      "content-video-track-index" /**< Current stream of video */
 #define MM_FILE_CONTENT_VIDEO_TRACK_COUNT      "content-video-track-count"/**< Number of video streams */
 #define MM_FILE_CONTENT_AUDIO_CODEC                    "content-audio-codec"           /**< Used audio codec */
-#define MM_FILE_CONTENT_AUDIO_BITRATE          "content-audio-bitrate"         /**< Bitrate of audio stream */
-#define MM_FILE_CONTENT_AUDIO_CHANNELS         "content-audio-channels"        /**< Channels of audio stream */
+#define MM_FILE_CONTENT_AUDIO_BITRATE          "content-audio-bitrate" /**< Bitrate of audio stream */
+#define MM_FILE_CONTENT_AUDIO_CHANNELS         "content-audio-channels"        /**< Channels of audio stream */
 #define MM_FILE_CONTENT_AUDIO_SAMPLERATE       "content-audio-samplerate" /**< Sampling rate of audio stream */
 #define MM_FILE_CONTENT_AUDIO_TRACK_INDEX      "content-audio-track-index"     /**< Current stream of audio */
 #define MM_FILE_CONTENT_AUDIO_TRACK_COUNT      "content-audio-track-count"/**< Number of audio streams */
@@ -123,7 +123,7 @@ typedef enum {
 /**
  * tag attributes.
  */
-#define MM_FILE_TAG_ARTIST                     "tag-artist"                    /**< Artist */
+#define MM_FILE_TAG_ARTIST                     "tag-artist"                    /**< Artist */
 #define        MM_FILE_TAG_TITLE                       "tag-title"                     /**< Title */
 #define        MM_FILE_TAG_ALBUM                       "tag-album"                     /**< Album */
 #define        MM_FILE_TAG_ALBUM_ARTIST        "tag-album-artist"                      /**< Album_Artist */
@@ -142,9 +142,9 @@ typedef enum {
 #define        MM_FILE_TAG_LONGITUDE       "tag-longitude"             /**< location Information*/
 #define        MM_FILE_TAG_LATIDUE         "tag-latitude"                      /**< location Information*/
 #define        MM_FILE_TAG_ALTIDUE         "tag-altitude"                      /**< location Information*/
-#define        MM_FILE_TAG_CONDUCTOR       "tag-conductor"             /**< Conductor Information*/
-#define        MM_FILE_TAG_UNSYNCLYRICS    "tag-unsynclyrics"          /**< Unsynchronized Lyrics Information*/
-#define        MM_FILE_TAG_SYNCLYRICS_NUM  "tag-synclyrics-num"        /**< Synchronized Lyrics Information*/
+#define        MM_FILE_TAG_CONDUCTOR       "tag-conductor"             /**< Conductor Information*/
+#define        MM_FILE_TAG_UNSYNCLYRICS    "tag-unsynclyrics"  /**< Unsynchronized Lyrics Information*/
+#define        MM_FILE_TAG_SYNCLYRICS_NUM  "tag-synclyrics-num"        /**< Synchronized Lyrics Information*/
 #define        MM_FILE_TAG_RECDATE                     "tag-recdate"                   /**< Recoding date */
 #define        MM_FILE_TAG_ROTATE                      "tag-rotate"                    /**< Rotate(Orientation) Information*/
 #define        MM_FILE_TAG_CDIS                        "tag-cdis"                              /**< CDIS in User Data Information*/
@@ -195,7 +195,7 @@ typedef enum {
   *
   * @pre               File should be exists.
   * @post      Handle is ready to use.
-  * @see       mm_file_destroy_tag_attrs, mm_file_get_attrs
+  * @see               mm_file_destroy_tag_attrs, mm_file_get_attrs
   * @par Example:
   * @code
 #include <mm_file.h>
@@ -239,7 +239,7 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename);
  * @remark     None.
  *     @pre            Handle should be valid.
  *     @post   Handle is not valid any more.
- * @see        mm_file_create_tag_attrs, mm_file_get_attrs
+ * @see                mm_file_create_tag_attrs, mm_file_get_attrs
  * @par Example:
  * @code
 #include <mm_file.h>
@@ -286,7 +286,7 @@ int mm_file_destroy_tag_attrs(MMHandleType tag_attrs);
  *
  * @pre        File should be exists.
  * @post       Handle is ready to use.
- * @see        mm_file_destroy_content_attrs, mm_file_get_attrs
+ * @see        mm_file_destroy_content_attrs, mm_file_get_attrs
  * @par Example:
  * @code
 #include <mm_file.h>
@@ -361,7 +361,7 @@ int mm_file_create_content_attrs(MMHandleType *content_attrs, const char *filena
   *
   * @pre               Handle should be valid.
   * @post      Handle is not valid anymore.
-  * @see       mm_file_create_content_attrs, mm_file_get_attrs
+  * @see               mm_file_create_content_attrs, mm_file_get_attrs
   * @par Example:
   * @code
 #include <mm_file.h>
@@ -431,9 +431,9 @@ int mm_file_destroy_content_attrs(MMHandleType content_attrs);
   *
   * @param     attrs           [in]    tag or content attribute handle.
   * @param   err_attr_name          [out]  Name of attribute which is failed to get
-  * @param   first_attribute_name [in]         Name of the first attribute to get
-  * @param   ...                                        [in]   Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
-  *                                                                            But, in the case of data or string type, it should be name/value/size.
+  * @param   first_attribute_name [in] Name of the first attribute to get
+  * @param   ...                                        [in]           Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
+  *                                                                            But, in the case of data or string type, it should be name/value/size.
   *
   * @return    This function returns MM_ERROR_NONE on success, or negative value with error code.
   *
@@ -441,7 +441,7 @@ int mm_file_destroy_content_attrs(MMHandleType content_attrs);
   *                    And, if this function is failed, err_attr_name param must be free.
   * @pre               Handle should be valid.
   * @post      Every input parameters are set by each information attributes.
-  * @see       mm_file_create_content_attrs, mm_file_create_tag_attrs
+  * @see               mm_file_create_content_attrs, mm_file_create_tag_attrs
   * @par Example:
   * @code
 #include <mm_file.h>
@@ -520,7 +520,7 @@ int mm_file_get_attrs(MMHandleType attrs, char **err_attr_name, const char *firs
   *
   * @pre       Input data pointer and input size should be valid. format should be matched with actual data.
   * @post      Tag attribute handle is ready to use.
-  * @see       mm_file_destroy_tag_attrs
+  * @see               mm_file_destroy_tag_attrs
   * @code
 #include <mm_file.h>
 
@@ -556,7 +556,7 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
   *
   * @pre       Input data pointer and input size should be valid. format should be matched with actual data.
   * @post      Content attribute handle is ready to use.
-  * @see       mm_file_destroy_content_attrs
+  * @see               mm_file_destroy_content_attrs
   * @par Example::
   * @code
 #include <mm_file.h>
@@ -617,7 +617,7 @@ int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *vi
   *
   * @pre       File should be exists.
   * @post      Handle is ready to use.
-  * @see       mm_file_destroy_content_attrs, mm_file_get_attrs
+  * @see               mm_file_destroy_content_attrs, mm_file_get_attrs
   * @par Example::
   * @code
 #include <mm_file.h>
index 10c58d8..55ee214 100755 (executable)
@@ -58,55 +58,55 @@ extern "C" {
 #define FONT_COLOR_GRAY     "\033[37m"
 
 #define debug_log(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGD(FONT_COLOR_RESET fmt, ##arg); \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGD(FONT_COLOR_RESET fmt, ##arg); \
                        }       \
                } while (0)
 
 #define debug_msg(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGD(FONT_COLOR_RESET fmt, ##arg); \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGD(FONT_COLOR_RESET fmt, ##arg); \
                        }       \
                } while (0)
 
 #define debug_warning(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGW(FONT_COLOR_GREEN fmt, ##arg); \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGW(FONT_COLOR_GREEN fmt, ##arg); \
                        }       \
                } while (0)
 
 #define debug_error(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE(FONT_COLOR_RED fmt, ##arg); \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE(FONT_COLOR_RED fmt, ##arg); \
                        }       \
                } while (0)
 
 #define debug_fenter(mode) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE(FONT_COLOR_RESET "<ENTER> \n");     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE(FONT_COLOR_RESET "<ENTER> \n");     \
                        }       \
                } while (0)
 
 #define debug_fleave(mode) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE(FONT_COLOR_RESET "<LEAVE> \n");     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE(FONT_COLOR_RESET "<LEAVE> \n");     \
                        }       \
                } while (0)
@@ -114,55 +114,55 @@ extern "C" {
 #else
 
 #define debug_log(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGD(" "fmt"", ##arg);     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGD(" "fmt"", ##arg);     \
                        }       \
                } while (0)
 
 #define debug_msg(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGD(" "fmt"", ##arg);     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGD(" "fmt"", ##arg);     \
                        }       \
                } while (0)
 
 #define debug_warning(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGW(" "fmt"", ##arg);     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGW(" "fmt"", ##arg);     \
                        }       \
                } while (0)
 
 #define debug_error(mode, fmt, arg...) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE(" "fmt"", ##arg);     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE(" "fmt"", ##arg);  \
                        }       \
                } while (0)
 
 #define debug_fenter(mode) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE("<ENTER> \n");     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE("<ENTER> \n");     \
                        }       \
                } while (0)
 
 #define debug_fleave(mode) do { \
-                       if(mode == DEBUG) {     \
+                       if (mode == DEBUG) {    \
                                LOGE("<LEAVE> \n");     \
-                       } else if(mode == RELEASE) {    \
-                               if(DEBUG_MODE == 1)     \
+                       } else if (mode == RELEASE) {   \
+                               if (DEBUG_MODE == 1)    \
                                        LOGE("<LEAVE> \n");     \
                        }       \
                } while (0)
index 257ff9b..3ba2a6f 100755 (executable)
@@ -38,7 +38,7 @@ extern "C" {
 
 #define MM_FILE_SET_MEDIA_FILE_SRC(Media, Filename)            do { \
                (Media).type = MM_FILE_SRC_TYPE_FILE; \
-               (Media).file.path = ((strstr(Filename, "file://")!=NULL) ? Filename+7:Filename); \
+               (Media).file.path = ((strstr(Filename, "file://") != NULL) ? Filename+7 : Filename); \
        } while (0);
 
 #define MM_FILE_SET_MEDIA_MEM_SRC(Media, Memory, Size, Format)         do { \
@@ -80,7 +80,7 @@ typedef struct _mmfilesteam {
        int     height;
        int     nbChannel;
        int     samplePerSec;
-       int     bitPerSample;
+       int     bitPerSample;
        bool is_uhqa;
 } MMFileFormatStream;
 
index 4170f4c..28ea7a2 100755 (executable)
--- a/mm_file.c
+++ b/mm_file.c
@@ -1495,4 +1495,4 @@ END:
        debug_fleave(RELEASE);
 
        return ret;
-}
\ No newline at end of file
+}
index 8dc8001..3116ddc 100755 (executable)
@@ -557,7 +557,7 @@ static int mmfile_get_video_frame(void *data, void *accurate, bool file_test)
        SAFE_STRLCPY(accurate_mode, (char *)accurate, sizeof(accurate_mode));
 
        if (strlen(accurate_mode) > 0) {
-               if (strncmp (accurate_mode, "1", 1) == 0)
+               if (strncmp(accurate_mode, "1", 1) == 0)
                        is_accurate = TRUE;
        }
 
index ef47dee..5dd8ddb 100755 (executable)
@@ -47,7 +47,7 @@ extern "C" {
 #define CAST_MM_HANDLE(x)                      (MMHandleType)(x)
 
 #ifndef TRUE
-#define TRUE   (1==1)
+#define TRUE   (1 == 1)
 #endif
 #ifndef FALSE
 #define FALSE  (!TRUE)
@@ -177,10 +177,7 @@ void mmfile_strfreev(char **str_array);
 int  mmfile_util_wstrlen(unsigned short *wText);
 short *mmfile_swap_2byte_string(short *mszOutput, short *mszInput, int length);
 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_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_strdup(const char *str);
 
 
@@ -204,8 +201,7 @@ typedef enum {
        MMFILE_PIXEL_FORMAT_MAX,
 } eMMFilePixelFormat;
 
-int mmfile_util_image_convert(unsigned char *src, eMMFilePixelFormat src_fmt, int src_width, int src_height,
-                              unsigned char *dst, eMMFilePixelFormat dst_fmt, int dst_width, int dst_height);
+int mmfile_util_image_convert(unsigned char *src, eMMFilePixelFormat src_fmt, int src_width, int src_height, unsigned char *dst, eMMFilePixelFormat dst_fmt, int dst_width, int dst_height);
 
 
 
@@ -213,7 +209,7 @@ int mmfile_util_image_convert(unsigned char *src, eMMFilePixelFormat src_fmt, in
 /*                            MEMORY API                              // */
 /*////////////////////////////////////////////////////////////////////// */
 void *mmfile_malloc(unsigned int size);
-#define mmfile_free(ptr)  do { if((ptr)) { mmfile_free_r((ptr)); (ptr) = NULL;} } while (0)
+#define mmfile_free(ptr)  do { if ((ptr)) { mmfile_free_r((ptr)); (ptr) = NULL; } } while (0)
 void  mmfile_free_r(void *ptr);
 void *mmfile_realloc(void *ptr, unsigned int size);
 void *mmfile_memset(void *s, int c, unsigned int n);
@@ -250,13 +246,11 @@ void  mmfile_free_debug(void *ptr, const char *func, unsigned int line);
 void *mmfile_realloc_debug(void *ptr, unsigned int size, const char *func, unsigned int line);
 void *mmfile_memset_debug(void *s, int c, unsigned int n, const char *func, unsigned int line);
 void *mmfile_memcpy_debug(void *dest, const void *src, unsigned int n, const char *func, unsigned int line);
-
-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 *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 *mmfile_strdup_debug(const char *str, const char *func, unsigned int line);
 
 #define mmfile_malloc(size)         mmfile_malloc_debug((size), __func__, __LINE__)
@@ -280,8 +274,8 @@ char *mmfile_strdup_debug(const char *str, const char *func, unsigned int line);
 #define MM_FILE_REVERSE_BYTE_ORDER_INT(i) ((int)((((i)&0xFF000000)>>24) | (((i)&0x00FF0000)>>8) | (((i)&0x0000FF00)<<8) | (((i)&0x000000FF)<<24)))
 #define MM_FILE_REVERSE_BYTE_ORDER_SHORT(s) ((short)((((s)&0xFF00)>>8) | (((s)&0x00FF)<<8)))
 
-#define _FREE_EX(ptr)               { if ((ptr)) {mmfile_free ((ptr)); (ptr) = NULL;} }
-#define _STRNCPY_EX(dst,src,size)   { if ((size>0)) {strncpy((char*)(dst), (char*)(src),(size)); *((dst) + (size)) = '\0';}}
+#define _FREE_EX(ptr)               { if ((ptr)) {mmfile_free((ptr)); (ptr) = NULL; } }
+#define _STRNCPY_EX(dst, src, size)   { if ((size > 0)) {strncpy((char*)(dst), (char*)(src), (size)); *((dst) + (size)) = '\0'; } }
 
 inline static int __AvMemstr(unsigned char *mem, unsigned char *str, int str_len, int search_range)
 {
@@ -383,7 +377,7 @@ typedef struct {
        int             pictureType;
        int             imageLen;
        int             imgDesLen;
-       int     imgMimetypeLen;
+       int             imgMimetypeLen;
        bool    bURLInfo;
 
 } AvTagVer2ImageInfo;
@@ -438,19 +432,19 @@ typedef struct {
        int             album_artistLen;
 
 /* for PC Studio Podcast */
-       int     contentGroupLen;
+       int             contentGroupLen;
 
 /* for ID3V2 Tag */
        int             encbyLen;
        int             urlLen;
        int             originartistLen;
        int             composerLen;
-       int             unsynclyricsLen;
-       int             syncLyricsNum;
+       int             unsynclyricsLen;
+       int             syncLyricsNum;
 
 /* To send resolution info to appl from OEM */
-       int     width;
-       int     height;
+       int     width;
+       int     height;
 
        unsigned int    bitRate;
        unsigned int    sampleRate;
@@ -486,7 +480,7 @@ typedef struct {
        char                    *pYear;
        char                    *pGenre;
        char                    *pTrackNum;             /*Track number/Position in set */
-       char                    *pRecDate;              /*Recording dates */
+       char                    *pRecDate;              /*Recording dates */
 
        char                    *pConductor;            /*[#TPE3 Conductor/performer refinement], ADDED: 2010-01-xx*/
 
@@ -512,13 +506,13 @@ typedef struct {
 typedef struct {
        int             videocodec;
        int             audiocodec;
-       int     width;
-       int     height;
+       int             width;
+       int             height;
 } AvExtraInfo;
 
 typedef struct {
-       unsigned long   time_info;
-       char                    *lyric_info;
+       unsigned long   time_info;
+       char                            *lyric_info;
 } AvSynclyricsInfo;
 
 void mm_file_free_synclyrics_list(GList *synclyrics_list);
index b134080..c17c73c 100755 (executable)
@@ -177,17 +177,17 @@ static int64_t mmf_mem_seek(MMFileIOHandle *h, int64_t pos, int whence)
        memHandle = h->privateData;
 
        switch (whence) {
-               case MMFILE_SEEK_SET:
-                       tmp_offset = 0 + pos;
-                       break;
-               case MMFILE_SEEK_CUR:
-                       tmp_offset = memHandle->offset + pos;
-                       break;
-               case MMFILE_SEEK_END:
-                       tmp_offset = memHandle->size + pos;
-                       break;
-               default:
-                       return MMFILE_IO_FAILED;
+       case MMFILE_SEEK_SET:
+               tmp_offset = 0 + pos;
+               break;
+       case MMFILE_SEEK_CUR:
+               tmp_offset = memHandle->offset + pos;
+               break;
+       case MMFILE_SEEK_END:
+               tmp_offset = memHandle->size + pos;
+               break;
+       default:
+               return MMFILE_IO_FAILED;
        }
 
        /*check validation*/
index bff44d6..e9ecdd9 100755 (executable)
@@ -217,17 +217,17 @@ static int64_t mmf_mmap_seek(MMFileIOHandle *h, int64_t pos, int whence)
        mmapHandle = h->privateData;
 
        switch (whence) {
-               case SEEK_SET:
-                       tmp_offset = 0 + pos;
-                       break;
-               case SEEK_CUR:
-                       tmp_offset = mmapHandle->offset + pos;
-                       break;
-               case SEEK_END:
-                       tmp_offset = mmapHandle->size + pos;
-                       break;
-               default:
-                       return MMFILE_IO_FAILED;
+       case SEEK_SET:
+               tmp_offset = 0 + pos;
+               break;
+       case SEEK_CUR:
+               tmp_offset = mmapHandle->offset + pos;
+               break;
+       case SEEK_END:
+               tmp_offset = mmapHandle->size + pos;
+               break;
+       default:
+               return MMFILE_IO_FAILED;
        }
 
        /*check validation*/
index 285b572..b78a2f8 100755 (executable)
@@ -132,7 +132,7 @@ int MMFileFormatIsValidMP3(MMFileIOHandle *pFileIO, const char *mmfileuri, int f
 
                                if ((j + frameSize) >= (readed - _MMFILE_MP3_HEADER_LENGTH)) {
                                        debug_msg(RELEASE, "MP3 coner hit %d %d\n", j, frameSize);
-                                       break;
+                                       break;
                                }
 
                                frameSize = _MMFileIsMP3Header(buffer + j + frameSize);
@@ -143,7 +143,7 @@ int MMFileFormatIsValidMP3(MMFileIOHandle *pFileIO, const char *mmfileuri, int f
                                        if (count == frameCnt) {
                                                ret = 1;
                                                debug_msg(RELEASE, "Header Detected at %d\n", i + j);
-                                               goto exit;
+                                               goto exit;
                                        }
                                } else {
                                        offset = 1;
@@ -158,7 +158,7 @@ int MMFileFormatIsValidMP3(MMFileIOHandle *pFileIO, const char *mmfileuri, int f
        }
 
 failMP3:
-       debug_msg(RELEASE, "Header Not Detected at: %d\n", i + j);
+       debug_msg(RELEASE, "Header Not Detected at: %d\n", i + j);
  exit:
        if (pFileIO == NULL && fp != NULL)
                mmfile_close(fp);
@@ -237,9 +237,9 @@ int MMFileFormatIsValidAAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
                        break;
                }
 
-               debug_msg(RELEASE, "read error. size = %d. i = %d\n", readed, i);
+               debug_msg(RELEASE, "read error. size = %d. i = %d\n", readed, i);
 
-               for (j = 0; (j < readed - _MMFILE_AAC_HEADER_LENGTH); j++) {
+               for (j = 0; (j < readed - _MMFILE_AAC_HEADER_LENGTH); j++) {
 
                        sync = ((buffer[j] << 8) | (buffer[j + 1]));
 
@@ -255,7 +255,7 @@ int MMFileFormatIsValidAAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
                                }
                                if ((j + frameSize) >= (readed - 2)) {
                                        debug_msg(RELEASE, "AAC coner hit %d %d\n", j, frameSize);
-                                       break;
+                                       break;
                                }
 
                                sync = ((buffer[j + frameSize] << 8) | (buffer[j + frameSize + 1]));
@@ -263,12 +263,12 @@ int MMFileFormatIsValidAAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
                                if ((sync & 0xFFF6) == 0xFFF0) {
                                        ret = 1;
                                        debug_msg(RELEASE, "AAC ADTS Header Detected at %d\n", i + j);
-                                       goto exit;
+                                       goto exit;
                                }
                        } else if (!memcmp((buffer + j), "ADIF", 4)) {
                                ret = 1;
                                debug_msg(RELEASE, "AAC ADIF Header Detected at %d\n", i + j);
-                               goto exit;
+                               goto exit;
                        }
                }
                /*If j is zero, this loop is infinite */
@@ -279,7 +279,7 @@ int MMFileFormatIsValidAAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
 
 
 fail:
-       debug_msg(RELEASE, "Header Detected Failed\n");
+       debug_msg(RELEASE, "Header Detected Failed\n");
 exit:
        if (pFileIO == NULL && fp != NULL)
                mmfile_close(fp);
@@ -359,8 +359,8 @@ int MMFileFormatIsValidOGG(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
                for (j = 0; (j <= readed - _MMFILE_OGG_HEADER_LENGTH); j++) {
                        if (1 == _MMFileIsOGGHeader(buffer + j)) {
                                ret = 1;
-                               debug_msg(RELEASE, "Header Detected at %d\n", i + j);
-                               goto exit;
+                               debug_msg(RELEASE, "Header Detected at %d\n", i + j);
+                               goto exit;
                        }
                }