/** \fn brief input is already a surface, in yv12 format */ bool dxvaRender::displayImage_surface(ADMImage *pic,admDx2Surface *surface) { // this does not work, both surfaces are coming from different device IDirect3DSurface9 *bBuffer; POINT point={0,0}; // 1 upload to myYV12 surface if(ADM_FAILED(IDirect3DDevice9_UpdateSurface(d3dDevice, surface->surface, // src &panScan, // src rect myYV12Surface, // dst &point // where to ))) { ADM_warning("Copying surface failed, switching to non accelerated path \n"); if(!pic->hwDownloadFromRef()) { ADM_warning("Failed to download yv12 from dxva\n"); return false; } // workaround : use default non bridged path if(useYV12) { return displayImage_yv12(pic); } return displayImage_argb(pic); return false; } // upload.... if( ADM_FAILED(IDirect3DDevice9_GetBackBuffer(d3dDevice, 0, 0, D3DBACKBUFFER_TYPE_MONO, &bBuffer))) { ADM_warning("D3D Cannot create backBuffer\n"); return false; } // data are in YV12 surface, blit it to mySurface // zoom and color conversion happen there if (ADM_FAILED(IDirect3DDevice9_StretchRect(d3dDevice, myYV12Surface, NULL, bBuffer, NULL, D3DTEXF_LINEAR))) { ADM_warning("StretchRec yv12 failed\n"); } IDirect3DDevice9_BeginScene(d3dDevice); IDirect3DDevice9_EndScene(d3dDevice); if( ADM_FAILED(IDirect3DDevice9_Present(d3dDevice, &targetRect, 0, 0, 0))) { ADM_warning("D3D Present failed\n"); } return true; }
/** \fn brief input is already a surface, in yv12 format */ bool dxvaRender::displayImage_surface(ADMImage *pic,admDx2Surface *surface) { // this does not work, both surfaces are coming from different device IDirect3DSurface9 *bBuffer; POINT point={0,0}; // OK ADM_info("surface duplicated\n"); if( ADM_FAILED(D3DCall(IDirect3DDevice9,GetBackBuffer,d3dDevice, 0, 0, D3DBACKBUFFER_TYPE_MONO, &bBuffer))) { ADM_warning("D3D Cannot create backBuffer\n"); return false; } // can we directly use the surface from dxva ? (can we at all ?) if (ADM_FAILED(D3DCall(IDirect3DDevice9,StretchRect,d3dDevice, surface->surface, NULL, bBuffer, NULL, D3DTEXF_LINEAR))) { ADM_warning("StretchRec yv12 failed\n"); // go to indirect route if(!pic->hwDownloadFromRef()) { ADM_warning("Failed to download yv12 from dxva\n"); return false; } // workaround : use default non bridged path if(useYV12) { return displayImage_yv12(pic); } return displayImage_argb(pic); } IDirect3DDevice9_BeginScene(d3dDevice); IDirect3DDevice9_EndScene(d3dDevice); if( ADM_FAILED(IDirect3DDevice9_Present(d3dDevice, &targetRect, 0, 0, 0))) { ADM_warning("D3D Present failed\n"); } return true; }
/** \fn displayImage \brief display an image */ bool dxvaRender::displayImage(ADMImage *pic) { if(pic->refType==ADM_HW_DXVA) { aprintf("Source is already a surface (dxva2 input)\n"); admDx2Surface *surface=(admDx2Surface *)pic->refDescriptor.refHwImage; return displayImage_surface(pic,surface); } #if 1 if(useYV12) #else if(0) #endif { return displayImage_yv12(pic); } return displayImage_argb(pic); }