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

📄 ig_defs.h

📁 这是DVD中伺服部分的核心代码
💻 H
字号:
/*****************************************************************************
******************************************************************************
**                                                                          **
**  Copyright (c) 2005-2006 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 ig_defs.h
 *
 * $Revision: 1.5 $ 
 *
 * IG module defines and data structures
 *
 */

#ifndef IG_DEFS_H
#define IG_DEFS_H

#ifdef __cplusplus
extern "C" {
#endif

#include "vdvd_types.h"
#include "osapi.h"
#include "cStream.h"
#include "ig_structs.h"
#include "ig_api.h"

#define IG_HANDLE_VALUE     0x12569034  /* arbitrary, but enforced */

/* local return codes to the module, these are not available above the IG_API layer */
#define IG_STILL_SCANNING_SC        0x00000400
#define IG_MORE_DATA                0x00000401
#define IG_WRAP_BUFFER              0x00000402
#define IG_STATUS_RLE_ERROR         0x00000403
#define IG_BUTTON_NOT_FOUND         0x00000404

/* spec -> ISO/IEC 13818-1: 1994(E) */
#define PRIVATE_STREAM_1_START_CODE     0x000001BD

/* mpeg related defines */
#define PTS_ONLY                        2
#define PTS_AND_DTS                     3
#define SIZE_START_CODE                 4
#define SIZE_IG_CODED_DATA_BUFFER       (0x600000) /* 6MB */
#define MAX_SIZE_IG_DECODED_DATA        (16 * 1024 * 1024)

/* queue depth and priorities */
#define IG_PARSE_PRIORITY               OS_TASK_NORMAL_PRIORITY
#define IG_RENDER_PRIORITY              OS_TASK_HIGH_PRIORITY  // high??
#define IG_PARSE_STACK_SIZE             (16*1024)
#define IG_RENDER_STACK_SIZE            (16*1024)
#define IG_PARSE_Q_DEPTH                5000  /* YES, we NEED this many, section 8.8.2.2 june 30 amendment to bluray 2.0 */
#define IG_RENDER_Q_DEPTH               30
#define IG_MAX_ODS                      4096
#define IG_MAX_PALETTES                 256
#define IG_MAX_VISIBLE_ODS              255
#define ODS_HEADER_SIZE                 14
#define ODS_HEADER_SIZE_NO_FRAGMENT     7
#define ICS_HEADER_SIZE_MULTIPES        12
#define ICS_HEADER_SIZE                 15
#define MAX_BUTTONID_VALUE              0x1FDF
#define AUTO_SELECT_SELTIMEOUT_VALUE    0xFFFE
#define NO_SELECT_SELTIMEOUT_VALUE      0xFFFF
#define NO_BUTTON_ID_SELECTION          0xFFFF
#define MAX_BUTTON_NUMBER_VALUE         0x270F /* '9999' */
#define MAX_GRFX_WIDTH                  1920
#define MAX_GRFX_HEIGHT                 1080

/* these are all Stream sizes of the data types given, they are NOT the sizes
    of the structures we actually store, this allows us to "jump past" a struct
    once we have read it and not need single byte alignment on our data structures
    be careful parsing data and only use sizeof() when directly refering to a structure */
#define SIZE_PALETTE_ENTRY              5
#define SIZE_RGB_PIXEL                  3
#define SIZE_COMPOSITION_OBJECT         16
#define SIZE_COMPOSITION_OBJECT_NO_CROP 8
#define SIZE_CROPPING_RECTANGLE         8
#define SIZE_SEGMENT_DESCRIPTOR         3
#define SIZE_COMPOSITION_DESCRIPTOR     3
#define SIZE_VIDEO_DESCRIPTOR           5
#define SIZE_WINDOW                     9
#define SIZE_NAVIGATION_COMMAND         12
#define SIZE_UO_MASK_TABLE              8


/* segment types */
/* 00 - 0x13, 0x19 - 0x7F, 0x83-0xFF reserved */
#define PALETTE_DEFINITION              0x14
#define OBJECT_DEFINITION               0x15
#define PRESENTATION_COMPOSITION        0x16
#define WINDOW_DEFINITION               0x17
#define INTERACTIVE_COMPOSITION         0x18
#define END_OF_DISPLAY_SET              0x80
#define SUBTITLE_STREAM_1               0x81
#define SUBTITLE_STREAM_2               0x82

/* interactive composition segment */
#define STREAM_MODEL_MASK               0x80
#define UI_MODEL_MASK                   0x40

#define NON_MULTIPLEXED                 0x80
#define MULTIPLEXED                     0
#define POP_UP                          0x40
#define ALWAYS_ON                       0

#define ANIMATION_NO_REPEAT             0
#define ANIMATION_REPEAT                1

#define AUTO_ACTION_NO_ACTIVATE         0
#define AUTO_ACTION_ACTIVATE            1

#define COMP_STATE_MASK                 0x03
#define COMP_STATE_NORMAL               0
#define COMP_STATE_ACQUISITION_POINT    1
#define COMP_STATE_EPOCH_START          2
#define COMP_STATE_EPOCH_CONT           3

/* macros */
#define SWITCH_1(byte)                  (0x80 & byte)
#define SWITCH_2(byte)                  (0x40 & byte)
#define RLZERO(byte)                    (0x3f & byte)
#define RL3TO63(byte)                   (0x3f & byte)
#define RL64TO16K_TOP(byte)             (0x3f & byte)

#define FIRST_IN_SEQUENCE               0x80
#define LAST_IN_SEQUENCE                0x40

/* some bit masks for clarity */
#define BIT0                            0x01
#define BIT1                            0x02
#define BIT2                            0x04
#define BIT3                            0x08
#define BIT4                            0x10
#define BIT5                            0x20
#define BIT6                            0x40
#define BIT7                            0x80


#define TIMER_NONE                      0
#define TIMER_SEL                       0x01
#define TIMER_COMP                      0x02
#define TIMER_SEL_AND_COMP              0x03


typedef struct tag_ACTIVATION_INFO
{
    INTERACTIVE_COMPOSITION_SEGMENT *ICS;
    BUTTON *Button;
    PAGE   *Page;
} ACTIVATION_INFO;

/* 601 or 709 color space is used based on resolution of source content, SD=601 HD=709 */
typedef enum tag_IG_COLOR_SPACE
{
    REC_601,       
    REC_709
} IG_COLOR_SPACE;

/* info about the current pes packet we are processing */
typedef struct tag_PESHdrInfo
{
    ULONG PTS;                  /* Presentation Time Stamp */
    ULONG DTS;                  /* Decode Time Stamp */
    BYTE PTSDTSFlags;           /* some bits that determine if we have PTS or PTS and DTS or non */
    BYTE SegAligned;            /* segment is aligned (PES header) */
    ULONG PacketSize;           /* Size of the PES packet */
    USHORT PesHeaderLen;        /* length of the PES header */
    BYTE HeaderComplete;        /* is the PES header complete? */
    BYTE HeaderNeedBytes;       /* how many bytes we need to complete a PES header*/
    USHORT PesHdrIndex;         /* index into the PesHdrBuff, so we can see if we have enough data */
    BYTE PesHdrBuff[259];       /* 8 bits of pes header max length + 3 bytes from pes packet header */
    ULONG ESRemaining;          /* size of the ES data in the PES packet */
    BYTE StartCodeBuff[6];      /* temp buffer to store start code for across buffer startcode sync */
    BYTE StartCodeBuffSize;     /* index into start code buffer */

    /* reading into the ES data we need to store some data */
    BYTE NeedSegmentBytes;      /* this field is used on 0xffff sized packets to get data sizes for buffer allocations */
    BYTE SegmentTemp[ICS_HEADER_SIZE]; /* size of a segment header and fragment header for parsing 0xffff  */
    BYTE SegmentIndex;          /* index into the segment temp buffer */

} PES_HDR_INFO;

/* flags to shutdown or stop the Parse and Render tasks  */
typedef enum tag_Quit_Flags
{
    IG_FLAGS_RUN,
    IG_FLAGS_STOP,
    IG_FLAGS_EXIT,
    IG_FLAGS_MAX
} QUIT_FLAGS;


/* a wait time, with a sem to block on */
typedef struct tag_IGWaitTimeSem
{
    ULONG WaitPTS;
    OS_SEM_ID WaitSem;  /* a semaphore to block on */
} IG_WAIT_TIME_SEM;


/* message to the IG parse thread */
typedef struct tag_IG_PARSE_MSG
{
    ULONG PTS;
    ULONG DTS;
    BYTE PTS_DTS_Flags;
    BYTE *DataStart;
    ULONG DataLength;
    BYTE MultiPES;
} IG_PARSE_MSG;

/* messages to the render contain the PCS to render and some flags */
typedef struct tag_IG_RENDER_MSG
{
    INTERACTIVE_COMPOSITION_SEGMENT *ICS;
    ULONG PTSRenderTime;  /* time we are waiting for to begin render of this PCS */
} IG_RENDER_MSG;

/* maintains handles to important DFB info */
typedef struct tag_IGDFB_INFO
{
    IDirectFB               *pDFBHandle;
    IDirectFBSurface        *PrimarySurface;
    IDirectFBSurfaceManager *SurfaceManager;
    IDirectFBDisplayLayer   *DispLayer;
    int                     ScreenWidth;
    int                     ScreenHeight;
} IGDFB_INFO;

/* local state info for all of the IG module - holds handles and flags for the module */
typedef struct tag_IGInfo
{
    BOOLEAN  fPopupEnabled;
    IG_STATE CurrentState;          /* one of the allowed state machine states */
    IG_SYNC_TYPE SyncState;         /* Synchronous (wait for DTS) or Asynchronous (don't wait) */

    /* ig adddata variables */
    ULONG PESWritePtr;              /* our write ptr to the IGParseBuffer  */
    ULONG PESWriteStart;            /* our write ptr to the IGParseBuffer where a segment begins */
    BYTE  SequenceDesc;             /* first or last in seqence flags, only used on multipes packets */
    BYTE  CopyingPES;               /* we are in the middle of finishing a PES packet */
    BYTE  CopyingMultiPES;          /* we are copying a multiple PES packet segment */
    BYTE  fGotStartPtr;             /* flags if we got some data or not */
    PES_HDR_INFO CurPesInfo;        /* current state of the PES info structure */
    BYTE  SegmentType;              /* for multiPES packets the type of packet we are working with */
    BYTE *IGParseBuffer;

    /* for ics rendering */
    INTERACTIVE_COMPOSITION_SEGMENT *ICS;   /* pointer to the current ICS */
    PAGE *ActivePage;                       /* pointer to the currently active page in IG */
    BUTTON *SelectedButton;                 /* pointer to the currently selected button in IG */

    IG_EVENT_CALLBACK IGEvent;              /* IG Callback event */
    PVOID             IGEventContext;       /* context pointer passed with the callback */

    /* osapi and cStream */
    OS_STATUS IGParseTask;          /* IGParse Thread handle */
    OS_STATUS IGRenderTask;         /* IGRender Thread handle */
    cStream *IGParseQ;              /* holds messages to the IGParse task */
    PVOID IGParseQPool;             /* holds messages to the IGParse task */
    cStream *IGRenderQ;             /* holds messages to the IGRender task */
    PVOID IGRenderQPool;            /* holds messages to the IGRender task */
    OS_SEM_ID ICSLock;              /* sema access to current ICS */
    OS_SEM_ID ParseLock;            /* sema access to Parse Task */
    OS_SEM_ID BlitLock;             /* lock around blits and flips */
    OS_SEM_ID StateLock;            /* lock around adddata, run and stop */
    OS_TIMER_ID TimerAnimation;     /* The animation timer */
    OS_TIMER_ID TimerUserSelection; /* User Selection timer */
    OS_TIMER_ID TimerFlip;          /* Timer for Flipping graphics buffers */
    ULONG CompositionTimeoutPTS;    /* Composition timeout PTS value (zero if none) */
    ULONG SelectionTimeoutPTS;      /* Selection timeout PTS value (zero if none) */
    IG_WAIT_TIME_SEM ParseWait;     /* a wait timer for the parse task */
    IG_WAIT_TIME_SEM RenderWait;    /* a wait timer for the render task */

    /* general vars */
    QUIT_FLAGS QuitFlags;           /* tell the IG threads to stop (but not exit) */
    ULONG CurPTS;                   /* the current PTS */
    IG_RENDER_MSG *pICSMessage;     /* work around for PTS not being updated during still frames, we send */
                                    /* the ICS to the renderer only after the EDSS comes in.*/
    int StreamAcquired;             /* throw away all data till we get an epoch start, acq point or epoch continue */
    IGDFB_INFO IGDFBInfo;           /* holds needed directfb handles */   
    BUTTON* ButtonHint;             /* the previously activated button when the activated button was disabled by IGEnableButton */
    BYTE CompositionEnding;         /* when a composition timeout is fired set this flag to help others release ICSLock */
    ULONG UserTimeRemaining;        /* when the User Timeout Timer is paused, this contains the remaining time */
    ULONG RLEHalfWidth;             /* decode images to half size in width direction */
    ULONG CoordsHalfWidth;          /* cut X position of graphics in half, works in tandem with RLEHalfWidth */
    BYTE SelectionTimedout;         /* SelectionTimeout fired button selection is not allowed */
    ULONG ParseReadPtr;             /* read pointer in the parse buffer */
    IG_COLOR_SPACE ColorSpace;      /* the current color space to use for YCrCb to RGB lookups */
} IGINFO;


typedef struct tag_IGStats
{
    ULONG Profiling;             /* profiling is enabled with this set to one */
    ULONG TotalCreateSurfaceTicks;
    ULONG TotalRLETicks;
    ULONG TotalBlitTicks;
    ULONG TotalFlipTicks;
    ULONG TotalAddDataTicks;
    ULONG TotalFrameDrops;
    ULONG TotalParseMsgDrops;
    ULONG TotalRLEFailures;
    ULONG TotalPixelsDecoded;
} IGSTATS;

/* NOTE all structures below are little endian */

#define GET_OBJ_DATA_LEN(obj_data) ((obj_data.data_length[0] << 16) |\
                                    (obj_data.data_length[1] << 8) |\
                                    obj_data.data_length[2])
#define GET_OBJ_DATA_WIDTH(obj_data) ((obj_data.width[0] << 8) | obj_data.width[1])
#define GET_OBJ_DATA_HEIGHT(obj_data) ((obj_data.height[0] << 8) | obj_data.height[1])

#define GET_SEGMENT_LENGTH(seg_desc) ((seg_desc.segment_length[0] << 8) | seg_desc.segment_length[1])

#ifdef __cplusplus
}
#endif


#endif /* IG_DEFS_H */

⌨️ 快捷键说明

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