⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 id3.h

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 H
字号:
#ifndef __ID3_H__
#define __ID3_H__

//080520,huangsl,增加 include.h文件用于转换 PACKED 定义,以便 兼容 PC仿真,保留.
#include "include.h"
//#define ID3_EXT_INCLUDE

#define MAX_ID3V1_SIZE  128
#ifdef MTP_INCLUDE
#define MAX_ID3V2_FIELD  512/*MAX_STRING_NUM*/
#else
#define MAX_ID3V2_FIELD  81
#endif
#define MAX_ID3V2_YEAR  40

#define MAX_ID3_FIND_SIZE 2048
#define MAX_WMA_TAG_SIZE 128

#define ID3_FLAG_UNSYNCH   0x80 // a. Unsynchronisation
#define ID3_FLAG_EXTHEADER 0x40 // b. Extended Header
#define ID3_FLAG_INDICATOR 0x20 // c. Experimental Indicator
#define ID3_FLAG_FOOTER    0x10 // d. Footer Present

#define ID3_FLAG_UPDATE    0x40
#define ID3_FLAG_CRCDATA   0x20
#define ID3_FLAG_RESTRICT  0x10

#define ID3_ENCODE_MASK    0x03
#define ID3_ENCODE_ISO88591   0x00
#define ID3_ENCODE_UTF16   0x01
#define ID3_ENCODE_UTF16BE   0x02
#define ID3_ENCODE_UTF8    0x03

#define ID3_UNICODE_BOM1   0xFFFE
#define ID3_UNICODE_BOM2   0xFEFF

#define ID3_GENRE_MAX_CNT   148

#ifdef MTP_INCLUDE
#define ID3_UNICODE_START   1
#else
#define ID3_UNICODE_START   0
#endif

#define WAVE_HEAD_SIZE     90

// MP3 Header Parse
/////////////////////////////////////////////////////////////////
enum ID3Version
{
    ID3_V10,
    ID3_V11,
    ID3_V2X
};

enum ID3FrameInfo
{
    ID3_TITLE,
    ID3_ARTIST,
    ID3_GENRE,
    ID3_ALBUM,
    ID3_YEAR,
#ifdef ID3_EXT_INCLUDE
    ID3_COMMENT,
    ID3_COMPOSER,
    ID3_ORIGARTIST,
    ID3_COPYRIGHT,
    ID3_URL,
    ID3_ENCODEDBY,
#endif
    ID3_NONINFO,
    ID3_TRACK,
#ifdef RK_JPEG_ID3
    ID3_PICTURE,
#endif
    ID3_GEOB,
    ID3_NOTUSEDFRAME
};

typedef PACKED struct stID3Info
{
    unsigned char mTAG[3];
    unsigned char mTitle[30];
    unsigned char mArtist[30];
    unsigned char mAlbum[30];
    unsigned char mYear[4];
    unsigned char mComment[29];
    unsigned char mTrack;
    unsigned char mGenre;
}stID3InfoType, *pstID3InfoType;

typedef  PACKED struct stID3V2XInfo
{
    unsigned short mTrack;
    unsigned char  mYear[MAX_ID3V2_YEAR];
    unsigned char  mMetaData[ID3_NONINFO-1][MAX_ID3V2_FIELD];
}stID3V2XInfoType, *pstID3V2XInfoType;

typedef PACKED struct _ID3V2XHeaderType
{
    unsigned char  mID3[3];
    unsigned short mVersion;
    unsigned char  mFlags;
    unsigned char  mSize[4];
}ID3V2XHeaderType, *pID3V2XHeaderType;

typedef  PACKED struct _ID3V2XFooterType
{
    unsigned char  mID3[3];
    unsigned short mVersion;
    unsigned char  mFlags;
    unsigned char  mSize[4];
}ID3V2XFooterType, *pID3V2XFooterType;

typedef PACKED struct _ID3V2XExtHeaderType
{
    unsigned char  mHeaderSize[4];
    unsigned char  mFlagNum;
    unsigned char  mExtFlags;
}ID3V2XExtHeaderType, *pID3V2XExtHeaderType;

typedef  PACKED struct _ID3V2XFrameInfoType
{
    unsigned char  mFrameID[4];
    unsigned char  mSize[4];
    unsigned char  mFlags[2];
}ID3V2XFrameInfoType, *pID3V2XFrameInfoType;

typedef PACKED struct _ID3V22FrameInfoType
{
    unsigned char  mFrameID[3];
    unsigned char  mSize[3];
}ID3V22FrameInfoType, *pID3V22FrameInfoType;

typedef  PACKED struct _ID3V2XEncodeInfoType
{
    unsigned char   mEncodeType;
    unsigned short  mUnicodeBOM;
}ID3V2XEncodeInfoType, *pID3V2XEncodeInfoType;

// WMA Header Parse
/////////////////////////////////////////////////////////////////
struct _WMATag
{
    unsigned int tagexist;
    unsigned char artist[MAX_WMA_TAG_SIZE+2];
    unsigned char title[MAX_WMA_TAG_SIZE+2];
};

typedef PACKED struct _ASFHeaderObjectType
{
    unsigned char  mObjectID[16];
    unsigned int   mObjectSize[2];
    unsigned int   mNumOfHeadObj;
    unsigned char  mReserved[2];
}ASFHeaderObjectType, *pASFHeaderObjectType;

typedef PACKED struct _ASFFilePropertiesObjectType
{
    unsigned char  mObjectID[16];
    unsigned int   mObjectSize[2];
    unsigned char  mFileID[16];
    unsigned int   mFileSize[2];
    unsigned char  mCreationDate[8];
    unsigned char  mDataPacketsCnt[8];
    unsigned int   mPlayDuration[2];
    unsigned int   mSendDuration[2];
    unsigned char  mPreroll[8];
    unsigned int   mFlags;
    unsigned int   mMinDataPacketSize;
    unsigned int   mMaxDataPacketSize;
    unsigned int   mMaxBitrate;
}ASFFilePropertiesObjectType, *pASFFilePropertiesObjectType;

typedef PACKED struct _ASFExtContentDescripObjType
{
    unsigned char  mObjectID[16];
    unsigned int   mObjectSize[2];
    unsigned short mContentDescriptorsCnt;
}ASFExtContentDescripObjType, *pASFExtContentDescripObjType;

typedef PACKED struct _WMAMetaHeaderType
{
    unsigned char  mObjectID[16];
    unsigned int   mObjectSize[2];
    unsigned short cbCDTitle;
    unsigned short cbCDAuthor;
    unsigned short cbCDCopyright;
    unsigned short cbCDDescription;
    unsigned short cbCDRating;
}WMAMetaHeaderType, *pWMAMetaHeaderType;

typedef PACKED struct _ASFContentDescriptorType
{
    unsigned char  mSize;
    unsigned char  mID;
    unsigned char* mDescriptor;
}ASFContentDescriptorType, *pASFContentDescriptorType;


#ifdef OGG_HEADER_PARSING
typedef  struct _OGGContentDescriptorType
{
    unsigned char  mSize;
    unsigned char  mID;
    unsigned char* Big_mDescriptor;
    unsigned char* Small_mDescriptor;
}OGGContentDescriptorType, *pOGGContentDescriptorType;

#endif

enum
{
    WMA_DESCRIPTOR_UNKNOWN,
    WMA_DESCRIPTOR_ID3TAG,
    WMA_DESCRIPTOR_ALBUM,
    WMA_DESCRIPTOR_GENRE,
    WMA_DESCRIPTOR_TRACK,
    WMA_DESCRIPTOR_TRACKNUMBER,
    WMA_DESCRIPTOR_YEAR,
#ifdef RK_JPEG_ASF
    WMA_DESCRIPTOR_PICTURE,
#endif
    WMA_DESCRIPTOR_MAX
};
// WAV Header Parse
/////////////////////////////////////////////////////////////////
typedef  struct _WAVMetaHeaderType
{
    unsigned char  mRIFF[4];    // "RIFF"
    unsigned int mFileSize;    //
    unsigned char  mWAVSignature[4];  //
    unsigned char  mfmt[3];    // "fmt"
    unsigned char  mTemp1[5];    // X + 50 + XXX
    unsigned char mFormtTag[2];   //
    unsigned short  mChannel;    //
    unsigned int mSamplePerSec;   //
    unsigned int  mAvgBytesPerSec;  //
    unsigned short  mBlockAlign;   //
    unsigned short  mBitPerSample;      //
    unsigned short  mcbSize;    // Extended information size after header
    unsigned short  mSamplePerBlock;   //
    unsigned char   mwNumCoef[2];   //
    unsigned char   maCoef[7][4];   //
    unsigned char   mfact[4];    // "fact"
    unsigned char  mTemp2[4];    // XXXX
    unsigned int    mDuration;    //
    unsigned char  mdata[4];    // "data"
    unsigned char  mTemp3[4];    // XXXX
}WAVMetaHeaderType, *pWAVMetaHeaderType;


#ifdef OGG_HEADER_PARSING
// OGG Header Parse
/////////////////////////////////////////////////////////////////

enum
{
    OGG_DESCRIPTOR_TITLE,
    OGG_DESCRIPTOR_VERSION ,
    OGG_DESCRIPTOR_ALBUM ,
    OGG_DESCRIPTOR_TRACKNUMBER ,
    OGG_DESCRIPTOR_ARTIST,
    OGG_DESCRIPTOR_PERFORMER,
    OGG_DESCRIPTOR_COPYRIGHT,
    OGG_DESCRIPTOR_LICENSE,
    OGG_DESCRIPTOR_ORGANIZATION ,
    OGG_DESCRIPTOR_DESCRIPTION ,
    OGG_DESCRIPTOR_GENRE ,
    OGG_DESCRIPTOR_DATE,
    OGG_DESCRIPTOR_LOCATION,
    OGG_DESCRIPTOR_CONTACT,
    OGG_DESCRIPTOR_ISRC,
    OGG_DESCRIPTOR_YEAR,

};

typedef struct _OGGHeaderObjectType
{
    unsigned char   CapturePattern[4];
    unsigned char   Version;
    unsigned char   HeaderType;
    unsigned long long GranulePosition;
    unsigned int   BitstreamSerialNumber;
    unsigned int   PageSequenceNumber;
    unsigned int   Checksum;
    unsigned char   PageSegments;
}OGGHeaderObjectType, *pOGGHeaderObjectType;

#endif


#define ID3_GetIntValue(x)   ((x[0]<<21)|(x[1]<<14)|(x[2]<<7)|x[3])
#define ID3_GetShortValue(x)  ((x[0]<<8)|(x[1]))
#define ID3_Get3ByteValue(x)  ((x[0]<<16)|(x[1]<<8)|(x[2]))
#define ID3_Get4byteIntValue(x)   ((x[0]<<24)|(x[1]<<16)|(x[2]<<8)|x[3])


extern int ID3_GetID3(int fd);

extern int PROFILE_GetID3MP3Info(int fHandle, unsigned char *tempbuf, void *pID3Info);

//extern int PROFILE_GetMetaData( FDIRENTstruc *pFDir, DIRENTstruc *pFile, int iCodec);
extern unsigned int   CheckID3V2Tag(unsigned char *pucBuffer);
extern unsigned char  CheckValidHeader(unsigned char *header);
extern unsigned short GetSamplingRate(unsigned char* pucBuffer);
extern unsigned char  GetChannels(unsigned char* pucBuffer);
extern unsigned long  DecodeVBRHeader(unsigned char *buffer, unsigned int *framesize);
extern unsigned char  CheckValidHeader(unsigned char *header);
extern unsigned short GetFrameSize(unsigned char* pucBuffer);
extern unsigned short GetBitrate(unsigned char* pucBuffer);
extern unsigned long  GetHeaderInfo(unsigned char* pucBuffer);

extern void     ID3_MakeWideChar2Unicode(char *SourceBuf, char *TargetBuf, int iSourceMaxSize);
#endif


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -