home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
[Beta - Update 2013/08/09] MP3D - Render 3D videos via MediaPortal!
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MaxMan23" data-source="post: 783462" data-attributes="member: 56215"><p><strong>AW: [Beta - Update 2011/04/30] MP3D - Render 3D videos via MediaPortal!</strong></p><p></p><p>Hi,</p><p></p><p>can you look at this Link. Here is an source code for programming a filter for 3D vision:</p><p><a href="http://www.codeproject.com/Answers/248272/Video-with-NVidia-3D-Vision.aspx#answer3" target="_blank">Video with NVidia 3D Vision - CodeProject</a></p><p></p><p>HRESULT CTransform::Transform( IMediaSample *pMediaSample, AM_MEDIA_TYPE* media_type, LPDIRECT3DDEVICE9 direct_3D_device )</p><p>{</p><p> if (</p><p> pMediaSample==NULL || media_type==NULL || direct_3D_device == NULL</p><p> )</p><p> {</p><p> return E_POINTER;</p><p> }</p><p> AM_MEDIA_TYPE* pType = media_type;</p><p> VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat;</p><p> BYTE *pData; // Pointer to the actual image buffer</p><p> long lDataLen; // Holds length of any given sample</p><p> RGBTRIPLE *prgb; // Holds a pointer to the current pixel</p><p> </p><p> pMediaSample->GetPointer(&pData);</p><p> lDataLen = pMediaSample->GetSize();</p><p> // Get the image properties from the BITMAPINFOHEADER</p><p> </p><p> int iPixelSize = pvi->bmiHeader.biBitCount / 8;</p><p> int cxImage = pvi->bmiHeader.biWidth;</p><p> int cyImage = pvi->bmiHeader.biHeight;</p><p> int cbImage = cyImage * cxImage * iPixelSize;</p><p> int numPixels = cxImage * cyImage;</p><p> iPixelSize = pvi->bmiHeader.biBitCount / 8;</p><p> cxImage = pvi->bmiHeader.biWidth;</p><p> cyImage = pvi->bmiHeader.biHeight;</p><p> cbImage = cyImage * cxImage * iPixelSize;</p><p> numPixels = cxImage * cyImage;</p><p> </p><p> prgb = (RGBTRIPLE*) pData;</p><p> int pixels_shift = 2*cxImage/100;</p><p> REFERENCE_TIME rtStart, rtEnd;</p><p> pMediaSample->GetTime(&rtStart, &rtEnd);</p><p> {</p><p> if(buffers_size!=cxImage*cyImage)</p><p> {</p><p> buffers_size = cxImage*cyImage;</p><p> delete []member_cash_buffer;</p><p> delete []member_buffer;</p><p> delete []local_member_buffer_1;</p><p> delete []local_member_buffer_2;</p><p> delete []local_member_entered_buffer;</p><p> member_cash_buffer = new RGBTRIPLE[buffers_size];</p><p> member_buffer = new RGBTRIPLE[buffers_size];</p><p> local_member_buffer_1 = new RGBTRIPLE[buffers_size];</p><p> local_member_buffer_2 = new RGBTRIPLE[buffers_size];</p><p> local_member_entered_buffer = new RGBTRIPLE[buffers_size];</p><p> member_valid_cash = 0;</p><p> }</p><p> }</p><p> </p><p></p><p>#define RGB_BYTE_ORDER(r, g ,b) ((DWORD) (((BYTE) (b) | ((WORD) (g) << 8)) | (((DWORD) (BYTE) (r)) << 16)))</p><p> HRESULT local_handle_result = S_OK;</p><p> {</p><p> IDirect3DSurface9* gImageSrcLeft = NULL; // Left Source image surface in video memory</p><p> IDirect3DSurface9* gImageSrcRight = NULL; // Right Source image Surface in video memory</p><p> </p><p> {</p><p> local_handle_result = direct_3D_device->CreateOffscreenPlainSurface(</p><p> cxImage-pixels_shift, // Stereo width is twice the source width</p><p> cyImage, // Stereo height add one raw to encode signature</p><p> D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory</p><p> &gImageSrcLeft, NULL);</p><p> if(local_handle_result!=S_OK)</p><p> {</p><p> return local_handle_result;</p><p> }</p><p> local_handle_result = direct_3D_device->CreateOffscreenPlainSurface(</p><p> cxImage-pixels_shift, // Stereo width is twice the source width</p><p> cyImage, // Stereo height add one raw to encode signature</p><p> D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory</p><p> &gImageSrcRight, NULL);</p><p> if(local_handle_result!=S_OK)</p><p> {</p><p> gImageSrcLeft->Release();</p><p> return local_handle_result;</p><p> }</p><p> {</p><p> DWORD *local_bit_map_buffer;</p><p> local_bit_map_buffer = new DWORD[(cxImage-pixels_shift)*cyImage]; </p><p> </p><p> for(int local_counter_width=pixels_shift;local_counter_width<cxImage;local_counter_width++)</p><p> {</p><p> for(int local_counter_height=0;local_counter_height<cyImage;local_counter_height++)</p><p> {</p><p> int local_couter = local_counter_width+local_counter_height*cxImage;</p><p> int local_bit_map_couter = local_counter_width-pixels_shift+(cyImage-(local_counter_height+1))*(cxImage-pixels_shift);</p><p> local_bit_map_buffer[local_bit_map_couter] = RGB_BYTE_ORDER(prgb[local_couter].rgbtRed,prgb[local_couter].rgbtGreen,prgb[local_couter].rgbtBlue);</p><p> }</p><p> }</p><p> </p><p> HBITMAP handle_bit_map = NULL;</p><p> </p><p> handle_bit_map = CreateBitmap(</p><p> cxImage-pixels_shift, </p><p> cyImage, </p><p> 1,</p><p> 32, </p><p> local_bit_map_buffer);</p><p> </p><p> delete []local_bit_map_buffer;</p><p> </p><p> HRESULT local_handle_result;</p><p> </p><p> </p><p> </p><p> HDC hdc; </p><p> gImageSrcLeft->GetDC(&hdc);</p><p> </p><p> HDC hdc_compatible = CreateCompatibleDC(hdc);</p><p> </p><p> SelectObject(hdc_compatible,handle_bit_map);</p><p> BitBlt(hdc, 0 ,0 ,cxImage-pixels_shift , cyImage , hdc_compatible, 0, 0, SRCCOPY);</p><p> gImageSrcLeft->ReleaseDC(hdc);</p><p> DeleteDC(hdc_compatible);</p><p> </p><p> bool local_result = DeleteObject(handle_bit_map);</p><p> }</p><p> </p><p> {</p><p> DWORD *local_bit_map_buffer;</p><p> local_bit_map_buffer = new DWORD[(cxImage-pixels_shift)*cyImage];</p><p> </p><p> for(int local_counter_width=0;local_counter_width<cxImage-pixels_shift;local_counter_width++)</p><p> {</p><p> for(int local_counter_height=0;local_counter_height<cyImage;local_counter_height++)</p><p> {</p><p> int local_couter = local_counter_width+local_counter_height*cxImage;</p><p> int local_bit_map_couter = local_counter_width+(cyImage-(local_counter_height+1))*(cxImage-pixels_shift);</p><p> local_bit_map_buffer[local_bit_map_couter] = RGB_BYTE_ORDER(prgb[local_couter].rgbtRed,prgb[local_couter].rgbtGreen,prgb[local_couter].rgbtBlue);</p><p> }</p><p> }</p><p> </p><p> HBITMAP handle_bit_map = NULL;</p><p> </p><p> handle_bit_map = CreateBitmap(</p><p> cxImage-pixels_shift, </p><p> cyImage, </p><p> 1,</p><p> 32, </p><p> local_bit_map_buffer);</p><p> </p><p> delete []local_bit_map_buffer;</p><p> </p><p> HRESULT local_handle_result;</p><p> </p><p> </p><p> </p><p> HDC hdc; </p><p> gImageSrcRight->GetDC(&hdc);</p><p> </p><p> HDC hdc_compatible = CreateCompatibleDC(hdc);</p><p> </p><p> SelectObject(hdc_compatible,handle_bit_map);</p><p> BitBlt(hdc, 0 ,0 ,cxImage-pixels_shift , cyImage , hdc_compatible, 0, 0, SRCCOPY);</p><p> gImageSrcRight->ReleaseDC(hdc);</p><p> DeleteDC(hdc_compatible);</p><p> </p><p> bool local_result = DeleteObject(handle_bit_map);</p><p> }</p><p> </p><p> int gImageWidth= cxImage-pixels_shift; // Source image width</p><p> int gImageHeight= cyImage;// Source image height</p><p> </p><p> IDirect3DSurface9* gImageSrc= NULL; // Source stereo image beeing created</p><p> </p><p> local_handle_result = direct_3D_device->CreateOffscreenPlainSurface(</p><p> gImageWidth* 2, // Stereo width is twice the source width</p><p> gImageHeight+ 1, // Stereo height add one raw to encode signature</p><p> D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory</p><p> &gImageSrc, NULL);</p><p> if(local_handle_result!=S_OK)</p><p> {</p><p> gImageSrcLeft->Release();</p><p> gImageSrcRight->Release();</p><p> return local_handle_result;</p><p> }</p><p> // Blit left srcimage to left side of stereo</p><p> RECT srcRect= { 0, 0, gImageWidth, gImageHeight};</p><p> RECT dstRect= { 0, 0, gImageWidth, gImageHeight};</p><p> direct_3D_device->StretchRect(gImageSrcLeft, &srcRect, gImageSrc, &dstRect, D3DTEXF_LINEAR);</p><p> // Blit right srcimage to right side of stereo</p><p>RECT srcRect2= { 0, 0, 2*gImageWidth, gImageHeight+1};</p><p> RECT dstRect2= {gImageWidth, 0, 2*gImageWidth, gImageHeight};</p><p> direct_3D_device->StretchRect(gImageSrcRight, &srcRect, gImageSrc, &dstRect2, D3DTEXF_LINEAR);</p><p> </p><p> // Stereo Blitdefines</p><p>#define NVSTEREO_IMAGE_SIGNATURE 0x4433564e //NV3D</p><p> typedef struct _Nv_Stereo_Image_Header</p><p> {</p><p> unsigned int dwSignature;</p><p> unsigned int dwWidth;</p><p> unsigned int dwHeight;</p><p> unsigned int dwBPP;</p><p> unsigned int dwFlags;</p><p> } NVSTEREOIMAGEHEADER, *LPNVSTEREOIMAGEHEADER;</p><p> // ORedflags in the dwFlagsfielsof the _Nv_Stereo_Image_Headerstructure above</p><p>#define SIH_SWAP_EYES 0x00000001</p><p>#define SIH_SCALE_TO_FIT 0x00000002</p><p> </p><p> // Lock the stereo image</p><p> D3DLOCKED_RECT lr;</p><p> gImageSrc->LockRect(&lr,NULL,0);</p><p> // write stereo signature in the last raw of the stereo image</p><p> LPNVSTEREOIMAGEHEADER pSIH=</p><p> (LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits) + (lr.Pitch* gImageHeight));</p><p> // Update the signature header values</p><p> pSIH->dwSignature= NVSTEREO_IMAGE_SIGNATURE;</p><p> pSIH->dwBPP= 32;</p><p> pSIH->dwFlags= SIH_SWAP_EYES; // Src image has left on left and right on right</p><p> pSIH->dwWidth= gImageWidth*2;</p><p> pSIH->dwHeight= gImageHeight;</p><p> // Unlock surface</p><p> gImageSrc->UnlockRect();</p><p> </p><p> </p><p> D3DVIEWPORT9 local_view_port;</p><p> direct_3D_device->GetViewport(&local_view_port);</p><p> RECT local_view_port_rect = {0,0,local_view_port.Width,local_view_port.Height};</p><p> </p><p> {</p><p> gImageSrcLeft->Release();</p><p> gImageSrcRight->Release();</p><p> }</p><p> {</p><p> direct_3D_device->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 0.0f, 0);</p><p> direct_3D_device->BeginScene ();</p><p> </p><p> IDirect3DSurface9* pDestSurface;</p><p> direct_3D_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pDestSurface);</p><p> </p><p> if(pDestSurface)</p><p> {</p><p> direct_3D_device->StretchRect(gImageSrc, &srcRect2, pDestSurface, &local_view_port_rect, D3DTEXF_LINEAR);</p><p> }</p><p> </p><p> direct_3D_device->EndScene ();</p><p>// direct_3D_device->Present (NULL, NULL, NULL, NULL);</p><p> </p><p> if(pDestSurface)</p><p> {</p><p> pDestSurface->Release();</p><p> }</p><p> </p><p> if(gImageSrc)</p><p> {</p><p> gImageSrc->Release();</p><p> }</p><p> }</p><p> }</p><p> }</p><p> return S_OK;</p><p>}</p><p></p><p></p><p></p><p>Mayby someone can help us for using 3d vision</p></blockquote><p></p>
[QUOTE="MaxMan23, post: 783462, member: 56215"] [b]AW: [Beta - Update 2011/04/30] MP3D - Render 3D videos via MediaPortal![/b] Hi, can you look at this Link. Here is an source code for programming a filter for 3D vision: [url=http://www.codeproject.com/Answers/248272/Video-with-NVidia-3D-Vision.aspx#answer3]Video with NVidia 3D Vision - CodeProject[/url] HRESULT CTransform::Transform( IMediaSample *pMediaSample, AM_MEDIA_TYPE* media_type, LPDIRECT3DDEVICE9 direct_3D_device ) { if ( pMediaSample==NULL || media_type==NULL || direct_3D_device == NULL ) { return E_POINTER; } AM_MEDIA_TYPE* pType = media_type; VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat; BYTE *pData; // Pointer to the actual image buffer long lDataLen; // Holds length of any given sample RGBTRIPLE *prgb; // Holds a pointer to the current pixel pMediaSample->GetPointer(&pData); lDataLen = pMediaSample->GetSize(); // Get the image properties from the BITMAPINFOHEADER int iPixelSize = pvi->bmiHeader.biBitCount / 8; int cxImage = pvi->bmiHeader.biWidth; int cyImage = pvi->bmiHeader.biHeight; int cbImage = cyImage * cxImage * iPixelSize; int numPixels = cxImage * cyImage; iPixelSize = pvi->bmiHeader.biBitCount / 8; cxImage = pvi->bmiHeader.biWidth; cyImage = pvi->bmiHeader.biHeight; cbImage = cyImage * cxImage * iPixelSize; numPixels = cxImage * cyImage; prgb = (RGBTRIPLE*) pData; int pixels_shift = 2*cxImage/100; REFERENCE_TIME rtStart, rtEnd; pMediaSample->GetTime(&rtStart, &rtEnd); { if(buffers_size!=cxImage*cyImage) { buffers_size = cxImage*cyImage; delete []member_cash_buffer; delete []member_buffer; delete []local_member_buffer_1; delete []local_member_buffer_2; delete []local_member_entered_buffer; member_cash_buffer = new RGBTRIPLE[buffers_size]; member_buffer = new RGBTRIPLE[buffers_size]; local_member_buffer_1 = new RGBTRIPLE[buffers_size]; local_member_buffer_2 = new RGBTRIPLE[buffers_size]; local_member_entered_buffer = new RGBTRIPLE[buffers_size]; member_valid_cash = 0; } } #define RGB_BYTE_ORDER(r, g ,b) ((DWORD) (((BYTE) (b) | ((WORD) (g) << 8)) | (((DWORD) (BYTE) (r)) << 16))) HRESULT local_handle_result = S_OK; { IDirect3DSurface9* gImageSrcLeft = NULL; // Left Source image surface in video memory IDirect3DSurface9* gImageSrcRight = NULL; // Right Source image Surface in video memory { local_handle_result = direct_3D_device->CreateOffscreenPlainSurface( cxImage-pixels_shift, // Stereo width is twice the source width cyImage, // Stereo height add one raw to encode signature D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory &gImageSrcLeft, NULL); if(local_handle_result!=S_OK) { return local_handle_result; } local_handle_result = direct_3D_device->CreateOffscreenPlainSurface( cxImage-pixels_shift, // Stereo width is twice the source width cyImage, // Stereo height add one raw to encode signature D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory &gImageSrcRight, NULL); if(local_handle_result!=S_OK) { gImageSrcLeft->Release(); return local_handle_result; } { DWORD *local_bit_map_buffer; local_bit_map_buffer = new DWORD[(cxImage-pixels_shift)*cyImage]; for(int local_counter_width=pixels_shift;local_counter_width<cxImage;local_counter_width++) { for(int local_counter_height=0;local_counter_height<cyImage;local_counter_height++) { int local_couter = local_counter_width+local_counter_height*cxImage; int local_bit_map_couter = local_counter_width-pixels_shift+(cyImage-(local_counter_height+1))*(cxImage-pixels_shift); local_bit_map_buffer[local_bit_map_couter] = RGB_BYTE_ORDER(prgb[local_couter].rgbtRed,prgb[local_couter].rgbtGreen,prgb[local_couter].rgbtBlue); } } HBITMAP handle_bit_map = NULL; handle_bit_map = CreateBitmap( cxImage-pixels_shift, cyImage, 1, 32, local_bit_map_buffer); delete []local_bit_map_buffer; HRESULT local_handle_result; HDC hdc; gImageSrcLeft->GetDC(&hdc); HDC hdc_compatible = CreateCompatibleDC(hdc); SelectObject(hdc_compatible,handle_bit_map); BitBlt(hdc, 0 ,0 ,cxImage-pixels_shift , cyImage , hdc_compatible, 0, 0, SRCCOPY); gImageSrcLeft->ReleaseDC(hdc); DeleteDC(hdc_compatible); bool local_result = DeleteObject(handle_bit_map); } { DWORD *local_bit_map_buffer; local_bit_map_buffer = new DWORD[(cxImage-pixels_shift)*cyImage]; for(int local_counter_width=0;local_counter_width<cxImage-pixels_shift;local_counter_width++) { for(int local_counter_height=0;local_counter_height<cyImage;local_counter_height++) { int local_couter = local_counter_width+local_counter_height*cxImage; int local_bit_map_couter = local_counter_width+(cyImage-(local_counter_height+1))*(cxImage-pixels_shift); local_bit_map_buffer[local_bit_map_couter] = RGB_BYTE_ORDER(prgb[local_couter].rgbtRed,prgb[local_couter].rgbtGreen,prgb[local_couter].rgbtBlue); } } HBITMAP handle_bit_map = NULL; handle_bit_map = CreateBitmap( cxImage-pixels_shift, cyImage, 1, 32, local_bit_map_buffer); delete []local_bit_map_buffer; HRESULT local_handle_result; HDC hdc; gImageSrcRight->GetDC(&hdc); HDC hdc_compatible = CreateCompatibleDC(hdc); SelectObject(hdc_compatible,handle_bit_map); BitBlt(hdc, 0 ,0 ,cxImage-pixels_shift , cyImage , hdc_compatible, 0, 0, SRCCOPY); gImageSrcRight->ReleaseDC(hdc); DeleteDC(hdc_compatible); bool local_result = DeleteObject(handle_bit_map); } int gImageWidth= cxImage-pixels_shift; // Source image width int gImageHeight= cyImage;// Source image height IDirect3DSurface9* gImageSrc= NULL; // Source stereo image beeing created local_handle_result = direct_3D_device->CreateOffscreenPlainSurface( gImageWidth* 2, // Stereo width is twice the source width gImageHeight+ 1, // Stereo height add one raw to encode signature D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory &gImageSrc, NULL); if(local_handle_result!=S_OK) { gImageSrcLeft->Release(); gImageSrcRight->Release(); return local_handle_result; } // Blit left srcimage to left side of stereo RECT srcRect= { 0, 0, gImageWidth, gImageHeight}; RECT dstRect= { 0, 0, gImageWidth, gImageHeight}; direct_3D_device->StretchRect(gImageSrcLeft, &srcRect, gImageSrc, &dstRect, D3DTEXF_LINEAR); // Blit right srcimage to right side of stereo RECT srcRect2= { 0, 0, 2*gImageWidth, gImageHeight+1}; RECT dstRect2= {gImageWidth, 0, 2*gImageWidth, gImageHeight}; direct_3D_device->StretchRect(gImageSrcRight, &srcRect, gImageSrc, &dstRect2, D3DTEXF_LINEAR); // Stereo Blitdefines #define NVSTEREO_IMAGE_SIGNATURE 0x4433564e //NV3D typedef struct _Nv_Stereo_Image_Header { unsigned int dwSignature; unsigned int dwWidth; unsigned int dwHeight; unsigned int dwBPP; unsigned int dwFlags; } NVSTEREOIMAGEHEADER, *LPNVSTEREOIMAGEHEADER; // ORedflags in the dwFlagsfielsof the _Nv_Stereo_Image_Headerstructure above #define SIH_SWAP_EYES 0x00000001 #define SIH_SCALE_TO_FIT 0x00000002 // Lock the stereo image D3DLOCKED_RECT lr; gImageSrc->LockRect(&lr,NULL,0); // write stereo signature in the last raw of the stereo image LPNVSTEREOIMAGEHEADER pSIH= (LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits) + (lr.Pitch* gImageHeight)); // Update the signature header values pSIH->dwSignature= NVSTEREO_IMAGE_SIGNATURE; pSIH->dwBPP= 32; pSIH->dwFlags= SIH_SWAP_EYES; // Src image has left on left and right on right pSIH->dwWidth= gImageWidth*2; pSIH->dwHeight= gImageHeight; // Unlock surface gImageSrc->UnlockRect(); D3DVIEWPORT9 local_view_port; direct_3D_device->GetViewport(&local_view_port); RECT local_view_port_rect = {0,0,local_view_port.Width,local_view_port.Height}; { gImageSrcLeft->Release(); gImageSrcRight->Release(); } { direct_3D_device->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 0.0f, 0); direct_3D_device->BeginScene (); IDirect3DSurface9* pDestSurface; direct_3D_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pDestSurface); if(pDestSurface) { direct_3D_device->StretchRect(gImageSrc, &srcRect2, pDestSurface, &local_view_port_rect, D3DTEXF_LINEAR); } direct_3D_device->EndScene (); // direct_3D_device->Present (NULL, NULL, NULL, NULL); if(pDestSurface) { pDestSurface->Release(); } if(gImageSrc) { gImageSrc->Release(); } } } } return S_OK; } Mayby someone can help us for using 3d vision [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
[Beta - Update 2013/08/09] MP3D - Render 3D videos via MediaPortal!
Contact us
RSS
Top
Bottom