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

📄 clpinfodb.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            DBGPRINT(DBG_ON(DBG_VERBOSE), (" ref to ep fine = %u\n", ref_to_EP_fine));
            DBGPRINT(DBG_ON(DBG_VERBOSE), (" ref to next ep fine = %u\n", next_ref_to_EP_fine));
            DBGPRINT(DBG_ON(DBG_VERBOSE), (" SPN_EP_coarse = 0x%x\n", SPN_EP_coarse));

            /* search through the fines of this coarse */
            if ( CLPINFO_SUCCESS == ClpInfoSearch_FineForAngle(fReverse, ref_to_EP_fine, next_ref_to_EP_fine-1, &i_fine))
            {
                /* FOUND angle change point */
                *ulAngleChangePointSPN = (SPN_EP_coarse & 0xfffe0000) | pClpInfoEpMapFine[i_fine].SPN_EP_fine;
                *ulAngleChangePointPTS = (PTS_EP_coarse << 19) | (pClpInfoEpMapFine[i_fine].PTS_EP_fine << 8);
                *ciAnglePoint          = i_coarse;
                *fiAnglePoint          = i_fine;
                return(CLPINFO_SUCCESS);
            }
            /* if not found, have another go */
        }
    }

errout:
    return(CLPINFO_FAILURE);
}


CLPINFO_STATUS  ClpInfo::ClpInfoSet_InOut(UBYTE ubRefToSTC, ULONG tIn, ULONG tOut)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoSet_InOut: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoSet_InOut: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if (!ClpInfoIsEPMapped())
    {
        /* it's an IG or Subtext stream - we don't have an EP map, so send the whole thing */
        clpinfoSPNfromSTCid(ubRefToSTC, &m_spnFirst, &m_spnLast);
    }
    else
    {
        /* use the ref_to_STC_id to find the range of indices into the EP_coarse that point to the desired STC-sequence */
        clpinfoIndexesFromSTCid(ubRefToSTC, &m_ciStart, &m_ciEnd);

        /* use the IN pointer to find the starting index and byte offset */
        if ( TRUE == clpinfoSPNfromPTS(tIn , &m_ciStart, &m_fiStart, &m_spnFirst, FALSE) )
        {
            DBGPRINT(DBG_ON(DBG_VERBOSE), ("\nEDGE CASE 1\n"));
            ULONG ulJunk;
            clpinfoSPNfromSTCid(ubRefToSTC, &m_spnFirst, &ulJunk);
        }

        DBGPRINT(DBG_ON(DBG_VERBOSE), ("\n\npresentation start time:  %u\n", m_tClpInfoData->SequenceInfo.atc_sequence[0].stc_sequence[ubRefToSTC].presentation_start_time));
        DBGPRINT(DBG_ON(DBG_VERBOSE), ("tIn: %u\n", tIn));
        DBGPRINT(DBG_ON(DBG_VERBOSE), ("presentation start spn:  0x%x\n", m_tClpInfoData->SequenceInfo.atc_sequence[0].stc_sequence[ubRefToSTC].SPN_STC_start));
        DBGPRINT(DBG_ON(DBG_VERBOSE), ("start SPN from EP_map: 0x%x\n\n", m_spnFirst));

        if ( tIn == m_tClpInfoData->SequenceInfo.atc_sequence[0].stc_sequence[ubRefToSTC].presentation_start_time && m_ciStart == 0 && m_fiStart == 0)
        {
            DBGPRINT(DBG_ON(DBG_VERBOSE), ("\nEDGE CASE 2\n"));
            m_spnFirst = MIN(m_tClpInfoData->SequenceInfo.atc_sequence[0].stc_sequence[ubRefToSTC].SPN_STC_start, m_spnFirst);
            DBGPRINT(DBG_ON(DBG_VERBOSE), ("start SPN is now: 0x%x\n\n", m_spnFirst));
        }

        /* use the OUT pointer to find the ending index and byte offset */
        if ( TRUE == clpinfoSPNfromPTS(tOut, &m_ciEnd,   &m_fiEnd,   &m_spnLast,  TRUE) )
        {
            /* if we're off the edge of the EP_map, set the spnLast to the end of the sequence */
            ULONG ulJunk;
            clpinfoSPNfromSTCid(ubRefToSTC, &ulJunk, &m_spnLast);
        }
    }

    /* @todo:  no magic numbers - 24657 is the maximum number of EPmap entries */
    if ( (m_ciStart > 24657) || (m_ciEnd > 24657) )
    {
        return(CLPINFO_FAILURE);
    }

    return(CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_ClipInfo -- Get the ClipInfo for the currently loaded Clip
 *
 * @param
 *      pClipInfo -- Pointer that gets set to the location of the ClipInfo
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_ClipInfo(CLIPINFO_db **pClipInfo)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipInfo: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipInfo: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if (pClipInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipInfo: NULL pointer!\n"));
        return (CLPINFO_FAILURE);
    }

    /* Set the ClpInfo pointer to the ClipInfo */
    *pClipInfo = &(m_tClpInfoData->ClipInfo);

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_SequenceInfo -- Get the SequenceInfo for the currently loaded Clip
 *
 * @param
 *      pClpInfoSeqInfo        -- Pointer that gets set to the location of the SequenceInfo
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_SequenceInfo(SEQUENCEINFO_db **pClpInfoSeqInfo)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_SequenceInfo: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_SequenceInfo: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if (pClpInfoSeqInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_SequenceInfo: NULL pointer!\n"));
        return (CLPINFO_FAILURE);
    }

    /* Set the ClpInfoEpMap pointer to the EP map */
    *pClpInfoSeqInfo = &(m_tClpInfoData->SequenceInfo);

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_ProgramInfo -- Get the ProgramInfo for the currently loaded Clip
 *
 * @param
 *      pClpInfoProgInfo        -- Pointer that gets set to the location of the ProgramInfo
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_ProgramInfo(PROGRAMINFO_db **pClpInfoProgInfo)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ProgramInfo: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ProgramInfo: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if (pClpInfoProgInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ProgramInfo: NULL pointer!\n"));
        return (CLPINFO_FAILURE);
    }

    /* Set the ClpInfoEpMap pointer to the EP map */
    *pClpInfoProgInfo = &(m_tClpInfoData->ProgramInfo);

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoIsEPMapped -- Boolean function.  True if an EP Map exists in the clip.
 *
 * @param
 *      none
 *
 * @retval
 *      BOOLEAN  - TRUE if an EP map exists in the clip
 *                 FALSE if the clip does not have an EP map
 */
BOOLEAN ClpInfo::ClpInfoIsEPMapped(void)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMap: Database not created!\n"));
        return (FALSE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMap: Clip not loaded!\n"));
        return(FALSE);
    }

    return ( (m_tClpInfoData->CPI.length != 0) ? TRUE : FALSE );
}

/**
 * ClpInfoGet_EPMap -- Get the EPMap for the currently loaded Clip
 *
 * @param
 *      pClpInfoEpMap        -- Pointer that gets set to the location of the EP map
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_EPMap(EP_MAP **pClpInfoEpMap)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMap: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMap: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if (pClpInfoEpMap == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMap: NULL pointer!\n"));
        return (CLPINFO_FAILURE);
    }

    /* Set the ClpInfoEpMap pointer to the EP map */
    *pClpInfoEpMap = &(m_tClpInfoData->CPI.EP_map);

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_EPMapCoarse -- Get the EPMap Coarse of given StreamID for the currently loaded Clip
 *
 * @param
 *      ubStreamIndex       -- index determining which stream to return the EP_coarse for.  (as of v0.90r2, this is set to 0)
 *      pClpInfoEpMapCoarse -- returns as a pointer to the EP_coarse map.
 *      ulNumEntries        -- The number of entries in the EPMapCoarse
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_EPMapCoarse(UBYTE ubStreamIndex, COARSEINFO **pClpInfoEpMapCoarse, ULONG *ulNumEntries)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapCoarse: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapCoarse: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if ( (m_tClpInfoData->CPI.EP_map.stream_pid_entry == NULL) ||
         (m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].EP_map_for_one_stream_PID.coarse == NULL) ||
         (pClpInfoEpMapCoarse == NULL) )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapCoarse: NULL pointer!\n"));
        return (CLPINFO_NULL_PTR);
    }

    /* Set the pClpInfoEpMapCoarse pointer to the EP map coarse */
    *pClpInfoEpMapCoarse = m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].EP_map_for_one_stream_PID.coarse;

    *ulNumEntries = m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].number_of_EP_coarse_entries;

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_EPMapFine -- Get the EPMap Fine of given StreamID for the currently loaded Clip
 *
 * @param
 *      ubStreamIndex       -- index determining which stream to return the EP_fine for.  (as of v0.90r2, this is set to 0)
 *      pClpInfoEpMapFine    -- returns as a pointer to the EP_fine map.
 *      ulNumEntries        -- The number of entries in the EPMapFine
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfo::ClpInfoGet_EPMapFine(UBYTE ubStreamIndex, FINEINFO **pClpInfoEpMapFine, ULONG *ulNumEntries)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapFine: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapFine: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    if ( (m_tClpInfoData->CPI.EP_map.stream_pid_entry == NULL) ||
         (m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].EP_map_for_one_stream_PID.fine == NULL) ||
         (pClpInfoEpMapFine == NULL) )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_EPMapFine: NULL pointer!\n"));
        return (CLPINFO_NULL_PTR);
    }

    /* Set the pClpInfoEpMapFine pointer to the EP map fine */
    *pClpInfoEpMapFine = m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].EP_map_for_one_stream_PID.fine;

    *ulNumEntries = m_tClpInfoData->CPI.EP_map.stream_pid_entry[ubStreamIndex].number_of_EP_fine_entries;

    return (CLPINFO_SUCCESS);
}

/**
 * IndexesFromSTCid - gets the start and end indexes in the EP_coarse of the STC_sequence as given by stc_id
 *
 * @param stc_id                - the stc_id of the desired STC_sequence
 * @param ulCoarseStartIndex    - the start index in the EP_coarse map of the STC_sequence as given by stc_id
 * @param ulCoarseEndIndex      - the end   index in the EP_coarse map of the STC_sequence as given by stc_id
 *
 * @retval none
 *
 * @remarks none.
 *
 * @date 08/08/2005  eric - Created.
 *
 */
CLPINFO_STATUS ClpInfo::clpinfoIndexesFromSTCid(UBYTE stc_id, ULONG *ulCoarseStartIndex, ULONG *ulCoarseEndIndex)
{
    SEQUENCEINFO_db *pClpInfoSeqInfo        = NULL;
    UBYTE           number_of_STC_sequences = 0;
    ULONG           currSPN_STC_start       = 0;
    ULONG           nextSPN_STC_start       = 0;

    COARSEINFO      *pClpInfoEpMapCoarse    = NULL;
    ULONG           ulNumCoarseEntries      = 0;

    const UBYTE     atc_id                  = 0;      /* VER 0.90r2  only one atc sequence possible in the ClipInfo */

    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("clpinfoIndexesFromSTCid: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("clpinfoIndexesFromSTCid: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    /* Get the SequenceInfo() */
    if ( CLPINFO_SUCCESS != ClpInfoGet_SequenceInfo(&pClpInfoSeqInfo) )
    {
	    DBGPRINT(DBG_ON(DBG_ERROR), (" ClpInfoGet_SequenceInfo Failed"));
	    return(CLPINFO_FAILURE);
    }

    number_of_STC_sequences

⌨️ 快捷键说明

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