clpinfodb.h

来自「这是DVD中伺服部分的核心代码」· C头文件 代码 · 共 400 行

H
400
字号
/*****************************************************************************
******************************************************************************
**                                                                          **
**  Copyright (c) 2005 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 clpinfodb.h
 *
 * API to the Clip Info Database.
 * The Clip Info Database handles the storage of and access to Clip Info data.
 *
 * $Id: clpinfodb.h,v 1.3 2007/01/26 20:39:19 rbehe Exp $
 */

#ifndef CLPINFODB_H
#define CLPINFODB_H

#include "vdvd_types.h"
#include "osapi.h"
#include "loader_app.h"

#ifdef DMALLOC
#include "dmalloc.h"
#else
#include <stdlib.h>
#endif

/**
 * Clip Info Database Status types
 */
typedef  LONG CLPINFO_STATUS;
#define  CLPINFO_SUCCESS            (0)
#define  CLPINFO_FAILURE            (-1)
#define  CLPINFO_NULL_PTR           (-2)
#define  CLPINFO_FILE_ERROR         (-3)
#define  CLPINFO_INVALID_FORMAT     (-4)
#define  CLPINFO_NOT_LOADED         (-5)
#define  CLPINFO_OUT_OF_MEMORY      (-6)

#define MAXnumber_of_stream_PID_entries     33      /* Ver 2.0 of BD spec */
#define MAXnumber_of_EP_coarse_entries      24576
#define MAXnumber_of_EP_fine_entries        180000
#define MAXnumber_of_ATC_sequences          1
#define MAXnumber_of_STC_sequences          255

#define MAXnumber_of_program_sequences      1
#define MAXnumber_of_streams_in_ps          129      /* 32*4 + 1 */
#define MAXnumber_of_ATC_delta_entries      16
#define MAXnumber_of_font_files             255

/* Application Types */
#define APPTYPE_MAIN_MOVIE                  1
#define APPTYPE_MAIN_TIMEBASE_SLIDESHOW     2
#define APPTYPE_MAIN_BROWSABLE_SLIDESHOW    3
#define APPTYPE_SUB_BROWSABLE_SLIDESHOW     4
#define APPTYPE_SUB_IG_MENU                 5
#define APPTYPE_SUB_TEXT_SUBTITLE           6
#define APPTYPE_SUB_ES                      7

#define EPMAP_STREAMINDEX                   0

/**
 * There can be many coarse info and fine info entries, so they need
 * to be memory efficient.
 */
typedef struct tagCOARSEINFO
{
    union
    {
        struct
        {
#if VDVD_PLATFORM_ENDIANESS == VDVD_BIG_ENDIAN
            ULONG   ref_to_EP_fine_id   : 18;
            ULONG   PTS_EP_coarse       : 14;
#else
            ULONG   PTS_EP_coarse       : 14;
            ULONG   ref_to_EP_fine_id   : 18;
#endif
        };
        ULONG ep_coarse;
    };
    ULONG   SPN_EP_coarse;
} COARSEINFO;

typedef struct tagFINEINFO
{
    union
    {
        struct
        {
#if VDVD_PLATFORM_ENDIANESS == VDVD_BIG_ENDIAN
            ULONG   is_angle_change_point   : 1;
            ULONG   I_end_position_offset   : 3;
            ULONG   PTS_EP_fine             : 11;
            ULONG   SPN_EP_fine             : 17;
#else
            ULONG   SPN_EP_fine             : 17;
            ULONG   PTS_EP_fine             : 11;
            ULONG   I_end_position_offset   : 3;
            ULONG   is_angle_change_point   : 1;
#endif
        };
        ULONG ep_fine;
    };
} FINEINFO;

typedef struct tagEPMAPONESTREAM
{
    ULONG       EP_fine_table_start_address;

    COARSEINFO  *coarse;
    FINEINFO    *fine;
} EPMAPONESTREAM;

typedef struct tagSTREAM_PID_ENTRY
{
    USHORT          stream_PID;
    UBYTE           EP_stream_type;
    USHORT          number_of_EP_coarse_entries;
    ULONG           number_of_EP_fine_entries;
    ULONG           EP_map_for_one_stream_PID_start_address;
    EPMAPONESTREAM  EP_map_for_one_stream_PID;
} STREAM_PID_ENTRY;

typedef struct tagEP_MAP
{
    UBYTE               number_of_stream_PID_entries;
    STREAM_PID_ENTRY    *stream_pid_entry;
} EP_MAP;

typedef struct tagTSBLOCK
{
    //USHORT  length;
    UBYTE   Validity_flags;
    UBYTE   Format_identifier[4];
    UBYTE   Network_information[9];
    UBYTE   Stream_format_name[16];
} TSBLOCK;

typedef struct tagATC_DELTA_ENTRY
{
    ULONG   ATC_delta;
    UBYTE   following_Clip_Information_file_name[5];
    UBYTE   Clip_codec_identifier[4];
} ATC_DELTA_ENTRY;

typedef struct tagCLIPINFO_db
{
    //ULONG           length;
    UBYTE           Clip_stream_type;
    UBYTE           application_type;
    BOOLEAN         is_ATC_delta;
    ULONG           TS_recording_rate;
    ULONG           number_of_source_packets;
    TSBLOCK         TS_type_info_block;
    UBYTE           number_of_ATC_delta_entries;
    ATC_DELTA_ENTRY *atc_delta_entry;
    UBYTE           number_of_font_files;
    UBYTE           *font_file_name;
} CLIPINFO_db;

typedef struct tagSTC_SEQUENCE
{
    USHORT  PCR_PID;
    ULONG   SPN_STC_start;
    ULONG   presentation_start_time;
    ULONG   presentation_end_time;
} STC_SEQUENCE;

typedef struct tagATC_SEQUENCE
{
    ULONG           SPN_ATC_start;
    UBYTE           number_of_STC_sequences;
    UBYTE           offset_STC_id;
    STC_SEQUENCE    *stc_sequence;
} ATC_SEQUENCE;

typedef struct tagSEQUENCEINFO_db
{
    //ULONG   length;
    UBYTE           number_of_ATC_sequences;
    ATC_SEQUENCE    *atc_sequence;
} SEQUENCEINFO_db;

typedef struct tagISRC_t
{
    UBYTE country_code[2];
    UBYTE copyright_holder[3];
    UBYTE recording_year[2];
    UBYTE recording_number[5];
} ISRC_t;

typedef struct tagSTREAMCODINGINFO
{
    UBYTE   length;
    UBYTE   stream_coding_type;
    union
    {
        struct
        {
            UBYTE   video_format;
            UBYTE   frame_rate;
            UBYTE   aspect_ratio;
            BOOLEAN cc_flag;
        };
        struct
        {
            UBYTE   audio_presentation_type;
            UBYTE   sampling_frequency;
            UBYTE   audio_language_code[3];
        };
        struct
        {
            UBYTE   PG_language_code[3];
        };
        struct
        {
            UBYTE   IG_language_code[3];
        };
        struct
        {
            UBYTE   character_code;
            UBYTE   textST_language_code[3];
        };
    };
    ISRC_t  ISRC;
} STREAMCODINGINFO;

typedef struct tagSTREAMINFO
{
    USHORT              stream_PID;
    STREAMCODINGINFO    StreamCodingInfo;
} STREAMINFO;

typedef struct tagPROGRAM_SEQUENCE
{
    ULONG               SPN_program_sequence_start;
    USHORT              program_map_PID;
    UBYTE               number_of_streams_in_ps;
    STREAMINFO          *stream_info;
} PROGRAM_SEQUENCE;

typedef struct tagPROGRAMINFO_db
{
    UBYTE               number_of_program_sequences;    
    PROGRAM_SEQUENCE    *program_sequence;
} PROGRAMINFO_db;

typedef struct tagCPI_db
{
    ULONG   length;
    UBYTE   CPI_type;
    EP_MAP  EP_map;
} CPI_db;

typedef struct tagCLIPMARK_db
{
} CLIPMARK_db;

/**
 * Clip Info database
 */
typedef struct tagCLPINFO_DATABASE
{
    //UBYTE   type_indicator[4];
    //UBYTE   version_number[4];
    ULONG   SequenceInfo_start_address;
    ULONG   ProgramInfo_start_address;
    ULONG   CPI_start_address;
    ULONG   ClipMark_start_address;

    CLIPINFO_db      ClipInfo;
    SEQUENCEINFO_db  SequenceInfo;
    PROGRAMINFO_db   ProgramInfo;
    CPI_db           CPI;
    CLIPMARK_db      ClipMark;

} CLPINFO_DATABASE;


#ifdef __cplusplus
extern "C" {
#endif

/**
 * Clip Info Database Manager Functions.  
 * These functions are for creating and loading the clip info from the disc into
 * the database buffer.
 */
CLPINFO_STATUS  ClpInfoMgrCreate(LOADER_HANDLE tLoader);
CLPINFO_STATUS  ClpInfoMgrDelete(void);
CLPINFO_STATUS  ClpInfoMgrLoad(ULONG ulClipnum);
CLPINFO_STATUS  ClpInfoMgrUnload(void);

/**
 * This class is the interface to the clip info database.
 * Each module that wants to access the database must create an instance of this class.
 */
class ClpInfo
{
private:
    CLPINFO_DATABASE  *m_tClpInfoData;
    ULONG             m_ulClipnum;
    ULONG             m_spnFirst;
    ULONG             m_spnLast;
    ULONG             m_ciStart;
    ULONG             m_ciEnd;
    ULONG             m_fiStart;
    ULONG             m_fiEnd;

    CLPINFO_STATUS clpinfoIndexesFromSTCid(UBYTE stc_id, ULONG *ulCoarseStartIndex, ULONG *ulCoarseEndIndex);
    CLPINFO_STATUS clpinfoSPNfromSTCid(UBYTE stc_id, ULONG *spnFirst, ULONG *spnLast);
    BOOLEAN        clpinfoSPNfromPTS(ULONG inTime, ULONG *ciRetIndex, ULONG *fiRetIndex, ULONG *spnRet, BOOLEAN fIsOut);

public:
    ClpInfo()
    {
        m_tClpInfoData = NULL;
        m_ulClipnum = 0xffffffff;
        m_spnFirst  = 0;
        m_spnLast   = 0;
        m_ciStart   = 0;
        m_ciEnd     = 0;
        m_fiStart   = 0;
        m_fiEnd     = 0;
    }
    ~ClpInfo()
    {

    }

    void * operator new( size_t size )
    {
        return ( OS_MemAlloc(size) );
    }


    void operator delete( void * pvPFB )
    {
        OS_MemFree(pvPFB);
    }

    /**
     * Clip Info Database Interface Functions
     */
    CLPINFO_STATUS  ClpInfoLoad(ULONG ulClipnum);

    CLPINFO_STATUS  ClpInfoSet_InOut(UBYTE ubRefToSTC, ULONG tIn, ULONG tOut);

    ULONG           ClpInfoGet_ptsFirst(void);
    ULONG           ClpInfoGet_ptsLast (void);
    ULONG           ClpInfoGet_spnFirst(void);
    ULONG           ClpInfoGet_spnLast (void);
    ULONG           ClpInfoGet_ciStart (void);
    ULONG           ClpInfoGet_ciEnd   (void);
    ULONG           ClpInfoGet_fiStart (void);
    ULONG           ClpInfoGet_fiEnd   (void);
    UBYTE           ClpInfoGet_ubAppType(void);

    CLPINFO_STATUS  ClpInfoGet_ClipNum (ULONG *ulClipnum);
    CLPINFO_STATUS  ClpInfoGet_ClipSize(ULONG *spnSize);
    CLPINFO_STATUS  ClpInfoGet_FontInfo(UBYTE *numFiles, UBYTE **font_names);

    CLPINFO_STATUS  ClpInfoGet_ClipInfo(CLIPINFO_db **pClipInfo);
    CLPINFO_STATUS  ClpInfoGet_SequenceInfo(SEQUENCEINFO_db **pClpInfoSeqInfo);
    CLPINFO_STATUS  ClpInfoGet_ProgramInfo(PROGRAMINFO_db **pClpInfoProgInfo);
    CLPINFO_STATUS  ClpInfoGet_EPMap(EP_MAP **pClpInfoEpMap);
    CLPINFO_STATUS  ClpInfoGet_EPMapCoarse(UBYTE ubStreamIndex, COARSEINFO **pClpInfoEpMapCoarse, ULONG *ulNumEntries);
    CLPINFO_STATUS  ClpInfoGet_EPMapFine(UBYTE ubStreamIndex, FINEINFO **pClpInfoEpMapFine, ULONG *ulNumEntries);

    CLPINFO_STATUS  ClpInfoSearch_CoarseForPTS(ULONG ciStart, ULONG ciEnd, ULONG inPTS, ULONG *index);
    CLPINFO_STATUS  ClpInfoSearch_FineForPTS(ULONG ciStart, ULONG ptsIN, ULONG *fiFound);
    CLPINFO_STATUS  ClpInfoSearch_CoarseForSPN(ULONG ciStart, ULONG ciEnd, ULONG spnIN, ULONG *ciFound);
    CLPINFO_STATUS  ClpInfoSearch_FineForSPN(ULONG ciStart, ULONG spnIN, ULONG *fiFound);
    CLPINFO_STATUS  ClpInfoSearch_FineForAngle(BOOLEAN fReverse, ULONG fiStart, ULONG fiEnd, ULONG *fiFound);
    CLPINFO_STATUS  ClpInfoSearch_ChangePoint(BOOLEAN fAngle, BOOLEAN fReverse, ULONG spnCurrentPosition, ULONG *ulAngleChangePointSPN, ULONG *ulAngleChangePointPTS, ULONG *ciAnglePoint, ULONG *fiAnglePoint);
    CLPINFO_STATUS  ClpInfoSearch_CoarseAndFineForSPN(ULONG spnCurrentPosition, ULONG *ciFound, ULONG *fiFound);
    CLPINFO_STATUS  ClpInfoSearch_CoarseForFine(ULONG ciStart, ULONG ciEnd, ULONG fiNewPosition, ULONG *ciFound, ULONG *spnFound);

    BOOLEAN         ClpInfoIsEPMapped(void);

};


#ifdef __cplusplus
}
#endif


#endif

⌨️ 快捷键说明

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