#define AAC_ADTS_FRAME_LEN_OFFSET 30
#define AAC_ADTS_SAMPLES_PER_FRAME 1024
-/* 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])))
-
-#define GET_SHORT_NUMBER(buff) (short)(((short)(buff)[0] << 8) | \
- ((short)(buff)[1]))
-
-
-
typedef enum _mmfile_aac_format_type {
AAC_FORMAT_ADIF,
AAC_FORMAT_ADTS,
return false;
}
- encSize = GET_INT_NUMBER(&tagHeader[6]);
+ encSize = MMFILE_CONVERT_INT(&tagHeader[6]);
pData->tagInfoSize = MP3_TAGv2_HEADER_LEN;
pData->tagInfoSize += (((encSize & 0x0000007F) >> 0) | ((encSize & 0x00007F00) >> 1) | \
extraByteFlag = 1;
}
- res = GET_INT_NUMBER(dest);
+ res = MMFILE_CONVERT_INT(dest);
if (!extraByteFlag) {
temp = (4 - occupiedBytes) * 8 + (7 - srcBitEndOff);
}
#define DATA_LENGTH 4
-#define CONVERT_TO_INT(dest, src) {dest = 0; dest |= (0 | src[0] << 24) | (0 | src[1] << 16) | (0 | src[2] << 8) | (0 | src[3]); }
static void __fill_picture_in_context(char *value, MMFileFormatContext *formatContext)
{
/* get mime_type */
memcpy(current_data, meta_data + current_pos, DATA_LENGTH);
- CONVERT_TO_INT(len, current_data);
+ len = MMFILE_CONVERT_INT(current_data);
current_pos += DATA_LENGTH;
mmfile_free(formatContext->artworkMime);
/* get description */
current_pos += len;
memcpy(current_data, meta_data + current_pos, DATA_LENGTH);
- CONVERT_TO_INT(len, current_data);
+ len = MMFILE_CONVERT_INT(current_data);
/* get picture data */
current_pos += len + (DATA_LENGTH * 5);
memcpy(current_data, meta_data + current_pos, DATA_LENGTH);
- CONVERT_TO_INT(len, current_data);
+ len = MMFILE_CONVERT_INT(current_data);
formatContext->artworkSize = len;
return MMFILE_FORMAT_SUCCESS;
}
-static int __AvExtractInt(unsigned char *buf, unsigned int size)
-{
- int ret = *buf;
-
- while (--size)
- ret = (ret << 8) | *(++buf);
-
- return ret;
-}
-
-
static bool __AvGetXingHeader(AvXHeadData *headData, unsigned char *buf)
{
int index, headFlags;
if (hId == 0)
headData->sampRate >>= 1;
- headFlags = headData->flags = __AvExtractInt(buf, 4); /* get flags */
+ headFlags = headData->flags = MMFILE_CONVERT_INT(buf); /* get flags */
buf += 4;
if (headFlags & FRAMES_FLAG) {
- headData->frames = __AvExtractInt(buf, 4);
+ headData->frames = MMFILE_CONVERT_INT(buf);
buf += 4;
}
if (headFlags & BYTES_FLAG) {
- headData->bytes = __AvExtractInt(buf, 4);
+ headData->bytes = MMFILE_CONVERT_INT(buf);
buf += 4;
}
headData->vbrScale = -1;
if (headFlags & VBR_SCALE_FLAG)
- headData->vbrScale = __AvExtractInt(buf, 4);
+ headData->vbrScale = MMFILE_CONVERT_INT(buf);
debug_msg(RELEASE, "Xing header: sampling-rate:%d, stream-size:%d, frame-number:%d",
headData->sampRate, headData->bytes, headData->frames);
if (hId == 0)
headData->sampRate >>= 1;
- headData->vID = __AvExtractInt(buf, 2); /* get ver ID */
+ headData->vID = MMFILE_CONVERT_SHORT(buf); /* get ver ID */
buf += 2;
- headData->delay = __AvExtractInt(buf, 2);
+ headData->delay = MMFILE_CONVERT_SHORT(buf);
buf += 2;
headData->qualityIndicator = buf[0];
buf += 2;
- headData->bytes = __AvExtractInt(buf, 4);
+ headData->bytes = MMFILE_CONVERT_INT(buf);
buf += 4;
- headData->frames = __AvExtractInt(buf, 4);
+ headData->frames = MMFILE_CONVERT_INT(buf);
buf += 4;
- headData->numOfTOC = __AvExtractInt(buf, 2);
+ headData->numOfTOC = MMFILE_CONVERT_SHORT(buf);
buf += 2;
- headData->vbriScale = __AvExtractInt(buf, 2);
+ headData->vbriScale = MMFILE_CONVERT_SHORT(buf);
buf += 2;
- headData->sizePerTable = __AvExtractInt(buf, 2);
+ headData->sizePerTable = MMFILE_CONVERT_SHORT(buf);
buf += 2;
- headData->framesPerTable = __AvExtractInt(buf, 2);
+ headData->framesPerTable = MMFILE_CONVERT_SHORT(buf);
debug_msg(RELEASE, "Vbri header: sampling-rate:%d, stream-size:%d, frame-number:%d", headData->sampRate, headData->bytes, headData->frames);
inline short mmfile_io_le_int16(unsigned short value);
inline float mmfile_io_be_float32(float value);
+#define MMFILE_CONVERT_INT(x) ((int)(x)[3] | (int)(x)[2]<<8 | (int)(x)[1]<<16 | (int)(x)[0]<<24)
+#define MMFILE_CONVERT_SHORT(x) ((int)(x)[1] | (int)(x)[0]<<8)
+
+
typedef struct MMFileIOHandle {
struct MMFileIOFunc *iofunc;
int flags; /* file flags */
};
/* header */
- head = (*(headc + 0) << 24 | *(headc + 1) << 16 | *(headc + 2) << 8 | *(headc + 3));
-
+ head = MMFILE_CONVERT_INT(headc);
if ((head & 0xffe00000) != 0xffe00000) {
return 0;
}
static int _MMFileSearchID3Tag(MMFileIOHandle *fp, unsigned int *offset)
{
#define _MMFILE_MP3_TAGV2_HEADER_LEN 10
-#define _MMFILE_GET_INT_NUMBER(buff) (int)((((int)(buff)[0]) << 24) | (((int)(buff)[1]) << 16) | (((int)(buff)[2]) << 8) | (((int)(buff)[3])))
unsigned char tagHeader[_MMFILE_MP3_TAGV2_HEADER_LEN] = {0, };
unsigned int tagInfoSize = 0;
goto search_end;
}
- encSize = _MMFILE_GET_INT_NUMBER(&tagHeader[6]);
+ encSize = MMFILE_CONVERT_INT(&tagHeader[6]);
tagInfoSize = _MMFILE_MP3_TAGV2_HEADER_LEN;
tagInfoSize += (((encSize & 0x0000007F) >> 0) | ((encSize & 0x00007F00) >> 1) | ((encSize & 0x007F0000) >> 2) | ((encSize & 0x7F000000) >> 3));