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

📄 dvd_vmgi.c

📁 这是DVD中伺服部分的核心代码
💻 C
📖 第 1 页 / 共 2 页
字号:


/**
 **  Name:        GetTable
 **
 **  Description: Loads into sbuf the span of the current table (up to 30 sectors)
 **
 **  Arguments:   curr_bufd_struct cBfd -- Current sector information
 **               UBYTE ubEA_index -- the index into the table which contains the table's end address
 **
 **  Returns:     status
 **
 **/
UBYTE GetTable(cur_bufd_struct *cBfd, UBYTE ubEA_index)
{
    UBYTE return_value = SUCCESS;

    /* Read One Sector */
    return_value = (UBYTE)(LoaderSectorRead(tLoader, cBfd->ulSSec + cBfd->ulCOff, sbuf, 1));
    if (return_value != LOADER_SUCCESS)
    {
        abort_startup();
        return (return_value);
    }

    /* Get end address for the table */
    cBfd->ulESec = MAKE_DWORD(&sbuf[ubEA_index]) / DVD_SECTOR_SIZE;
    if (MAKE_DWORD(&sbuf[ubEA_index]) % DVD_SECTOR_SIZE)    /* if remainder */
    {
        cBfd->ulESec++;                                          /* get one more sector */
    }

    /* If more sectors must be read in order to get the whole table, do so */
    if (cBfd->ulESec > 1)
    {
        return_value = (UBYTE)(LoaderSectorRead(tLoader, cBfd->ulSSec + cBfd->ulCOff + 1, &sbuf[DVD_SECTOR_SIZE], MIN(cBfd->ulESec - cBfd->ulCOff - 1, BUFSIZE - 1)));
        if (return_value != LOADER_SUCCESS)
        {
            abort_startup();
            return (return_value);
        }
    }

    return(return_value);
}


/**
 **  Name:        Parse_TT_SRPT
 **
 **  Description: Parses the Title search pointer
 **
 **  Arguments:   tt_srpt_sa Relative Start Address of Program Chain Command
 **               Table
 **               DVD Part 3:Video Spec Version 1.0 section 4.1.2
 **
 **  Returns:     Fills TT_SRPTI and tt_srp sturcture
 **
 **  Structures:  TT_SRPTI
 **               tt_srp
 **
 *   Pseudocode:
 *
 **/
void Parse_TT_SRPT(ULONG tt_srpt_sa, ULONG vmgi_sa)
{
    ULONG index;
    ULONG Offset;

    /* Parse the Title Sear Pointer Table Information */
    /* Number of Title Search Pointers Parse */
    store((UBYTE *) & tt_srpti.tt_srp_n, (tt_srpt_sa * Logical_Block), 2, STORE_LITTLE_ENDIAN);

    /* End address of the TT_SRPT */
    store((UBYTE *) & tt_srpti.tt_srpt_ea, ((tt_srpt_sa * Logical_Block) + 4), 4, STORE_LITTLE_ENDIAN);

    /* Parse the Title Search Pointers */
    Offset = tt_srpt_sa * Logical_Block + 8;    /* +8 to get past TT_SRPTI */
    for (index = 0; index < tt_srpti.tt_srp_n && index < MAX_NUM_TT; index++)
    {
        /* store Title Playback Type */
        store((UBYTE *) & tt_srp[index].tt_pb_ty, Offset, 1, STORE_LITTLE_ENDIAN);

        /* Store Number of Angles */
        store((UBYTE *) & tt_srp[index].agl_n, (Offset + 1), 1, STORE_LITTLE_ENDIAN);

        /* Store Number of Part_of_Titles */
        store((UBYTE *) & tt_srp[index].ptt_n, (Offset + 2), 2, STORE_LITTLE_ENDIAN);

        /* Store Parental_ID_Field for Title */
        store((UBYTE *) & tt_srp[index].tt_ptl_id_fld[0], (Offset + 4), 2, STORE_BIG_ENDIAN);

        /* Store VTS number */
        store((UBYTE *) & tt_srp[index].vtsn, (Offset + 6), 1, STORE_LITTLE_ENDIAN);

        /* Store VTS Title Number */
        store((UBYTE *) & tt_srp[index].vts_ttn, (Offset + 7), 1, STORE_LITTLE_ENDIAN);

        /* Store Start Address of the VTS */
        store((UBYTE *) & tt_srp[index].vts_sa, (Offset + 8), 4, STORE_LITTLE_ENDIAN);

        tt_srp[index].vts_sa += vmgi_sa;

        Offset += 12;
    }

    ERROR_CHECK(index, MAX_NUM_TT, "MAX_NUM_TT");
}


/**
 **  Name:        Parse_VMGM_PGCI_UT
 **
 **  Description: Parses the Video Manager Menu PGCI Unit Table
 **
 **  Arguments:   vmgm_pgci_ut_sa Relative Start Address of VMGM_PGCI_UT
 **               DVD Part 3:Video Spec Version 1.0 section 4.1.3
 **
 **  Returns:     Fills structures.
 **
 **  Structures:  vmgm_pgci_uti
 **               vmgm_lu_srp
 **               VMGM_LUI
 **               VMGM_PGCI_SRP
 **
 *   Pseudocode:
 *
 **/
void Parse_VMGM_PGCI_UT(ULONG vmgm_pgci_ut_sa)
{
    ULONG index;
    ULONG count;
    ULONG Offset;
    vmgm_pgci_srp_struct *vmgm_pgci_srp_ptr     = (vmgm_pgci_srp_struct *)vmgm_pgci_srp_buf;
    vmgm_pgci_srp_struct *vmgm_pgci_buf_end_adr = vmgm_pgci_srp_buf + MAX_VMGM_PGCI_BUF;
    USHORT tmp_vmgm_lu_n;

    /* Parse the Video Manager Menu PGCI Unit Table Information */
    /* Parse Number of Video Manager Menu Language Units */
    store((UBYTE *)&vmgm_pgci_uti.vmgm_lu_n, (vmgm_pgci_ut_sa * Logical_Block), 2, STORE_LITTLE_ENDIAN);

    /* back up the real number for calculating the next tables offset */
    tmp_vmgm_lu_n = vmgm_pgci_uti.vmgm_lu_n;

    /* we are clamping the number of languages at MAX_NUM_LANG */
    if (vmgm_pgci_uti.vmgm_lu_n > MAX_NUM_LANG)
    {
        DbgPrint(("Parse_VMGM_PGCI_UT: vmgm_lu_n=%d, clamping to MAX_NUM_LANG!!!!\n", vmgm_pgci_uti.vmgm_lu_n));
        vmgm_pgci_uti.vmgm_lu_n = MAX_NUM_LANG;
    }

    /* Parse End address of VMGM_PGCI_UT */
    store((UBYTE *)&vmgm_pgci_uti.vmgm_pgci_ut_ea, (vmgm_pgci_ut_sa * Logical_Block + 4), 4, STORE_LITTLE_ENDIAN);

    /* Build array of vmgm_lu_srp */
    /* Parse the vmgm_lu_srp */
    /* +8 to get past vmgm_pgci_uti */
    Offset = vmgm_pgci_ut_sa * Logical_Block + 8;
    for (index = 0; index < vmgm_pgci_uti.vmgm_lu_n; index++)
    {
        /* store Video Manager Menu Language Code */
        store((UBYTE *) & vmgm_lu_srp[index].vmgm_lcd[0], Offset, 2, STORE_BIG_ENDIAN);

        /* Store Video Manager Menu existance */
        store((UBYTE *) & vmgm_lu_srp[index].vmgm_exst, (Offset + 3), 1, STORE_LITTLE_ENDIAN);

        /* Store Start address of VMGM_LU */
        store((UBYTE *) & vmgm_lu_srp[index].vmgm_lu_sa, (Offset + 4), 4, STORE_LITTLE_ENDIAN);

        Offset += 8;
    }

    /* Parse Language Units Information */
    /* Start address = (((vmgm_pgci_ut_sa * Logical_Block) + 8) + */
    /* (vmgm_pgci_uti.BMGM_LU_N *8)) */
    Offset = (((vmgm_pgci_ut_sa * Logical_Block) + 8) + (tmp_vmgm_lu_n * 8));
    for (index = 0; index < vmgm_pgci_uti.vmgm_lu_n; index++)
    {
        /* Store the number of PGCI_SRP for this language unit */
        store((UBYTE *) & vmgm_lui[index].vmgm_pgci_srp_n, Offset, 2, STORE_LITTLE_ENDIAN);

        /* Store the end address of this language unit */
        store((UBYTE *) & vmgm_lui[index].vmgm_lu_ea, (Offset + 4), 4, STORE_LITTLE_ENDIAN);

        Offset += 8;

        vmgm_pgci_srp[index] = (vmgm_pgci_srp_struct *) vmgm_pgci_srp_ptr;

        /* Report an OSD message if ERROR_REPORTING enabled */
        ERROR_CHECK((ULONG) vmgm_pgci_srp_ptr - (ULONG) vmgm_pgci_srp_buf + (2 * (ULONG) vmgm_lui[index].vmgm_pgci_srp_n),
            sizeof(vmgm_pgci_srp_struct)*MAX_VMGM_PGCI_BUF,  "MAX_VMGM_PGCI_BUF");

        for (count = 0; count < vmgm_lui[index].vmgm_pgci_srp_n &&
                        (ULONG) &vmgm_pgci_srp[index][count+1] <
                        (ULONG) vmgm_pgci_buf_end_adr;
                        count++)
        {
            /* Store data for search pointer */
            store((UBYTE *) & vmgm_pgci_srp[index][count].vmgm_pgc_cat[0], (Offset), 4, STORE_BIG_ENDIAN);

            /* Store data for search pointer */
            store((UBYTE *) & vmgm_pgci_srp[index][count].vmgm_pgci_sa, (Offset + 4), 4, STORE_LITTLE_ENDIAN);

            Offset += 8;
        }

        /* NEED TO ADD CONDITION FOR THE LAST CASE ROUTINE */
        if ((index + 1) < MAX_NUM_LANG)
        {
            Offset = vmgm_lu_srp[index + 1].vmgm_lu_sa;
        }

        vmgm_pgci_srp_ptr += count;
    }

    ERROR_CHECK(index, MAX_NUM_LANG, "MAX_NUM_LANG");
}


/**
 **  Name:        Parse_PTL_MAIT
 **
 **  Description: Parses the Parental Management Information Table
 **               DVD Part 3:Video Spec Version 1.0 section 4.1.4
 **
 **  Arguments:   PTLL_MAIT_SA Relative Start Address of PTL_MAIT
 **
 **  Returns:     Fills in structures
 **
 **  Structures:  ptl_maiti
 **               PTL_MAI_SRP
 **
 *   Pseudocode:
 *
 **/
void Parse_PTL_MAIT(ULONG ptl_mait_sa)
{
    ULONG index;
    ULONG count;
    USHORT vts_num;
    ULONG Offset;

    /* Store the ptl_maiti  (INFO) */
    Offset = (ptl_mait_sa * Logical_Block);

    /* Store the CTY_N  (Number of countries) */
    store((UBYTE *) & ptl_maiti.cty_n, Offset, 2, STORE_LITTLE_ENDIAN);

    /* Store the VTS_N  (Number of Video Title Sets) */
    store((UBYTE *) & ptl_maiti.vts_n, (Offset + 2), 2, STORE_LITTLE_ENDIAN);

    /* Store the PTL_MAIT_EA  (End address of PTL_MAIT) */
    store((UBYTE *) & ptl_maiti.ptl_mait_ea, (Offset + 4), 4, STORE_LITTLE_ENDIAN);

    /* Parse the Parental Management Search Pointers */
    Offset += 8;
    for (index = 0; index < ptl_maiti.cty_n; index++)
    {
        /* Store country code */
        store((UBYTE *) & ptl_mai_srp[index].cty_cd, Offset, 2, STORE_LITTLE_ENDIAN);

        /* Store start address of PTL_MAI */
        store((UBYTE *) & ptl_mai_srp[index].ptl_mai_sa, (Offset + 4), 2, STORE_LITTLE_ENDIAN);

        Offset += 8;
    }

    /* Parse the Parental level information for each country code */
    for (index = 0; index < ptl_maiti.cty_n; index++)
    {
        Offset = ptl_mai_srp[index].ptl_mai_sa;
        /* Get parental level information for each */
        for (count = MAX_NUM_PTL_LVL; count > 0; count--)
        {
            for (vts_num = 0; vts_num < (ptl_maiti.vts_n + 1); vts_num++)
            {
                store((UBYTE *) & ptl_lvli[index][count - 1][vts_num], (Offset), 2, STORE_LITTLE_ENDIAN);
                Offset += 2;
            }
        }
    }
}


/**
 **  Name:        Parse_VTS_ATRT
 **
 **  Description: Parses the Video Title Set Attribute Table (VTS_ATRT)
 **               DVD Part 3:Video Spec Version 1.0 section 4.1.5
 **
 **  Arguments:   vts_atrt_sa the logical block start address for the VTS_ATRT
 **
 **  Returns:     Fills in structures
 **
 **  Structures:  VTS_ATRTI
 **               VTS_ATR_SRP
 **
 *   Pseudocode:
 *
 **/
void Parse_VTS_ATRT(ULONG vts_atrt_sa)
{
    ULONG index;
    ULONG Offset;

    /* Set the Offset position to the start of the data */
    Offset = (vts_atrt_sa * Logical_Block);

    /* Store The number of Video Title Sets */
    store((UBYTE *) & vts_atrti.vts_n, Offset, 2, STORE_LITTLE_ENDIAN);

    /* Store The end address of the VTS_ATRT */
    store((UBYTE *) & vts_atrti.vts_atrt_ea, (Offset + 4), 4, STORE_LITTLE_ENDIAN);

    /* Move past the VTS_ATRTI */
    Offset += 8;
    /* Fill the VTS_ATR_SRP array */
    for (index = 0; index < vts_atrti.vts_n && index < MAX_NUM_VTS; index++)
    {
        store((UBYTE *) & vts_atr_srp[index], (Offset), 4, STORE_LITTLE_ENDIAN);
        Offset += 4;
    }
    ERROR_CHECK(index, MAX_NUM_VTS, "MAX_NUM_VTS");
}

⌨️ 快捷键说明

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