📄 mvplaylistdb.cpp
字号:
uint32 length;
uint8 pTmpBuf[34];
/* read up to an including the still_time field */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 34, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* Play item length */
length = MAKE_WORD(&pTmpBuf[0]);
/* PlayItem File Name */
pPlayItem->Clip_Information_file_name[0] = pTmpBuf[2];
pPlayItem->Clip_Information_file_name[1] = pTmpBuf[3];
pPlayItem->Clip_Information_file_name[2] = pTmpBuf[4];
pPlayItem->Clip_Information_file_name[3] = pTmpBuf[5];
pPlayItem->Clip_Information_file_name[4] = pTmpBuf[6];
DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList_PlayItem: clip# = %d\n",
GET_INT_FROM_ASCII4(pPlayItem->Clip_Information_file_name)));
/* verify codec identifier */
DbgAssert(pTmpBuf[7] == 'M');
DbgAssert(pTmpBuf[8] == '2');
DbgAssert(pTmpBuf[9] == 'T');
DbgAssert(pTmpBuf[10] == 'S');
/* is_multi_angle flag */
pPlayItem->is_multi_angle = ( (pTmpBuf[12] & 0x10) != 0 );
DBGPRINT(DBG_ON(DBG_VERBOSE), ("is_multi_angle: %u\n", pPlayItem->is_multi_angle));
/* connection condition */
pPlayItem->connection_condition = (pTmpBuf[12] & 0x0f);
/* ref_to_STC_id[0] */
pPlayItem->ref_to_STC_id = pTmpBuf[13];
/* PlayItem IN_time and OUT_time */
pPlayItem->IN_time = MAKE_DWORD(&pTmpBuf[14]);
pPlayItem->OUT_time = MAKE_DWORD(&pTmpBuf[18]);
DBGPRINT(DBG_ON(DBG_VERBOSE), (" IN_time: %lx\n", pPlayItem->IN_time));
DBGPRINT(DBG_ON(DBG_VERBOSE), (" OUT_time: %lu\n", pPlayItem->OUT_time));
/* store the UO mask table */
#if VDVD_PLATFORM_ENDIANESS == VDVD_BIG_ENDIAN
memcpy(&(pPlayItem->UO_mask_table), &pTmpBuf[22], 8);
#else
((BYTE *)(&(pPlayItem->UO_mask_table)))[0] = pTmpBuf[29];
((BYTE *)(&(pPlayItem->UO_mask_table)))[1] = pTmpBuf[28];
((BYTE *)(&(pPlayItem->UO_mask_table)))[2] = pTmpBuf[27];
((BYTE *)(&(pPlayItem->UO_mask_table)))[3] = pTmpBuf[26];
((BYTE *)(&(pPlayItem->UO_mask_table)))[4] = pTmpBuf[25];
((BYTE *)(&(pPlayItem->UO_mask_table)))[5] = pTmpBuf[24];
((BYTE *)(&(pPlayItem->UO_mask_table)))[6] = pTmpBuf[23];
((BYTE *)(&(pPlayItem->UO_mask_table)))[7] = pTmpBuf[22];
#endif
/* store the random access flag */
pPlayItem->PlayItem_random_access_flag = ( (pTmpBuf[30] & 0x80) != 0);
/* still_mode and still_time */
pPlayItem->still_mode = pTmpBuf[31];
pPlayItem->still_time = MAKE_WORD(&pTmpBuf[32]);
/*
* multi_clip_entries()
********************************************************************/
if (pPlayItem->is_multi_angle != 0)
{
/* number_of_angles, is_different_audios, and is_seamless_angle_change */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 2, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* number_of_angles */
pPlayItem->number_of_angles = pTmpBuf[0];
DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList_PlayItem: number_of_angles = %d\n", pPlayItem->number_of_angles));
DbgAssert(pPlayItem->number_of_angles >= 2);
DbgAssert(pPlayItem->number_of_angles <= 9);
/* is_different_audios */
pPlayItem->is_different_audios = ( (pTmpBuf[1] & 0x02) != 0 );
DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList_PlayItem: is_different_audios = %d\n", pPlayItem->is_different_audios));
/* is_seamless_angle_change */
pPlayItem->is_seamless_angle_change = ( (pTmpBuf[1] & 0x01) != 0 );
/* fill in multi_clip_entry for each angle */
for (int angle=0; angle < (pPlayItem->number_of_angles - 1); angle++)
{
/* read data for current angle */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 10, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* PlayItem File Name */
pPlayItem->multi_clip_entry[angle].Clip_Information_file_name[0] = pTmpBuf[0];
pPlayItem->multi_clip_entry[angle].Clip_Information_file_name[1] = pTmpBuf[1];
pPlayItem->multi_clip_entry[angle].Clip_Information_file_name[2] = pTmpBuf[2];
pPlayItem->multi_clip_entry[angle].Clip_Information_file_name[3] = pTmpBuf[3];
pPlayItem->multi_clip_entry[angle].Clip_Information_file_name[4] = pTmpBuf[4];
/* verify codec identifier */
DbgAssert(pTmpBuf[5] == 'M');
DbgAssert(pTmpBuf[6] == '2');
DbgAssert(pTmpBuf[7] == 'T');
DbgAssert(pTmpBuf[8] == 'S');
/* PlayItem ref_to_STC_id */
pPlayItem->multi_clip_entry[angle].ref_to_STC_id = pTmpBuf[9];
}
}
/*
* STN_table()
********************************************************************/
tStatus = mplsLoadPlayList_STN_table(file, &pPlayItem->STN_table);
if (tStatus != MPLS_SUCCESS)
{
goto errout;
}
return (MPLS_SUCCESS);
errout:
return (tStatus);
}
/**
* mplsUnLoadPlayList_PlayItem -- Dealloc any PlayItem allocations.
*
* @param
* file - handle to open file; this could be the main, or backup copy
* pPlayItem - pointer to record to receive the parsed data
*
* @retval
* MPLS_SUCCESS, MPLS_FILE_ERROR
*/
static MPLS_STATUS mplsUnLoadPlayList_PlayItem(PLAYITEM *pPlayItem)
{
mplsUnLoadPlayList_STN_table(&pPlayItem->STN_table);
return (MPLS_SUCCESS);
}
static MPLS_STATUS mplsLoadStreamEntry(LOADER_FILE_HANDLE file, STREAM_ENTRY *entry)
{
MPLS_STATUS tStatus = MPLS_SUCCESS;
uint8 pTmpBuf[10];
/* read the entire stream entry */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 10, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* get stream type */
entry->type = pTmpBuf[1];
switch (entry->type)
{
case 1:
/* this is a clip used by the playitem */
entry->ref_to_stream_PID_of_mainClip = MAKE_WORD(&pTmpBuf[2]);
break;
case 2:
/* this is a clip used by the subpath */
entry->ref_to_SubPath_id = pTmpBuf[2];
entry->ref_to_subClip_entry_id = pTmpBuf[3];
entry->ref_to_stream_PID_of_subClip = MAKE_WORD(&pTmpBuf[4]);
break;
case 3:
/* this is a clip used by the subpath, with subpath type 7 */
entry->ref_to_SubPath_id = pTmpBuf[2];
entry->ref_to_stream_PID_of_mainClip = MAKE_WORD(&pTmpBuf[3]);
break;
default:
DbgPrint(("entrytype: %u\n", entry->type));
DbgAssert(0);
}
errout:
return (tStatus);
}
static MPLS_STATUS mplsLoadStreamAttributes(LOADER_FILE_HANDLE file, STREAM_ATTRIBUTES *attributes)
{
MPLS_STATUS tStatus = MPLS_SUCCESS;
uint8 pTmpBuf[10];
/* read stream attributes */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 6, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* get stream coding type */
attributes->stream_coding_type = pTmpBuf[1];
switch (attributes->stream_coding_type)
{
case MPLS_STREAM_CODING_TYPE_MPEG2:
case MPLS_STREAM_CODING_TYPE_AVC:
case MPLS_STREAM_CODING_TYPE_VC1:
attributes->video_format = ((pTmpBuf[2] & 0xF0) >> 4);
attributes->frame_rate = ( pTmpBuf[2] & 0x0F);
attributes->aspect_ratio = ((pTmpBuf[3] & 0xF0) >> 4);
break;
case MPLS_STREAM_CODING_TYPE_LPCM:
case MPLS_STREAM_CODING_TYPE_AC3:
case MPLS_STREAM_CODING_TYPE_DTS:
case MPLS_STREAM_CODING_TYPE_DOLBY_LOSSLESS:
case MPLS_STREAM_CODING_TYPE_AC3_PLUS:
case MPLS_STREAM_CODING_TYPE_DTS_HD:
case MPLS_STREAM_CODING_TYPE_DTS_HD_XLL:
case MPLS_STREAM_CODING_TYPE_AC3_PLUS_SECONDARY:
case MPLS_STREAM_CODING_TYPE_DTS_HD_SECONDARY:
attributes->audio_presentation_type = ((pTmpBuf[2] & 0xF0) >> 4);
attributes->sampling_frequency = (pTmpBuf[2] & 0x0F);
memcpy(&(attributes->audio_language_code), &pTmpBuf[3], 3);
break;
case MPLS_STREAM_CODING_TYPE_PG:
memcpy(&(attributes->PG_language_code), &pTmpBuf[2], 3);
break;
case MPLS_STREAM_CODING_TYPE_IG:
memcpy(&(attributes->IG_language_code), &pTmpBuf[2], 3);
break;
case MPLS_STREAM_CODING_TYPE_TEXT_SUBTITLE:
attributes->character_code = pTmpBuf[2];
memcpy(&(attributes->textST_language_code), &pTmpBuf[3], 3);
break;
default:
DbgAssert(0);
}
errout:
return (tStatus);
}
/**
* mplsLoadPlayList_STN_table -- Parses the STN_table portion of the current PlayItem.
*
* @param
* file - handle to open file; this could be the main, or backup copy
* pSTN_table - pointer to record to receive the parsed data
*
* @retval
* MPLS_SUCCESS, MPLS_FILE_ERROR
*/
static MPLS_STATUS mplsLoadPlayList_STN_table(LOADER_FILE_HANDLE file, STN_TABLE *pSTN_table)
{
MPLS_STATUS tStatus;
uint32 length;
uint8 pTmpBuf[11];
uint32 version;
int ref_entry;
/* get version number so that we can support old versions of the spec that
* don't have a secondary audio stream */
version = GET_INT_FROM_ASCII4(pMPLS_DB->tMovPlayListData.version_number);
DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList_STN_table - version=%ld\n", version));
/* read up to an including the number_of_secondary_audio_stream_entries field */
if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 11, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u Read Failed!\n", __FUNCTION__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* get length */
length = MAKE_WORD(&pTmpBuf[0]);
/* get number of stream entries */
pSTN_table->number_of_primary_video_stream_entries = pTmpBuf[4];
pSTN_table->number_of_primary_audio_stream_entries = pTmpBuf[5];
pSTN_table->number_of_PG_textST_stream_entries = pTmpBuf[6];
pSTN_table->number_of_IG_stream_entries = pTmpBuf[7];
if (version > BDROM_SPEC_VERSION)
{
pSTN_table->number_of_secondary_audio_stream_entries = pTmpBuf[8];
}
else
{
pSTN_table->number_of_secondary_audio_stream_entries = 0;
}
if (version > 95)
{
pSTN_table->number_of_secondary_video_stream_entries = pTmpBuf[9];
pSTN_table->number_of_PiP_PG_textST_stream_entries_plus = pTmpBuf[10];
}
else
{
pSTN_table->number_of_secondary_video_stream_entries = 0;
pSTN_table->number_of_PiP_PG_textST_stream_entries_plus = 0;
}
/* Seek past reserved data */
if (LoaderFileSeek(pMPLS_DB->hLoader, file, LOADER_SEEK_CURRENT, 5) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: %u: Failed to seek in file!\n", __FILE__, __LINE__));
tStatus = MPLS_FILE_ERROR;
goto errout;
}
/* Video Stream Entries */
if (pSTN_table->number_of_primary_video_stream_entries > 0)
{
#if DBG_ON(DBG_TRACE)
gMPLSMemUsage += sizeof(STREAM_TABLE) * pSTN_table->number_of_primary_video_stream_entries;
#endif
/* allocate the required number of streams */
pSTN_table->primary_video_stream = (STREAM_TABLE *)OS_MemAlloc(sizeof(STREAM_TABLE) * pSTN_table->number_of_primary_video_stream_entries);
if (pSTN_table->primary_video_stream == NULL)
{
tStatus = MPLS_NO_MEMORY;
goto errout;
}
/* intialize primary video stream data */
memset(pSTN_table->primary_video_stream, 0, (sizeof(STREAM_TABLE) * pSTN_table->number_of_primary_video_stream_entries) );
for (int stream=0; stream<pSTN_table->number_of_primary_video_stream_entries; stream++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -