神龙卡OSD代码完整版本(0)

  • 主题发起人 主题发起人 jingtao
  • 开始时间 开始时间
J

jingtao

Unregistered / Unconfirmed
GUEST, unregistred user!
不记得谁弄的了....unit xlOSD;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, UnitRmOSD, ActiveX, UnitOSDFunctions, Dialogs, ExtCtrls,Jpeg;const HEADERLONG = 1032;
//osd文件头部大小 c_PANELVALUE = $4F;
type TOsdSWMode = (ssSWText,ssSWImage,ssSWTextImage,ssSWNone);
TScrollStyle = (ssLeftToRight, ssRightToLeft, ssTopToBottom, ssBottomToTop,ssNoScroll);
{ TxlOSD } TxlOSD = class (TComponent) private FFree: Boolean;
//是否空闲 FPOldData: Pointer;
//OSD文件指针 FPBakData: Pointer;
//当文字和图片同时显示时,保存的数据。 FPPalette: Pointer;
//调色板指针 FPData: Pointer;
//数据指针 FPTempData: Pointer;
//文字数据指针 FPBitmapData: Pointer;
//位图数据指针 可用于模拟动画 FBitmapFrames: Integer;
//位图帧数 FPlaying: Boolean;
FTimer: TTimer;
FInterval: Cardinal;
pOSD: IRmStream;
pDevice: IRmControlNode;
pMemAlloc: IRmMapMem;
rc_dest: MPEG_OVERLAY_RECT;
FSize: RMuint32;
//OSD文件大小 FCaptionScrolled: Boolean;
FCaptionX: Integer;
FCaptionY: Integer;
FOldCaptionX: Integer;
FOldCaptionY: Integer;
FOldCaptionWidth: Integer;
FOldCaptionHeight: Integer;
FCaptionWidth: Integer;
FCaptionHeight: Integer;
FScrollStyle: TScrollStyle;
FScrollStep: Integer;
FScrolled: Boolean;
FIsUsePanel: Boolean;
FRectx: Integer;
FRecty: Integer;
FRectWidth: Integer;
FRectHeight: Integer;
FBitmapY: Integer;
FBitmapX: Integer;
FCaption: TStringList;
FBitmapFile: string;
FBitmap: TBitmap;
FBitmapWidth: Integer;
FBitmapHeight: Integer;
FActive: Boolean;
FVisible: Boolean;
FHeight: Integer;
FWidth: Integer;
FFont: TFont;
FY: LongWord;
FX: LongWord;
FIsShowBitmap: Boolean;
FIsFillGrid: Boolean;
FlogFont: TlogFont;
FSwMode: TOsdSWMode;
FStretch: Boolean;
FInitOSD : Boolean;
function MakeBitmap(var AmStream: TMemoryStream): Boolean;
procedure ShowOSD;
function WriteToOSD(var AmStream: TMemoryStream): Boolean;
procedure WriteData(pdata: Pointer;
Size: RMuint32);
function InitDevice: Boolean;
procedure ClearOldData(x, y, AWidth, AHeight: Integer);
procedure SetCaptionPos;
procedure CalPos(var ASrcx, ASrcy, ASize, ALines, ADstx, ADsty: Integer);
function CopyFromTempData(ASrcx, ASrcy: Integer;
ASize: Integer;
ALines: Integer;
ADstx, ADsty: Integer): Boolean;
function CopyDataToOldData(APSrcData, APDstData: Pointer;
ASrcx, ASrcy: Integer;
ASize: Integer;
ALines: Integer;
ADstx, ADsty: Integer): Boolean;
procedure MakePanel;
procedure EditWordValue;
procedure OSDTimer(Sender: TObject);
function ConvertOSDFromWord(var AOutStream: TMemoryStream): Boolean;
function GetOSDDataFromStream(var ASourceStream, AOutStream: TmemoryStream): Boolean;
function CopyPaletteToOldData(AmsSrc: TMemoryStream): Boolean;
function CopyBitmapDataToOldData: Boolean;
procedure SetActive(const Value: Boolean);
procedure SetBitmap(const Value: TBitmap);
procedure SetBitmapFile(const Value: string);
procedure SetBitmapX(const Value: Integer);
procedure SetBitmapY(const Value: Integer);
procedure SetCaption(Value: TStringList);
procedure SetCaptionScrolled(const Value: Boolean);
procedure SetCaptionX(const Value: Integer);
procedure SetcaptionY(const Value: Integer);
procedure SetInterval(const Value: Cardinal);
procedure SetScrollStyle(const Value: TScrollStyle);
procedure SetHeight(const Value: Integer);
procedure SetWidth(const Value: Integer);
procedure SetFont(const Value: TFont);
procedure SetX(const Value: LongWord);
procedure SetY(const Value: LongWord);
procedure SetScrollStep(const Value: Integer);
procedure SetScrolled(const Value: Boolean);
procedure SetVisible(const Value: Boolean);
procedure SetCaptionRect(const Value: TRect);
procedure SetIsUsePanel(const Value: Boolean);
procedure SetRectHeight(const Value: Integer);
procedure SetRectWidth(const Value: Integer);
procedure SetRectx(const Value: Integer);
procedure SetRecty(const Value: Integer);
procedure SetIsShowBitmap(const Value: Boolean);
procedure SetIsFillGrid(const Value: Boolean);
public constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure InitTempData;
function Play: Boolean;
function Stop: Boolean;
property Active: Boolean read FActive write SetActive;
property Caption: TStringList read FCaption write SetCaption;
property BitmapFile: string read FBitmapFile write SetBitmapFile;
property Bitmap: TBitmap read FBitmap write SetBitmap;
property ScrollStyle: TScrollStyle read FScrollStyle write SetScrollStyle default ssRightToLeft;
property BitmapX: Integer read FBitmapX write SetBitmapX default 1;
property BitmapY: Integer read FBitmapY write SetBitmapY default 1;
property CaptionX: Integer read FCaptionX write SetCaptionX default 1;
property CaptionY: Integer read FCaptionY write SetCaptionY default 300;
property CaptionScrolled: Boolean read FCaptionScrolled write SetCaptionScrolled;
property Interval: Cardinal read FInterval write SetInterval default 1000;
property Width: Integer read FWidth write SetWidth default 640;
property Height: Integer read FHeight write SetHeight default 480;
property Font: TFont read FFont write SetFont;
property X: LongWord read FX write SetX default 0;
property Y: LongWord read FY write SetY default 0;
property Scrolled: Boolean read FScrolled write SetScrolled default False;
property ScrollStep: Integer read FScrollStep write SetScrollStep default 10;
property Visible: Boolean read FVisible write SetVisible default False;// property IsUsePanel: Boolean read FIsUsePanel write SetIsUsePanel;
property Rectx: Integer read FRectx write SetRectx;
property Recty: Integer read FRecty write SetRecty;
property RectWidth: Integer read FRectWidth write SetRectWidth;
property RectHeight: Integer read FRectHeight write SetRectHeight;// property IsShowBitmap: Boolean read FIsShowBitmap write SetIsShowBitmap;
property IsFillGrid: Boolean read FIsFillGrid write SetIsFillGrid;
property SwMode : TOsdSWMode read FSwMode write FSwMode;
property Stretch : Boolean read FStretch write FStretch;
property isInitOK : Boolean read FInitOSD;
end;
implementation{************************************ TxlOSD ************************************}constructor TxlOSD.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FWidth := 650;
FHeight := 525;
FRectx := 0;
FRecty := 0;
FRectWidth := FWidth;
FRectHeight := FHeight;
FBitmapX := 10;
FBitmapY := 20;
FCaptionX := 20;
FCaptionY := 20;
FOldCaptionX := 0;
FOldCaptionY := 200;
FX := 30;
FY := 10;
FScrollStep := 10;
FIsUsePanel := False;
FScrolled := False;
FScrollStyle:= ssTopToBottom;
FSwMode:=ssSWTextImage;
FStretch:=False;
FCaption := TStringList.Create;
FBitmap := TBitmap.Create;
FTimer := TTimer.Create(self);
FTimer.Enabled := False;
FTimer.Interval := 10;
FTimer.OnTimer := OSDTimer;//MovePanel;
FFont := TFont.Create;
FFont.Color := clBlue;
FFont.Size := 20;
FFont.Name := '幼圆';
FIsFillGrid := True;
FPlaying := False;
FVisible := False;
FFree := True;
FInitOSD:=InitDevice();
if FInitOSD=False then
begin
// MessageBox(0,'初试化OSD接口失败!!!','OSD叠加程序',MB_ICONEXCLAMATION);
end;

Play();
end;
//------------------------------------------------------------------------------destructor TxlOSD.Destroy;
begin
Stop();
if FTimer <> nil then
begin
FTimer.Enabled := False;
FTimer.Free;
end;

if FPOldData <> nil then
FreeMem(FPOldData);
if FPBakData <> nil then
FreeMem(FPBakData);
if FPTempData <> nil then
FreeMem(FPTempData);
if FFont <> nil then
FFont.Free;
if FBitmap <> nil then
FBitmap.Free;
if FCaption <> nil then
FCaption.Free;
CoUninitialize();
inherited Destroy;
end;
//------------------------------------------------------------------------------function TxlOSD.MakeBitmap(var AmStream: TMemoryStream): Boolean;var OSDBitmap: TBitmap;
Rect : TRect;
TmpBitmap: TBitmap;
MyJpeg: TJpegImage;
ExtStr : String;
begin
Result := False;
if AmStream.Size > 0 then
AmStream.Clear;
OSDBitmap := TBitmap.Create;
TmpBitmap := TBitmap.Create;
try OSDBitmap.Width := FWidth;
OSDBitmap.Height := FHeight;
OSDBitmap.PixelFormat := pf8bit;
Rect.Top:=0;
Rect.Left:=0;
Rect.Bottom:=OSDBitMap.Height ;
Rect.Right:=OSDBitMap.Width;
OSDBitmap.Canvas.Brush.Color :=clLime;
OSDBitMap.Canvas.FillRect(Rect);
if FIsShowBitmap and Fileexists(BitmapFile) then
begin
ExtStr:=Lowercase(ExtractFileExt(BitmapFile));
if not((ExtStr='.jpg')or(ExtStr='.jpeg')) then
TmpBitmap.LoadFromFile(FBitmapFile) else
begin
MyJpeg:= TJpegImage.Create;
try myjpeg.LoadFromFile(BitmapFile);
TmpBitmap.Assign(myjpeg);
finally myjpeg.Free;
end;

end;

TmpBitmap.Transparent:=True;
if FStretch=False then
OSDBitMap.Canvas.Draw(FBitmapX,FBitmapY,TmpBitmap) else
OSDBitMap.Canvas.StretchDraw(Rect,TmpBitmap);
end;

OSDBitmap.SaveToStream(AmStream);
Result := True;
finally TmpBitmap.Free;
OSDBitmap.Free;
end;

end;
//------------------------------------------------------------------------------//******************初始化********************************function TxlOSD.InitDevice: Boolean;var hr: HRESULT;
pIRmObjectFinder: IRmObjectFinder;
dwTvOutKeep: RMint32;
HwLibVersion, dwTvOut: RMint32;
begin
Result := False;
CoInitialize(nil);
hr := CoCreateInstance( CLSID_RMBASE, nil, CLSCTX_INPROC_SERVER, IID_IRmObjectFinder, pIRmObjectFinder );
if FAILED(hr) then
Exit; hr := pIRmObjectFinder.FindObject(nil, FIRST_AVALIABLE_INSTANCE, CATEGORY_PIN_OSD, IID_IRmStream, pOSD); pIRmObjectFinder := nil;
if FAILED(hr) then
Exit;
pOSD.Reset();
pDevice := nil;
hr := pOSD.QueryInterface(IID_IRmControlNode, pDevice);
if FAILED(hr) then
Exit;
hr := pOSD.QueryInterface(IID_IRmMapMem, pMemAlloc);
if FAILED(hr) then
Exit;
pDevice.GetAttributes(MpegAttrCodeVersion, HwLibVersion);
pDevice.GetAttributes(MpegAttrVideoTv, dwTvOutKeep);
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);
Result := True;
end;
//------------------------------------------------------------------------------//*****************清除上一次的滚动文字数据***************procedure TxlOSD.ClearOldData(x, y, AWidth, AHeight: Integer);var p: Pointer;
i: Integer;
begin
CopyMemory(FPData,FPBakData,FSize-HEADERLONG);
p := Ptr(DWORD(FPData) + FWidth * y + x);
for i := 0 to AHeight - 1do
begin
p := Ptr(DWORD(p) + FWidth);
FillChar(P^, AWidth , $7F);
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.OSDTimer(Sender: TObject);var pLine, ptmp: Pointer;
i, ii: Integer;
iX: Integer;
iY: Integer;
p: Pointer;
srcx,srcy,isize,lines,dstx,dsty: Integer;
begin
if (FCaption.Count < 0) or (not FScrolled) or (not FActive) then
begin
FTimer.Enabled := False;
Exit;
end;

if not FFree then
Exit;
if (FSwMode=ssSWImage) then
Exit;
FFree := False;
//if not FIsUsePanel then
ClearOldData(FOldCaptionx, FOldCaptionY, FOldCaptionWidth, FOldCaptionHeight);
//清除上一次内容 SetCaptionPos;
//改变坐标 CalPos(srcx,srcy,isize,lines,dstx,dsty);
//计算出现范围 if FIsUsePanel then
MakePanel();
//加面板条 CopyFromTempData(srcx,srcy,isize,lines,dstx,dsty);
//复制数据 if FIsUsePanel then
EditWordValue();
// WriteData(FPOldData, FSize);
//写OSD数据end;
//------------------------------------------------------------------------------function TxlOSD.Play: Boolean;var ms: TMemoryStream;
begin
Result := False;
if FPlaying then
Exit;
if pOSD <> nil then
begin
Result := FAILED(pOSD.Play);
ms := TMemoryStream.Create;
try FPlaying := True;
FActive := True;
finally ms.Free;
end;

end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetActive(const Value: Boolean);
begin
if FActive <> Value then
begin
FActive := Value;
if Value then
Play else
Stop;
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetBitmap(const Value: TBitmap);
begin
if Value <> nil then
begin
FBitmap.Assign(Value);
FBitmapFile := '';
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetBitmapFile(const Value: string);
begin
if Value <> FBitmapFile then
FBitmapFile := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetBitmapX(const Value: Integer);
begin
if FBitmapX <> Value then
FBitmapX := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetBitmapY(const Value: Integer);
begin
if FBitmapY <> Value then
FBitmapY := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetCaption(Value: TStringList);
begin
if nil <> Value then
FCaption.Assign(Value);
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetCaptionScrolled(const Value: Boolean);
begin
if FCaptionScrolled <> Value then
FCaptionScrolled := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetCaptionX(const Value: Integer);
begin
if FCaptionX <> Value then
begin
FCaptionX := Value;
FOldCaptionX := Value;
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetcaptionY(const Value: Integer);
begin
if FCaptionY <> Value then
begin
FCaptionY := Value;
FOldCaptionY := Value;
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetFont(const Value: TFont);
begin
if FFont <> nil then
begin
if Value is TFont then
FFont.Assign(Value);
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetHeight(const Value: Integer);
begin
if FHeight <> Value then
FHeight := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetInterval(const Value: Cardinal);
begin
if FInterval <> Value then
begin
FInterval := Value;
FTimer.Interval := Value;
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetScrolled(const Value: Boolean);
begin
if FScrolled <> Value then
FScrolled := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetScrollStep(const Value: Integer);
begin
if FScrollStep <> Value then
FScrollStep := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetScrollStyle(const Value: TScrollStyle);
begin
if FScrollStyle <> Value then
FScrollStyle := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetWidth(const Value: Integer);
begin
if FWidth <> Value then
FWidth := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetX(const Value: LongWord);
begin
if FX <> Value then
FX := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetY(const Value: LongWord);
begin
if FY <> Value then
FY := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.ShowOSD;var msSrc, msDest: TMemoryStream;
mslines: TMemoryStream;
begin
msSrc := TMemoryStream.Create;
msDest := TMemoryStream.Create;
mslines := TMemoryStream.Create;
try case FSwMode of ssSWImage : FIsShowBitmap:=True;
ssSWText : FIsShowBitmap:=False;
ssSWTextImage : FIsShowBitmap:=True;
end;

MakeBitmap(msSrc);
Streamrgb2x(msSrc, msDest);
if (FSwMode<>ssSWImage) and (FCaption.Count > 0) then
begin
InitTempData();
end else
FScrolled := False;
WriteToOSD(msDest);
if (FSwMode<>ssSWImage) and (FPTempData <> nil) and (not Scrolled) then
CopyFromTempData(0, 0, FOldCaptionWidth, FOldCaptionHeight, FOldCaptionX, FOldCaptionY);
WriteData(FPOldData, FSize);
finally msSrc.Free;
msDest.Free;
mslines.Free;
end;

FVisible := True;
FTimer.Enabled := FScrolled;
end;
//------------------------------------------------------------------------------function TxlOSD.Stop: Boolean;
begin
Result := False;
if not FPlaying then
Exit;
FTimer.Enabled := False;
while not FFreedo
begin
end;

FFree := False;
if pOSD <> nil then
begin
Result := FAILED(pOSD.Stop);
if pDevice <> nil then
//pDevice.SetAttributes(MpegAttrVideoTv,dwTvOutKeep) pDevice.SetAttributes(MpegAttrOsdOFF,1);
FActive := False;
FPlaying := False;
FVisible := False;
end;

end;
//------------------------------------------------------------------------------//*****************写入OSD数据到pDevice中*************************procedure TxlOSD.WriteData(pdata: Pointer;
Size: RMuint32);var hdr: HEADER;
ovr: RMOVERLAPIO;
begin
FillChar(hdr, Sizeof(hdr), 0);
hdr.multi.Count := 1;
hdr.multi.Size := SizeOf(HEADER);
hdr.header.Size := SizeOf(RMSTREAM_HEADER);
hdr.header.pData := pdata;
hdr.header.FrameExtent := Size;
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);
WaitForSingleObject(ovr.hEvent,10000);
pDevice.SetAttributes(MpegAttrOsdDest, LongInt(@rc_dest));
pDevice.SetAttributes(MpegAttrOsdON, 1);
CloseHandle(ovr.hEvent);
FFree := True;
end;
//------------------------------------------------------------------------------//************转换成OSD数据**************************function TxlOSD.WriteToOSD(var AmStream: TMemoryStream): Boolean;var phys: Pointer;
hdr: HEADER;
Buff_8: array[0..7] of Byte;
pshared: Pointer;
i,j: Integer;
b: Boolean;
p,ptmp: PBYTE;
begin
Result := False;
AmStream.Seek(0, soFrombegin
ning);
AmStream.ReadBuffer(Buff_8[0], SizeOf(Buff_8)); // 从前8个字节中算出图形大小Width, Height FSize := (buff_8[1] shl (8*2)) or (buff_8[2] shl 8) or buff_8[3];
rc_dest.X := FX;
rc_dest.Y := FY;
rc_dest.cX := (buff_8[4] shl 8) or buff_8[5];
rc_dest.cY := (buff_8[6] shl 8) or buff_8[7]; // 重新读取所有的数据 if FSize = 0 then
Exit;
AmStream.Seek(0, soFrombegin
ning);
if FPoldData <> nil then
begin
FreeMem(FPOldData);
FPOldData := nil;
end;

if FPBakData <> nil then
begin
FreeMem(FPBakData);
FPBakData := nil;
end;

Getmem(pshared, FSize);
Getmem(FPOldData, FSize);
if pshared = nil then
Exit;
AmStream.ReadBuffer(pshared^, FSize);
if FIsFillGrid then
begin
for i := 0 to FHeight - 1do
begin
p := PBYTE(DWORD(pshared) + 1032 + i * FWidth);
ptmp := p;
if Odd(i) then
for j := 0 to FWidth - 1do
begin
if Odd(j) then
ptmp^ := $7F;
ptmp := PBYTE(DWORD(p) + j);
end else
for j := 0 to FWidth - 1do
begin
if not Odd(j) then
ptmp^ := $7F;
ptmp := PBYTE(DWORD(p) + j);
end;

end;

end;

WriteData(pshared, FSize);
CopyMemory(FPOldData, pshared, FSize);
FPPalette := Pointer(DWORD(FPOldData) + 8);
FPData := Pointer(DWORD(FPOldData) + HEADERLONG);
FreeMem(pshared);
Getmem(FPBakData, FSize-HEADERLONG);
CopyMemory(FPBakData,FPData, FSize-HEADERLONG);
Result := True;
end;
//------------------------------------------------------------------------------//***************复制数据到OSD数据中****************************function TxlOSD.CopyFromTempData(ASrcx, ASrcy, ASize, ALines, ADstx, ADsty: Integer): Boolean;var pSrc, pDst: Pointer;
i, j, ii: Integer;
b: Boolean;
ptmp: PBYTE;
begin
Result := False;
pSrc := Pointer(DWORD(FPTempData) + ASrcy * FCaptionWidth + ASrcx);
pDst := Pointer(DWORD(FPOldData) + HEADERLONG + ADsty * FWidth + ADstx);
for i := 0 to ALines - 1do
begin
CopyMemory(pDst, pSrc, ASize);
pSrc := Ptr(DWORD(pSrc) + FCaptionWidth);
pDst := Ptr(DWORD(pDst) + FWidth);
end;

Result := True;
end;
//------------------------------------------------------------------------------//*************改变滚动文字的坐标*************************procedure TxlOSD.SetCaptionPos;
begin
case FScrollStyle of ssLeftToRight: begin
if FCaptionX >= FRectx + FRectWidth then
FCaptionX := FRectx - FCaptionWidth + 10 else
Inc(FCaptionX, FScrollStep);
end;

ssRightToLeft: begin
if FCaptionX <= FRectx - FCaptionWidth then
FCaptionX := FRectx + FRectWidth - 10 else
Dec(FCaptionX, FScrollStep);
end;

ssTopToBottom: begin
if FCaptionY >= FRecty + FRectHeight then
FCaptionY := FRecty - FCaptionHeight + 10 else
Inc(FCaptionY, FScrollStep);
end;

ssBottomToTop: begin
if FCaptionY <= FRecty - FCaptionHeight then
FCaptionY := FRecty + FRectHeight - 10 else
Dec(FCaptionY, FScrollStep);
end;

end;

end;
//------------------------------------------------------------------------------//************计算要复制的数据cx,cy, 坐标**************************procedure TxlOSD.CalPos(var ASrcx, ASrcy, ASize, ALines, ADstx, ADsty: Integer);
begin
if (FCaptionX >= FRectx) and (FCaptionX < FRectx + FRectWidth) then
//FCaptionX 在画中 begin
ADstx := FCaptionX;
ASrcx := 0;
if FCaptionX + FCaptionWidth >= FRectx + FRectWidth then
ASize := FRectx + FRectWidth - FCaptionX else
ASize := FCaptionWidth;
end else
begin
if (FCaptionX >= FRectx + FRectWidth) or (FCaptionX + FCaptionWidth <= FRectx) then
begin
ASize := 0;
ADstx := 0;
ADsty := 0;
ALines := 0;
end else
begin
if FCaptionWidth + FCaptionX > FRectx then
begin
ADstx := FRectx;
ASrcx := FRectx - FCaptionX;
if FCaptionWidth + FCaptionX >= FRectx + FRectWidth then
ASize := FRectWidth else
ASize := FCaptionWidth - ASrcx;
end;

end;

end;

if (FCaptionY >= FRecty) and (FCaptionY < FRecty + FRectHeight) then
//FCaptionY 在画中 begin
ADsty := FCaptionY;
ASrcy := 0;
if FCaptionY + FCaptionHeight > FRecty + FRectHeight then
ALines := FRecty + FRectHeight - FCaptionY else
ALines := FCaptionHeight;
end else
begin
//y<0 if (FCaptionY >= FRecty + FRectHeight) or (FCaptionY + FCaptionHeight <= FRecty) then
begin
ASize := 0;
ADstx := 0;
ADsty := 0;
ALines := 0;
end else
if FCaptionY + FCaptionHeight > FRecty then
begin
ADsty := FRecty;
ASrcy := FRectY - FCaptionY;
if FCaptionY + FCaptionHeight >= FRecty + FRectHeight then
ALines := FRectHeight else
ALines := FCaptionHeight - ASrcy;
end;

end;

FOldCaptionX := ADstx;
FOldCaptionY := ADsty;
FOldCaptionWidth := ASize;
FOldCaptionHeight := ALines;
end;
//------------------------------------------------------------------------------procedure TxlOSD.InitTempData;var mstmp: TMemoryStream;
begin
if FPTempData <> nil then
begin
FreeMem(FPTempData);
FPTempData := nil;
end;

mstmp := TmemoryStream.Create;
try ConvertOSDFromWord(mstmp);
GetMem(FPTempData, FCaptionWidth * FCaptionHeight);// mstmp.Seek(0, soFrombegin
ning);
mstmp.ReadBuffer(FPTempData^, FCaptionWidth * FCaptionHeight);
finally mstmp.Free;
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetVisible(const Value: Boolean);var p: Pointer;
begin
if FInitOSD=False then
Exit;
if FVisible <> Value then
begin
while not FFreedo
begin
end;

FFree := False;
if Value then
begin
ShowOSD();
end else
begin
FTimer.Enabled := False;
p := Ptr(DWORD(FPOldData) + HEADERLONG);
FillChar(p^, FWidth * FHeight, $7F);
end;

FVisible := Value;
WriteData(FPOldData, FSize);
end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetCaptionRect(const Value: TRect);
begin
// FCaptionRect := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetIsUsePanel(const Value: Boolean);
begin
if Value <> FIsUsePanel then
FIsUsePanel := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.MakePanel;var i, j: Integer;
p ,p1, p2: PBYTE;
begin
if not FScrolled then
Exit;
if (FScrollStyle = ssLeftToRight) or (FScrollStyle = ssRightToLeft) then
begin
p := PBYTE(DWORD(FPData) + FOldCaptionY * FWidth);
for i := 0 to FOldCaptionHeight - 1do
begin
p1 := PBYTE(DWORD(p1) + FWidth);
p2 := p1;
if Odd(i) then
begin
for j := 0 to FWidth - 1do
begin
if Odd(j) then
p2^ := c_PANELVALUE;
p2 := PBYTE(DWORD(p2) + 1);
end;

end else
begin
for j := 0 to FWidth - 1do
begin
if not Odd(j) then
p2^ := c_PANELVALUE;
p2 := PBYTE(DWORD(p2) + 1);
end;

end;

end;

end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.EditWordValue;var i, j: Integer;
p ,p1, p2: PBYTE;
begin
if not FScrolled then
Exit;
if (FScrollStyle = ssLeftToRight) or (FScrollStyle = ssRightToLeft) then
begin
p := PBYTE(DWORD(FPOldData) + HEADERLONG + FOldCaptionY * FWidth + FOldCaptionX);
for i := 0 to FOldCaptionHeight - 1do
begin
p1 := PBYTE(DWORD(p) + i * FWidth);
p2 := p1;
if Odd(i) then
begin
for j := 0 to FOldCaptionWidth - 1do
begin
if Odd(j) then
if p2^ = $7F then
p2^ := c_PANELVALUE;
p2 := PBYTE(DWORD(p2) + 1);
end;

end else
begin
for j := 0 to FOldCaptionWidth - 1do
begin
if not Odd(j) then
if p2^ = $7F then
p2^ := c_PANELVALUE;
p2 := PBYTE(DWORD(p2) + 1);
end;

end;

end;

end;

end;
//------------------------------------------------------------------------------procedure TxlOSD.SetRectHeight(const Value: Integer);
begin
if Value <> FRectHeight then
FRectHeight := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetRectWidth(const Value: Integer);
begin
if Value <> FRectWidth then
FRectWidth := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetRectx(const Value: Integer);
begin
if Value <> FRectx then
FRectx := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetRecty(const Value: Integer);
begin
if Value <> FRecty then
FRecty := Value;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetIsShowBitmap(const Value: Boolean);
begin
if FIsShowBitmap <> Value then
FIsShowBitmap := Value;
end;
//------------------------------------------------------------------------------function TxlOSD.GetOSDDataFromStream(var ASourceStream, AOutStream: TmemoryStream): Boolean;var bmfh: BITMAPFILEHEADER; bmih: BITMAPINFOHEADER;
pb,pData, pSrc, pDst, pTemp: PBYTE;
i: Integer;
align: Integer;
xx: array[0..3] of Byte;
begin
Result := False;
ASourceStream.Seek(0, soFrombegin
ning);
if AOutStream.Size > 0 then
AOutStream.Clear;
ASourceStream.ReadBuffer(bmfh, SizeOf(bmfh));
ASourceStream.ReadBuffer(bmih, Sizeof(bmih));
if bmih.biBitCount<>8 then
bmih.biBitCount := 7;
Getmem(pData, bmih.biWidth * bmih.biHeight);
Getmem(pTemp, bmih.biWidth * bmih.biHeight);
ASourceStream.ReadBuffer(pData^, bmih.biClrUsed * 4);
pb := pData;
align := bmih.biWidth mod 4;
for i := 0 to bmih.biHeight - 1do
begin
ASourceStream.ReadBuffer(pb^, bmih.biWidth);
pb := PBYTE(DWORD(pb) + bmih.biWidth);
ASourceStream.Read(xx[0], align);
end;

FCaptionWidth := bmih.biWidth;
FCaptionHeight := bmih.biHeight;
FOldCaptionWidth := bmih.biWidth;
FOldCaptionHeight := bmih.biHeight;
pb := pData;
for i := 0 to bmih.biWidth * bmih.biHeight - 1do
begin
pb^ := pb^ and $7F;
pb := PBYTE(DWORD(pb) + 1);
end;

pSrc := PBYTE(DWORD(pData) + bmih.biWidth * bmih.biHeight);
pDst := pTemp;
for i := 0 to bmih.biHeight - 1do
begin
pSrc :=PBYTE(DWORD(pSrc) - bmih.biWidth);
CopyMemory(pdst, psrc, bmih.biWidth); pDst := PBYTE(DWORD(pDst) + bmih.biWidth);
end;

CopyMemory(pData, pTemp, bmih.biWidth * bmih.biHeight);
AOutStream.WriteBuffer(pData^, bmih.biWidth * bmih.biHeight);
FreeMem(pData);
FreeMem(pTemp);
Result := True;
end;
//------------------------------------------------------------------------------//返回OSD可识别的数据流function TxlOSD.ConvertOSDFromWord(var AOutStream: TMemoryStream): Boolean;var stmp: TMemoryStream;
bitmaptmp: TBitmap;
i, j, fIndex: Integer;
m,n: Integer;
begin
Result := False;
if AOutStream.Size > 0 then
AOutStream.Clear;
bitmaptmp := TBitmap.Create;
stmp := TMemoryStream.Create;
try bitmaptmp.PixelFormat := pf8bit;
bitmaptmp.Canvas.Font := FFont;
m := 0;
n := 0;
fIndex := 0;
for i := 0 to FCaption.Count - 1do
begin
n := Length(FCaption.Strings);
if n > m then
begin
m := n;
fIndex := i;
end;

end;

bitmaptmp.Width := bitmaptmp.Canvas.TextWidth(FCaption.Strings[fIndex]);
bitmaptmp.Height := bitmaptmp.Canvas.TextHeight(FCaption.Strings[0]) * FCaption.Count;
j := bitmaptmp.Canvas.TextHeight(FCaption.Strings[0]);
for i := 0 to FCaption.Count - 1do
begin
bitmaptmp.Canvas.TextOut(0, i * j , FCaption.Strings);
end;

bitmaptmp.SaveToStream(stmp);// MakeMoreLinesWords(FCaption.Strings[0], 400, FFont, stmp);
GetOSDDataFromStream(stmp, AOutStream);
finally bitmaptmp.Free;
stmp.Free;
end;

Result := True;
end;
//------------------------------------------------------------------------------procedure TxlOSD.SetIsFillGrid(const Value: Boolean);
begin
if Value <> FIsFillGrid then
FIsFillGrid := Value;
end;
//------------------------------------------------------------------------------function TxlOSD.CopyDataToOldData(APSrcData, APDstData: Pointer;
ASrcx, ASrcy, ASize, ALines, ADstx, ADsty: Integer): Boolean;
begin
//图形模拟动画 只变源x坐标,将其一帧的数据复制到FPOldData中去end;
//------------------------------------------------------------------------------function TxlOSD.CopyPaletteToOldData(AmsSrc: TMemoryStream): Boolean;
begin
Result := False;
if AmsSrc.Size <= 0 then
Exit;
AmsSrc.Seek(0, soFrombegin
ning);
if (FPPalette <> nil) and (AmsSrc.Size >= 1024) then
begin
AmsSrc.ReadBuffer(FPPalette^, 1024);
Result := True;
end;

end;
//------------------------------------------------------------------------------function TxlOSD.CopyBitmapDataToOldData: Boolean;var tmpBitmap: TBitmap;
tmpStream: TMemoryStream;
PaletteStream: TMemoryStream;
tmpmsOsd: TMemoryStream;
cx,cy: Integer;
pSrc, p1, p2: Pointer;
pbd: PBYTE;
i, j: Integer;
begin
Result := False;
if FBitmapFile = '' then
Exit;
if not FileExists(FBitmapFile) then
Exit;
tmpBitmap := TBitmap.Create;
tmpStream := TMemoryStream.Create;
PaletteStream := TMemoryStream.Create;
tmpmsOSD := TMemoryStream.Create;
try tmpBitmap.LoadFromFile(FBitmapFile);
tmpBitmap.SaveToStream(tmpStream);
if GetPaletteFromBitmap(tmpStream, PaletteStream) then
begin
CopyPaletteToOldData(PaletteStream);
GetOSDDataFromStream(tmpStream, tmpmsOsd);
if tmpBitmap.Width + FBitmapX > FWidth then
cx := FWidth - FBitmapX else
cx := tmpBitmap.Width;
if tmpBitmap.Height + FBitmapY > FHeight then
cy := FHeight - FBitmapY else
cy := tmpBitmap.Height;
FBitmapWidth := cx;
FBitmapHeight := cy;
GetMem(pSrc, tmpBitmap.Width * tmpBitmap.Height);
tmpmsOsd.Seek(0, soFrombegin
ning);
tmpmsOsd.ReadBuffer(pSrc^, tmpBitmap.Width * tmpBitmap.Height);
p1 := pSrc;
p2 := Ptr(DWORD(FPData) + FBitmapY * FWidth + FBitmapX);
for i := 0 to cy - 1do
begin
CopyMemory(p2, p1, cx);
pbd := PBYTE(DWORD(p2));
if FIsFillGrid then
begin
if Odd(i) then
begin
for j := 0 to cx - 1do
begin
if Odd(j) then
pbd^ := $7F;
pbd := PBYTE(DWORD(pbd) + 1);
end;

end else
begin
for j := 0 to cx - 1do
begin
if not Odd(j) then
pbd^ := $7F;
pbd := PBYTE(DWORD(pbd) + 1);
end;

end;

end;

p1 := Ptr(DWORD(p1) + tmpBitmap.Width);
p2 := Ptr(DWORD(p2) + FWidth);
end;

FreeMem(pSrc);
end;

finally tmpBitmap.Free;
tmpStream.Free;
PaletteStream.Free;
tmpmsOSD.Free;
end;

Result := True;
end;
//------------------------------------------------------------------------------end.
 
unit UnitRmOSD;interfaceuses{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:do
uble );
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 settype 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 codesconst FACILITY_MPEG_STATUS = $106;// Define the severity codesconst 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 computerconst 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 flagsconst BROADCASTED_VIDEO = $0200;const DVD_VIDEO = $0000;const FORCED_PROGRESSIVE_OFF = $0100; // display progressive or interlaced like in the video streamconst FORCED_PROGRESSIVE_ON = $0000; // display only progressive if the stream switches very fast from interlaced to progressiveconst PROGRESSIVE_ALWAYS = $0080;const PROGRESSIVE_MOVIES = $0000;const FRAME_DROP = $0040;const FIELD_DROP = $0000;const VGA_INTERLACED = $0002;const VGA_PROGRESSIVE = $0000;// MpegAttrHardwareInfo1 flagsconst DARK_COLOR_LETTERBOX = $0001; // hwDecoder is Quasar1 - letterbox bugconst VGA_CABLE_NOT_CONNECTED = $0002; // VGA cable is not connected for analog overlay boards// MpegAttrOverlayFlagsconst 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;// MpegAttrPlayOptionstype 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 flagsconst 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 flagsconst 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;// MpegAttrAudioFormatconst 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 insteadconst AUDIO_FORMAT_REVERSE_PCM = 7;const AUDIO_FORMAT_AAC = 8;// MpegAttrAudioOutputconst AUDIO_OUTPUT_STEREO = 0;const AUDIO_OUTPUT_AC3DTS = 1;// flags used to enable/disable the hardware audio outputsconst 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.hconst AUDIO_MODE_STEREO = 0;const AUDIO_MODE_RIGHT_ONLY = 1;const AUDIO_MODE_LEFT_ONLY = 2;const AUDIO_MODE_MONOMIX = 3;// MpegAttrVideoAspectRatioconst VIDEO_ASPECT_RATIO_16_9 = 3;const VIDEO_ASPECT_RATIO_4_3 = 2;// MpegAttrVideoOutputModeconst 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;// MpegAttrVideoTvconst COMPONENT_MASK = $02C0; // old was 0x00C0const 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 playingconst TV_DACS_DISABLE = $0100; // force TvDacs disabledconst 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 TVconst 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 typeconst MPEG_ATTRIBUTE_VIDEO_GEN_LOCK_TV = 0;const MPEG_ATTRIBUTE_VIDEO_GEN_LOCK_VTR = 1;// MpegAttrVideoSignalType typeconst MPEG_ATTRIBUTE_VIDEO_SIGNAL_COMPOSITE = 0;const MPEG_ATTRIBUTE_VIDEO_SIGNAL_SVHS = 1;// MpegAttrAudioChannel Mpeg channel// auxiliary channels are mini-port specificconst MPEG_ATTRIBUTE_AUDIO_CHANNEL_MPEG = 0;// MpegAttrVideoChannel Mpeg channel// auxiliary channels are mini-port specificconst 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 adjustedconst MPEG_CAPABILITY_BSC_ADJUST = $00000004;// The analog overlay supports auto-calibrationconst MPEG_CAPABILITY_AUTO_CALIBRATE = $00000008;// Mpeg4 capabilityconst MPEG_CAPABILITY_MPEG4_DECODE = $00000010;// Gamma correction can be adjustedconst MPEG_CAPABILITY_GAMMA_ADJUST = $00000020;// ????????const MPEG_CAPABILITY_HIRES = $00000040;// ????????const MPEG_CAPABILITY_USES_VPM = $00000080;// The hardware can play DVD titlesconst 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 hardwareconst 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 Forwardconst 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// capabilitydo
es 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 timeconst 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 boardconst 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//do
uble conversion)const MPEG_CAPABILITY_NTSC_ONLY = $01000000;// Indicates that hardware only supports NTSC (Only used for IGS to prevent//do
uble conversion)const MPEG_CAPABILITY_PAL_ONLY = $02000000;// Indicates that hardware supports Tv Component YUVconst MPEG_CAPABILITY_TV_YUV_COMPONENT = $04000000;// Indicates that hardware can play in the same time PCM data// through Dac and Spdifconst MPEG_CAPABILITY_DAC_SPDIF = $08000000;// Indicates that hardware has a 480P connector to display fullscreen on// another Vga monitor - Ventura2000const MPEG_CAPABILITY_480P = $10000000;// Indicates that hardware supports Tv Component RGBconst MPEG_CAPABILITY_TV_RGB_COMPONENT = $20000000;// Indicates that hardware has DVI outputconst MPEG_CAPABILITY_DVI = $40000000;// Indicates that hardware has the audio clock controlled by VCXOconst 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 // pleasedo
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 mmmidldo
esn'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 indo
coder 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_DEFINEDtype 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 begin
Flush: 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 begin
ning if size = 0 then
goto exit_20 else
begin
// pos := 0; // Seek(f, Pos);
fs.Seek(0, soFrombegin
ning); 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 19do
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 bitmapdo
wn // 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.
 
unit UnitOSDFunctions;interfaceuses Windows, SysUtils, Classes, Graphics,Dialogs;type rgb2xFlag = (rfUseRLE, rf2Output, rf2RLE, rf7Output, rf7RLE);
//默认为rf7Output 输入为8位procedure bmp8_reverse(pRgb: PBYTE;
width, height: Integer);procedure bmp4_reverse(pRgb: PBYTE;
width, height: Integer);// rgb 2 yuv:// Y = 0.257r + 0.504g + 0.098b + 16// Cb = -0.148r - 0.291g + 0.439b + 128// Cr = 0.439r + 0.368g + 0.071b + 128function rgb2y(r, g, b: Byte): Byte;//------------------------function rgb2u(r, g, b: Byte): Byte;function rgb2v(r, g, b: Byte): Byte;procedure rgb24_yuv420(w, h: Integer;
pRgb, pYuv: PBYTE);// converts paletteprocedure rgb24_yuv444 (n: Integer;
pRgb, pYuv: PBYTE);procedure ConvertTo7bit(var fsSrc: TMemoryStream;
outfsDst: TMemoryStream;
var bmih: BITMAPINFOHEADER);procedure ConvertTo8bit(var fsSrc: TMemoryStream;
outfsDst: TMemoryStream;
var bmih: BITMAPINFOHEADER);function GetPaletteFromBitmap(AmsSrc: TMemoryStream;
var AmsOut: TMemoryStream): Boolean;function MakeMoreLinesWords(const ACaption: string;
AWidth: Integer;
AFont: TFont;
var AOutStream: TMemoryStream): Boolean;function Streamrgb2x(var AmStreamSrc: TMemoryStream;
var AmStreamDest: TMemoryStream): Boolean;implementationfunction Streamrgb2x(var AmStreamSrc: TMemoryStream;
var AmStreamDest: TMemoryStream): Boolean;var bmfh: BITMAPFILEHEADER; bmih: BITMAPINFOHEADER;
begin
if AmStreamDest.Size > 0 then
AmStreamDest.Clear;
Result := False;
AmStreamSrc.Seek(0, soFrombegin
ning);
AmStreamSrc.ReadBuffer(bmfh, SizeOf(bmfh));
AmStreamSrc.ReadBuffer(bmih, sizeof(bmih));// Showmessage(Format('%d',[bmih.biBitCount]));// bmih.biBitCount := 7;
if bmih.biBitCount = 8 then
ConvertTo8bit(AmStreamSrc, AmStreamDest, bmih) else
begin
bmih.biBitCount := 7;
ConvertTo7bit(AmStreamSrc, AmStreamDest, bmih);
end;

Result := True;
end;
//------------------------------------------------------------------------------//function MakeMoreLinesWords(const ACaption: string;
AWidth: Integer;
AFont: TFont;
var AOutStream: TMemoryStream): Boolean;var srcstr, substr: string;
sl: TStringList;
i, y,j, Len, AllLen, LineHeight, CurrentPos: Integer;
bmTemp: TBitmap;
begin
if AOutStream.Size > 0 then
AOUtStream.Clear;
srcStr := ACaption;
AllLen := Length(srcStr);
bmTemp := TBitmap.Create;
sl := TStringList.Create;
try bmTemp.PixelFormat := pf8bit;
bmTemp.Width := AWidth;
bmtemp.Canvas.Font := AFont;
if bmTemp.Canvas.TextWidth(srcStr) > AWidth then
Len := AWidth div (bmTemp.Canvas.TextWidth(srcStr) div AllLen) else
Len := AllLen;
LineHeight := bmTemp.Canvas.TextHeight(srcStr);
CurrentPos := 0;
//bmTemp.Height := 0;
y := 0;
while Truedo
begin
//bmTemp.Height := bmTemp.Height + LineHeight;
subStr := Copy(srcStr, CurrentPos, Len);
Inc(CurrentPos, Len);
while bmTemp.Canvas.TextWidth(subStr) > AWidthdo
begin
SetLength(subStr, Length(subStr) - 1);
Dec(CurrentPos);
if Ord(subStr[Length(subStr)]) > 128 then
begin
SetLength(subStr, Length(subStr) - 1);
Dec(CurrentPos);
end;

end;

sl.Add(subStr);
subStr := Copy(srcStr, CurrentPos, Len);
if subStr = '' then
Break;
end;

bmTemp.Height := sl.Count * LineHeight;
for i := 0 to sl.Count - 1do
begin
bmTemp.Canvas.TextOut(0, i * LineHeight, sl.Strings);
end;

bmTemp.SaveToStream(AOutStream);
finally bmTemp.Free;
sl.Free;
end;

end;
//------------------------------------------------------------------------------//从位图中取得调色板function GetPaletteFromBitmap(AmsSrc: TMemoryStream;
var AmsOut: TMemoryStream): Boolean;var PalEntries: LongWord;
bmfh: BITMAPFILEHEADER; bmih: BITMAPINFOHEADER;
pPalRgb, pPalYuv: PBYTE;
begin
Result := False;
if AmsSrc.Size <= 0 then
Exit;
if AmsOut.Size > 0 then
AmsOut.Clear;
AmsSrc.Seek(0, soFrombegin
ning);
AmsSrc.ReadBuffer(bmfh, SizeOf(bmfh));
AmsSrc.ReadBuffer(bmih, sizeof(bmih));
if not ((bmih.biBitCount = 7) or (bmih.biBitCount = 8)) then
Exit;
if bmih.biBitCount<>8 then
bmih.biBitCount := 7;
if bmih.biClrUsed >= 1 then
PalEntries := bmih.biClrUsed else
PalEntries := 256;
GetMem(pPalRgb, PalEntries * 4);
GetMem(pPalYuv, 256 * 4);
AmsSrc.ReadBuffer(pPalRgb^, PalEntries * 4);
rgb24_yuv444 (PalEntries, pPalRgb, pPalYuv);
AmsOut.WriteBuffer(pPalYuv^, 256 * 4);
FreeMem(pPalRgb);
FreeMem(pPalYuv);
Result := True;
end;
//------------------------------------------------------------------------------//不知哪位高手是有OSDShell.ax的一些接口信息没有?//<RMGMODULE Name="OSD" GUID="{00140BB8-D735-46BE-A997-B382486DCC04}">//- <RMGINTERFACE Name="OSD_PANEL" ClassID="OSDPanel" InterfaceID="IOSDPanel" Permanent="yes" LoadOnce="yes" TempDirectory="WorkingDirectory">//- <RMGINTERFACE Name="OSD_PAGE" ClassID="OSDPage" InterfaceID="IOSDPage" Permanent="no" TempDirectory="WorkingDirectory">// <RMGINTERFACE Name="OSD_BITMAP" ClassID="OSDBitmap" InterfaceID="IOSDBitmap" Permanent="no" TempDirectory="WorkingDirectory" />// <RMGINTERFACE Name="OSD_TEXT" ClassID="OSDText" InterfaceID="IOSDText" Permanent="no" TempDirectory="WorkingDirectory" />//- <RMGINTERFACE Name="OSD_PROGRESS" ClassID="OSDProgress" InterfaceID="IOSDProgress" Permanent}//******************支持256色************************************procedure ConvertTo7bit(var fsSrc: TMemoryStream;
outfsDst: TMemoryStream;
var bmih: BITMAPINFOHEADER);var n: Integer;
p, pPalRgb, pPalYuv, pRgb, pRgb2, pYuv, pb: PBYTE;
ii: Integer;
PalEntries: LongWord;
b: Byte;
size: LongWord;
ll: Integer;
align : Integer;
xx: array[0..3] of Char;
sl: TStringList;
subs: string;
begin
if bmih.biClrUsed >= 1 then
PalEntries := bmih.biClrUsed else
PalEntries := 256; // convert to quasar 8 bit osd format and write to a file GetMem(pPalRgb, PalEntries * 4); GetMem(pPalYuv, 256 * 4); GetMem(pRgb, bmih.biWidth * bmih.biHeight); GetMem(pRgb2, bmih.biWidth * bmih.biHeight); // read the palette fsSrc.ReadBuffer(pPalRgb^, PalEntries * 4); p := pRgb; align := bmih.biWidth mod 4; for ii := 0 to bmih.biHeight - 1do
begin
fsSrc.ReadBuffer(p^, bmih.biWidth); p := PBYTE(DWORD(p) + bmih.biWidth);
fsSrc.Read(xx[0], align); end;
// read the bitmap data // convert the palette rgb24_yuv444 (PalEntries, pPalRgb, pPalYuv); // write osd file // write header //if(!rle) b := $3c; //else
b = 0x3d; outfsDst.WriteBuffer(b, 1); // write size size := (bmih.biWidth * bmih.biHeight) + 1024 + 8; b := BYTE(size shr 16);
outfsDst.WriteBuffer(b, 1); b := BYTE(size shr 8); outfsDst.WriteBuffer(b, 1); b := BYTE(size shr 0); outfsDst.WriteBuffer(b, 1); // write width b := BYTE(bmih.biWidth shr 8); outfsDst.WriteBuffer(b, 1); b := BYTE(bmih.biWidth shr 0); outfsDst.WriteBuffer(b, 1); // write height b := BYTE(bmih.biHeight shr 8); outfsDst.WriteBuffer(b, 1); b := BYTE(bmih.biHeight shr 0); outfsDst.WriteBuffer(b, 1); // write palette outfsDst.WriteBuffer(pPalYuv^, 256 * 4); // write the data // for 7bit make kill the most significant bit // fsSrc.Seek(576, soFrombegin
ning);
// fsSrc.Read(pRgb^, 20000);
pb := pRgb; for ii := 0 to bmih.biWidth * bmih.biHeight - 1do
begin
pb^ := pb^ and $7f; pb := PBYTE(DWORD(pb) + 1); end;

bmp8_reverse(pRgb, bmih.biWidth, bmih.biHeight); // reverse the data (bmp is stored upside-down) outfsDst.WriteBuffer(pRgb^, bmih.biWidth * bmih.biHeight); freeMem(pPalRgb); FreeMem(pPalYuv); FreeMem(pRgb);
end;
//******************支持256色************************************procedure ConvertTo8bit(var fsSrc: TMemoryStream;
outfsDst: TMemoryStream;
var bmih: BITMAPINFOHEADER);var n: Integer;
p, pPalRgb, pPalYuv, pRgb, pRgb2, pYuv, pb: PBYTE;
ii: Integer;
PalEntries: LongWord;
b: Byte;
size: LongWord;
ll: Integer;
align : Integer;
xx: array[0..3] of Char;
sl: TStringList;
subs: string;
begin
if bmih.biClrUsed >= 1 then
PalEntries := bmih.biClrUsed else
PalEntries := 256;
// convert to quasar 8 bit osd format and write to a file GetMem(pPalRgb, PalEntries * 4);
GetMem(pPalYuv, 256 * 4);
GetMem(pRgb, bmih.biWidth * bmih.biHeight);
GetMem(pRgb2, bmih.biWidth * bmih.biHeight);
// read the palette fsSrc.ReadBuffer(pPalRgb^, PalEntries * 4);
p := pRgb;
align := bmih.biWidth mod 4;
for ii := 0 to bmih.biHeight - 1do
begin
fsSrc.ReadBuffer(p^, bmih.biWidth);
p := PBYTE(DWORD(p) + bmih.biWidth);
fsSrc.ReadBuffer(xx[0], align);
// fsSrc.Read(xx[0], align);
end;

// read the bitmap data // convert the palette rgb24_yuv444 (PalEntries, pPalRgb, pPalYuv);
// write osd file // write header b := $3E;
outfsDst.WriteBuffer(b, 1);
// write size size := (bmih.biWidth * bmih.biHeight) + 1024 + 8;
b := BYTE(size shr 16);
outfsDst.WriteBuffer(b, 1);
b := BYTE(size shr 8);
outfsDst.WriteBuffer(b, 1);
b := BYTE(size shr 0);
outfsDst.WriteBuffer(b, 1);
// write width b := BYTE(bmih.biWidth shr 8);
outfsDst.WriteBuffer(b, 1);
b := BYTE(bmih.biWidth shr 0);
outfsDst.WriteBuffer(b, 1);
// write height b := BYTE(bmih.biHeight shr 8);
outfsDst.WriteBuffer(b, 1);
b := BYTE(bmih.biHeight shr 0);
outfsDst.WriteBuffer(b, 1);
// write palette outfsDst.WriteBuffer(pPalYuv^, 256 * 4);
bmp8_reverse(pRgb, bmih.biWidth, bmih.biHeight); // reverse the data (bmp is stored upside-down) outfsDst.WriteBuffer(pRgb^, bmih.biWidth * bmih.biHeight);
freeMem(pPalRgb);
FreeMem(pPalYuv);
FreeMem(pRgb);
end;
//------------------------------------------------------------------------------procedure rgb24_yuv444 (n: Integer;
pRgb, pYuv: PBYTE);var i: Integer;
r, g, b, y, u, v, a: PBYTE;
begin
r := PBYTE(DWORD(pRgb) + 2); g := PBYTE(DWORD(pRgb) + 1); b := PBYTE(DWORD(pRgb) + 0); y := PBYTE(DWORD(pYuv) + 1); u := PBYTE(DWORD(pYuv) + 2); v := PBYTE(DWORD(pYuv) + 3); a := PBYTE(DWORD(pYuv) + 0); for i := 0 to n - 1do
begin
y^ := rgb2y(r^, g^, b^); u^ := rgb2u(r^, g^, b^); v^ := rgb2v(r^, g^, b^); if (i = $7F ) or ( i = $FA) then
a^ := 0 else
a^ := $FF;
if (i = $FC) then
a^ := $7f;
r := PBYTE(DWORD(r) + 4); g := PBYTE(DWORD(g) + 4); b := PBYTE(DWORD(b) + 4); y := PBYTE(DWORD(y) + 4); u := PBYTE(DWORD(u) + 4); v := PBYTE(DWORD(v) + 4); a := PBYTE(DWORD(a) + 4); end;

end;
//------------------------------------------------------------------------------procedure bmp8_reverse(pRgb: PBYTE;
width, height: Integer);var pTemp, pDst, pSrc: PBYTE;
bytes_in_line: ULONG;
i: Integer;
begin
GetMem(pTemp, (width * height)); pDst := pTemp; pSrc := PBYTE(DWORD(pRgb) + (width * height)); bytes_in_line := width; if (pDst = nil) then
Exit; for i := 0 to height - 1do
begin
pSrc := PBYTE(DWORD(pSrc) - bytes_in_line);
// CopyMemory(pdst, psrc, bytes_in_line);
StrMove(Pointer(Pdst), Pointer(pSrc), bytes_in_line); pDst := PBYTE(DWORD(pDst) + bytes_in_line);
end;
StrMove(Pointer(pRgb), Pointer(pTemp), width * height);
FreeMem(pTemp);
end;
//------------------------------------------------------------------------------procedure bmp4_reverse(pRgb: PBYTE;
width, height: Integer);var bytes_in_line: ULONG;
num: Integer;
pTemp, pSrc, pDst: PBYTE;
i: Integer;
begin
//BYTE *pTemp = (BYTE *)malloc (width * height); num := (width * height) div 2; if Odd(width * height) then
Inc(num);
GetMem(pTemp, num); pSrc := PBYTE(DWORD(pRgb) + num); pDst := pTemp; bytes_in_line := width div 2; if Odd(width) then
Inc(bytes_in_line); if (pDst = nil) then
Exit; for i := 0 to height - 1do
begin
pSrc := PBYTE(DWORD(pSrc) - bytes_in_line); Move(pSrc, pDst, bytes_in_line); pDst := PBYTE(DWORD(pDst) + bytes_in_line);
end;
Move(pTemp, pRgb, num);
FreeMem(pTemp);
end;
//------------------------------------------------------------------------------function rgb2y(r, g, b: Byte): Byte;var f:do
uble;
begin
f := 0.257*r + 0.504*g + 0.098*b + 16.0; if f > 255.0 then
f := 255.0; Result := BYTE(Trunc(f));
end;
//------------------------------------------------------------------------------function rgb2u(r, g, b: Byte): Byte;var f:do
uble;
begin
f := -0.148*r - 0.291*g + 0.439*b + 128; if f > 255.0 then
f := 255.0;
if f < 0.0 then
f := 0.0; Result := BYTE(Trunc(f));
end;
//------------------------------------------------------------------------------function rgb2v(r, g, b: Byte): Byte;var f:do
uble;
begin
f := 0.439*r - 0.368*g - 0.071*b + 128; if f > 255.0 then
f := 255.0;
if f < 0.0 then
f := 0.0; Result := BYTE(Trunc(f));
end;
//------------------------------------------------------------------------------procedure rgb24_yuv420(w, h: Integer;
pRgb, pYuv: PBYTE);var rgb, y, uv: PBYTE;
u0, u1, u2, u3: BYTE;
v0, v1, v2, v3: BYTE;
i, j, k: Integer;
begin
rgb := PBYTE(DWORD(pRgb) + (w*(h-1)*3)); y := pYuv; uv := PBYTE(DWORD(pYuv) + (w*h));
i := 0;
j := 0;
k := 0; for j := 0 to h - 1do
begin
for k := 0 to w - 1do
begin
PBYTE(DWORD(y) + i)^ := rgb2y(PBYTE(DWORD(rgb) + 2)^, PBYTE(DWORD(rgb) + 1)^, rgb^);
Inc(i); if (((j and 1) = 0) and ((k and 1) = 0)) then
begin
// average the uv values // [2][3] // [0][1] u0 := rgb2u (PBYTE(DWORD(rgb) + 2)^, PBYTE(DWORD(rgb) + 1)^, rgb^); v0 := rgb2v (PBYTE(DWORD(rgb) + 2)^, PBYTE(DWORD(rgb) + 1)^, rgb^); u1 := rgb2u (PBYTE(DWORD(rgb) + 5)^, PBYTE(DWORD(rgb) + 4)^, PBYTE(DWORD(rgb) + 3)^); v1 := rgb2v (PBYTE(DWORD(rgb) + 5)^, PBYTE(DWORD(rgb) + 4)^, PBYTE(DWORD(rgb) + 3)^); u2 := rgb2u (PBYTE(DWORD(rgb) + 2 - w*3)^, PBYTE(DWORD(rgb) + 1 - w*3)^, PBYTE(DWORD(rgb) + 0 - w*3)^); v2 := rgb2v (PBYTE(DWORD(rgb) + 2 - w*3)^, PBYTE(DWORD(rgb) + 1 - w*3)^, PBYTE(DWORD(rgb) + 0 - w*3)^); u3 := rgb2u (PBYTE(DWORD(rgb) + 5 - w*3)^, PBYTE(DWORD(rgb) + 4 - w*3)^, PBYTE(DWORD(rgb) + 3 - w*3)^); v3 := rgb2v (PBYTE(DWORD(rgb) + 5 - w*3)^, PBYTE(DWORD(rgb) + 4 - w*3)^, PBYTE(DWORD(rgb) + 3 - w*3)^); uv^ := BYTE((ULONG(u0) + ULONG(u1) + ULONG(u2) + ULONG(u3) div ULONG(4)));
uv := PBYTE(DWORD(uv) + 1); uv^ := BYTE((ULONG(v0) + ULONG(v1) + ULONG(v2) + ULONG(v3) div ULONG(4)));
uv := PBYTE(DWORD(uv) + 1); end;
rgb := PBYTE(DWORD(rgb) + 3); end;
rgb := PBYTE(DWORD(rgb) - w*3*2);//rgb -= (w*3*2);
end;

end;
//------------------------------------------------------------------------------end.
 
library Osd;uses SysUtils, Classes, OsdUnit in 'OsdUnit.pas';exports InitRmOSD, FreeRmOSD, ShowRmOSD, SetImageRmOSD, SetTextRmOSD, SetParamRmOSD, SetRegSn;
begin
end.
 
支持图片和文字unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls;type TDemoForm = class(TForm) Memo1: TMemo;
Label1: TLabel;
EditFileName: TEdit;
SpeedButton1: TSpeedButton;
Label2: TLabel;
ComboboxScrollMode: TComboBox;
btnImage: TButton;
btnText: TButton;
btnHide: TButton;
btnTxtImg: TButton;
EditSize: TEdit;
UdFontSize: TUpDown;
Label10: TLabel;
Label3: TLabel;
ColorBox1: TColorBox;
CheckBoxStretch: TCheckBox;
GroupBox2: TGroupBox;
Label4: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit9: TEdit;
UdOsdX: TUpDown;
Edit10: TEdit;
UdOsdY: TUpDown;
Edit11: TEdit;
UdOsdW: TUpDown;
Edit12: TEdit;
UdOsdH: TUpDown;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
Label14: TLabel;
Label15: TLabel;
Edit13: TEdit;
UdBitmapx: TUpDown;
Edit14: TEdit;
UdBitmapy: TUpDown;
Label5: TLabel;
Edit1: TEdit;
UpDownTxtX: TUpDown;
Label6: TLabel;
Edit2: TEdit;
UpDownTxtY: TUpDown;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
procedure btnTextClick(Sender: TObject);
procedure btnImageClick(Sender: TObject);
procedure btnTxtImgClick(Sender: TObject);
procedure btnHideClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure CheckBoxStretchClick(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var DemoForm: TDemoForm;function InitRmOSD():integer;
stdcall;
external 'OSD.DLL' name 'InitRmOSD';function FreeRmOSD():integer;
stdcall;external'OSD.DLL' name 'FreeRmOSD';function SetParamRmOSD(X,Y,W,H : integer):integer;
stdcall;external'OSD.DLL' name 'SetParamRmOSD';function ShowRmOSD(SwMode:integer):integer;
stdcall;external'OSD.DLL' name 'ShowRmOSD';function SetImageRmOSD(FileName:Pchar;isStretch:Bool;Posx,Posy:integer):integer;
stdcall;external'OSD.DLL' name 'SetImageRmOSD';function SetTextRmOSD(Text:Pchar;X,Y:integer;ScrollStyle : integer;
FontSize,FontColor:integer):integer;
stdcall;external 'OSD.DLL' name 'SetTextRmOSD';function SetRegSn(RegStr : Pchar):integer;stdcall;external'OSD.DLL' name 'SetRegSn';implementation{$R *.dfm}procedure TDemoForm.FormCreate(Sender: TObject);var sFileName : String;
begin
sFileName:=ExtractFilePath(ParamStr(0))+'demo.bmp';
if Fileexists(sFileName) then
EditFileName.Text := sFileName;
if InitRmOSD < 0 then
MessageBox(Handle,'初试化OSD接口失败!!!',Pchar(Caption),MB_ICONEXCLAMATION);
end;
procedure TDemoForm.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
FreeRmOSD;
end;
procedure TDemoForm.btnTextClick(Sender: TObject);
begin
SetParamRmOSD(UdOsdX.Position,UdOsdY.Position, UdOsdW.Position,UdOsdH.Position);
SetTextRmOSD(Pchar(Memo1.Text),UpDownTxtX.Position,UpDownTxtY.Position,ComboboxScrollMode.ItemIndex, UdFontSize.Position,ColorBox1.Selected);
ShowRmOSD(0);
end;
procedure TDemoForm.btnImageClick(Sender: TObject);
begin
SetParamRmOSD(UdOsdX.Position,UdOsdY.Position, UdOsdW.Position,UdOsdH.Position);
SetImageRmOSD(Pchar(EditFileName.Text),CheckBoxStretch.Checked,0,0);
ShowRmOSD(1);
end;
procedure TDemoForm.btnTxtImgClick(Sender: TObject);
begin
SetParamRmOSD(UdOsdX.Position,UdOsdY.Position, UdOsdW.Position,UdOsdH.Position);
SetTextRmOSD(Pchar(Memo1.Text),UpDownTxtX.Position,UpDownTxtY.Position,ComboboxScrollMode.ItemIndex, UdFontSize.Position,ColorBox1.Selected);
SetImageRmOSD(Pchar(EditFileName.Text),CheckBoxStretch.Checked,0,0);
ShowRmOSD(2);
end;
procedure TDemoForm.btnHideClick(Sender: TObject);
begin
ShowRmOSD(3);
end;
procedure TDemoForm.SpeedButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
EditFileName.Text := OpenDialog1.FileName ;
end;

end;
procedure TDemoForm.CheckBoxStretchClick(Sender: TObject);
begin
Panel1.Enabled := not CheckBoxStretch.Checked ;
end;

end.
 

Similar threads

I
回复
0
查看
638
import
I
I
回复
0
查看
644
import
I
I
回复
0
查看
558
import
I
I
回复
0
查看
740
import
I
后退
顶部