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

📄 parstask.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************
******************************************************************************
**                                                                          **
**  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 parstask.cpp
 *
 * nav pack parsing.
 *
 * $Id: parstask.cpp,v 1.102 2007/01/26 23:35:48 jared Exp $
 */

#include <stdlib.h>
#include <string.h>
#include "vdvd_types.h"
#include "osapi.h"
#include "loader_app.h"
#include "dr_app.h"
#include "pe_app.h"
#include "nav_task.h"
#include "readdir.h"
#include "dvd_pgci.h"
#include "dvdnvpck.h"
#include "hw_init.h"
#include "init.h"
#include "disctask.h"
#include "usrapi.h"
#include "timer.h"
#include "pgc_play.h"
#include "dvd_prm.h"
#include "dvd_vtsi.h"
#include "cStream.h"
#include "spu_con.h"
#include "trickmode.h"
#include "parstask.h"
#include "dbgprint.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif

/* MACROS */
#define DEBUG_PARSTASK DBG_ERROR
#define DBG_ON(x) (DEBUG_PARSTASK >= x)


#ifdef __cplusplus
extern "C" {
#endif

static UCHAR  vob_cgms = 0; /* Default to no CGMS */

/* EXTERNS */
extern PE_HANDLE tPE;
extern int    reset_scr_count;
extern UBYTE  angle_change;    /* no angle change allowed */
extern UBYTE  goto_angle;      /* number key select angle */
extern USHORT last_vobu_c_idn;
extern UBYTE  last_vobu_vob_idn;
extern ULONG  highlight_expire;
extern ULONG  button_sl_expire;
extern ULONG  valid_lbn_for_rsm;
extern USHORT next_cell_v1;
extern USHORT send_another_cell_request;
extern UBYTE  next_pgn_v1;
extern UBYTE  trick_rsm;
extern USHORT angle_cell_start;
extern UBYTE  zoom_on;  /* flag to indicate if the zoom mode is turned on */
extern UBYTE  prev_apstb;
extern UBYTE  TV_TYPE;
extern USHORT angle_num_tt;
extern UBYTE  angle_flag;
extern UBYTE  change_hl_forbidden;
extern ULONG  hli_end_ptm;
extern UBYTE  trick_rsm_cell;
extern UBYTE  AGAP_FLG;
extern ULONG  pgc_still_expire, nav_timer_counter, nv_tmr_100, nv_tmr_set;
extern UBYTE  adjust_nv_tmr;
extern ULONG  prev_ptt_time, A_addr, B_addr;
extern UBYTE  repeat_mode, A_B_count, repeat_count;
extern ULONG  trick_resume_offset;
extern UBYTE  WAIT_NEXT_CMD;
extern USHORT vobu_button_hl;
extern USHORT wait_for_button_hl;
extern USHORT hli_count;
#if LOADER_ERROR_RECOVER == TRUE
extern UBYTE  disc_error_count;
extern UBYTE  disc_error_flag;
#endif
extern UBYTE  reset_scr_flag;
extern UBYTE  forcedly_reset_scr;
extern UBYTE  S_AUDIO;
extern BOOLEAN   fAngleReady;
extern ULONG ptt_v1, vts_tt_v1, tt_v1;
extern USHORT num_of_times;
extern VMG_FILE_STRUCT video_ts;
extern TITLE_SET_FILE_STRUCT vts_file[];
#ifdef __cplusplus
    }
#endif


/**
 * proc_nvpck()
 * Processes the nvpck info after it has been parsed from the stream.
 */
BOOLEAN proc_nvpck(void)
{
    USHORT i;
    USHORT astn;     /* cell counter */
    ULONG  ticks;
    ULONG  message[4];
    SHORT  tmp;
    ULONG  bin_cur_time = 0;
    ULONG  time_interval;
    static ULONG bin_start_time = 0, last_nv_time = 0, last_time = 0;
    UBYTE  angle_num = 0;
    USHORT done = 0;
    UBYTE  n_spst;
    ULONG  start_highlight_ticks;
    ULONG  end_highlight_ticks;
    ULONG  new_angle_cell_data;
    USHORT new_cgms = 0;

    DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: nvpck_lbn=%d\n", nvpck[CURRENT].dsi_gi.nv_pck_lbn));

    num_of_times++;

    send_another_cell_request = 0;

    if (last_vobu_flag == 2)
    {
        last_vobu_flag = 1;
    }

    /* Just another way to determine new angle cell arrive during angle change   */
    /* Fixed angle cell block with same cell and same VOBU ID in all angle cells */
    /* This happens in "DVD from Toshiba" Toshiba DVDZ-9017                      */

    new_angle_cell_data = ((last_vobu_c_idn != nvpck[CURRENT].dsi_gi.vobu_c_idn) ||
        (last_vobu_vob_idn != nvpck[CURRENT].dsi_gi.vobu_vob_idn) ) && (angle_change & 0x01);

    if ((((nvpck[CURRENT].dsi_gi.vobu_c_idn != c_posi[next_cell - 1].c_idn)      ||
        (nvpck[CURRENT].dsi_gi.vobu_vob_idn != c_posi[next_cell - 1].c_vob_idn)) ||
        new_angle_cell_data                                                      ||
        /* if the new cell id's are the same as the current cell, can not
        use the above criteria to update cell number */
        (((nvpck[CURRENT].vobu_sri[FWDI_NEXT] & 0xbfffffff) == SRI_END_OF_CELL) &&
        compare_cell(next_cell, next_cell + 1) == TRUE)) &&
        !(reset_scr_flag & 0x1))
    {
        reset_scr_flag &= ~0x04;        /* NOT to send next cell request */
        done = 0;

        /* if coming VOBU is the expected one, updated cell and program */
        /* info., and request next cell                                 */

        if (angle_change & 0x01)
        {
            /* angle change */
            DBGPRINT(DBG_ON(DBG_TRACE), ("angle_change, %s, %d\n", __FILE__, __LINE__));

            for (i = 0; i < pgc_gi.pgc_cnt[3]; i++)
            {
                if ((c_posi[i].c_idn == nvpck[CURRENT].dsi_gi.vobu_c_idn) &&
                    (c_posi[i].c_vob_idn == nvpck[CURRENT].dsi_gi.vobu_vob_idn))
                {
                    done = 1;
                    break;
                }
            }

            /* Just update the cell number for in range NV PCK */
            if (1 == done)
            {
                next_cell = i + 1;

                if (c_pbi[next_cell - 1].c_cat[0] & 0x10)   /* angle change flag */
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: reset_scr_flag, LINE=%d\n", __LINE__));
                    reset_scr_flag |= 0x05;   /* reset SCR if necessary */
                    /* send next cell request */
                }

                DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: - next_cell=%d, next_pgn=%d\n", next_cell, next_pgn));
            }
            else
            {
                /* Just another way to update cell number during angle change
                 * Fixed angle cell block with same cell and same VOBU ID in all angle cells.
                 * This happens in "DVD from Toshiba" Toshiba DVDZ-9017 */

                if (new_angle_cell_data)
                {
                    next_cell = angle_cell_start + (angle_num_tt & 0x7f) - 1;
                    last_vobu_c_idn   = nvpck[CURRENT].dsi_gi.vobu_c_idn;
                    last_vobu_vob_idn = (UBYTE)(nvpck[CURRENT].dsi_gi.vobu_vob_idn);

                    if (c_pbi[next_cell - 1].c_cat[0] & 0x10)   /* angle change flag */
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: reset_scr_flag, LINE=%d\n", __LINE__));
                        reset_scr_flag |= 0x05;     /* reset SCR if necessary */
                        /* send next cell request */
                    }

                    DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: - next_cell=%d, next_pgn=%d\n", next_cell, next_pgn));
                }
            }
        }
        else
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: - vobu_c_idn=%d, c_idn=%d, vobu_vob_idn=%d, c_vob_idn=%d\n",
                nvpck[CURRENT].dsi_gi.vobu_c_idn, c_posi[next_cell_v1 - 1].c_idn,
                nvpck[CURRENT].dsi_gi.vobu_vob_idn, c_posi[next_cell_v1 - 1].c_vob_idn));

            if ((nvpck[CURRENT].dsi_gi.vobu_c_idn == c_posi[next_cell_v1 - 1].c_idn) &&
                (nvpck[CURRENT].dsi_gi.vobu_vob_idn == c_posi[next_cell_v1 - 1].c_vob_idn))
            {
                if (repeat_mode == REPEAT_PTT)
                {
                    if (ptt_v1 != 0xffffffff)
                    {
                        ptt_v1 = 0xffffffff;
                        vts_tt_v1 = 0xffffffff;
                        ptt_search((USHORT) sprm[SPRM_PTTN_ONE_SEQ_PGC]);
                        return (SUCCESS);
                    }
                }
                else
                {
                    if (ptt_v1 != 0xffffffff)
                    {
                        set_sprm(SPRM_PTTN_ONE_SEQ_PGC, (USHORT) (ptt_v1));
                        ptt_v1 = 0xffffffff;
                    }

                    if (vts_tt_v1 != 0xffffffff)
                    {
                        set_sprm(SPRM_VTS_TTN_TT_DOM, (USHORT) (vts_tt_v1));
                        vts_tt_v1 = 0xffffffff;
                    }
                }

                if (repeat_mode == REPEAT_TT)
                {
                    if (tt_v1 != 0xffffffff)
                    {
                        UBYTE retval;

                        tt_v1 = 0xffffffff;

                        retval = title_play((UBYTE) sprm[SPRM_TTN_TT_DOM]);

                        if (retval)
                        {
#if LOADER_ERROR_RECOVER == TRUE
                            if ( (0xff != retval) && !parental_prohibit)
                                disc_error_flag = 1;
#endif
                            pgc_mode = PGC_STOP;
                        }

                        pgc_play();
                        return (SUCCESS);
                    }
                }
                else
                {
                    if (tt_v1 != 0xffffffff)
                    {
                        set_sprm(SPRM_TTN_TT_DOM, (USHORT) (tt_v1));
                        tt_v1 = 0xffffffff;
                    }
                }

                next_cell = next_cell_v1;
                next_pgn  = next_pgn_v1;

                DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: - next_cell=%d, next_pgn=%d\n", next_cell, next_pgn));
                DBGPRINT(DBG_ON(DBG_TRACE), ("proc_nvpck: reset_scr_flag, LINE=%d\n", __LINE__));
                reset_scr_flag |= 0x05;     /* reset SCR if necessary */
                                            /* send next cell request */
                done = 1;
            }
        }

        if (((c_pbi[next_cell - 1].c_cat[0] & 0x30) == 0x10) &&     /* angle block */
            (0 == trick_rsm) && (1 == done) )
        {
            /* search for first cell in the block */
            for (i = next_cell; i > 0; i--)
            {
                if ((c_pbi[i - 1].c_cat[0] & 0xc0) == 0x40)

⌨️ 快捷键说明

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