![]() |
VMR9 custom allocator-presenter
In Bezug zu meinem Post
![]() Damals wie heute lese ich immer wieder die Aussage im MSDN: Zitat:
Im DSPack gib es eine Allocator-Demo, die auch funzt und sehr nett das Video-Bild als Scheibe im 3D-Raum drehen lässt ! Ich hätt's aber gerne ohne 3D-Gimmicks 'moveless' - was ja auch s weit klappt, aber ... irgendwie bekomme ich kein wirklichliches Vollbild und der Inhalt "hängt irgendwie auf halb-acht" im Raum/Fenster .... Nett, aber so unbrauchbar. Ich habe (leider noch) keinen Plan, wie das da bewerkstelligt wird, auch fleissiges lesen/suchen im WWW hat mich nicht wirklich weitergebracht. Entweder alles nur kopiertes unfertiges Dummzeug ohne Funktion oder extrem C-kryptsich nur für diejenigen, welche schon min. 1x Papst waren. Kann hier vielleicht der eine oder andere aus der Gamer-Ecke o. ä helfen ? |
AW: VMR9 custom allocator-presenter
Bei solchen komplexen Themen, die einiges Wissen an Direct3D und DirectShow erfordern, ist es sicherlich hilfreich, wenn du uns ein minimales Beispielprojekt sowie entsprechende Videodateien zur Verfügung stellst.
In einem Programmierforum ohne Quelltext helfen und diskutieren zu wollen ist ein bisschen wie Schwimmen aufn Trockenen. Vielleicht ist es nur eine kleine Sache, eventuell wird nur ein HRESULT nicht vernünftig auswertet oder beim Initialisieren fehlt ein Wert und du siehst es vor lauter Betriebsblindheit nicht mehr. |
AW: VMR9 custom allocator-presenter
Zitat:
Mein Player unterstützt das alles insbesondere Madvr und LAV Filtern. EVR -> VMR9 Habe mich aber um solche Spielereien bisher nicht gekümmert da ich mich auf ein Video Konzentrieren will. Zitat:
gruss |
AW: VMR9 custom allocator-presenter
Zitat:
![]() Einfach mal zählen, wie oft der Begriff "Direct3D" vorkommt, danke! |
AW: VMR9 custom allocator-presenter
Zitat:
Ich benötige es nicht einmal. Einfach mal zählen wie oft das in Zusammenhang mit Videos zum tragen kommt. danke EDIT: Sorry.. Bin jetzt von meiner Anwendung. Natürlich verwendet meine DLL es. gruss |
AW: VMR9 custom allocator-presenter
Zitat:
Daraus mal "eben schnell was extrahieren" geht z 100% in die Hose, weil sehr komplex und sehr verflochten.... Im Prinzip ist die Demo allerdings identisch mit der MS-WIN7-SDK Demo '\multimedia\directshow\vmr9\vmr9allocator' und betriff im wesentlichen die Dateien 'Allocator.cpp/.pas' und 'PlaneScene.cpp/.pas'. Laufen tut die Demo mit jedem x-beliegiegen Video - wenn man wie EWeiss anmerkte, die LAV-Filter verwendet. Der LAVSplitterSource-Filter frisst fast alles. Ich habs hier mit div. .AVI, .MPG und .TS probiert. Das Prinzip, so wie ich es bisher herausgebrezelt habe: Das VideoWindow muss explizit zur Nutzung von VMR9 im Renderless-Mode gesetzt werden. Dazu muss man noch eine TAllocator-Klasse an's Window übergeben. Der VMR9 ruft dann bei jedem Frame die Funktion "PresentImage" und hilfsweise die Funktion "PresentHelper" auf. Siehe hier auszugsweise im org. DSPack-File 'Allocator-pas':
Delphi-Quellcode:
Letztendlich wird im File 'PlaneScene.pas' (Auszug) die Funktion "DrawScene" aufgerufen und dort YXZ-Werte in Matrizen und Transformationen "verwurstet", was die Drehung der "Video-Scheibe" veranlasst ..... die ich gerne da raus hätte !
function TAllocator.PresentImage(dwUserID: DWORD;
lpPresInfo: PVMR9PresentationInfo): HResult; var hr: HRESULT; AMonitor: HMONITOR; function FailRet(hr: HResult): boolean; begin PresentImage := hr; Result := Failed(hr); end; begin FObjectLock.Enter; try // if we are in the middle of the display change if NeedToHandleDisplayChange then begin // NOTE: this piece of code is left as a user exercise. // The D3DDevice here needs to be switched // to the device that is using another adapter end; hr := PresentHelper(lpPresInfo); // IMPORTANT: device can be lost when user changes the resolution // or when (s)he presses Ctrl + Alt + Delete. // We need to restore our video memory after that if (hr = D3DERR_DEVICELOST) then begin if (FD3DDev.TestCooperativeLevel = D3DERR_DEVICENOTRESET) then begin DeleteSurfaces; if FailRet(CreateDevice) then exit; AMonitor := FD3D.GetAdapterMonitor(D3DADAPTER_DEFAULT); if FailRet(FlpIVMRSurfAllocNotify.ChangeD3DDevice(FD3DDev, AMonitor)) then exit; end; hr := S_OK; end; result := hr; finally FObjectLock.Leave; end; end; function TAllocator.PresentHelper( lpPresInfo: PVMR9PresentationInfo): HRESULT; var surface: IDirect3DSurface9; texture: IDirect3DTexture9; function FailRet(hr: HResult): boolean; begin PresentHelper := hr; Result := Failed(hr); end; begin // parameter validation if (lpPresInfo = nil) then begin result := E_POINTER; exit; end else if (lpPresInfo.lpSurf = nil) then begin result := E_POINTER; exit; end; FObjectLock.Enter; try FD3DDev.SetRenderTarget(0, FrenderTarget); // if we created a private texture // blt the decoded image onto the texture. if(FprivateTexture <> nil) then begin if FailRet(FprivateTexture.GetSurfaceLevel(0 , surface)) then exit; // copy the full surface onto the texture's surface if FailRet(FD3DDev.StretchRect(lpPresInfo.lpSurf, nil, surface, nil, D3DTEXF_NONE)) then exit; if FailRet(Fscene.DrawScene(FD3DDev, FprivateTexture)) then exit; end else // this is the case where we have got the textures allocated by VMR // all we need to do is to get them from the surface begin if FailRet(lpPresInfo.lpSurf.GetContainer(IID_IDirect3DTexture9, Pointer(texture))) then exit; if FailRet(Fscene.DrawScene(FD3DDev, texture)) then exit; end; if FailRet(FD3DDev.Present(nil, nil, 0, nil)) then exit; // result := hr; finally Pointer(texture) := nil; FObjectLock.leave; end; end;
Delphi-Quellcode:
Hier endet leider mein mathematisches & delphianotisches Knoff-Hoff.
function TPlaneScene.DrawScene(d3ddev: IDirect3DDevice9;
texture: IDirect3DTexture9): HRESULT; function FailRet(hr: HResult): boolean; begin DrawScene := hr; Result := Failed(hr); end; var dwCurrentTime: DWord; difference: Int64; x, y, z: Single; mask0, mask3: DWord; pData: Pointer; begin if ((d3ddev = nil) or (texture = nil)) then begin Result := E_POINTER; Exit; end; if( FvertexBuffer = nil) then begin Result := D3DERR_INVALIDCALL; Exit; end; // get the difference in time dwCurrentTime := GetTickCount; difference := Ftime - dwCurrentTime; // figure out the rotation of the plane x := -cos(difference / 2000); y := cos(difference / 2000); z := sin(difference / 2000); // update the two rotating vertices with the new position Fvertices[0].position := MakePosition(x, y, z); // top left Fvertices[3].position := MakePosition(-x, -y, -z); // bottom right // Adjust the color so the blue is always on the bottom. // As the corner approaches the bottom, get rid of all the other // colors besides blue mask0 := Trunc((255 * (( y + 1) / 2))); mask3 := Trunc((255 * ((-y + 1) / 2))); Fvertices[0].color := $ff0000ff or (mask0 shl 16) or (mask0 shl 8); Fvertices[3].color := $ff0000ff or (mask3 shl 16) or (mask3 shl 8); // write the new vertex information into the buffer if FailRet(FvertexBuffer.Lock(0, sizeof(pData), pData, 0)) then exit; move(Fvertices, pData^ , sizeof(Fvertices)); if FailRet(FvertexBuffer.Unlock) then exit; // clear the scene so we don't have any articats left d3ddev.Clear(0, nil, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255), 1.0, 0); if FailRet(d3ddev.BeginScene) then exit; if FailRet(d3ddev.SetTexture(0, texture)) then exit; if FailRet(d3ddev.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE)) then exit; if FailRet(d3ddev.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE)) then exit; if FailRet(d3ddev.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE)) then exit; if FailRet(d3ddev.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE)) then exit; if FailRet(d3ddev.SetStreamSource(0, FvertexBuffer, 0, sizeof(TCustomVertex))) then exit; //set next source ( NEW ) if FailRet(d3ddev.SetFVF(D3DFVF_CUSTOMVERTEX)) then exit; if FailRet(d3ddev.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2)) then exit; //draw quad if FailRet(d3ddev.SetTexture(0, nil)) then exit; if FailRet(d3ddev.EndScene) then exit; end; |
AW: VMR9 custom allocator-presenter
Zitat:
Es geht hier nicht darum was du willst oder kannst oder brauchst! Ist doch völlig egal, ob irgendwelche ABC- oder XYZ-Filter in deinen Player dir die Details vorenthalten. Mit irgendeiner API werden die ja auf die Grafikkarte zugreifen (GDI, GDI+, Direct3D9, Direct3D10/11/12, DirectDraw, Direct2D, OpenGL, Vulkan). Es geht hier um DirectShow und die Implementierung eines eigenen Allocator-Presenter für einen Video Mixing Renderer 9 (VMR-9) Filter. Der verwendet nun mal halt ein D3D9-Device und entsprechende D3D9-Surface nebst D3D9-Texturen. Siehe entsprechend den Codeauszügen von Terwi (Variablen: FD3DDev, FD3D, surface, texture, ...). |
AW: VMR9 custom allocator-presenter
Zitat:
So das man als Helfender einfach nur das ZIP-Archiv entpackt und das Projekt öffnet und startet. Nichts desto trotz musst du im oben zitierten Quelltext doch bloß das Drehen verhindern. Probiere mal testweise diese Zeile
Delphi-Quellcode:
gegen
difference := Ftime - dwCurrentTime;
Delphi-Quellcode:
auszustauschen.
difference := 0;
Ansonsten kannst du alles ab der Zeile bis zum d3ddev.Clear auskommentieren und ausprobieren. |
AW: VMR9 custom allocator-presenter
![]() Das ist die letzte offizielle Version - es gib auch noch 'überarbeitungen'. Auspacken, Anweisungen zur Installation in der README.HTM lesen, VCL-Komponenten installieren, notwendige Verzeichnisse zuweisen und die Demo im Unterverzeichnis starten: '\DEMOS\D6-D7\VMR\VMR9ALLOCATOR\PlayFile' Sonst braucht es nix. Zitat:
Zitat:
|
AW: VMR9 custom allocator-presenter
Noch eine nachträgliche Info zum kompilieren und DirextX:
Vor etwa 1/2 Jahr hab ich noch mit XP (32bit) und Win7 (auch 32bit, testweise x64) "rumgemacht". Damit ließ sich das DSPack immer einwandfrei kompilieren. Verwendet wurde derzeit schon D2009. Nach "Zusammenstellung" meines neuen Power-Schleppi's ist nun Win8.1 x64 auf dem Trapez. (10.x ++ gönne ich mir wahrscheinlich erst viel später ....) Hier meckert mir Delphi das fehlen der Datei "d3dx9d_33.dll" an. (.... HALLO, EWeiss ! ) Zur Abhilfe muss man in der DSPack-Datei "D3DX9.pas" die Zeile 95 (je nach Version !?) // d3dx9MicrosoftDebugDLL = 'd3dx9d_33.dll'; auskommentieren. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:25 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz