#define AV_MMF_MAX_TRACK_NUM 8
#define AV_MMF_MAX_PHRASE_INFO 7
-#define AV_MMF_STATUS_IDLE 0
-#define AV_MMF_STATUS_SAT_PROFILE 1
-#define AV_MMF_STATUS_LOADED 2
-
#define AV_MMF_CRC_NULL 0xFFFF0000
#define AV_MMF_POSITION_OF_CCLASS 16
#define AV_MMF_POSITION_OF_CTYPE 17
/* SMAF information structure */
typedef struct AvTagSmafInfo {
- unsigned int dStatus; /* converter status */
LOADINFO sLoad_Info[2];
} SMAFINFO, *PSMAFINFO;
static const unsigned short g_awBitMaskTable2[8] = {0x00FF, 0x01FE, 0x03FC, 0x07F8, 0x0FF0, 0x1FE0, 0x3FC0, 0x7F80};
/* internals */
-static int __mmf_file_mmf_get_duration(char *src, int is_xmf);
+static int __mmf_file_mmf_get_duration(char *src);
/* mm plugin porting */
/* plugin manadatory API */
{
int total = 0;
- total = __mmf_file_mmf_get_duration(formatContext->uriFileName, 0 /*not XMF*/);
+ total = __mmf_file_mmf_get_duration(formatContext->uriFileName);
mm_file_retvm_if_fails(DEBUG, total > 0, MMFILE_FORMAT_FAIL);
formatContext->duration = total;
return rVal;
}
-static bool __mmf_RenewalProfile(unsigned char *pbFile)
-{
- PLOADINFO psLoad;
- POPTIONINFO psOptn;
- PTRACKINFO psTrk;
- PHUFFMANINFO psHuf;
-
- psLoad = &(g_sSmaf_Info.sLoad_Info[1]);
- psOptn = &(psLoad->sOption_Info);
- psTrk = &(psLoad->sTrack_Info[5]);
- psHuf = &(psLoad->sHuffman_Info);
-
- /* renew pointer offset to pointer */
- psLoad->pbMmmd = pbFile;
- psLoad->dCrc = AV_MMF_CRC_NULL;
-
- psOptn->pbCnti = &(pbFile[(unsigned int)psOptn->pbCnti]);
- psOptn->pbOpda = &(pbFile[(unsigned int)psOptn->pbOpda]);
-
- psTrk->pbMtr = &(pbFile[(unsigned int)psTrk->pbMtr]);
- psTrk->pbMspi = &(pbFile[(unsigned int)psTrk->pbMspi]);
- psTrk->pbMtsu = &(pbFile[(unsigned int)psTrk->pbMtsu]);
- psTrk->pbMtsq = &(pbFile[(unsigned int)psTrk->pbMtsq]);
- psTrk->pbMtsp = &(pbFile[(unsigned int)psTrk->pbMtsp]);
-
- /* Initialize Huffman information structure */
- psHuf->psBuffer = psTrk->pbMtsq;
- psHuf->dMtsqSize = psTrk->dMtsqSize;
-
- if (psTrk->pbMtr[0] == 0x01) {
- psHuf->dSeqSize = __mmf_DecodeInit(psHuf);
- if (psHuf->dSeqSize == 0)
- return false;
- }
-
- psHuf->psFBuf = psHuf->psBuffer;
- psHuf->sbFBit = psHuf->sbBitC;
- psHuf->bFByte = psHuf->bByte;
-
- return true;
-}
-
-static bool __mmf_ParseSkipXmf2Mmf(unsigned char *pbFile, unsigned int dFSize, unsigned int *pdSkipOffSet)
-{
- unsigned int skipVal = 0, sizeOfpbFile = dFSize;
- char cmpXmfCMMD[5];
-
- if (pbFile)
- memcpy(cmpXmfCMMD, pbFile, 4);
- else {
- debug_error(DEBUG, "NULL pointer!\n");
- return false;
- }
-
- cmpXmfCMMD[4] = 0;
-
- if (strncmp(cmpXmfCMMD, "CMMD", 4) == 0) {
- while (1) {
- if (pbFile[skipVal] == 'M' && pbFile[skipVal + 1] == 'M' && pbFile[skipVal + 2] == 'M' && pbFile[skipVal + 3] == 'D') {
- debug_msg(RELEASE, "MMMD Header found!\n");
- break;
- } else {
- skipVal++;
- if (skipVal >= sizeOfpbFile) {
- debug_msg(RELEASE, "MMMD Header is not found!\n");
- return false;
- }
- }
-
- }
- } else {
- debug_msg(RELEASE, "File header is not started CMMD\n");
- }
-
- debug_msg(RELEASE, "skip value: %d\n", skipVal);
- *pdSkipOffSet = skipVal;
-
- return true;
-}
-
-static int __mmf_file_mmf_get_duration(char *src, int is_xmf)
+static int __mmf_file_mmf_get_duration(char *src)
{
int readn = 0;
- unsigned int xmf_skip_offset = 0;
MMFileIOHandle *fp = NULL;
unsigned char *buf = 0;
long long src_size = 0L;
-
- PLOADINFO load_info;
- unsigned char *p_crc = NULL;
- unsigned int dCrc = 0;
- int ret = 0;
-
- /*total time (millisecond)*/
- int ret_msec = 0;
+ int ret_msec = 0;
debug_fenter(RELEASE);
- /*open*/
- ret = mmfile_open(&fp, src, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
+ if (mmfile_open(&fp, src, MMFILE_RDONLY) == MMFILE_UTIL_FAIL) {
debug_error(DEBUG, "open failed.\n");
- return -1;
+ return 0;
}
- /*get file size*/
src_size = mmfile_get_size(fp);
if (src_size <= 0) {
debug_error(DEBUG, "failed to get file size.\n");
- ret_msec = -1;
goto _RELEASE_RESOURCE;
}
- /*alloc work buffer*/
buf = g_malloc0(src_size + 1);
- /*read data*/
if ((readn = mmfile_read(fp, buf, src_size)) <= 0) {
debug_error(DEBUG, "read error. size = %d\n", readn);
-
- ret_msec = -1;
goto _RELEASE_RESOURCE;
}
- /*if XMF, get skip offset.*/
- if (is_xmf) {
- if (!__mmf_ParseSkipXmf2Mmf(buf, src_size, &xmf_skip_offset)) {
- ret_msec = -1;
- goto _RELEASE_RESOURCE;
- }
- }
-
- if (g_sSmaf_Info.dStatus == AV_MMF_STATUS_SAT_PROFILE) {
- load_info = &(g_sSmaf_Info.sLoad_Info[1]);
- if (load_info->dMmmdSize <= src_size) {
- p_crc = &(buf[load_info->dMmmdSize - 2 + xmf_skip_offset]);
- dCrc = (unsigned int)((((unsigned int)p_crc[0]) << 8) + (unsigned int)p_crc[1]);
- } else {
- dCrc = AV_MMF_CRC_NULL;
- }
-
- if (dCrc == load_info->dCrc) {
- if (__mmf_RenewalProfile(buf + xmf_skip_offset)) {
- g_sSmaf_Info.dStatus = AV_MMF_STATUS_LOADED;
- ret_msec = -1;
- goto _RELEASE_RESOURCE;
- }
- }
- }
-
- ret_msec = __mmf_MALoad(buf + xmf_skip_offset, src_size);
+ ret_msec = __mmf_MALoad(buf, src_size);
_RELEASE_RESOURCE: