📄 dvd_vtsi.c
字号:
/******************************************************************************
*******************************************************************************
** **
** Copyright (c) 2002 Videon Central, Inc. **
** All rights reserved. **
** **
** The computer program contained herein contains proprietary information **
** which is the property of Videon Central, Inc. The program may be used **
** and/or copied only with the written permission of Videon Central, Inc. **
** or in accordance with the terms and conditions stipulated in the **
** agreement/contract under which the programs have been supplied. **
** **
*******************************************************************************
******************************************************************************/
/**
* @file dvd_vtsi.c
*
* Functions to parse through VTS DVD information files.
*
* $Id: dvd_vtsi.c,v 1.47 2007/01/26 22:52:37 rbehe Exp $
*/
#include "vdvd_types.h"
#include "osapi.h"
#include "loader_app.h"
#include "pe_app.h"
#include "nav_task.h"
#include "dvd_vmgi.h"
#include "dvd_vtsi.h"
#include "store.h"
#include "nav_xtra.h"
#include "readdir.h"
#include "init.h"
#include "dvd_prm.h"
#include "dbgprint.h"
#include "utility.h"
#include "usrapi.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* MACROS AND DEFINES */
#define NON_CACHED_SBUF ((UBYTE *)KSEG1(sbuf))
#define DEBUG_DVD_VTSI DBG_ERROR /* set the debug level for prints, 0 for no prints */
#define DBG_ON(x) (DEBUG_DVD_VTSI >= x) /* local macro for deciding if should print */
extern LOADER_HANDLE tLoader;
vtsi_mat_struct vtsi_mat;
ptt_srpti_struct ptt_srpti;
ULONG ttu_srp[MAX_NUM_TT];
USHORT ttu_srp_num[MAX_NUM_TT];
/*
* The maximum number of PTTs is 1024 so we need to use a buffer to handle
* DVDs with few titles and large numbers of PTTs and vice-versa
*/
#ifdef FIXED_PTT
ptt_srp_struct ptt_srp[MAX_NUM_TT][MAX_PTT_SRP]; /* first array is TTU second is PTT_SRP */
#else
ptt_srp_struct *ptt_srp[MAX_NUM_TT];
ptt_srp_struct ptt_srp_buf[MAX_PTT_BUF];
#endif
vts_pgciti_struct vts_pgciti;
vts_pgci_srp_struct vts_pgci_srp[MAX_NUM_TMAP]; /* same as number of pgci */
vtsm_pgci_uti_struct vtsm_pgci_uti;
vtsm_lu_srp_struct vtsm_lu_srp[MAX_NUM_LANG];
vtsm_lui_struct vtsm_lui[MAX_NUM_LANG];
#ifdef FIXED_PGC
vts_pgci_srp_struct vtsm_pgci_srp[MAX_VTSM_PGCI_SRP_i][MAX_VTSM_PGCI_SRP_j];
#else
vts_pgci_srp_struct *vtsm_pgci_srp[MAX_VTSM_PGCI_SRP_i];
vts_pgci_srp_struct vtsm_pgci_srp_buf[MAX_VTSM_PGCI_BUF];
#endif
vts_tmapti_struct vts_tmapti;
ULONG vts_tmap_srp[MAX_NUM_TMAP];
vts_tmap_struct vts_tmap[MAX_NUM_TMAP];
#ifdef NOT_USED
vtsm_c_adti_struct vtsm_c_adti;
vtsm_cpi_struct vtsm_cpi[MAX_VTSM_CPI];
ULONG vtsm_vobu_admap_ea;
ULONG vtsm_vobu_sa[MAX_VTSM_VOBU_SA];
#endif
vts_c_adti_struct vts_c_adti;
vts_cpi_struct vts_cpi[MAX_VTS_CPI];
ULONG vts_vobu_admap_ea;
ULONG vts_vobu_sa[VTS_VOBU_SIZE];
ULONG vts_vobu_ad_size;
extern cur_bufd_struct cBfd;
/* EXTERNS */
extern ULONG last_sector_address; /* Prevents unnecessary parse in parse_pgci */
extern UBYTE next_vtsn;
extern UBYTE disc_error_flag;
extern UBYTE *sbuf;
extern ULONG lbuf[LBUFSIZE];
extern VMG_FILE_STRUCT video_ts;
extern TITLE_SET_FILE_STRUCT vts_file[99];
#if SUBTITLE_MODE == SUBTITLE_1
extern unsigned subtitle_menu;
#endif
/**
* Name: get_vtsi_ifo
*
* Description: Gets the VTSI_MAT info
*
* Arguments: ULONG vtsi_sa
*
* Returns: 0 - success
* 1 - failure due to parse error
* 2 - failure for unsupported disc
*
* Structures: sbuf -- sector buffer
*
* Pseudocode: Parses the video_ts.ifo file and
* the first play program chain
*
*/
UBYTE get_vtsi_ifo(ULONG vtsi_sa)
{
UBYTE count = 0;
UBYTE readerr = 0;
LOADER_ERR return_value = LOADER_SUCCESS;
const UCHAR dvdvideo_vts[13] = {"DVDVIDEO-VTS"};
#if SUBTITLE_MODE == SUBTITLE_1
ULONG out_msg[4];
#endif
/* Initialize sector buffer pointer to first sector of local buffer */
sbuf = (UBYTE *) lbuf;
DBGPRINT(DBG_ON(DBG_TRACE), ("get_vtsi_ifo() vtsi_sa: %u\n", vtsi_sa));
/*
* VTSI_MAT
*/
last_sector_address = 0;
Readerr:
cBfd.ulSSec = vtsi_sa;
cBfd.ulCOff = 0;
cBfd.ulESec = 1;
return_value = LoaderSectorRead(tLoader, cBfd.ulSSec + cBfd.ulCOff, sbuf, cBfd.ulESec);
/* If loader error during VMGI read, try reading */
/* the backup area for VMGI */
if (LOADER_SUCCESS != return_value)
{
cBfd.ulSSec = vts_file[tt_srp[sprm[SPRM_TTN_TT_DOM] - 1].vtsn - 1].bup_address;
cBfd.ulCOff = 0;
cBfd.ulESec = 1;
return_value = LoaderSectorRead(tLoader, cBfd.ulSSec + cBfd.ulCOff, sbuf, cBfd.ulESec);
if (return_value != LOADER_SUCCESS)
{
disc_error_flag = 1;
return (FAILURE);
}
}
/* Do inital check to verify valid DVDVIDEO-VTS data */
for (count = 0; count < 12; count++)
{
if ( NON_CACHED_SBUF[count] != dvdvideo_vts[count] )
{
if (readerr++ > 5)
{
DBGPRINT(DEBUG_DVD_VTSI, ("VTS STRING INVALID\n"));
return (FAILURE);
}
goto Readerr;
}
}
/* Parse The Video Title Set Information Management Table */
Parse_VTSI_MAT();
#ifndef _PAL_
/* Check Video attributes to determine if video is for PAL */
if ( ( (vtsi_mat.vtsm_v_atr[0] & 0x30) == 0x10) || ( (vtsi_mat.vts_v_atr[0] & 0x30) == 0x10) )
{
/* Send status event that there is a disc error, since PAL is not enabled. */
ULONG message[4];
message[0] = VDVD_STATUS_DISC_TYPE;
message[1] = MEDIA_FORMAT_CANNOT_PLAY;
UsrEventHandler(message);
return (2);
}
#endif
/*
* VTS_TT_SRPT
*/
cBfd.ulSSec = vtsi_sa + vtsi_mat.vts_ptt_srpt_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
/* Parse The Title Set Part of Title Search Pointer Table */
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTS_PTT_SRPT((ULONG) 0);
/*
* VTS_PGCIT
*/
cBfd.ulSSec = vtsi_sa + vtsi_mat.vts_pgcit_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
/* Parses the VTS Program Chain Information Table */
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTS_PGCIT((ULONG) 0);
/*
* If it exists, parse the VTSM_PGCI_UT
*/
if (vtsi_mat.vtsm_pgci_ut_sa) /* If VTSM_PGCI_UT exists parse it */
{
cBfd.ulSSec = vtsi_sa + vtsi_mat.vtsm_pgci_ut_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTSM_PGCI_UT((ULONG) 0);
}
/*
* If it exists, parse the VTS_TMAPT
*/
if (vtsi_mat.vts_tmapt_sa) /* If VTSM_TMAPT exists parse it */
{
cBfd.ulSSec = vtsi_sa + vtsi_mat.vts_tmapt_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTS_TMAPT((ULONG) 0);
}
/*
* If it exists, parse the VTSM_C_ADT
*/
#ifdef NOT_USED
if (vtsi_mat.vtsm_c_adt_sa) /* If VTSM_C_ADT exists parse it */
{
cBfd.ulSSec = vtsi_sa + vtsi_mat.vtsm_c_adt_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTSM_C_ADT((ULONG) 0);
}
#endif
/*
* If it exists, parse the VTSM_VOBU_ADMAP
*/
#ifdef NOT_USED
if (vtsi_mat.vtsm_vobu_admap_sa) /* If VTSM_VOBU_ADMAP exists parse it */
{
cBfd.ulSSec = vtsi_sa + vtsi_mat.vtsm_vobu_admap_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 0);
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTSM_VOBU_ADMAP((ULONG) 0);
}
#endif
/*
* Parse the Video Title Set Cell Address Table (VTS_C_ADT)
*/
cBfd.ulSSec = vtsi_sa + vtsi_mat.vts_c_adt_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 4);
DBGPRINT(DBG_ON(DBG_VERBOSE), ("\nget_vtsi_ifo() vtsi_mat.vts_c_adt_sa: %u\n", vtsi_mat.vts_c_adt_sa));
/*
* Parse the VTS Cell Address Table
*/
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTS_C_ADT((ULONG) 0);
/*
* Parse the Video Title Set Video Object Unit Address Map
* (VTS_VOBU_ADMAP)
*/
DBGPRINT(DBG_ON(DBG_VERBOSE), ("\nget_vtsi_ifo() vtsi_mat.vts_vobu_admap_sa: %u\n\n", vtsi_mat.vts_vobu_admap_sa));
cBfd.ulSSec = vtsi_sa + vtsi_mat.vts_vobu_admap_sa;
cBfd.ulCOff = 0;
GetTable(&cBfd, 0);
/*
* Parse The Title Set Video Object Unit Address Map
*/
/* If it's greater than the size of sbuf, store() does another LoaderSectorRead */
Parse_VTS_VOBU_ADMAP((ULONG) 0);
#if SUBTITLE_MODE == SUBTITLE_1
if (subtitle_menu == TRUE)
{
subtitle_menu = FALSE;
out_msg[0] = VDVD_STATUS_SUBTITLE_ON;
if (UsrEventHandler(out_msg) != USR_SUCCESS)
{
DbgPrint(("\nUsrEventHandler FAILURE, %s, %d\n\n", __FILE__, __LINE__));
}
}
#endif
return (SUCCESS);
}
/*
* Name: get_tmap_entry
*
* Description: Reads DVD vtsi_ifo and gets tmap for a
* specific program chain and index
*
* Arguments: pgcn index to search pointer table to find time map
* map_ent index in time map to find start address of VOBU
* RLBN from first LB of VTSTT_VOBS in the VTS
* vts_sa start address of video title set vtsi or vtsi_mat
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -