Merge the same macro 76/234376/3
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 26 May 2020 02:15:44 +0000 (11:15 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 28 May 2020 23:20:58 +0000 (23:20 +0000)
Change-Id: I400949e2b6a548b334cd3579ec9c995a32642c56
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
formats/ffmpeg/mm_file_format_aac.c
formats/ffmpeg/mm_file_format_ffmpeg.c
formats/ffmpeg/mm_file_format_mp3.c
utils/include/mm_file_utils.h
utils/mm_file_util_validity.c

index 3ebb8d1ce51f9187ace1c101cad4bdd78d0dc5f7..c554fe5f37d40aedfb28cc81b7a8fc20c7f85c00 100644 (file)
 #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,
@@ -143,7 +132,7 @@ static bool __search_id3tag(tMMFILE_AAC_HANDLE *pData)
                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) |  \
@@ -266,7 +255,7 @@ static int __get_range_bits_value(unsigned char *buff, int fieldOffset, int fiel
                extraByteFlag = 1;
        }
 
-       res = GET_INT_NUMBER(dest);
+       res = MMFILE_CONVERT_INT(dest);
 
        if (!extraByteFlag) {
                temp = (4 - occupiedBytes) * 8 + (7 - srcBitEndOff);
index d1a3a89a30edfe0b06c2edbfe1ebc3be3ea6fe00..2da6a634532b684b6d2e8ad2f1d0aab48d1db128 100644 (file)
@@ -589,7 +589,6 @@ exception:
 }
 
 #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)
 {
@@ -606,7 +605,7 @@ static void __fill_picture_in_context(char *value, MMFileFormatContext *formatCo
 
        /* 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);
@@ -615,12 +614,12 @@ static void __fill_picture_in_context(char *value, MMFileFormatContext *formatCo
        /* 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;
 
index d490284b377c34b2b41a9069b85e40546a1a7db9..6367d5681b63c91caf9c915a02ff733dba1dd894 100644 (file)
@@ -207,17 +207,6 @@ int mmfile_format_close_mp3(MMFileFormatContext *formatContext)
        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;
@@ -266,15 +255,15 @@ static bool __AvGetXingHeader(AvXHeadData *headData,  unsigned char *buf)
        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;
        }
 
@@ -288,7 +277,7 @@ static bool __AvGetXingHeader(AvXHeadData *headData,  unsigned char *buf)
 
        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);
@@ -320,23 +309,23 @@ static bool __AvGetVBRIHeader(AvVBRIHeadData *headData,  unsigned char *buf)
        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);
 
index 68f0de170d3a2ea13c2f36136550c3912400919e..16310465f1e70674e00fc4e683883c1e5db84aa5 100755 (executable)
@@ -59,6 +59,10 @@ inline short            mmfile_io_be_int16(unsigned short value);
 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 */
index e8e321b31462b81112d6ac5c62f098e1b3a284a4..8e13f4d69d2cb461f963b9b9318055a2a04ad4d7 100755 (executable)
@@ -1509,8 +1509,7 @@ static int _MMFileIsMP3Header(void *header)
        };
 
        /* header */
-       head = (*(headc + 0) << 24 | *(headc + 1) << 16 | *(headc + 2) << 8 | *(headc + 3));
-
+       head = MMFILE_CONVERT_INT(headc);
        if ((head & 0xffe00000) != 0xffe00000) {
                return 0;
        }
@@ -1576,7 +1575,6 @@ static int _MMFileIsMP3Header(void *header)
 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;
@@ -1623,7 +1621,7 @@ _START_TAG_SEARCH:
                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));