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

📄 spu_con.c

📁 这是DVD中伺服部分的核心代码
💻 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 spu_con.c
 *
 * Subpicture decode and display configuration.
 *
 * $Id: spu_con.c,v 1.31 2006/06/13 14:18:07 rbehe Exp $
 */

#include <string.h>
#include "vdvd_types.h"
#include "spu_con.h"
#include "pe_app.h"
#include "dbgprint.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif

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

UCHAR gSPUSubStreamID = 0;
UCHAR gSPUStateInfo   = 0;

/* externs */
extern PE_HANDLE tPE;

/*
 * Update the subpic to be demuxed. This should not change the subpic decoder state
 */
void spu_set_id(UCHAR id)
{
    if (id & SPU_SUBSTREAM_ID)
    {
        /* if decode is on and the new id is different than the current need to cancel the old stream */
        if ( (gSPUStateInfo & SPU_DECODE_START) != 0 )
        {
            if ( (gSPUSubStreamID & 0x3f) != (id & 0x3f) )
            {
                /* stop processing current id */
                PEiStreamCtrlDemuxRemoveSubpic(tPE);
            }
        }

        /* update global id BEFORE calling start_spu */
        gSPUSubStreamID = id;

        /* start subpic processing */
        if ( (gSPUStateInfo & SPU_DECODE_START) == 0 )
        {
            start_spu();
        }
    }
    else
    {
        if ( (gSPUSubStreamID & 0x3f) != (id & 0x3f) )
        {
            /* stop processing current id*/
            PEiStreamCtrlDemuxRemoveSubpic(tPE);

            /* invalidate global id */
            gSPUSubStreamID = id;
        }
    }
}

UCHAR spu_get_id(void)
{
    return (gSPUSubStreamID);
}

void start_spu(void)
{
    /* no sence adding an invalid subpic demux */
    if (0 != gSPUSubStreamID)
    {
        /* start subpic processing */
        PEiStreamCtrlDemuxAddSubpicPS(tPE, SPU_STREAM_ID, (gSPUSubStreamID & 0x3f));

        /* reenable display if necessary */
        if ( ( (gSPUStateInfo & SPU_DISPLAY_HIDDEN) != SPU_DISPLAY_HIDDEN) &&
            ( (gSPUStateInfo & SPU_DISPLAY_OFF) != SPU_DISPLAY_OFF) )
        {
            PE_ICONFIGURE_SUBPIC_STATE spu_state;

            /* get spu state */
            PEiConfigureGetSubPicState(tPE, &spu_state);

            /* if subpics are disabled then reenable them */
            if ( (spu_state & SUBPIC_STATE_SHOWING) != SUBPIC_STATE_SHOWING )
            {
                PEiConfigureShowSubPic(tPE);
            }
        }
    }

    /* update state info */
    gSPUStateInfo |= SPU_DECODE_START;
}

void stop_spu(void)
{
    /* reset state info */
    gSPUStateInfo = 0;

    /* detach subpic stream from demux */
    if (0 != gSPUSubStreamID)
    {
        PEiStreamCtrlDemuxRemoveSubpic(tPE);
    }

    /* erase any onscreen subpics */
    PEiConfigureHideSubPic(tPE);

    /* invalidate global id */
    gSPUSubStreamID = 0;
}

/* stop spu processing, but don't invalidate the stream id so that we can reenable it later */
void stop_spu_decode(void)
{
    /* update state info */
    gSPUStateInfo &= ~SPU_DECODE_START;

    if (0 != gSPUSubStreamID)
    {
        /* stop processing current id*/
        DBGPRINT(DBG_ON(DBG_TRACE), ("stop_spu_decode: stop processing current id\n"));
        PEiStreamCtrlDemuxRemoveSubpic(tPE);
    }
}

BOOLEAN spu_is_decode_on(void)
{
    return (gSPUStateInfo & SPU_DECODE_START);
}

void pause_spu(void)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("pause_spu()\n"));
    gSPUStateInfo |= SPU_PAUSE;
}

void unpause_spu(void)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("unpause_spu()\n"));
    gSPUStateInfo &= ~SPU_PAUSE;
}

/**
 * Display sub pictures
 */
void spu_disp_on(void)
{
    /* if necessary reenable subpic display */
    if ( (gSPUStateInfo & SPU_DISPLAY_HIDDEN) != SPU_DISPLAY_HIDDEN )
    {
        PE_ICONFIGURE_SUBPIC_STATE spu_state;

        /* get spu state */
        PEiConfigureGetSubPicState(tPE, &spu_state);

        /* if subpics are disabled then reenable them */
        if ( (spu_state & SUBPIC_STATE_SHOWING) != SUBPIC_STATE_SHOWING )
        {
            PEiConfigureShowSubPic(tPE);
        }
    }

    /* recorde state info */
    gSPUStateInfo &= ~SPU_DISPLAY_OFF;
}

/**
 * Decode but do not display sub pictures.
 *
 * @remark SPU windows displayed by the FSTA_DSP command are still displayed.
 */
void spu_disp_off(void)
{
    /* configure the hardware */
    PEiConfigureHideSubPic(tPE);

    /* recorde state info */
    gSPUStateInfo |= SPU_DISPLAY_OFF;
}

BOOLEAN spu_is_disp_off(void)
{
    return (gSPUStateInfo & SPU_DISPLAY_OFF);
}

void spu_disp_force_off(void)
{
    /* configure the hardware */
    PEiConfigureDisableForcedSubPics(tPE);
    PEiConfigureHideSubPic(tPE);

    /* recorde state info */
    gSPUStateInfo |= SPU_DISPLAY_FORCE_OFF;
}

void spu_disp_force_on(void)
{
    PE_ICONFIGURE_SUBPIC_STATE spu_state;

    /* get spu state */
    PEiConfigureGetSubPicState(tPE, &spu_state);

    /* if forced subpics are disabled then reenable them */
    if (spu_state & SUBPIC_STATE_FORCED_DISABLED)
    {
        PEiConfigureEnableForcedSubPics(tPE);
    }

    /* if necessary reenable subpic display */
    if ( ( (gSPUStateInfo & SPU_DISPLAY_HIDDEN) != SPU_DISPLAY_HIDDEN) &&
        ( (gSPUStateInfo & SPU_DISPLAY_OFF) != SPU_DISPLAY_OFF) )
    {
        if ( (spu_state & SUBPIC_STATE_SHOWING) != SUBPIC_STATE_SHOWING )
        {
            PEiConfigureShowSubPic(tPE);
        }
    }

    /* record state info */
    gSPUStateInfo &= ~SPU_DISPLAY_FORCE_OFF;
}

/**
 * Disable display of subpics.
 */
void spu_disp_hide(void)
{
    /* hide subpics */
    PEiConfigureHideSubPic(tPE);

    /* record state info */
    gSPUStateInfo |= SPU_DISPLAY_HIDDEN;
}

/**
 * Reenable display of subpics if they are being hidden.
 */
void spu_disp_unhide(void)
{
    /* If the subpic display is on then reenable them */
    if ( (gSPUStateInfo & SPU_DISPLAY_OFF) != SPU_DISPLAY_OFF )
    {
        PE_ICONFIGURE_SUBPIC_STATE spu_state;

        /* get spu state */
        PEiConfigureGetSubPicState(tPE, &spu_state);

        /* if necessary reenable subpic display */
        if ( (spu_state & SUBPIC_STATE_SHOWING) != SUBPIC_STATE_SHOWING )
        {
            PEiConfigureShowSubPic(tPE);
        }
    }

    /* record state info */
    gSPUStateInfo &= ~SPU_DISPLAY_HIDDEN;
}

void discard_spu(void)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("discard_spu -- NOT_IMPLEMENTED\n"));
}

void get_n_spu(ULONG * ptm_spu)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("get_n_spu -- NOT_IMPLEMENTED\n"));
}

void get_c_spu(ULONG * ptm_spu)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("get_c_spu -- NOT_IMPLEMENTED\n"));
}

⌨️ 快捷键说明

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