⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvd_vmgi.c

📁 这是DVD中伺服部分的核心代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
*******************************************************************************
**                                                                           **
**  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_vmgi.c
 *
 * Functions to parse through various DVD information files.
 *
 * $Id: dvd_vmgi.c,v 1.37 2007/01/26 22:47:10 rbehe Exp $
 */

#include "vdvd_types.h"
#include "osapi.h"
#include "pe_app.h"
#include "nav_task.h"
#include "store.h"
#include "dvd_vmgi.h"
#include "nav_xtra.h"
#include "dvd_pgci.h"
#include "dvd_prm.h"
#include "loader_app.h"
#include "readdir.h"
#include "dbgprint.h"
#include "utility.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif


/* MACROS AND DEFINES */
#define NON_CACHED_SBUF ((UBYTE *)KSEG1(sbuf))

#define DEBUG_DVD_VMGI DBG_ERROR
#define DBG_ON(x) (DEBUG_DVD_VMGI >= x)



/*------------------- Variables --------------------------------------------- */

vmgi_mat_struct vmgi_mat;       /* Struct containing the Video Manager Information */

 /* Management table */

tt_srpti_struct tt_srpti;       /* Struct containing the Title Search Pointer */

 /* Table Info */

tt_srp_struct tt_srp[MAX_NUM_TT];       /* Array of TT_SRP */

vmgm_pgci_uti_struct vmgm_pgci_uti;

vmgm_lu_srp_struct vmgm_lu_srp[MAX_NUM_LANG];

vmgm_lui_struct vmgm_lui[MAX_NUM_LANG];

vmgm_pgci_srp_struct *vmgm_pgci_srp[MAX_NUM_LANG];
vmgm_pgci_srp_struct vmgm_pgci_srp_buf[MAX_VMGM_PGCI_BUF];

 /* First array LU#, second PGCI# */

ptl_maiti_struct ptl_maiti;

ptl_mai_srp_struct ptl_mai_srp[MAX_NUM_CTY];

USHORT ptl_lvli[MAX_NUM_LANG][MAX_NUM_PTL_LVL][MAX_NUM_VTS];

 /* First array is lanuguage then parental level, then VTS */

vts_atrti_struct vts_atrti;

ULONG vts_atr_srp[MAX_NUM_VTS];

/* DVDVIDEO_VMG identifier to verify the disk */
UCHAR dvdvideo_vmg[12] = {'D', 'V', 'D', 'V', 'I', 'D', 'E', 'O', '-', 'V', 'M', 'G'};

/* This struct is used by store() to track the data in the lbuf */
cur_bufd_struct cBfd;

/* EXTERNS */
extern LOADER_HANDLE   tLoader;
extern UBYTE           *sbuf;
extern ULONG           lbuf[LBUFSIZE];
extern VMG_FILE_STRUCT video_ts;

/**
 *  Name:           get_vmgi_ifo
 *
 *  Description:    Gets the VMGI_MAT info
 *
 *  Arguments:      none
 *
 *  Returns:        nothing
 *
 *  Structures:     sbuf  -- sector buffer
 *
 *  Pseudocode:     Parses the video_ts.ifo file and
 *                  the first play program chain
 *
 */
UBYTE get_vmgi_ifo(ULONG vmgi_sa, ULONG ifo_length)
{
    UBYTE      count        = 0;
    LOADER_ERR return_value = LOADER_SUCCESS;

    /* Initialize sector buffer pointer to first sector of local buffer */
    sbuf = (UBYTE *)lbuf;

    DBGPRINT(DBG_ON(DBG_VERBOSE), ("\nget_vmgi_ifo() sector offset to begin the read from %u\n\n", vmgi_sa));

    cBfd.ulSSec = vmgi_sa;
    cBfd.ulCOff = 0;
    cBfd.ulESec = 1;

    return_value = LoaderSectorRead(tLoader, cBfd.ulSSec + cBfd.ulCOff, sbuf, cBfd.ulESec);

#if LOADER_ERROR_RECOVER == TRUE
    /* If loader error during VMGI read, try reading */
    /* the backup area for VMGI                      */
    if (return_value != LOADER_SUCCESS)
    {
        cBfd.ulSSec = video_ts.bup_address;
        cBfd.ulCOff = 0;
        cBfd.ulESec = 1;

        return_value = LoaderSectorRead(tLoader, cBfd.ulSSec + cBfd.ulCOff, sbuf, cBfd.ulESec);
        if (return_value != LOADER_SUCCESS)
        {
            abort_startup();
            return (FAILURE);
        }
    }
#else
    if (return_value != LOADER_SUCCESS)
    {
        abort_startup();
        return (FAILURE);
    }
#endif

    /* Do inital check to verify valid DVDVIDEO-VMG data */
    for (count = 0; count < 12; count++)
    {
        if (NON_CACHED_SBUF[count] != dvdvideo_vmg[count])
        {
            DbgPrint(("ERROR - vmg string invalid\n"));
            return (FAILURE);
        }
    }

    /* Parse the VMGI_MAT data in the sector buffer */
    Parse_VMGI_MAT();

    if (vmgi_mat.fp_pgci_sa)
    {
        /* Parse the First play program chain */
        parse_fp_pgci();
    }

    /*
     * Title Search Pointer
     */
    cBfd.ulSSec = vmgi_sa + vmgi_mat.tt_srpt_sa;
    cBfd.ulCOff = 0;
    GetTable(&cBfd, 4);

    /* Parse the Title Search Pointer */
    Parse_TT_SRPT(0, vmgi_sa);

    /*
     * Video Manager Menu PGCI Unit Table
     */
    if (vmgi_mat.vmgm_pgci_ut_sa != 0)
    {
        cBfd.ulSSec = vmgi_sa + vmgi_mat.vmgm_pgci_ut_sa;
        cBfd.ulCOff = 0;
        GetTable(&cBfd, 4);

        /* Parse the Video Manager Menu PGCI Unit Table */
        Parse_VMGM_PGCI_UT(0);
    }

    /*
     * Parental Managment Information Table
     */
    /* If the ptl_mait_sa exists, load it and parse it */
    if (vmgi_mat.ptl_mait_sa != 0)
    {
        cBfd.ulSSec = vmgi_sa + vmgi_mat.ptl_mait_sa;
        cBfd.ulCOff = 0;
        GetTable(&cBfd, 4);

        /* Parse the Parental Managment Information Table */
        Parse_PTL_MAIT(0);
    }

    /*
     * Video Title Set Attribute Table
     */
    if (vmgi_mat.vts_atrt_sa != 0)
    {

        cBfd.ulSSec = vmgi_sa + vmgi_mat.vts_atrt_sa;
        cBfd.ulCOff = 0;
        GetTable(&cBfd, 4);

        /* Parse the Video Title Set Attribute Table */
        Parse_VTS_ATRT(0);
    }

#if 0
    if (vmgi_mat.txtdt_mg_sa != 0)
    {
        cBfd.ulSSec = vmgi_sa + vmgi_mat.txtdt_mg_sa;
        cBfd.ulCOff = 0;
        GetTable(&cBfd, 16);
    }
#endif

    return (SUCCESS);
}


/**
 *  Name:        Parse_VMGI_MAT
 *
 *  Description: Parses the Video Manager Information Management Table
 *               DVD Part 3:Video Spec Version 1.0 section 4.1.1
 *
 *  Arguments:   none
 *
 *  Returns:     fills VMGI_MAT structure
 *
 *  Structures:  vmgi_mat
 *
 *  Pseudocode:
 *
 **/
void Parse_VMGI_MAT()
{
    /* parse VMG identifier  (VMG_ID) */
    store((UBYTE *)&vmgi_mat.vmg_id[0], 0, 12, STORE_BIG_ENDIAN);

    /* End address of VMG  (VMG_EA) */
    store((UBYTE *)&vmgi_mat.vmg_ea, 12, 4, STORE_LITTLE_ENDIAN);

    /* End address of VMGI  (VMGI_EA) */
    store((UBYTE *)&vmgi_mat.vmgi_ea, 28, 4, STORE_LITTLE_ENDIAN);

    /* Version number of DVD Video Specificatins  (VERN) */
    store((UBYTE *)&vmgi_mat.vern, 32, 2, STORE_LITTLE_ENDIAN);

    /* Video Manager Category   (VMG_CAT) */
    store((UBYTE *)&vmgi_mat.vmg_cat[0], 34, 4, STORE_BIG_ENDIAN);

    /* Volume Set Identifier  (VLMS_ID) */
    store((UBYTE *)&vmgi_mat.vlms_id.num_of_volumes, 38, 2, STORE_LITTLE_ENDIAN);

    store((UBYTE *)&vmgi_mat.vlms_id.volume_number, 40, 2, STORE_LITTLE_ENDIAN);

    store((UBYTE *)&vmgi_mat.vlms_id.disc_side_id, 42, 1, STORE_LITTLE_ENDIAN);

    /* Number of Video Titles Sets   (VTS_N) */
    store((UBYTE *)&vmgi_mat.vts_n, 62, 2, STORE_LITTLE_ENDIAN);

    /* Provider Unique ID   (PVR_ID) */
    store((UBYTE *)&vmgi_mat.pvr_id[0], 64, 32, STORE_BIG_ENDIAN);

    /* POS code   (POS_CD) */
    store((UBYTE *)&vmgi_mat.pos_cd[0], 96, 8, STORE_BIG_ENDIAN);

    /* End address of vmgi_mat  (vmgi_mat_EA) */
    store((UBYTE *)&vmgi_mat.vmgi_mat_ea, 128, 4, STORE_LITTLE_ENDIAN);

    /* Start address of FP_PGCI */
    store((UBYTE *)&vmgi_mat.fp_pgci_sa, 132, 4, STORE_LITTLE_ENDIAN);

    /* Start address of VMGM_VOBS */
    store((UBYTE *)&vmgi_mat.vmgm_vobs_sa, 192, 4, STORE_LITTLE_ENDIAN);

    /* Start address of TT_SRTP */
    store((UBYTE *)&vmgi_mat.tt_srpt_sa, 196, 4, STORE_LITTLE_ENDIAN);

    /* Start address of VMGM_PGCI_UT */
    store((UBYTE *)&vmgi_mat.vmgm_pgci_ut_sa, 200, 4, STORE_LITTLE_ENDIAN);

    /* Start address of PTL_MAIT */
    store((UBYTE *)&vmgi_mat.ptl_mait_sa, 204, 4, STORE_LITTLE_ENDIAN);

    /* Start address of VTS_ATRT */
    store((UBYTE *)&vmgi_mat.vts_atrt_sa, 208, 4, STORE_LITTLE_ENDIAN);

    /* Start address of TXTDT_MG */
    store((UBYTE *)&vmgi_mat.txtdt_mg_sa, 212, 4, STORE_LITTLE_ENDIAN);

    /* Start address of VMGM_C_ADT */
    store((UBYTE *)&vmgi_mat.vmgm_c_adt_sa, 216, 4, STORE_LITTLE_ENDIAN);

    /* Start address of VMGM_VOBU_ADMAP */
    store((UBYTE *)&vmgi_mat.vmgm_vobu_admap_sa, 220, 4, STORE_LITTLE_ENDIAN);

    /* Video attribute of VMGM */
    store((UBYTE *)&vmgi_mat.vmgm_v_atr[0], 256, 2, STORE_BIG_ENDIAN);

    /* Number of audio streams of VMGM */
    store((UBYTE *)&vmgi_mat.vmgm_ast_n[0], 258, 2, STORE_BIG_ENDIAN);

    /* Audio stream attribute of VMGM */
    store((UBYTE *)&vmgi_mat.vmgm_ast_atr[0], 260, 8, STORE_BIG_ENDIAN);

    /* Number of Sub-picture streams of VMGM */
    store((UBYTE *)&vmgi_mat.vmgm_spst_n[0], 340, 2, STORE_BIG_ENDIAN);

    /* Sub-picture stream attribute of VMGM */
    store((UBYTE *)&vmgi_mat.vmgm_spst_atr[0], 342, 6, STORE_BIG_ENDIAN);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -