Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: Help needed for developing video plugin for VDJx64 (DX11)

This topic is old and might contain outdated or incorrect information.

djlgm70PRO InfinityMember since 2012
Hello everybody,

I would kindly ask for help developing a video plugin for x64 using DX11. I used to be a professional programmer in C/C++ - Java for more than 10 years but here I need more information about the VDJ API. Is it possible to have more documentation on how to handle the existing functions found in the header files posted in this forum? Only the header files are not enough. E.g. even if I know how to call a function it is not obvious what values of the arguments are acceptable from the source code.

An existing example with source code would be of great help. (For D11 x64)

Your help is much appreciated!

George
 

Posted Mon 25 May 20 @ 5:26 pm
djlgm70PRO InfinityMember since 2012
Thank you for your reply, I have seen these two links already many times. The second one is actually only for DX9, is this the only help we can have?
Do you believe this is enough to do a video plugin to stretch the video size for x64 with DX11?

Can you give me a tip of how to do it? I guess I have to play with the texture buffers.

Any more help would be appreciated
 

Posted Wed 27 May 20 @ 6:20 pm
NicotuxHome userMember since 2014
yes it is ^^
there is everything needed to get d3d11 & d3d9 infos
then use dx stuffs
you can play with texture buffers if you want or with vertice or matrix
but nothing specific to VDJ

simple resize code using viewport (32 & 64):

#if (defined(VDJ_WIN))
#if (defined(VDJ_IS_WIN64))
#define VDJ_D3D11
#else
#define VDJ_D3D9
#endif
#elif (defined(VDJ_MAC))
#define VDJ_OPENGL
#endif


#if (defined(VDJ_D3D9))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX9;
typedef IDirect3DDevice9 VDJVIDEODEVICE;
typedef IDirect3DTexture9 VDJVIDEOTEXTURE;
#elif (defined(VDJ_D3D11))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX11;
typedef ID3D11Device VDJVIDEODEVICE;
typedef ID3D11ShaderResourceView VDJVIDEOTEXTURE;
#elif (defined(VDJ_OPENGL))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineOpenGL;
#endif


HRESULT VDJ_API Resize8::OnDraw()
{

VDJVIDEODEVICE* pDevice;
GetDevice(VDJVIDEOENGINE, (void**)&pDevice);
if (!pDevice) return E_FAIL;
#ifdef VDJ_IS_WIN64
ID3D11DeviceContext* pImmediateContext = nullptr;
pDevice->GetImmediateContext(&pImmediateContext);
if (!pImmediateContext) return E_FAIL;


/** Direct modify the viewport is enough */
D3D11_VIEWPORT vp;
vp.TopLeftX = m_Position[0] * m_Width;
vp.TopLeftY = m_Position[1] * m_Height;
vp.Width = m_Position[2] * m_Width;
vp.Height = m_Position[3] * m_Height;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
pImmediateContext->RSSetViewports(1, &vp);

/* test resizing the background */
// Get the current render targets
ID3D11RenderTargetView* pCurrentRenderTarget;
ID3D11DepthStencilView* pCurrentDepthStencil;
pImmediateContext->OMGetRenderTargets(1, &pCurrentRenderTarget, &pCurrentDepthStencil);

if (pCurrentRenderTarget)
{

VDJVIDEOTEXTURE* pTexture; // ID3D11ShaderResourceView
TVertex* vertices;

pImmediateContext->DSGetShaderResources(0, 1, &pTexture);

GetTexture(VDJVIDEOENGINE, (void**) &pTexture, &vertices);
memset(m_DefaultVertices, 0, 4 * sizeof(TVertex8));

// Copy actual vertices
memcpy(m_DefaultVertices, vertices, 4 * sizeof(TVertex8));

int WidthOriginalVideo = 0;
int HeightOriginalVideo = 0;
// Taille de l'image originale depuis les vertices actuels
WidthOriginalVideo = m_DefaultVertices[1].position.x - m_DefaultVertices[0].position.x;
HeightOriginalVideo = m_DefaultVertices[3].position.y - m_DefaultVertices[0].position.y;

D3D11_VIEWPORT vp;
/* resize*/
vp.TopLeftX = m_Position[0] * WidthOriginalVideo;
vp.TopLeftY = m_Position[1] * HeightOriginalVideo;
vp.Width = m_Position[2] * WidthOriginalVideo;
vp.Height = m_Position[3] * HeightOriginalVideo;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;

pImmediateContext->RSSetViewports(1, &vp);


}
#else
VDJVIDEOTEXTURE* pTexture; // ID3D11ShaderResourceView
TVertex* vertices;

GetTexture(VDJVIDEOENGINE, (void**)&pTexture, &vertices);
memset(m_DefaultVertices, 0, 4 * sizeof(TVertex8));

// Copy les vertices actuels
memcpy(m_DefaultVertices, vertices, 4 * sizeof(TVertex8));


int WidthOriginalVideo = 0;
int HeightOriginalVideo = 0;
// Taille de l'image originale depuis les vertices actuels
WidthOriginalVideo = m_DefaultVertices[1].position.x - m_DefaultVertices[0].position.x;
HeightOriginalVideo = m_DefaultVertices[3].position.y - m_DefaultVertices[0].position.y;

/* Resize only */
D3DVIEWPORT9 vp;
pDevice->GetViewport(&vp);

vp.Width = m_Position[2] * WidthOriginalVideo;
vp.Height = m_Position[3] * HeightOriginalVideo;
vp.X = m_Position[0] * WidthOriginalVideo;
vp.Y = m_Position[1] * HeightOriginalVideo;

vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;

pDevice->SetViewport(&vp);


#endif
return DrawDeck();
}

 

Posted Wed 27 May 20 @ 7:35 pm
djlgm70PRO InfinityMember since 2012
Thank you so much for this example. I will give it a try and return with feedback!

I appreciate your help a lot!
 

Posted Wed 27 May 20 @ 8:01 pm
djlgm70PRO InfinityMember since 2012
One question:
I have seen this TVertex8 struct again in some other message in this forum but this is not defined in the header files.
Can I guess is 8 time TVertex? can you give structure definition of Tvertex8? Do you put this definition in the VDJ API header files?
 

Posted Wed 27 May 20 @ 8:06 pm
NicotuxHome userMember since 2014
just an alias to TVertex ( most trailing 8 wanna say "for use with sdk8" added 8 a little too much "8")

#ifndef TVertex8
#define TVertex8 TVertex
#endif
 

Posted Wed 27 May 20 @ 8:48 pm
djlgm70PRO InfinityMember since 2012
Well, I played around with viewport and vertices and is all fine but what actually I want to do is to resize an e.g. 720x576 video that is playing (.vob) to 1920x1080 to fit because the video although it is 4:3 inside it is 16:9 as they did the old days when they wanted to show 16:9 picture from 4:3 screens (see also picture attached).
Now, whatever I do with the viewport or vertices all the changes that are happening are still inside the 720x576 frame and not to the whole of the screen (1920x1080).

My aim is to expand and actually crop all the black picture that is not necessary to occupy screen space.

So do you think I can do this only with playing with viewport and verttices or should I do something more with the backbuffer since VDJ considers the video to be 720x576 and not 1920x1080. VDJ actually decides to position the specific video in the center of a 1920x1080 screen.
Any ideas how to do this?
 

Posted Fri 29 May 20 @ 9:26 am
djlgm70PRO InfinityMember since 2012
ORIGINAL:


MY AIM:
 

Posted Fri 29 May 20 @ 9:27 am
NicotuxHome userMember since 2014
All you need now is to learn how to use DirectX D3D11... SDK

you can acheive (easily) this using both the existing examples and the code i posted
DX11 is much simple for that
 

Posted Fri 29 May 20 @ 9:54 am
djlgm70PRO InfinityMember since 2012
With the code from your post and existing examples I managed easily to resize the video picture but only inside the 720x520 frame that VDJ places in the center of the actual 1920x1080 frame of the screen.
I guess that I have to get the texture buffer from the 720x520 frame to put it in a new 1920x1080 buffer to send to VDJ instead and then resize this one. Is this correct? is it easier than this?

I will continue studying DX11 SDK anyway, I hope I do not re-invent the circle!
 

Posted Fri 29 May 20 @ 10:58 am
AdionPRO InfinityCTOMember since 2006
I think it is not yet in the current SDK, but in that case you need to adjust the flags for your plugin:
#define VDJFLAG_VIDEO_OUTPUTRESOLUTION 0x400000 // If the effect is applied on deck, the effect will be applied onto the video output resolution instead of the video source resolution
#define VDJFLAG_VIDEO_OUTPUTASPECTRATIO 0x800000 // If the effect is applied on deck, the effect will be applied in same aspect ratio as video output (and minimum resolution between video source and video output)

In your case VDJFLAG_VIDEO_OUTPUTASPECTRATIO is probably sufficient.
 

Posted Fri 29 May 20 @ 11:03 am
djlgm70PRO InfinityMember since 2012
First of all I want to thank you for all this useful information.
Now concerning these definitions I have seen them in the VDJ header file but how do you actually utilize them? With which command from the VDJ API?

I have not seen this in an example so far. So how do you indicate to VDJ which mode to use? VDJFLAG_VIDEO_OUTPUTRESOLUTION or VDJFLAG_VIDEO_OUTPUTASPECTRATIO.

I believe there must be a command I am not aware of. E.G SendCommand(const char *command) or something else?

 

Posted Fri 29 May 20 @ 12:07 pm
AdionPRO InfinityCTOMember since 2006
Flags should be set in OnGetPluginInfo to the info->Flags parameter.
 

Posted Fri 29 May 20 @ 12:57 pm
djlgm70PRO InfinityMember since 2012
Well, I have just finished my first tests with success!

With your kind help I managed to center the video and cover all the screen through my plugin.

I will make it work nice with buttons and adjustable triggers and I believe it may be useful to all video DJs that are playing older .VOB videos that need to be re-scaled to 16:9

I wish to thank you all for your valuable information!

L.G.M.
 

Posted Sat 30 May 20 @ 1:21 am
djcelPRO InfinityModeratorMember since 2004
 

Posted Sun 31 May 20 @ 3:28 pm
djlgm70PRO InfinityMember since 2012
Thank you Charles, (djCel),

I have studied extensively your example also before, although I wanted to make a effects plugin and not a transition plugin. Since I had no information at all about the API I had to gather all information possible from any source that I found in the forum (also studied a lot of direct x techniques).

Now I have finished with a first version of my plugin and I am testing it. I believe many video djs will find it useful, I wanted to find this plugin for years! (I am playing only with video since 2012 and always wanted a way to stretch/expand old .vob 4:3 videos that had actually 16:9 content to cover all the screen instead of having black bars all around the video (as you can see in my previous screenshots).

Now one more question: when I finish testing and I am confident enough that the plugin is safe to use, how can I share it to VDJ community? what is the procedure? Do other users share their plugins for free or there is also a money benefit sharing a useful plugin?
 

Posted Sun 31 May 20 @ 6:19 pm
You can upload your plugin here: http://www.virtualdj.com/plugins/upload.html

It will be tested by the team to make sure it doesn’t cause any issues then it will be made available to users.
There is no financial reward through VDJ for creating plugins. Other than the thanks and feedback from the community.
 

Posted Sun 31 May 20 @ 6:24 pm


(Old topics and forums are automatically closed)