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

📄 pgc_play.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                else if ((vmgi_mat.vmgm_v_atr[0] & DISPLAY_MODE) == LETTERBOX_ONLY)
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: LetterBox\n"));
                    which_sp = 2;       /* LetterBox */
                }
            }
        }

        /* any valid SPSTN */
        n_spst = vmgi_mat.vmgm_spst_n[1] & 0x3f;

        spstn = 0x00;

        /* get the palette and send to decoder */
        sp_plt = (UBYTE *)&pgc_gi.pgc_sp_plt[0];

        if (n_spst != 0)
        {
            if (pgc_gi.pgc_spst_ctlt[n_spst - 1][0] & 0x80)
            {
                /* select correct SP stream ID based on aspect ratio & display mode */
                spstn = pgc_gi.pgc_spst_ctlt[n_spst - 1][which_sp] | SPU_STREAM_AVAILABLE;
            }
        }

        /* any valid ASTN */
        n_ast = vmgi_mat.vmgm_ast_n[1] & 0x0f;

        astn = 0;
        if (n_ast)
        {
            /* Check stream availibility */
            if (pgc_gi.pgc_ast_ctlt[n_ast - 1][0] & 0x80)
            {
                /* Extract the decoding audio stream number */
                astn = (pgc_gi.pgc_ast_ctlt[n_ast - 1][0] & 0x07);
            }
        }
        break;

    case VTSM_PGC:    /* video title set menu PGC */
        a_atr = (UBYTE *) (&(vtsi_mat.vtsm_ast_atr.flags[0]));
        v_atr = (UBYTE *) (&(vtsi_mat.vtsm_v_atr[0]));
        a_drc_fs = vtsi_mat.vtsm_ast_atr.flags[1];

        /* select correct SP stream ID based on aspect ratio & display mode */
        if ((vtsi_mat.vtsm_v_atr[0] & ASPECT_RATIO_MASK) == RATIO_4_3)
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: 4:3 aspect ratio\n"));
            which_sp = 0;       /* 4:3 aspect ratio */
        }
        else
        {
            /* 16:9 aspect ratio */
            if ((sysparam_value[0] & 0x0c) == 0x0c)     /* user TV 16:9 */
            {
                DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Wide\n"));
                which_sp = 1;   /* Wide */
            }
            else        /* user TV 4:3 */
            {
                if ((vtsi_mat.vtsm_v_atr[0] & DISPLAY_MODE) == PAN_SCAN_AND_LETTERBOX)
                {
                    if ((sysparam_value[0] & 0x03) == 0x01)     /* pan & scan */
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Pan & Scan\n"));
                        which_sp = 3;   /* Pan & Scan */
                    }
                    else
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: LetterBox\n"));
                        which_sp = 2;   /* LetterBox */
                    }
                }
                else if ((vtsi_mat.vtsm_v_atr[0] & DISPLAY_MODE) == PAN_SCAN_ONLY)
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Pan & Scan\n"));
                    which_sp = 3;       /* Pan & Scan */
                }
                else if ((vtsi_mat.vtsm_v_atr[0] & DISPLAY_MODE) == LETTERBOX_ONLY)
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: LetterBox\n"));
                    which_sp = 2;       /* LetterBox */
                }
            }
        }

        /* any valid SPSTN */
        n_spst = vtsi_mat.vtsm_spst_n[1] & 0x3f;

        spstn = 0x00;

        /* get the palette and send to decoder */
        sp_plt = (UBYTE *) & pgc_gi.pgc_sp_plt[0];

        if (n_spst)
        {
            if (pgc_gi.pgc_spst_ctlt[n_spst - 1][0] & 0x80)
            {
                /*
                 * select correct SP stream ID based on aspect ratio & display mode
                 */
                spstn = pgc_gi.pgc_spst_ctlt[n_spst - 1][which_sp] | SPU_STREAM_AVAILABLE;
            }
        }

        /* any valid ASTN */
        n_ast = vtsi_mat.vtsm_ast_n[1] & 0x0f;

        astn = 0;
        if (n_ast)
        {
            /* Check stream availibility */
            if (pgc_gi.pgc_ast_ctlt[n_ast - 1][0] & 0x80)
            {
                /* Extract the decoding audio stream number */
                astn = (pgc_gi.pgc_ast_ctlt[n_ast - 1][0] & 0x07);
            }
        }
        break;

    case TT_PGC:      /* title PGC, just get for Audio Stream #0 for now */
        a_atr = (UBYTE *) (&(vtsi_mat.vts_ast_atrt[0].flags[0]));
        v_atr = (UBYTE *) (&(vtsi_mat.vts_v_atr[0]));

        /* select correct SP stream ID based on aspect ratio & display mode */
        if ((vtsi_mat.vts_v_atr[0] & ASPECT_RATIO_MASK) == RATIO_4_3)
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: 4:3 aspect ratio\n"));
            which_sp = 0;       /* 4:3 aspect ratio */
        }
        else
        {
            /* 16:9 aspect ratio */
            if ((sysparam_value[0] & 0x0c) == 0x0c)     /* user TV 16:9 */
            {
                DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Wide\n"));
                which_sp = 1;   /* Wide */
            }
            else        /* user TV 4:3 */
            {
                if ((vtsi_mat.vts_v_atr[0] & DISPLAY_MODE) == PAN_SCAN_AND_LETTERBOX)
                {
                    if ((sysparam_value[0] & 0x03) == 0x01)     /* pan & scan */
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Pan & Scan\n"));
                        which_sp = 3;   /* Pan & Scan */
                    }
                    else
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: LetterBox\n"));
                        which_sp = 2;   /* LetterBox */
                    }
                }
                else if ((vtsi_mat.vts_v_atr[0] & DISPLAY_MODE) == PAN_SCAN_ONLY)
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: Pan & Scan\n"));
                    which_sp = 3;       /* Pan & Scan */
                }
                else if ((vtsi_mat.vts_v_atr[0] & DISPLAY_MODE) == LETTERBOX_ONLY)
                {
                    DBGPRINT(DBG_ON(DBG_TRACE), ("which_sp: LetterBox\n"));
                    which_sp = 2;       /* LetterBox */
                }
            }
        }

        /* any valid ASTN */
        n_ast = get_sprm(SPRM_ASTN_TT_DOM) & 0x0f;

        if (n_ast != 0x0f)
        {
            if (!(pgc_gi.pgc_ast_ctlt[n_ast][0] & 0x80))
            {
                n_ast = get_available_ast();
            }
        }
        else
        {
            n_ast = get_available_ast();
        }

        astn = 0;
        if (n_ast != 0x0f)
        {
            /* Extract the decoding audio stream number */
            astn = (pgc_gi.pgc_ast_ctlt[n_ast][0] & 0x07);  /* Note: n_ast is zero index adjusted by 'get_available_ast()' */
            a_atr = (UBYTE *) (&(vtsi_mat.vts_ast_atrt[n_ast].flags[0]));
        }

        if ((a_drc_fs & 0xf0) != (a_atr[1] & 0xf0))
        {
            audio_mode[0] = 0xff;
        }

        a_drc_fs = a_atr[1];

        /* any valid SPSTN */
        n_spst = get_sprm(SPRM_SPSTN_TT_DOM) & 0x7f;

        if ((n_spst & 0x40) || nvpck[CURRENT].hl_gi.hli_ss)
        {
            n_spst &= 0x3f;

            if (n_spst == 62)
            {
                n_spst = get_available_spst_62();
            }
            else if (n_spst == 63)
            {
                n_spst = get_available_spst_63(n_ast);
            }
            else
            {
                if (!(pgc_gi.pgc_spst_ctlt[n_spst][0] & 0x80))
                {
                    n_spst = get_available_spst_62();
                }
                else
                {
                    n_spst |= 0x40;
                }
            }

            /* enable SPU if it is not language */
        }
        else
        {
            if (n_spst == 62)
            {
                n_spst = get_available_spst_62();
            }
            else if (n_spst == 63)
            {
                n_spst = get_available_spst_63(n_ast);
            }
            else
            {
                if (!(pgc_gi.pgc_spst_ctlt[n_spst][0] & 0x80))
                {
                    n_spst = get_available_spst_62();
                }
                else
                {
                    n_spst |= 0x40;
                }
            }

            /* enable SPU if it is not language */
        }

        spstn = 0x00;

        /* get the palette and send to decoder */
        sp_plt = (UBYTE *) & pgc_gi.pgc_sp_plt[0];
        spstn = pgc_gi.pgc_spst_ctlt[n_spst & (MAX_SP_CH-1)][which_sp] | SPU_STREAM_AVAILABLE;
        break;
    }

    update_osd_audio(astn, a_atr);

    /* ready to read the VOB file and start up the decoder */
    start_dvd(cell_still_time, spstn, sp_plt, astn, a_atr, v_atr);
}


/**
 **  Name:           pb_mode_init
 **
 **  Description:    get here in PGC_PT_INIT,after the vob_init() is called
 **
 **  Arguments:
 **
 **  Returns:
 **
 *   Structures:
 *
 *   Pseudocode:
 *
 *   Functionality:
 *
 *   Theory of Operation:
 *
 **/
static void pb_mode_init(void)
{
    UBYTE pg_pb_mode, i;

    /* determine the PG playback mode of this PGC */
    pg_pb_mode = pgc_gi.pgc_nv_ctl.pg_playback_mode;
    if (pg_pb_mode == 0)
    {
        playback_mode = PG_SEQUENTIAL;
    }
    else
    {
        if (pg_pb_mode < 0x80)
        {
            playback_mode = PG_RANDOM;
        }
        else
        {
            playback_mode = PG_SHUFFLE;
            for (i = 0; i < (pgc_gi.pgc_cnt[2] & 0x7f); i++)
                shuffle_list[i] = 0;
            num_of_sh_stored = 0;
        }
        pg_repeat_count = pg_pb_mode &= 0x7F;
        pg_repeat_count++;
        srand((SHORT) (nav_timer_counter >> 4));
    }

}

/**
 **  Name:           cell_play
 **
 **  Description:    cell playback
 **
 **  Arguments:      none
 **
 **  Returns:
 **
 *   Structures:
 *
 *   Functionality:
 *    A Cell is the basic unit of content to be presented.  It consists of an
 *    integer number of VOBU and forms part of VOB.  A PGC has a list of
 *    pointers to Cells in presentation order.  A VOBU consists of an integer
 *    number of LBs and starts with a NV_PCK.  VOBU includes an integer number
 *    of GOPs, if it is not in a video gap.  The number of Cells in a PGC
 *    having VOB is between 1 and 255.  There may be up to 128 cell commands
 *    in a PGC.
 *
 *   Pseudocode:
 *    1) Play back the associated VOB using the presentation engine.
 *    2) Enforce any Cell Still control.  There are two Still flags: VOBU
 *       Still and Cell Still.  In case of VOBU Still, the Presentation Engine
 *       enforces a Still condition at the end of each VOBU within the Cell.
 *    3) Execute any Cell Command.
 */

void cell_play(UBYTE av_start)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("cell_play: ENTER\n"));

    if (trick_rsm != 2)
    {
        angle_change = 0;
        goto_angle   = 0;
    }

    send_cell_address(av_start);

    DBGPRINT(DBG_ON(DBG_TRACE), ("cell_play: EXIT\n"));

} /* end cell_play() */

/**
 * send_cell_address()
 *
 * @param NONE
 *
 * @return NONE
 */
void send_cell_address(UBYTE av_start)
{
    ULONG         start_address = 0;
    ULONG         start_sector  = 0;
    ULONG         end_sector    = 0;
    USHORT        angle_offset;
    USHORT        i;
    ULONG         startLBN, endLBN, beginLBN = 0;
    DR_ERROR      dr_status;
    DR_QUEUE_TYPE seamless_mode;
    BOOLEAN       fCallPlay = TRUE;
    USHORT        newCell = next_cell;

    DBGPRINT(DBG_ON(DBG_TRACE), ("send_cell_address: ENTER, next_cell=%d, next_pgn=%d\n", next_cell, next_pgn));

    clear_loader_queue();
    ptt_v1 = vts_tt_v1 = tt_v1 = 0xffffffff;
    reset_scr_flag = 0x05;

    seamless_mode      = DR_QUEUE_SEAMLESS;
    forcedly_reset_scr = 1;
    hli_count          = 0;
    old_cell           = next_cell;

    /* Checking Cell Category info in Cell Playback Information Table (C_PBI)
     * to determine if Interleaved allocation flag bit is set. If it is set then the cell
     * exists in an interleaved block. Otherwise it exists in a contiguous block. */
    if (c_pbi[next_cell - 1].c_cat[0] & 0x04)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("send_cell_address: Cell exists in an interleaved block\n"));

        if ((0 == trick_rsm) && (0 == menu_rsm))
        {
            i = next_cell;
            while( i > 0 )
            {
                i--;

                /* Looking for the first cell in the angle cell block */
                if ((c_pbi[i].c_cat[0] & 0xf0) == 0x50)
                {
                    angle_cell_start = i + 1;
                    i = 0;
                }
            }
        }
    }

    if (trick_rsm != 2)
    {
        angle_num_tt = 0;
    }

    angle_offset = get_sprm(SPRM_AGLN_TT_DOM);

    if ( (angle_offset > 1) && (c_pbi[next_cell - 1].c_cat[0] & 0x04) && (0 == trick_rsm) && (0 == menu_rsm) )
    {
        /* Check to see if this is the first cell in the block (0x40), and if it is an Angle Block (0x10) */
        if ( (c_pbi[next_cell - 1].c_cat[0] & 0xf0) == 0x50)
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("send_cell_address: This is the first cell in an angle block\n"));
            next_cell = next_cell + angle_offset - 1;
        }
    }

⌨️ 快捷键说明

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