www.pudn.com > OSD 测试程序.rar > UnitRmOSD.pas


{ *********************************************************************** } 
{                                                                         } 
{ 接口声明单元                                                            } 
{ Created: 03-18-2004                                                     } 
{ Copyright (c) 2001 Sigma Designs Inc. All rights reserved.              } 
{ Last update: 03-20-2004    by xlkjok                                    } 
{ irmosinc.h irmcmn.h irmbase.h mpegerr.h  mpegcmn.h                      } 
{                                                                         } 
{ *********************************************************************** } 
 
unit UnitRmOSD; 
 
 
interface 
 
uses 
{types,} Windows, ActiveX, Dialogs, Classes, SysUtils; 
 
 
 
{*** Copyright (c) 2001 Sigma Designs Inc. All rights reserved. ***} 
{***rmbasictypes.h rmosbasictypes.h                                } 
 
type 
  RMuint8        = UChar; 
  RMint8         = Char; 
  RMuint16       = WORD; 
  RMint16        = SHORT; 
  PRMuint32      = ^RMuint32; 
  RMuint32       = ULONG; 
  PRMint32       = ^RMint32; 
  RMint32        = LongInt; 
  RMascii        = RMuint8; 
  RMuint64       = LONGLONG; 
  RMint64        = LONGLONG; 
  RMnewOperatorSize= UINT; 
  RMbool         = UChar; 
 
const 
  MaxRMuint8    = 255; 
  MinRMuint8    = 0; 
  MaxRMint8     = RMint8(127); 
  MinRMint8     = RMint8(-128); 
  MaxRMuint16   = RMint16(65535); 
  MinRMuint16   = 0; 
  MaxRMint16    = RMint16(32767); 
  MinRMint16    = RMint16(-32768); 
  UNUSED_ARG    = $deadbeef; 
  MaxRMuint32   = RMuint32(4294967295); 
  MinRMuint32   = RMuint32(0); 
  MaxRMint32    = RMint32(2147483647); 
  MinRMint32    = RMint32(-2147483647-1); 
  MaxRMuint64   = RMuint64($7FFFFFFFFFFFFFFF); 
  MinRMuint64   = RMuint64(0); 
  MaxRMint64    = RMint64(9223372036854775807); 
  MinRMint64    = RMint64(-9223372036854775807-1); 
  //TRUE          = RMbool(1); 
  //FALSE         = RMbool(0); 
 
function RMuint32LSBfromRMuint64(l: RMuint64): RMuint32; 
function RMuint32MSBfromRMuint64(l: RMuint64): RMuint32; 
function RMuint64from2RMuint32(MSB, LSB: RMuint32): RMuint64; 
 
 
//===================irmosinc.h=============================== 
type 
	RMUCHAR       = UChar; 
	RMCHAR        = Char; 
	RMBYTE        = UChar; 
	RMUSHORT      = Word; 
	RMSHORT       = SHORT; 
	RMULONG       = ULONG; 
	RMLONG        = LongInt; 
	RMUINT        = UINT; 
	RMINT         = Integer; 
 
  uRecord = record 
    LowPart : DWORD; 
    HighPart: LongInt; 
	end; 
 
  RM64 = record 
    case Integer of 
      0 : ( LowPart : DWORD; 
            HighPart: LongInt ); 
      1 : ( QuadPart: LONGLONG ); 
      //       1 : ( QuadPart: double ); 
  end; 
  RMRESULT = HRESULT; 
  RMHANDLE = THANDLE; 
  RMID     = TGUID; 
  REFIID   = RMID; 
const 
 //	#define	IRMCALLTYPE STDMETHODCALLTYPE 
	//#define DEFINE_RMID DEFINE_GUID 
	//#define REFRMID		const GUID & 
  IID_IRMBase : TGUID = '{00000000-0000-0000-C000-000000000046}'; 
 
type 
  PIRMBase = ^IRMBase; 
  IRMBase = IUnknown; 
 
 
//================================irmcmn.h================================= 
//	miniport propsets, used by clients of IRm ... interface set 
type 
  RMVIDEO = (   RMVIDEO_CaptureToBuffer, 
	              RMVIDEO_GetSTC, 
	              RMVIDEO_SetSTC, 
	              RMVIDEO_PositionEvent, 
	              RMVIDEO_DeviceInfo, 
	              RMVIDEO_ClearBuffer 
            ); 
 
  RMOVERLAY = (	RMOVERLAY_Mode, 
	              RMOVERLAY_VGAKey, 
	              RMOVERLAY_VGAKey2, 
	              RMOVERLAY_Source, 
	              RMOVERLAY_Destination, 
	              RMOVERLAY_Calibration, 
	              RMOVERLAY_CalibParam, 
	              RMOVERLAY_FullScreen, 
	              RMOVERLAY_VideoPosition 
              ); 
 
  RMSPU = (	RMSPU_HliCommand ); 
 
  RMMEMORY = ( RMMEM_DeviceBase, 
               RMMEM_DMA_buffer 
              ); 
 
  RMIMPL_PROPSETS = ( 
	                    PROPSET_ATTRIBUTES	= $80000000, 
                    	PROPSET_RMVIDEO, 
                    	PROPSET_RMOVERLAY, 
                    	PROPSET_RMSPU, 
                    	PROPSET_RMMEMORY 
                    ); 
 
// SHARED 
// 
  PRMSTATE = ^RMSTATE; 
  RMSTATE  = ( RMSTATE_STOP, 
               RMSTATE_ACQUIRE, 
               RMSTATE_PAUSE, 
               RMSTATE_RUN 
              ); 
 
  PRMTIME = ^RMTIME; 
  RMTIME =  packed record 
    Time        : RMint64; 
    Numerator   : RMuint32; 
    Denominator : RMuint32; 
  end; 
   
  PRMSTREAM_HEADER = ^RMSTREAM_HEADER; 
  RMSTREAM_HEADER = packed record 
	  Size               : RMuint32; 
	  TypeSpecificFlags  : RMuint32; 
    PresentationTime   : RMTIME; 
    Duration           : RMuint64; 
    FrameExtent        : RMuint32; 
    DataUsed           : RMuint32; 
    pData              : Pointer; 
    OptionsFlags       : RMuint32; 
  end; 
   
  uRMDATAFORMAT = packed record 
    FormatSize  : RMuint32; 
    Flags       : RMuint32; 
    SampleSize  : RMuint32; 
    Reserved    : RMuint32; 
    MajorFormat : TGUID; 
    SubFormat   : TGUID; 
    Specifier   : TGUID; 
  end; 
 
  PRMDATAFORMAT = ^ RMDATAFORMAT; 
  RMDATAFORMAT = packed record 
    case Integer of 
      0: (u: uRMDATAFORMAT); 
      1: (Alignment: Int64); 
  end; 
 
  PRMDATARANGE = ^RMDATARANGE; 
  RMDATARANGE = RMDATAFORMAT; 
 
  PRMOVERLAPIO = ^RMOVERLAPIO; 
  RMOVERLAPIO = packed record 
    do_not_use : array[0..3] of RMuint32; 
    hEvent     : RMHANDLE; 
  end; 
 
///////////////////////////////////////////////////////////////////////////////////////// 
// CAPABILITIES 
// Capability types 
// 
  RMCAP_TYPE = ( RMCAPF_2RM32, 
	               RMCAPF_RM64, 
	               RMCAPF_MULTI 
                ); 
 
  PRMMULTIPLE_ITEM = ^RMMULTIPLE_ITEM; 
  RMMULTIPLE_ITEM = packed record 
    Size    : RMuint32; 
    Count   : RMuint32; 
  end; 
 
  PRMCAPABILITIES = ^RMCAPABILITIES; 
  RMCAPABILITIES = packed record 
	  utype     : RMCAP_TYPE; 
		reserved  : RMuint32; 
	  case Integer of 
		  0 : (dwCaps       : array[0..1] of RMuint32); 
			1 : (ullCaps      : RMuint64); 
			2 : (multi_header : RMMULTIPLE_ITEM); 
  end; 
(*==========================================================================; 
 * 
 *  File:       mpegerr.h 
 * 
 ***************************************************************************) 
// Define the facility codes 
const FACILITY_MPEG_STATUS             = $106; 
// Define the severity codes 
const STATUS_SEVERITY_WARNING          = 2; 
const STATUS_SEVERITY_SUCCESS          = 0; 
const STATUS_SEVERITY_INFORMATIONAL    = 1; 
const STATUS_SEVERITY_ERROR            = 3; 
 
// MessageId: MpegStatusSuccess 
// MessageText: 
//  MPEG no error. 
const MpegStatusSuccess: LongInt = $01060000; 
 
// MessageId: MpegStatusPending 
// MessageText: 
//  MPEG request pending. 
const MpegStatusPending: LongInt = $01060001;//                ((long)0x01060001L) 
 
// MessageId: MpegStatusCancelled 
// MessageText: 
//  MPEG request cancelled. 
 
const MpegStatusCancelled: LongInt = $C1060002;//              ((long)0xC1060002L) 
 
// MessageId: MpegStatusNoMore 
// MessageText: 
//  MPEG no more entries. 
const MpegStatusNoMore: LongInt = $C1060003;//                 ((long)0xC1060003L) 
 
// MessageId: MpegStatusBusy 
// MessageText: 
//  MPEG device busy. 
const MpegStatusBusy: LongInt = $C1060004;//                   ((long)0xC1060004L) 
 
// MessageId: MpegStatusInvalidParameter 
// MessageText: 
//  MPEG invalid parameter. 
const MpegStatusInvalidParameter: LongInt = $C1060005;//       ((long)0xC1060005L) 
 
// MessageId: MpegStatusUnsupported 
// MessageText: 
//  MPEG request unsupported. 
const MpegStatusUnsupported: LongInt = $C1060006;//            ((long)0xC1060006L) 
 
// MessageId: MpegStatusResourceFailure 
// MessageText: 
//  MPEG resource failure. 
const MpegStatusResourceFailure: LongInt = $C1060007;//        ((long)0xC1060007L) 
 
// MessageId: MpegStatusHardwareFailure 
// MessageText: 
//  MPEG device failure. 
const MpegStatusHardwareFailure: LongInt = $C1060008;//        ((long)0xC1060008L) 
 
// MessageId: MpegStatusVersionMismatch 
// MessageText: 
//  MPEG mismatched component version. 
const MpegStatusVersionMismatch: LongInt = $C1060009;//        ((long)0xC1060009L) 
 
// MessageId: MpegStatusDeviceNotFound 
// MessageText: 
//  MPEG device not found. 
// 
const MpegStatusDeviceNotFound: LongInt = $C106000A;//         ((long)0xC106000AL) 
 
// MessageId: MpegStatusInternalError 
// MessageText: 
//  MPEG internal error. 
const MpegStatusInternalError: LongInt = $C106000B;//          ((long)0xC106000BL) 
 
// MessageId: MpegStatusDeviceIOError 
// MessageText: 
//  MPEG internal error. 
const MpegStatusDeviceIOError: LongInt = $C106000C;//          ((long)0xC106000CL) 
 
(*==========================================================================; 
 * 
 *  File:       mpegcmn.h 
 * 
 ***************************************************************************) 
 
// maximum number of mpeg devices in the computer 
const MAX_MPEG_DEVICES          = $40;	// equivalent for RM_MAXIMUM =40 in fmpdefs.h 
 
//#ifndef _NO_64BITS_SUPPORT_ 
type 
  PMPEG_SYSTEM_TIME = ^ MPEG_SYSTEM_TIME; 
  MPEG_SYSTEM_TIME = Int64; 
 
const MPEG_SYSTEM_TIME_MASK     = $00000001FFFFFFFF; 
// information flags or-ed with Scr, Pts, Stc ( 64 bits variables ) 
const PTS_VALIDITY		= $8000000000000000; 
const PTS_WAVIFACE_4000		= $4000000000000000; 
const FIRST_AUDIO_PTS		= $0004000000000000; 
const PTS_WAVIFACE_0002		= $0002000000000000; 
const PTS_DISCONTINUITY		= $0001000000000000; 
// Information flags to indicate new DATA Format (See RM_DATA_FORMAT_STRUCT) 
const RMFLAG_DATA_FORMAT_CHANGE	= $2000000000000000; 
const CTS_VALIDITY		= $1000000000000000; 
 
//#endif 
 
// MpegAttrForcedProgressive flags 
const BROADCASTED_VIDEO		= $0200; 
const DVD_VIDEO			= $0000; 
const FORCED_PROGRESSIVE_OFF	= $0100;	// display progressive or interlaced like in the video stream 
const FORCED_PROGRESSIVE_ON	= $0000;	// display only progressive if the stream switches very fast from interlaced to progressive 
const PROGRESSIVE_ALWAYS	= $0080; 
const PROGRESSIVE_MOVIES	= $0000; 
const FRAME_DROP		= $0040; 
const FIELD_DROP		= $0000; 
const VGA_INTERLACED		= $0002; 
const VGA_PROGRESSIVE		= $0000; 
 
// MpegAttrHardwareInfo1 flags 
const DARK_COLOR_LETTERBOX	= $0001;	// hwDecoder is Quasar1 - letterbox bug 
const VGA_CABLE_NOT_CONNECTED	= $0002;	// VGA cable is not connected for analog overlay boards 
 
//	MpegAttrOverlayFlags 
const OVERLAY_FLAGS_MASK       	= $000F; 
const VIDEO_ZOOM_ENABLE		= $0001; 
const VIDEO_TV_DEST_ENABLE	= $0002; 
const VIDEO_HDTV_DEST_ENABLE	= $0004; 
const OSD_VIDEO_INDEPENDENT_DEST= $0008; 
 
// MpegAttrPlayOptions 
type 
   PLAY_OPTIONS = ( 
                   VideoHwPlayNormal = 0, 
                   VideoHwPlayToEvent, 
                   VideoHwPlayIFrame, 
                   VideoHwPlaySyncFaster, 
                   VideoHwPlayYUV 
                   ); 
 
 
//**************************************************************************** 
// Enumerated Constants 
//**************************************************************************** 
  PMPEG_ATTRIBUTE = ^MPEG_ATTRIBUTE; 
  MPEG_ATTRIBUTE = ( 
                    MpegAttrAudioBass =     0, 
                    MpegAttrAudioChannel, 
                    MpegAttrAudioMode, 
                    MpegAttrAudioTreble, 
                    MpegAttrAudioVolumeLeft, 
                    MpegAttrAudioVolumeRight, 
                    MpegAttrAudioPosition, 
                    MpegAttrAudioRate, 
	                  MpegAttrAudioLayerIndex, 
                    MpegAttrAudioBitrateIndex, 
                    MpegAttrAudioFormat, 
                    MpegAttrAudioNumChannels, 
                    MpegAttrAudioBlockAlign, 
                    MpegAttrAudioEnableSpdif, 
                    MpegAttrAudioSetPcmOutputSpdif, 
                    MpegAttrAudioVcxo, 
                    MpegAttrAudioOutput, 
                    MpegAttrMaximumAudioAttribute, 
 
                    MpegAttrVideoBrightness  =400, 
                    MpegAttrVideoChannel, 
                    MpegAttrVideoContrast, 
                    MpegAttrVideoHue, 
                    MpegAttrVideoMode, 
                    MpegAttrVideoSaturation, 
                    MpegAttrVideoAGC, 
                    MpegAttrVideoClamp, 
                    MpegAttrVideoCoring, 
                    MpegAttrVideoGain, 
                    MpegAttrVideoGenLock,			//410 
                    MpegAttrVideoSharpness, 
                    MpegAttrVideoSignalType, 
                    MpegAttrVideoPosition, 
                    MpegAttrVideoSpeed, 
                    MpegAttrVideoFramePosition, 
                    MpegAttrVideoRate, 
                    MpegAttrVideoAspectRatio, 
                    MpegAttrVideoSpeed2, 
                    MpegAttrVideoCD10Parameter, 
                    MpegAttrVideoGamma,				//420 
                    MpegAttrVideoAccessHardware, 
                    MpegAttrVideoTv, 
                    MpegAttrGetSubID, 
                    MpegAttrVideoEnableSync, 
                    MpegAttrVideoOutputMode, 
                    MpegAttrVideoStill, 
                    MpegAttrVideoMacrovisionFlags, 
                    MpegAttrChgKey, 
                    MpegAttrKey, 
                    MpegAttrDiscKey,				//430 
                    MpegAttrTitleKey, 
                    MpegAttrVideoForceEos, 
                    MpegAttrAddPerfStat, 
                    MpegAttrRemovePerfStat, 
                    MpegAttrVideoDeviceSize, 
                    MpegAttrVideoModeChange, 
                    MpegAttrVideoKeepAspectRatio, 
                    MpegAttrTvFullScreen, 
                    MpegAttrTvEncoderToleranceNtsc, 
                    MpegAttrTvEncoderTolerancePal,	//440 
                    MpegAttrForcedProgressive, 
                    MpegAttrHDTVMode, 
                    MpegAttrVideoFramePts45k, 
                    MpegAttrVideoFrameNumberInGOP, 
                    MpegAttrPlayOptions, 
                    MpegAttrCodeVersion, 
                    MpegAttrMaximumVideoAttribute, 
 
                    MpegAttrOverlayXOffset = 800, 
                    MpegAttrOverlayYOffset, 
                    MpegAttrOverlayVgaCorrection, 
        	    MpegAttrOverlayVgaRUpper, 
        	    MpegAttrOverlayVgaRLower, 
        	    MpegAttrOverlayVgaGUpper, 
        	    MpegAttrOverlayVgaGLower, 
                    MpegAttrOverlayVgaBUpper, 
                    MpegAttrOverlayVgaBLower, 
                    MpegAttrOverlaySourceWidth, 
                    MpegAttrOverlaySourceHeight, 
                    MpegAttrOverlayHFrequency, 
                    MpegAttrOverlayFineAdjustment, 
                    MpegAttrOverlayInDelay, 
                    MpegAttrOverlayOutDelay, 
                    MpegAttrOverlayCropLeft, 
                    MpegAttrOverlayCropRight, 
                    MpegAttrOverlayCropTop, 
                    MpegAttrOverlayCropBottom, 
                    MpegAttrOverlayJitterAdjustment, 
                    MpegAttrOverlayTVXYPos, 
                    MpegAttrOverlayFlags, 
                    MpegAttrOsdDest, 
                    MpegAttrOsdHiLiDest, 
                    MpegAttrOsdON, 
                    MpegAttrOsdOFF, 
                    MpegAttrOsdFLUSH, 
                    MpegAttrOsdBufferSize, 
                    MpegAttrDisplayResolutionEx, 
                    MpegAttrMaximumOverlayAttribute, 
 
                    // Subpicture & other 
                    MpegAttrWindowHandle = 1000, 
	            MpegAttrSubpicturePalette, 
	            MpegAttrUserPalette, 
                    MpegAttrPaletteHWnd, 
                    MpegAttrSprm8, 
                    MpegAttrCmd, 
                    MpegAttrDisplayState, 
                    MpegAttrDisplayType, 
                    MpegAttrCapabilities, 
                    MpegAttrDisplayResolution, 
                    MpegAttrHighlight, 
                    MpegAttrButtonAvailable, 
                    MpegAttrHardwareInfo1, 
                    MpegAttrPowerState, 
                    MpegAttrDirectShow, 
                    MpegAttrGetFreeInstanceNmb, 
                    MpegAttrGetMaxInstanceNmb, 
                    MpegAttrVgaVendorInfo, 
                    MpegAttrMaximumSubpictureAttribute, 
 
                    // Values used for debug purposes 
                    MpegAttrOverlayAdjustmentA = 1200, 
                    MpegAttrOverlayAdjustmentB, 
                    MpegAttrOverlayAdjustmentC, 
                    MpegAttrOverlayAdjustmentD, 
                    MpegAttrOverlayAdjustmentE, 
                    MpegAttrOverlayAdjustmentF, 
 
                    MpegAttrMaximum 
                   ); 
 
  _MPEG_ATTRIBUTE= MPEG_ATTRIBUTE; 
 
//#define MPEG_OEM_ATTRIBUTE(a) ((MPEG_ATTRIBUTE)(((unsigned)(a))+0x00008000)) 
//  function MPEG_OEM_ATTRIBUTE(a: LongWord): MPEG_ATTRIBUTE; 
 
// MpegAttrAudioMode flags 
const MPEG_ATTRIBUTE_AUDIO_MONO				= 0; 
const MPEG_ATTRIBUTE_AUDIO_STEREO			= 1; 
const MPEG_ATTRIBUTE_AUDIO_SPATIAL_STEREO		= 2; 
const MPEG_ATTRIBUTE_AUDIO_PSEUDO_STEREO		= 3; 
 
// MpegAttrVideoMode flags 
const MPEG_ATTRIBUTE_VIDEO_COMPONENT			= 0; 
const MPEG_ATTRIBUTE_VIDEO_PAL				= 1; 
const MPEG_ATTRIBUTE_VIDEO_NTSC				= 2; 
const MPEG_ATTRIBUTE_VIDEO_SECAM			= 3; 
const MPEG_ATTRIBUTE_VIDEO_MAC				= 4; 
const MPEG_ATTRIBUTE_VIDEO_AUTO				= 5; 
 
// MpegAttrAudioFormat 
const AUDIO_FORMAT_MPEG1			        = 1; 
const AUDIO_FORMAT_MPEG2				= 2; 
const AUDIO_FORMAT_AC3					= 3; 
const AUDIO_FORMAT_PCM					= 4; 
const AUDIO_FORMAT_DTS					= 5; 
const AUDIO_FORMAT_DVD_AUDIO				= 6; 
const AUDIO_FORMAT_ADPCM				= 7;	// Use AUDIO_FORMAT_REVERSE_PCM instead 
const AUDIO_FORMAT_REVERSE_PCM				= 7; 
const AUDIO_FORMAT_AAC					= 8; 
 
// MpegAttrAudioOutput 
const AUDIO_OUTPUT_STEREO				= 0; 
const AUDIO_OUTPUT_AC3DTS				= 1; 
 
// flags used to enable/disable the hardware audio outputs 
const AUDIO_DAC_ENABLE					= $0001; 
const AUDIO_DAC_DISABLE					= $0000; 
const AUDIO_SPDIF_ENABLE				= $0002; 
const AUDIO_SPDIF_DISABLE				= $0000; 
 
// MpegAttrAudioMode; Audio modes defined also in impeg32, hardware.h 
const AUDIO_MODE_STEREO					= 0; 
const AUDIO_MODE_RIGHT_ONLY				= 1; 
const AUDIO_MODE_LEFT_ONLY				= 2; 
const AUDIO_MODE_MONOMIX				= 3; 
 
// MpegAttrVideoAspectRatio 
const VIDEO_ASPECT_RATIO_16_9				= 3; 
const VIDEO_ASPECT_RATIO_4_3				= 2; 
 
// MpegAttrVideoOutputMode 
const VIDEO_OUTPUT_MODE_NORMAL_OR_WIDE		        = 0; 
const VIDEO_OUTPUT_MODE_PAN_SCAN			= 1; 
const VIDEO_OUTPUT_MODE_LETTERBOX			= 2; 
const VIDEO_OUTPUT_MODE_HORZCENTER			= 3; 
const VIDEO_OUTPUT_MODE_VERTCENTER			= 4; 
 
// MpegAttrVideoTv 
const COMPONENT_MASK		                        = $02C0;	// old was 0x00C0 
const COMPOSITE			                        = $0000; 
const COMPONENT_YUV		                        = $0080; 
const COMPONENT_RGB		                        = $00C0; 
const OUTPUT_OFF			                = $0040; 
const COMPONENT_RGB_SCART	                        = $0200; 
 
const TV_DACS_ENABLE		                        = $0000;	// default behaviour - disabled after HwReset, enabled when playing 
const TV_DACS_DISABLE	                        	= $0100;	// force TvDacs disabled 
 
const VIDEOOUT_MASK		                        = $0021; 
const SET_VGA			                	= $0000; 
const SET_TV			                	= $0001; 
const SET_HDTV		                        	= $0020; 
 
const STANDARDTV_MASK		                        = $010A; 
const SET_NTSC		                        	= $0000; 
const SET_PAL 		                        	= $0002; 
const SET_PAL60			                        = $0008; 
const SET_PALM			                        = $000A; 
const SET_480P			                        = $0100;	// used only for Vga scan convertion 
 
// The following define prevents the driver from forcing TV output back 
// to the VGA when using NetStream 2000 TV (TvOut under "General"), 
const SET_NO_TV_CHANGE	                                = $8000; 
 
const SET_ONETOONE	                        	= $0000; 
const SET_SCALE		                        	= $0004; 
 
const SET_TV_AS_SOURCE	                                = $0010; 
const SET_TV_AS_USER	                                = $0000; 
 
// settings for NetStream2k TV 
const SCART_MASK		                	= $0003; 
const SCART_EX_MASK	                               	= $0004; 
const SCART_DISABLE	                        	= $0000; 
const SCART_ENABLE_4x3	                                = $0001; 
const SCART_ENABLE_16x9                         	= $0003; 
const SCART_EX_RGB	                        	= $0004; 
 
// MpegAttrVideoGenLock type 
const MPEG_ATTRIBUTE_VIDEO_GEN_LOCK_TV		        = 0; 
const MPEG_ATTRIBUTE_VIDEO_GEN_LOCK_VTR		        = 1; 
 
// MpegAttrVideoSignalType type 
const MPEG_ATTRIBUTE_VIDEO_SIGNAL_COMPOSITE	        = 0; 
const MPEG_ATTRIBUTE_VIDEO_SIGNAL_SVHS		        = 1; 
 
// MpegAttrAudioChannel Mpeg channel 
//  auxiliary channels are mini-port specific 
const MPEG_ATTRIBUTE_AUDIO_CHANNEL_MPEG                 = 0; 
 
// MpegAttrVideoChannel Mpeg channel 
//  auxiliary channels are mini-port specific 
const MPEG_ATTRIBUTE_VIDEO_CHANNEL_MPEG                 = 0; 
 
// MpegAttrCapabilities 
// Values must same as FMP_CAPABILITY_xxx 
 
// An analog overlay is present and a border adjustment utility is needed 
// in order to be able to adjust the overlay to the VGA resolution. 
const MPEG_CAPABILITY_BORDER_ADJUST                     = $00000001; 
 
// Every key color can be independantly ajusted. This is only used when 
// an analog overlay is used. 
const MPEG_CAPABILITY_KEYCOLOR_ADJUST                   = $00000002; 
 
// Brightness, contrast and saturation can be adjusted 
const MPEG_CAPABILITY_BSC_ADJUST                        = $00000004; 
 
// The analog overlay supports auto-calibration 
const MPEG_CAPABILITY_AUTO_CALIBRATE                    = $00000008; 
 
// Mpeg4 capability 
const MPEG_CAPABILITY_MPEG4_DECODE                      = $00000010; 
 
// Gamma correction can be adjusted 
const MPEG_CAPABILITY_GAMMA_ADJUST                      = $00000020; 
 
// ???????? 
const MPEG_CAPABILITY_HIRES                             = $00000040; 
 
// ???????? 
const MPEG_CAPABILITY_USES_VPM                          = $00000080; 
 
// The hardware can play DVD titles 
const MPEG_CAPABILITY_DVD_CAN_PLAY                      = $00000100; 
 
// ???????? 
const MPEG_CAPABILITY_ASPECT_RATIO                      = $00000200; 
 
// The video can be displayed on the VGA monitor. Note that it might 
// also be possible to display it on TV when MPEG_CAPABILITY_TV_OUTPUT 
// is set but it may not be possible at the same time. Use the flag 
// MPEG_CAPABILITY_VGA_AND_TV to find if this is possible. 
const MPEG_CAPABILITY_VGA_WINDOW                        = $00000400; 
 
// Indicates that hardware decryption is supported by the hardware 
const MPEG_CAPABILITY_DVD_DECRYPTION                    = $00000800; 
 
// Used by DVD station to know if the video source size can change 
// depending on the VGA alignement. This is to determine the default DVD 
// station window size and to prevent scaling (and therefore video 
// artifacts) when scale is 1:1. 
const MPEG_CAPABILITY_SRC_CHANGE                        = $00001000; 
 
// Indicates that the hardware supports Frame Fast Forward 
const MPEG_CAPABILITY_FRAME_FF                          = $00002000; 
 
// The video can be displayed on TV. Note that it might also be possible 
// to display the video on VGA when the flag MPEG_CAPABILITY_VGA_WINDOW 
// is set but it may not be possible at the same time. Use the flag 
// MPEG_CAPABILITY_VGA_AND_TV to find if this is possible. 
const MPEG_CAPABILITY_TV_OUTPUT                         = $00004000; 
 
// Indicates that the video can be displayed both on TV and VGA. When this 
// flag is set, both flag MPEG_CAPABILITY_VGA_WINDOW and 
// MPEG_CAPABILITY_TV_OUTPUT needs to be set. This capability can change 
// in real time depending on the TV output format set using MpegAttrVideoTv. 
// Therefore, every time DVD station changes the TV output format to 
// PAL or NTSC with or without scale, it needs to verify this flag. 
const MPEG_CAPABILITY_VGA_AND_TV                        = $00008000; 
 
// Indicates that the TV supports PAL 60, Note that this flag is invalid when 
// MPEG_CAPABILITY_TV_OUTPUT is not set. Note also that PAL60 can only be used 
// when source is NTSC unless MPEG_CAPABILITY_PAL_NTSC_CONVERT is set. This 
// capability does not concern VGA. 
const MPEG_CAPABILITY_PAL60                             = $00010000; 
 
// Indicates that the hardware is capable of converting NTSC source into PAL and 
// vice-versa. This is mostly usefull when a TV output is present. 
const MPEG_CAPABILITY_PAL_NTSC_CONVERT                  = $00020000; 
 
// Indicates that the video can be displayed on a HDTV (progressive scan). This 
// output format is incompatible (for now) with VGA and TV (ie, it cannot be 
// displayed both on HDTV and TV or HDTV and VGA). 
const MPEG_CAPABILITY_HDTV_OUTPUT                       = $00040000; 
 
// Indicates that the video on VGA cannot be scaled (Dragon products) 
// MPEG_CAPABILITY_VGA_WINDOW cannot be set in the same time 
const MPEG_CAPABILITY_FULLSCREEN_ONLY                   = $00080000; 
 
// Indicates that the video output cannot play simultaneously on VGA  
// and TV. If set DVD station will paint a VGA_TV button. 
const MPEG_CAPABILITY_VGATV_SWITCH_BUTTON               = $00100000; 
 
// Indicates that the TV encoder can be slightly adjusted for color 
// control one some PAL TVs that only display back and white. 
const MPEG_CAPABILITY_TV_TOLERANCE                      = $00200000; 
 
// Indicates that the EEPROM to store the region code is present on the board 
const MPEG_CAPABILITY_EEPROM_PRESENT                    = $00400000; 
 
// Indicates that hardware supports seeking accurately (this is used by DirectShow 
// in order to allow playing first frame after a StreamPause or Video flush). 
const MPEG_CAPABILITY_SEEK_ACCURATE                     = $00800000; 
 
// Indicates that hardware only supports NTSC (Only used for IGS to prevent 
// double conversion) 
const MPEG_CAPABILITY_NTSC_ONLY                         = $01000000; 
 
// Indicates that hardware only supports NTSC (Only used for IGS to prevent 
// double conversion) 
const MPEG_CAPABILITY_PAL_ONLY                          = $02000000; 
 
// Indicates that hardware supports Tv Component YUV 
const MPEG_CAPABILITY_TV_YUV_COMPONENT		        = $04000000; 
 
// Indicates that hardware can play in the same time PCM data 
// through Dac and Spdif 
const MPEG_CAPABILITY_DAC_SPDIF				= $08000000; 
 
// Indicates that hardware has a 480P connector to display fullscreen on 
// another Vga monitor - Ventura2000 
const MPEG_CAPABILITY_480P				= $10000000; 
 
// Indicates that hardware supports Tv Component RGB 
const MPEG_CAPABILITY_TV_RGB_COMPONENT		        = $20000000; 
 
// Indicates that hardware has DVI output 
const MPEG_CAPABILITY_DVI				= $40000000; 
 
// Indicates that hardware has the audio clock controlled by VCXO 
const MPEG_CAPABILITY_AUDIO_VCXO			= $80000000; 
 
type 
 
  PMPEG_DEVICE_TYPE = ^MPEG_DEVICE_TYPE; 
  MPEG_DEVICE_TYPE = ( 
                      MpegAudioDevice, 
                      MpegVideoDevice, 
                      MpegOverlayDevice, 
                      MpegCombinedDevice, 
                      MpegSubpictureDevice 
                      ); 
  _MPEG_DEVICE_TYPE = MPEG_DEVICE_TYPE; 
 
  PMPEG_STREAM_TYPE = ^MPEG_STREAM_TYPE; 
  MPEG_STREAM_TYPE = ( 
                      MpegSystemStream = 1, 
                      MpegAudioStream, 
                      MpegVideoStream, 
                      MpegSubpictureStream, 
                      MpegPCIStream 
                      ); 
  _MPEG_STREAM_TYPE = MPEG_STREAM_TYPE; 
 
  PMPEG_CAPABILITY = ^MPEG_CAPABILITY; 
  MPEG_CAPABILITY = ( 
                     MpegCapAudioDevice = 0, 
                     MpegCapVideoDevice, 
                     MpegCapSeparateStreams, 
                     MpegCapCombinedStreams, 
                     MpegCapBitmaskOverlay, 
                     MpegCapChromaKeyOverlay, 
                     MpegCapAudioRenderToMemory, 
                     MpegCapVideoRenderToMemory, 
                     MpegCapSubPictureDevice, 
                     MpegCapMaximumCapability 
                     ); 
  _MPEG_CAPABILITY = MPEG_CAPABILITY; 
 
//#define MPEG_OEM_CAPABILITY(a)  ((MPEG_CAPABILITY)(((unsigned)a) + 0x00008000)) 
  PMPEG_INFO_ITEM = ^MPEG_INFO_ITEM; 
  MPEG_INFO_ITEM = ( 
                    MpegInfoCurrentPendingRequest = 1,      // Video and Audio 
                    MpegInfoMaximumPendingRequests,         // Video and Audio 
                    MpegInfoDecoderBufferSize,              // Video and Audio 
                    MpegInfoDecoderBufferBytesInUse,        // Video and Audio 
                    MpegInfoCurrentPacketBytesOutstanding,  // Video and Audio 
                    MpegInfoCurrentFrameNumber,             // Video and Audio 
                    MpegInfoStarvationCount,                // Video and Audio 
                    MpegInfoDecompressHeight,               // Video 
                    MpegInfoDecompressWidth,                // Video 
                    MpegInfoMinDestinationHeight,           // Overlay 
                    MpegInfoMaxDestinationHeight,           // Overlay 
                    MpegInfoMinDestinationWidth,            // Overlay 
                    MpegInfoMaxDestinationWidth,            // Overlay 
                    MpegInfoEventStatus,					// Video and Audio 
                    MpegInfoHwDecode						// Audio 
                    ); 
  _MPEG_INFO_ITEM = MPEG_INFO_ITEM; 
 
//#define MPEG_OEM_INFO_ITEM(a)   ((MPEG_INFO_ITEM)(((unsigned)a) + 0x00008000)) 
 
  PMPEG_DEVICE_STATE = ^MPEG_DEVICE_STATE; 
  MPEG_DEVICE_STATE = ( 
                       MpegStateStartup = 0, 
                       MpegStatePaused, 
                       MpegStatePlaying, 
                       MpegStateStarved, 
                       MpegStateFailed, 
                       MpegStateFrozen 
                       ); 
  _MPEG_DEVICE_STATE = MPEG_DEVICE_STATE; 
 
  REQUESTED_STATE_TYPE = ( 
                          RequestedNone = 0, 
                          RequestedPlay, 
                          RequestedPause, 
                          RequestedStop 
                          ); 
  _REQUESTED_STATE_TYPE = REQUESTED_STATE_TYPE; 
 
 
  PMPEG_OVERLAY_MODE = ^MPEG_OVERLAY_MODE; 
  MPEG_OVERLAY_MODE = ( 
                       MpegModeNone = 1, 
                       MpegModeRectangle, 
                       MpegModeOverlay, 
                       MpegModeCalibrate 
                       ); 
  _MPEG_OVERLAY_MODE = MPEG_OVERLAY_MODE; 
 
 
  PMPEG_EVENT_TYPE = ^MPEG_EVENT_TYPE; 
  MPEG_EVENT_TYPE = ( 
                     MpegPulseEvent = 0, 
                     MpegTimerEvent, 
                     MpegNullEvent 
                     ); 
  _MPEG_EVENT_TYPE = MPEG_EVENT_TYPE; 
 
 
  PMPEG_DISPLAY_CONTEXT = ^MPEG_DISPLAY_CONTEXT; 
  MPEG_DISPLAY_CONTEXT = ( 
                          MpegDisplayGdi = 0 
                          ); 
  _MPEG_DISPLAY_CONTEXT = MPEG_DISPLAY_CONTEXT; 
{ 
#ifdef _WINGDI_ 
 
typedef struct _MPEG_DISPLAY_PALETTE 
 begin 
	PLOGPALETTE pLogPalette; 
	HPALETTE hPalette; 
 end// 
 MPEG_DISPLAY_PALETTE, *PMPEG_DISPLAY_PALETTE; 
 
#endif 
} 
 
  PMPEG_HLI_CMD = ^MPEG_HLI_CMD; 
  MPEG_HLI_CMD = ( 
        	  MpegSelectAdjacentButton = 0, 
  	          MpegActivate, 
        	  MpegSelectAndActivate, 
	          MpegMouseMove, 
        	  MpegMouseButton, 
	          MpegSelectButton 
                  ); 
  _MPEG_HLI_CMD = MPEG_HLI_CMD; 
 
 
  PMPEG_HLI_DIRECTION = ^MPEG_HLI_DIRECTION; 
  MPEG_HLI_DIRECTION = ( 
                	MpegUpperButton = 0, 
                	MpegLowerButton, 
                	MpegLeftButton, 
                	MpegRightButton 
                        ); 
 _MPEG_HLI_DIRECTION = MPEG_HLI_DIRECTION; 
 
 
 PMPEG_DISPLAY_STATE = ^MPEG_DISPLAY_STATE; 
 MPEG_DISPLAY_STATE = ( 
                       MpegDisplayOff = 0, 
                       MpegDisplayOn 
                       ); 
  _MPEG_DISPLAY_STATE = MPEG_DISPLAY_STATE; 
 
 
  PMPEG_DISPLAY_TYPE = ^MPEG_DISPLAY_TYPE; 
  MPEG_DISPLAY_TYPE = ( 
                       MpegDisplayNormal = 0,  //  4:3 
                       MpegDisplayWide,        // 16:9 
                       MpegDisplayLetterBox, 
                       MpegDisplayPanScan 
                       ); 
  _MPEG_DISPLAY_TYPE = MPEG_DISPLAY_TYPE; 
 
 
  PMPEG_DISPLAY_RESOLUTION = ^MPEG_DISPLAY_RESOLUTION; 
  MPEG_DISPLAY_RESOLUTION = packed record 
    iBitsPerPixel: Integer; 
    iScreenWidth : Integer; 
    iScreenHeight: Integer; 
  end; 
  _MPEG_DISPLAY_RESOLUTION = MPEG_DISPLAY_RESOLUTION; 
 
 
  PMPEG_DISPLAY_RESOLUTION_EX = ^MPEG_DISPLAY_RESOLUTION_EX; 
  MPEG_DISPLAY_RESOLUTION_EX = packed record 
    iBitsPerPixel       : Integer; 
    iScreenWidth        : Integer; 
    iScreenHeight       : Integer; 
    iHFrequency         : Integer; 
    iTotalPixelsPerLine : Integer; 
    iTotalLinesPerFrame : Integer; 
    iPixelXOffset       : Integer; 
    iLineYOffset        : Integer; 
    dwReserved          : array[0..3] of DWORD; 
  end; 
  _MPEG_DISPLAY_RESOLUTION_EX = PMPEG_DISPLAY_RESOLUTION_EX; 
 
  PMPEG_ASYNC_CONTEXT = ^MPEG_ASYNC_CONTEXT; 
  MPEG_ASYNC_CONTEXT = packed record 
    hEvent      : THandle; 
    Reserved    : array [0..9] of LongWord; 
  end; 
  _MPEG_ASYNC_CONTEXT = PMPEG_ASYNC_CONTEXT; 
 
// Color limits for one specified color 
// 
  PCOLOR_LIMITS = ^COLOR_LIMITS; 
  COLOR_LIMITS = packed record 
    crKeyColor   : COLORREF; 
    crUpperLimit : COLORREF; 
    crLowerLimit : COLORREF; 
  end; 
  tagCOLOR_LIMITS = COLOR_LIMITS; 
 
 
  PMPEG_DISPLAY_FRAME = ^MPEG_DISPLAY_FRAME; 
  MPEG_DISPLAY_FRAME = ( 
                	MpegDisplayMotion, 
                	MpegDisplayStill 
                        ); 
  _MPEG_DISPLAY_FRAME = MPEG_DISPLAY_FRAME; 
 
  POWNER = ^OWNER; 
  OWNER = ( 
  	   NO_OWNER,			// WDM, SYS and VXD not currently using the hardware 
	   OWNER_IS_WDM, 
	   OWNER_IS_SYS,		// We may want later to differentiate SYS from VxD 
	   OWNER_IS_VXD 
           ); 
 
  PHDTV_MODE = ^HDTV_MODE; 
  HDTV_MODE = packed record 
    HFreq       : DWORD; 
    VFreq       : DWORD; 
    VideoWidth  : DWORD; 
    VideoHeight : DWORD; 
 
    HSyncTotal  : DWORD; 
    PreHSync    : DWORD; 
    HSyncActive : DWORD; 
    PostHSync   : DWORD; 
 
    VSyncTotal  : DWORD; 
    PreVSync    : DWORD; 
    VSyncActive : DWORD; 
    PostVSync   : DWORD; 
 
    PixelFreq   : DWORD; 
    Interlaced  : DWORD; 
  end; 
  tagHDTV_MODE = HDTV_MODE; 
 
//**************************************************************************** 
// Data Structures 
//**************************************************************************** 
  PMPEG_PACKET_LIST_ENTRY = ^ MPEG_PACKET_LIST_ENTRY; 
  MPEG_PACKET_LIST_ENTRY = packed record 
    pPacketData         : Pchar; 
    ulPacketSize        : LongWord; 
    Scr                 : MPEG_SYSTEM_TIME; 
    // the following 2 fields are used by the windows 95 VxDs 
    // please do not use! 
    pData               : Pchar; 
    ulDataSize          : LongWord; 
  end; 
  _MPEG_PACKET_LIST_ENTRY = MPEG_PACKET_LIST_ENTRY; 
 
  PMPEG_ATTRIBUTE_PARAMS = ^ MPEG_ATTRIBUTE_PARAMS; 
  MPEG_ATTRIBUTE_PARAMS = packed record 
    Attribute   :MPEG_ATTRIBUTE;			// attribute to Get or Set 
    Value       : LongInt;                      // attribute dependent parameter 1 
  end; 
  _MPEG_ATTRIBUTE_PARAMS = MPEG_ATTRIBUTE_PARAMS; 
 
 
  PMPEG_ATTRIBUTE_PARAMS_EX = ^ MPEG_ATTRIBUTE_PARAMS_EX; 
  MPEG_ATTRIBUTE_PARAMS_EX = packed record 
    Attribute   : MPEG_ATTRIBUTE;	// attribute to Get or Set 
    pData       : Pointer;				// pointer to attribute data 
    ulDataSize  : LongWord;			// size of attribute data 
  end; 
  _MPEG_ATTRIBUTE_PARAMS_EX = MPEG_ATTRIBUTE_PARAMS_EX; 
 
 
  PMPEG_OVERLAY_RECT = ^MPEG_OVERLAY_RECT; 
  MPEG_OVERLAY_RECT = packed record 
    X   : Integer;//LongWord;                         // window x position,width 
    Y   : LongWord;                         // window y position,height 
    cX  : LongWord;                        // window x position,width 
    cY  : LongWord;                        // window y position,height 
  end; 
  _MPEG_OVERLAY_RECT = MPEG_OVERLAY_RECT; 
 
 
  PMPEG_POINT = ^MPEG_POINT; 
  MPEG_POINT = packed record 
    x   : LongWord; 
    y   : LongWord; 
  end; 
  _MPEG_POINT = MPEG_POINT; 
 
// Overlay VGA key 
  PMPEG_OVERLAY_KEY = ^MPEG_OVERLAY_KEY; 
  MPEG_OVERLAY_KEY = packed record 
    rgbColor    : COLORREF;              // palette index or RGB color 
    rgbMask     : COLORREF;               // significant bits in color 
  end; 
  _MPEG_OVERLAY_KEY = MPEG_OVERLAY_KEY; 
 
 
  POVERLAY_COLOUR_REGISTERS = ^OVERLAY_COLOUR_REGISTERS; 
  OVERLAY_COLOUR_REGISTERS = packed record 
    RedUpper    : Word; 
    RedLower    : Word; 
    GreenUpper  : Word; 
    GreenLower  : Word; 
    BlueUpper   : Word; 
    BlueLower   : Word; 
    Mask        : Word; 
    Status      : Word; 
  end; 
  _OVERLAY_COLOUR_REGISTERS = OVERLAY_COLOUR_REGISTERS; 
 
 
  PMPEG_OVERLAY_KEY2 = ^MPEG_OVERLAY_KEY2; 
  MPEG_OVERLAY_KEY2 = packed record 
    rgbColor    : COLORREF;					// RGB color 
    pOverride   : POVERLAY_COLOUR_REGISTERS; 
  end;   
  _MPEG_OVERLAY_KEY2 = MPEG_OVERLAY_KEY2; 
 
 
  PCALIBRATION_PARAMETERS = ^CALIBRATION_PARAMETERS; 
  CALIBRATION_PARAMETERS = packed record 
    UpperFF     : COLORREF; 
    LowerFF     : COLORREF; 
    Upper80     : COLORREF; 
    Lower80     : COLORREF; 
    Upper00     : COLORREF; 
    Lower00     : COLORREF; 
  end; 
  _CALIBRATION_PARAMETERS = CALIBRATION_PARAMETERS; 
 
 
  PMPEG_OVERLAY_BIT_MASK = ^MPEG_OVERLAY_BIT_MASK; 
  MPEG_OVERLAY_BIT_MASK = packed record 
    PixelHeight          : LongWord;            // the height of the bit-mask buffer 
    PixelWidth           : LongWord;             // the wight of the bit-mask buffer 
    BufferPitch          : LongWord;            // the number of bytes-per-line 
    LeftEdgeBitOffset    : LongWord;      // the number of bits to skip on the left edge 
    pBitMask             : Pchar;               // pointer to the data 
  end; 
  _MPEG_OVERLAY_BIT_MASK = MPEG_OVERLAY_BIT_MASK; 
 
// 
// This should really be a union but mmmidl doesn't support them 
// 
  PMPEG_DEVICE_INFO = ^MPEG_DEVICE_INFO; 
  MPEG_DEVICE_INFO = packed record 
    DeviceState                 : MPEG_DEVICE_STATE;		// Current MPEG device decode state 
    RequestedState              : REQUESTED_STATE_TYPE;// Current requested state of MPEG device 
    DecoderBufferSize           : LongWord;			// Size of the decoder buffer 
    DecoderBufferFullness       : LongWord;		// Used bytes in docoder buffer 
    StarvationCount             : LongWord;				// The numer of times the device has 
										//     entered the starvation state 
 
    // The following two are only valid for video 
    DecompressHeight            : LongWord;				// Native MPEG decode height 
    DecompressWidth             : LongWord;				// Native MPEG decode width 
 
    // The following are only valid for overlay 
    MinDestinationHeight        : LongWord;         // Minimum height of overlay 
    MaxDestinationHeight        : LongWord;         // Maximum height of overlay 
    MinDestinationWidth         : LongWord;          // Minimum width of overlay 
    MaxDestinationWidth         : LongWord;          // Maximum width of overlay 
 
    EventStatus                 : LongWord;					// status of an event 
  end; 
  _MPEG_DEVICE_INFO = MPEG_DEVICE_INFO; 
 
const MPEG_EVENT_PAUSE_ON_EVENT		= $0001; 
const MPEG_EVENT_CONTINUE_ON_EVENT	= $0002; 
const MPEG_EVENT_CANCEL_ON_EVENT	= $0004; 
const MPEG_EVENT_PAUSE_DSP_ON_EVENT	= $0008; 
const MPEG_EVENT_VIDEO_RELATIVE_FRAME	= $0010; 
const MPEG_EVENT_VIDEO_ABSOLUTE_FRAME	= $0020; 
const MPEG_EVENT_VIDEO_BYTES		= $0040; 
const MPEG_EVENT_AUDIO_BYTES		= $0080; 
const MPEG_EVENT_STEP			= $0100; 
 
type 
 
  PMPEG_EVENT = ^MPEG_EVENT; 
  MPEG_EVENT = packed record 
    MpegEvent   : MPEG_EVENT_TYPE;			// type of event requested 
    ulData      : LongWord;						// event specific info (eg #of frames) 
    ulFlags     : LongWord;					// event flags - pause or continue? 
  end; 
  _MPEG_EVENT = MPEG_EVENT; 
 
 
  PCIRCULAR_BUFFER_INFO = ^CIRCULAR_BUFFER_INFO; 
  CIRCULAR_BUFFER_INFO = packed record 
    pBuffer     : Pchar;	// pointer to start of buffer 
    ulSize      : LongWord;		// size of buffer 
    RdPtr       : Word;		// offset from start of buffer 
    WrPtr       : Word;		// offset from start of buffer 
  end; 
  _CIRCULAR_BUFFER_INFO = CIRCULAR_BUFFER_INFO; 
 
 
  PVXD_ADDRESS = ^VXD_ADDRESS; 
  VXD_ADDRESS = packed record 
    BaseAddress : LongWord; 
    Length      : LongWord; 
  end; 
  _VXD_ADDRESS = VXD_ADDRESS; 
 
 
  PWDM_ADDRESS = ^WDM_ADDRESS; 
  WDM_ADDRESS = packed record 
    HighPart            : LongWord; 
    LowPart             : LongWord; 
    RangeLength         : LongWord; 
    RangeInMemory       : Boolean; 
  end; 
  _WDM_ADDRESS = WDM_ADDRESS; 
 
 
  PHIGHLIGHT_COMMAND = ^HIGHLIGHT_COMMAND; 
  HIGHLIGHT_COMMAND = packed record 
    command     : MPEG_HLI_CMD; 
    dwParameter : DWORD; 
  end; 
  _HIGHLIGHT_COMMAND = HIGHLIGHT_COMMAND; 
 
 
  uCommandex = record 
    case integer of 
      0: (bButtonNumber  : Byte); 
      1: (dwParam        : DWORD); 
      2: (point          : MPEG_POINT); 
  end; 
 
  PHIGHLIGHT_COMMANDEX = ^HIGHLIGHT_COMMANDEX; 
  HIGHLIGHT_COMMANDEX = packed record 
    command     : MPEG_HLI_CMD; 
    u           : uCommandex; 
  end; 
  _HIGHLIGHT_COMMANDEX = HIGHLIGHT_COMMANDEX; 
 
 
  PPERFORMANCE_STAT = ^PERFORMANCE_STAT; 
  PERFORMANCE_STAT = packed record 
    pAddr       : Pchar; 
    szDesc      : array [0..63] of Char; 
  end; 
  _PERFORMANCE_STAT = PERFORMANCE_STAT; 
 
 
  PI2C_INFO = ^I2C_INFO; 
  I2C_INFO = packed record 
    i2c_address : LongWord; 
    reg         : LongWord; 
    data        : LongWord; 
  end; 
  _I2C_INFO = I2C_INFO; 
 
// 
  BOARD_CTL_PROPERTY_SUBID = ( 
                              NoType = 0, 
                              chip_reg, 
                              ucode_sym, 
                              ovr_reg, 
                              tvenc_reg, 
                              var_rm8400, 
                              rtMaxActiveTable, 
                              rtEEPROM, 
                              data_memory, 
                              rtMaxType 
                              ); 
  _BOARD_CTL_PROPERTY_SUBID = BOARD_CTL_PROPERTY_SUBID; 
 
{$ifndef _RM_WRITE_DEFINED} 
{$define _RM_WRITE_DEFINED} 
type 
  PRM_WRITE = ^RM_WRITE; 
  RM_WRITE = packed record 
    Addr        : LongWord; 
    Data        : LongWord; 
  end; 
  _RM_WRITE = RM_WRITE; 
{$endif} // _RM_WRITE_DEFINED 
 
type 
  BI_HEADER = packed record 
    ExtraSize   : LongWord;		// in bytes 
    PropSubID   :BOARD_CTL_PROPERTY_SUBID; 
  end; 
  _BI_HEADER = BI_HEADER; 
 
 
  uBoardInfo = record 
    case integer of 
      0: (Write         : RM_WRITE); 
      1: (uchar         : Byte); 
      2: (ushort        : Word); 
      3: (ulong         : LongWord); 
      4: (ulonglong     : Int64); 
  end; 
 
  PBOARD_INFO = ^BOARD_INFO; 
  BOARD_INFO = packed record 
    Header      : BI_HEADER; 
    u           : uBoardInfo; 
  end; 
  _BOARD_INFO = BOARD_INFO; 
 
 
 
const DMABFLAGS_KernelMode	= $00000001; 
const DMABFLAGS_CheckStatus	= $00000002; 
 
type 
  PDMABUFFER_INFO = ^DMABUFFER_INFO; 
  DMABUFFER_INFO = packed record 
    Size                : LongWord; 
    UserVirtualAddress  : Pointer; 
    PhysicalAddress     : Int64; 
    Flags               : LongWord; 
    Reserved            : LongWord; 
  end; 
 
  PVCXO_SET = ^VCXO_SET; 
  VCXO_SET = packed record 
    Coefficients        : array [0..1] of LongWord;	// N,M,K,ppmError; 
    RepeatCount         : array [0..1] of LongWord;		// number of VSyncs to keep the corresponding Coefficients 
  end; 
  _VCXO_SET = VCXO_SET; 
 
 
  HW_VCXO = ( 
             eHwVcxoDefault = -1, 
	     eHwVcxoPio0, 
	     eHwVcxoPio1, 
	     eHwVcxoPio2, 
	     eHwVcxoPio3, 
	     eHwVcxoPio4, 
	     eHwVcxoPio5, 
	     eHwVcxoPio6, 
	     eHwVcxoPio7, 
             eHwVcxoPio8, 
	     eHwVcxoPio9, 
	     eHwVcxoPio10, 
	     eHwVcxoPio11, 
	     eHwVcxoPio12, 
	     eHwVcxoPio13, 
	     eHwVcxoPio14, 
	     eHwVcxoPio15, 
	     eHwVcxoNovaLitePll, 
	     eHwVcxoMax 
             ); 
  tagHW_VCXO = HW_VCXO; 
 
  PCR_INFO = packed record	// used for PropId=etimPcrInfo in PropSet=TIME_SET 
    wStructureVersion   : WORD;		// 0 
    PcrEnable           : WORD;				// 1 for Pcr master, 0 for Apts master 
    RecoveryTime        : DWORD;			// = log2(TimeRecovery/200us) = 16 for 13.1072sec 
    PcrIntrPeriodUs     : DWORD;		// 200us ... 13,107,000us (1*200us ... 0xFFFF*200us) 
    TimeResolution      : DWORD;		// 90000 for unit90k 
    DeltaPCR_SCR_Max    : DWORD;		// unit90k, ex: 9000 unit90k = 100ms 
    DeltaSCR_APTS_Max   : DWORD;	// unit90k, ex: 180 unit90k = 2ms 
    HwVcxo              : HW_VCXO;				// Pio5 for Siemens box 
    PpmRange            : DWORD;				// 150, for +/-150 
  end; 
  tagPCR_INFO = PCR_INFO; 
 
 
 
  TIME_INFO = packed record	// used for PropId=etimPcrTime in PropSet=TIME_SET 
    dwTimeResolution    : DWORD;	// 90000 for 90k pts unit 
    dwlTime             : Int64;		// Pts //ULONGLONG 
  end; 
  tagTIME_INFO = TIME_INFO; 
 
 
 
  DualMonoMode = (	// used for PropId = eaDualMonoMode in PropSet=AUDIO_SET 
  	          eDualModeStereo = 0, 
	          eDualModeMonoRight, 
	          eDualModeMonoLeft, 
	          eDualModeMonoMix 
                  ); 
 
 
  Ac3SpeakerConfig = (	// used for PropId = eaAc3Conf in PropSet=AUDIO_SET 
                      eAc3SpeakerSurround = 0, 
                      eAc3Speaker1_0, 
                      eAc3Speaker2_0 
                      ); 
 
 
  Ac3ComprDlgNorm = (	// used for PropId = eaAc3Conf in PropSet=AUDIO_SET 
                     eAc3ComprDiagNormOff = 0, 
        	     eAc3DiagNormOn, 
	             eAc3LineOut, 
        	     eAc3RFModulation 
                     ); 
 
  AC3_CONF = packed record	// used for PropId = eaAc3Conf in PropSet=AUDIO_SET 
    wStructureVersion           : WORD;			// 0 
    bAc3ComprDlgNorm            : BYTE;			// HwLib default eAc3LineOut 
    bAc3SpeakerConfig		: BYTE; 	// HwLib default eAc3SpeakerSurround 
    wAc3HiLoDynamicRange        : WORD;		// HwLib default 0xFFFF 
    wAc3RepeatCounter           : WORD;			// HwLib default 0x0000 
  end; 
  tagAC3_CONF = AC3_CONF; 
 
// MpegAttrVgaVendorInfo 
  PVGA_VENDOR_INFO = ^VGA_VENDOR_INFO; 
  VGA_VENDOR_INFO = packed record 
    wVendorID           : WORD; 
    wDeviceID           : WORD; 
    wSubSystemVendorID  : WORD; 
    wSubSystemID        : WORD; 
    bRevisionID         : BYTE; 
  end; 
  _VGA_VENDOR_INFO = VGA_VENDOR_INFO; 
 
// List all the different data format type passed in RM_DATA_FORMAT_STRUCT 
 
  PRM_DATA_FORMAT_ENUM = ^RM_DATA_FORMAT_ENUM; 
  RM_DATA_FORMAT_ENUM = ( 
                	 RmDataFormatUnknown = -1, 
 
                	 RmDataFormatMPEG12Video = 0, 
                	 RmDataFormatMPEG4Video = 1, 
 
                	 RmDataFormatMPEG1Audio = $10 + AUDIO_FORMAT_MPEG1, 
                	 RmDataFormatMPEG2Audio = $10 + AUDIO_FORMAT_MPEG2, 
	                 RmDataFormatAC3Audio = $10 + AUDIO_FORMAT_AC3, 
	                 RmDataFormatPCMAudio = $10 + AUDIO_FORMAT_PCM, 
	                 RmDataFormatDTSAudio = $10 + AUDIO_FORMAT_DTS, 
	                 RmDataFormatDVDAudio = $10 + AUDIO_FORMAT_DVD_AUDIO, 
	                 RmDataFormatReversePCMAudio = $10 + AUDIO_FORMAT_REVERSE_PCM, 
	                 RmDataFormatMPEG4PCMAudio,			// AUDIO_FORMAT_PCM 
	                 RmDataFormatMPEG4ReversePCMAudio	// AUDIO_FORMAT_REVERSE_PCM, 
                         ); 
  tagRM_DATA_FORMAT_ENUM = RM_DATA_FORMAT_ENUM; 
 
// Base structure used to pass new data format to driver inside a data buffer. 
// The flags of this packet needs to be set to RMFLAG_DATA_FORMAT_CHANGE 
 
  PRM_DATA_FORMAT_STRUCT = ^RM_DATA_FORMAT_STRUCT; 
  RM_DATA_FORMAT_STRUCT = packed record 
    wStructSize : WORD; 
    bStandard   : BYTE;		// See RM_DATA_FORMAT_ENUM (Use (BYTE) RM_DATA_FORMAT_ENUM) 
    bRevision   : BYTE;		// Revision number (== RM_DATA_FORMAT_REVISION) 
  end; 
  tagRM_DATA_FORMAT_STRUCT = RM_DATA_FORMAT_STRUCT; 
 
const RM_DATA_FORMAT_REVISION = 1;	// Changes every time RM_DATA_FORMAT_STRUCT changes 
 
// Base structure used to pass new data format to driver inside a data buffer. 
// The flags of this packet needs to be set to RMFLAG_DATA_FORMAT_CHANGE] 
type 
 
  PRM_MPEG4_DATA_FORMAT_STRUCT = ^RM_MPEG4_DATA_FORMAT_STRUCT; 
  RM_MPEG4_DATA_FORMAT_STRUCT = packed record 
    wStructSize : WORD; 
    bStandard   : BYTE;		// See RM_DATA_FORMAT_ENUM (Use (BYTE) RM_DATA_FORMAT_ENUM) 
    bRevision   : BYTE;		// Revision number (== RM_DATA_FORMAT_REVISION) 
 
    dwTimeScale : DWORD;	// MPEG4 track Time Scale 
  end; 
  tagRM_MPEG4_DATA_FORMAT_STRUCT = RM_MPEG4_DATA_FORMAT_STRUCT; 
 
// RM_DATA_FORMAT_STRUCT structure used to pass RmDataFormatMPEG4Video video format 
 
  PRM_MPEG4_VIDEO_FORMAT_STRUCT = ^RM_MPEG4_VIDEO_FORMAT_STRUCT; 
  RM_MPEG4_VIDEO_FORMAT_STRUCT = packed record 
    wStructSize                         : WORD; 
    bStandard                           : BYTE;		// See RM_DATA_FORMAT_ENUM (Use (BYTE) RM_DATA_FORMAT_ENUM) 
    bRevision                           : BYTE;		// Revision number (== RM_DATA_FORMAT_REVISION) 
 
    dwTimeScale                         : DWORD;	// MPEG4 track Time Scale 
 
    dwVopTimeIncrementResolution        : DWORD;	// Number of ticks per second found in DSI or forced 
										// when bForceFixedVOPRate is 1 
    bAspectRatio                        : BYTE;	// See MPEG4 Video Aspect Ratios 
    wWidth                              : WORD;		// Video Width 
    wHeight                             : WORD;		// Video Height 
 
    bForceFixedVOPRate                  : BOOL;		// Force VOP Rate <> DSI (Only for DivX) 
    dwFixedVopTimeIncrement             : DWORD;	// When bForceFixedVOPRate==1, number of ticks per VOP 
									// (Use dwVopTimeIncrementResolution for time resolution) 
  end; 
  tagRM_MPEG4_VIDEO_FORMAT_STRUCT = RM_MPEG4_VIDEO_FORMAT_STRUCT; 
 
// RM_DATA_FORMAT_STRUCT structure used to pass RmDataFormatPCMAudio audio format 
  PRM_MPEG4_PCM_FORMAT_STRUCT = ^RM_MPEG4_PCM_FORMAT_STRUCT; 
  RM_MPEG4_PCM_FORMAT_STRUCT = packed record 
    wStructSize         : WORD; 
    bStandard           : BYTE;		// See RM_DATA_FORMAT_ENUM (Use (BYTE) RM_DATA_FORMAT_ENUM) 
    bRevision           : BYTE;		// Revision number (== RM_DATA_FORMAT_REVISION) 
 
    dwTimeScale         : DWORD;	// MPEG4 track Time Scale 
 
    lBitsPerSample      : LongInt; 
    lNumberOfChannels   : LongInt; 
    lSampling_Frequency : LongInt; 
  end; 
  tagRM_MPEG4_PCM_FORMAT_STRUCT = RM_MPEG4_PCM_FORMAT_STRUCT; 
 
// Make sure the following size is bigger or equal to the maximum RM_xxx_FORMAT_STRUCT! 
const MAX_DATA_FORMAT_STRUCT_SIZE = 100; 
 
//--------------------------------------------------------------------------- 
//============================irmbase.h================================= 
////////////////////////////////////////////////////////////////////////////////// 
const 
  FIRST_AVALIABLE_INSTANCE	        = $FFFFFFFE; 
 
  CATEGORY_MODULE_QUAD_BOARD	      = 'CATEGORY_MODULE_QuadBoard'; 
  CATEGORY_MODULE_SINGLE_HOST	      = 'CATEGORY_MODULE_SingleHost'; 
  CATEGORY_NODE_HW_LIB		          = 'CATEGORY_NODE_HwLibrary'; 
  CATEGORY_PIN_VIDEO			          = 'CATEGORY_PIN_Video'; 
  CATEGORY_PIN_AUDIO			          = 'CATEGORY_PIN_Audio'; 
  CATEGORY_PIN_OVERLAY		          = 'CATEGORY_PIN_Overlay'; 
  CATEGORY_PIN_SUBPICTURE		        = 'CATEGORY_PIN_Subpicture'; 
  CATEGORY_PIN_OSD	              	= 'CATEGORY_PIN_OSD'; 
 
// Categories can be extended like this: 
 
  CATEGORY_NODE_MPEG_DECODER	      = 'CATEGORY_NODE_MPEG Decoder'; 
  CATEGORY_NODE_AUDIO_DECODER	      = 'CATEGORY_NODE_Audio Decoder'; 
  CATEGORY_NODE_TV_ENCODER	        = 'CATEGORY_NODE_TvEncoder'; 
 
// Obsolete Categories can be dropped. 
//	IRmObjectEnumerator enumerates: 
// 
//	CoCreateInstance()		BOARD instance 
//	GetSubEnumerator()			Logical Devices with direct access(nodes) 
//	GetSubEnumerator()					Connection points(pins,streams) 
type 
  //RMMPEG_ATTRIBUTE = RMuint32; 
  //typedef char		char; 
  ENUM_OBJECT_TYPE = ( EOTYPE_MODULE, 
                       EOTYPE_NODE, 
                       EOTYPE_PIN 
                      ); 
// Information about all resources, allocated or not 
 
  IT_STANDARD = (	IT_STANDARD_CATEGORY, 
                	IT_STANDARD_DISPLAY_NAME, 
                	IT_STANDARD_INSTANCE_ID, 
                	IT_STANDARD_LOCATION 
                ); 
 
  IT_PIN = ( IT_PIN_DIRECTION, 
             IT_PIN_TYPE_INDEX, 
           	IT_PIN_NAME 
           ); 
// new implementation - specific infosets can be added in future 
  IS_MONIKER = (  IS_MONIKER_INTERNAL, 
                	IS_MONIKER_STANDARD, 
                	IS_MONIKER_PIN 
               ); 
///////////////////////////////////////////////////////////////////////////////////////// 
// 
//	CLASS FACTORY IDENTIFIERS 
// 
///////////////////////////////////////////////////////////////////////////////////////// 
 
// Class Factory ID. If client use this CLSID resulting object represent HwLibrary. 
// Any other object types must use different CLSID. 
 
// old interfaces, used for backward compatibility 
// USED BY: 
//		OSD 
//		quadro_test 
// 
//DEFINE_RMID(CLSID_rm8400	,0x2f921938,0x54ab,0x4fc3,0x8a,0xdf,0x71,0x9b,0x8c,0xc8,0xf4,0xbb); 
 
// interfaces represents HwLibrary for EM8xxx chipset 
// 
const 
  CLSID_RM8400                : TGUID = '{00140BB8-D735-46BE-A997-B382486DCC04}'; 
  IID_IRmOSD                  : TGUID = '{41189722-20DF-43a8-8719-F956DD8BB970}'; 
  CLSID_RMBASE                : TGUID = '{5e91af27-24d3-47ac-9c55-132f04c98281}'; 
  IID_IRmObjectMoniker        : TGUID = '{77167D8A-8090-11d5-B85E-00902765E16C}'; 
  IID_IRmObjectEnumerator     : TGUID = '{CD83BC0A-8090-11d5-B85E-00902765E16C}'; 
  IID_ICompletionCallBack     : TGUID = '{EDB5A0D2-E32B-4290-9EDC-0F9FE41327F2}'; 
  IID_IRmControlNode          : TGUID = '{5D896824-4239-4ddb-AF13-C80936C246BD}'; 
  IID_IRmBridge               : TGUID = '{18ca821d-7e35-464c-9e17-c5f438f1c551}'; 
  IID_IRmStream               : TGUID = '{4757FEB1-883D-41d4-990B-2E7E9018B73A}'; 
  IID_IPivateRegProfile	      : TGUID = '{EE543A70-2D27-43fb-966F-CCF8E5396E62}'; 
  IID_IRmObjectFinder         : TGUID =	'{27128970-797a-460e-92ee-b63f98d755bf}'; 
  IID_IRmMapMem               : TGUID = '{9CB7F9A8-0AE5-4a2c-99DB-9B4D58967B45}'; 
///////////////////////////////////////////////////////////////////////////////////////// 
// 
//	INTERFACES 
// 
///////////////////////////////////////////////////////////////////////////////////////// 
 
type 
  IRmObjectEnumerator = interface;	// Forward declaration 
 
  PPIRmObjectMoniker = ^PIRmObjectMoniker; 
  PIRmObjectMoniker = ^IRmObjectMoniker; 
  IRmObjectMoniker = interface(IRMBase) 
  ['{77167D8A-8090-11d5-B85E-00902765E16C}'] 
    function BindToObject(riid: TGUID; pObj: Pointer): RMRESULT; stdcall; 
    function IsRunning: HRESULT; stdcall; 
	  function GetEnumerator(p: IRmObjectEnumerator): RMRESULT; stdcall; 
	  function GetSubEnumerator(p: IRmObjectEnumerator): RMRESULT; stdcall; 
    function GetInfo(info_set: RMuint32; info_type: RMuint32; 
				             pBuffer: Pointer; buff_size: RMuint32; 
				             cbRet: RMuint32): RMRESULT;stdcall; 
  end; 
 
  IRmObjectEnumerator = interface(IRMBase) 
  ['{CD83BC0A-8090-11d5-B85E-00902765E16C}'] 
    function Reset: HRESULT; stdcall; 
    function Next(pIRmObjectMoniker: IRmObjectMoniker): RMRESULT; stdcall; 
  end; 
 
  PICompletionCallBack = ^ICompletionCallBack; 
  ICompletionCallBack = interface(IRMBase) 
  ['{EDB5A0D2-E32B-4290-9EDC-0F9FE41327F2}'] 
    function Complete(Conext: Pointer): RMRESULT; stdcall; 
  end; 
 
 
  IRmControlNode = interface(IRMBase) 
  ['{5D896824-4239-4ddb-AF13-C80936C246BD}'] 
    function GetCapabilities(pCaps: PRMCAPABILITIES): RMRESULT; stdcall; 
    function GetProperty( PropertySetID: RMuint32; 
                          PropertyItemID: RMuint32; 
                          PropertyItemFlags : RMuint32; 
                          PropertySize: RMuint32; 
                          pPropertyData: Pointer; 
                          cbReturn: RMuint32 ): RMRESULT; stdcall; 
    function SetProperty(	PropertySetID: RMuint32; 
                          PropertyItemID: RMuint32; 
                          PropertyItemFlags: RMuint32; 
                          PropertySize: RMuint32; 
                          pPropertyData: Pointer ): RMRESULT; stdcall; 
	// TODO: drop it and use instead SetProperty(PROPSET_ATTRIBUTES,MpegAttr...,flags,size,data); 
    function SetAttributes( eAttribute: MPEG_ATTRIBUTE{RMMPEG_ATTRIBUTE}; 
                    				lValue: RMint32 ): RMRESULT; stdcall; 
    function GetAttributes( eAttribute: MPEG_ATTRIBUTE{RMMPEG_ATTRIBUTE}; 
        				            out lValue: RMint32): RMRESULT; stdcall; 
  end; 
 
// No streaming, but can be connected using Format Negotiation algoritm. 
// This is Control Point, like Overlay - it can be connected using different 
// formats, but there is not streaming data. 
 
 
  IRmBridge = interface(IRMBase) 
  ['{18ca821d-7e35-464c-9e17-c5f438f1c551}'] 
    function Play: RMRESULT; stdcall; 
    function Pause: RMRESULT; stdcall; 
    function Stop: RMRESULT; stdcall; 
	//RMRESULT IRMCALLTYPE GetStreamState( PRMSTATE state) = 0; ??? 
	//RMRESULT IRMCALLTYPE SetStreamState( RMSTATE state) = 0; ??? 
    function Reset: RMRESULT; stdcall; 
    function CheckFormat(format: PRMDATAFORMAT): RMRESULT; stdcall; 
    function GetFormat(out format_list: PRMMULTIPLE_ITEM): RMRESULT; stdcall; 
    function SetFormat(format: PRMDATAFORMAT): RMRESULT; stdcall; 
  end; 
 
  IRmStream = interface(IRmBridge) 
  ['{4757FEB1-883D-41d4-990B-2E7E9018B73A}'] 
    function BeginFlush: RMRESULT; stdcall; 
    function EndFlush: RMRESULT; stdcall; 
    function Write( pHeaders: PRMMULTIPLE_ITEM; 
                    out ovr: RMOVERLAPIO): RMRESULT; stdcall; 
    function WriteEx( pHeaders: RMMULTIPLE_ITEM; 
                      pICCallback: ICompletionCallBack; 
                      CompletionContext: Pointer): RMRESULT; stdcall; 
    function Read( pHeaders: RMMULTIPLE_ITEM; 
                   ovr: RMOVERLAPIO): RMRESULT; stdcall; 
    function ReadEx( pHeaders: RMMULTIPLE_ITEM; 
                     pICCallback: ICompletionCallBack; 
                     CompletionContext: Pointer): RMRESULT; stdcall; 
  end; 
 
// object instance - specific place to save some information 
  IPivateRegProfile =interface(IRMBase) 
  ['{EE543A70-2D27-43fb-966F-CCF8E5396E62}'] 
    function GetInt( SectionName: PChar; 
                     ValueName: PChar; 
                     Default: RMint32; 
                     pValue: PRMint32 ): RMRESULT; stdcall; 
    function WriteInt( SectionName: PChar; 
                       ValueName: PChar; 
                       Value: RMint32): RMRESULT; stdcall; 
    function WriteDisplayInt( ValueName: PChar; 
                              Value: RMint32 ): RMRESULT; stdcall; 
    function GetDisplayInt( ValueName: PChar; 
                            Default: RMint32; 
                            Value: PRMint32): RMRESULT; stdcall; 
  end; 
// Helper interface, use istead of IRmObjectEnumerator in simple cases 
 
  IRmObjectFinder = interface(IRMBase) 
  ['{27128970-797a-460e-92ee-b63f98d755bf}'] 
    function FindMoniker( root: IRmObjectMoniker; 
                        	InstanceNumber: RMuint32; 
                          Category: PChar; 
		                    	out pIRmObjectMoniker: IRmObjectMoniker): RMRESULT; stdcall; 
 
    function FindObject( root: IRMBase; 
		            			   const InstanceNumber: RMuint32; 
		                     Category: PChar; 
						             const riid: TGUID; 
		                     out ppObj): RMRESULT; stdcall; 
  end; 
 
 
  IRmMapMem = interface(IRMBase) 
  ['{9CB7F9A8-0AE5-4a2c-99DB-9B4D58967B45}'] 
    function GetDeviceBase(pAddr: Pointer): RMRESULT; stdcall; 
    function FreeDeviceBase: RMRESULT; stdcall; 
  	function GetDMABuffer( size: RMuint32; 
		                       out pLinearAddr; 
		                       out pPhysicalAddr): RMRESULT; stdcall; 
	  function FreeDMABuffer(LinearAddr: Pointer): RMRESULT; stdcall; 
  	function GetBuffer( size: RMuint32; 
                        pAddr: Pointer): RMRESULT; stdcall; 
	  function	FreeBuffer(Addr: Pointer): RMRESULT; stdcall; 
  end; 
 
 
type 
 
  HEADER = record 
		multi   : RMMULTIPLE_ITEM; 
    header  : RMSTREAM_HEADER; 
  end; 
function SetOSDFromFile(AFileName : string): Boolean; 
 
 
implementation 
 
{*****  osd_test.cpp *********} 
 
//********************OSD测试********************** 
function SetOSDFromFile(AFileName : string): Boolean; 
  label exit_1; 
  label exit_10; 
  label exit_20; 
var 
  hr: HRESULT; 
  f: file; 
  fs: TFileStream; 
  i: Integer; 
  pOSD: IRmStream; 
  pDevice: IRmControlNode; 
  pMemAlloc: IRmMapMem; 
  count, size: Integer; 
  buff_8: array[0..7] of Byte; 
  rc_dest : MPEG_OVERLAY_RECT; 
  pshared : Pointer;//PUCHAR; 
  pIRmObjectFinder: IRmObjectFinder; 
  dwTvOutKeep, bn: RMint32; 
  HwLibVersion, dwTvOut: RMint32; 
  pos: LongInt; 
  phys: Pointer; 
  ret: DWORD; 
  hdr: HEADER; 
  ovr: RMOVERLAPIO; 
  //MpegAttrVideoTv : RMMPEG_ATTRIBUTE; 
  //MpegAttrCodeVersion: RMMPEG_ATTRIBUTE; 
begin 
  Result := Boolean(0); 
  pshared := nil; 
  rc_dest.X := 100; 
  rc_dest.Y := 10; 
  rc_dest.cX := 100; 
  rc_dest.cY := 100; 
	CoInitialize(nil); 
	hr := CoCreateInstance(CLSID_RMBASE, nil, 
                        CLSCTX_INPROC_SERVER, 
                        IID_IRmObjectFinder, 
                        pIRmObjectFinder); 
	if (FAILED(hr)) then Exit; 
	// GET OSD 
	hr := pIRmObjectFinder.FindObject( 
					nil, 
					FIRST_AVALIABLE_INSTANCE, 
					CATEGORY_PIN_OSD, 
					IID_IRmStream, 
					pOSD); 
 
	pIRmObjectFinder := nil; 
 
 
 
	if (FAILED(hr)) then goto exit_1; 
	///////////////////////////////////////////////////////////////////////////////////// 
	// do something useful 
 
	pOSD.Reset(); 
  //pOsd.GetFormat() 
  pDevice := nil; 
  hr := pOSD.QueryInterface(IID_IRmControlNode, pDevice); 
  if FAILED(hr) then goto exit_1; 
  hr := pOSD.QueryInterface(IID_IRmMapMem, pMemAlloc); 
  if FAILED(hr) then goto exit_1; 
  pDevice.GetAttributes(MpegAttrCodeVersion, HwLibVersion); 
  pDevice.GetAttributes(MpegAttrVideoTv, dwTvOutKeep); 
  pDevice.GetAttributes(MpegAttrOsdHiLiDest, bn); 
 // bn := 10;// bn and $80000000; 
 // pDevice.SetAttributes(MpegAttrVideoBrightness, bn); 
  dwTvOut := dwTvOutKeep and (not OUTPUT_OFF); 
  if HwLibVersion < 9 then 
			dwTvOut := dwTvOut or SET_TV 
  else 
  begin 
			dwTvOut := dwTvOut or SET_TV or $80000000; 
			dwTvOut := dwTvOut and (not SET_HDTV); 
	end; 
 
 
  pDevice.SetAttributes(MpegAttrVideoTv, dwTvOut); 
 
 // OpenFile(AfileName, nil, 
 
  //AssignFile(f, AFileName); 
  fs := TFileStream.Create(AfileName, fmOpenRead); 
  Count := fs.Read(Buff_8, SizeOf(Buff_8)); 
  //Reset(f, 1); 
  // Read header 
 // system.BlockRead(f, buff_8, SizeOf(buff_8), count); 
	if count <> 8 then goto exit_20; 
	// extract some bitmap information from header 
	size := (buff_8[1] shl (8*2)) or (buff_8[2] shl 8) or buff_8[3]; 
	rc_dest.cX := (buff_8[4] shl 8) or buff_8[5]; 
	rc_dest.cY := (buff_8[6] shl 8) or buff_8[7]; 
	// rewind to beginning 
	if size = 0 then goto exit_20 
  else begin 
	 //	pos := 0; 
	//	Seek(f, Pos); 
    fs.Seek(0, soFromBeginning); 
	end; 
	// if data will be sent using physically continious memory buffer 
	// it will be transferred by one DMA operation. OSD only: anything 
	// more then ~63K will be devided by separate transfers ~63K each, 
	// up to 8 transfers can be programmed by one VSYNC. 
	// 
	hr := pMemAlloc.GetDMABuffer(size, pshared, phys); 
	if pshared = nil then goto exit_20; 
 // BlockRead(f, pshared, size); 
   fs.ReadBuffer(pshared^, size); 
  //showmessage( String(Pchar(@pshared))); 
	pOSD.Play; 
 
	for i := 0 to 19 do 
  begin 
    FillChar(hdr, Sizeof(hdr), 0); 
		//ZeroMemory(&hdr,sizeof(hdr)); 
 
		hdr.multi.Count := 1; 
		hdr.multi.Size  := SizeOf(HEADER); 
		hdr.header.Size := SizeOf(RMSTREAM_HEADER); 
		hdr.header.pData := pshared; 
		hdr.header.FrameExtent := size; 
		// Send whole bitmap down 
		// 
 
    ovr.do_not_use[0] := 0; 
    ovr.do_not_use[1] := 0; 
    ovr.do_not_use[2] := 0; 
    ovr.do_not_use[3] := 0; 
    ovr.hEvent := CreateEvent(nil, True, False, nil); 
    pOSD.Write(@hdr.multi, ovr); 
 
		// Wait for completion 
		// 
		ret := WaitForSingleObject(ovr.hEvent,1000); 
		//if (ret = WAIT_TIMEOUT) then 
			//printf("  !!! TIMEOUT\n");		// 
		// Attributes can be set only if bitmap was completely loaded in DRAM 
		// or after last packet with bitmap data has been released by the driver. 
		// 
		//printf("Set OSD Destination: x - %X, y - %X, w - %X, h - %X\n", 
		//	rc_dest.X, rc_dest.Y, rc_dest.cX, rc_dest.cY); 
 
	 pDevice.SetAttributes(MpegAttrOsdDest, LongInt(@rc_dest)); 
 
		Inc(rc_dest.X, 10);// := rc_dest.X +10; 
		Inc(rc_dest.Y, 10);// := 10; 
 
		pDevice.SetAttributes(MpegAttrOsdON, 1); 
		CloseHandle(ovr.hEvent); 
  end; 
 
	pOSD.Stop(); 
	if pDevice = nil then 
		pDevice.SetAttributes(MpegAttrVideoTv,dwTvOutKeep) 
  else 
	  pDevice.SetAttributes(MpegAttrOsdOFF,1); 
//	pDevice->SetAttributes(MpegAttrOsdFLUSH,0); 
exit_20: 
  fs.Free; 
	//CloseFile(f); 
	if pDevice = nil then 
		pDevice := nil; 
exit_10: 
{#ifndef USE_RMBASE_CLSID 
	if (NULL != pshared) 
		free(pshared); 
#else} 
	if pMemAlloc = nil then 
  begin 
		if pshared = nil then 
			pMemAlloc.FreeDMABuffer(pshared); 
		pMemAlloc := nil; 
	end; 
	pOSD := nil; 
Exit_1: 
	CoUninitialize(); 
	Exit; 
end; 
 
 
function RMuint32LSBfromRMuint64(l: RMuint64): RMuint32; 
begin 
  Result := RMuint32(l); 
end; 
 
function RMuint32MSBfromRMuint64(l: RMuint64): RMuint32; 
begin 
  Result := RMuint32((l shr 32) and $ffffffff); 
end; 
 
function RMuint64from2RMuint32(MSB, LSB: RMuint32): RMuint64; 
begin 
  Result := RMuint64(RMuint64(MSB shl 32) + RMuint64(LSB)); 
end; 
 
end.