[vlc-devel] [PATCH] direct3d9: support rendering of D3D9 surfaces coming out of DXVA2

Steve Lhomme robux4 at videolabs.io
Wed Apr 29 08:18:11 CEST 2015


On Tue, Apr 28, 2015 at 10:38 PM, Jean-Baptiste Kempf <jb at videolan.org> wrote:
> On 28 Apr, Steve Lhomme wrote :
>> +#include "../../src/win32/direct3d9_pool.h"
>
> This is fugly :)

Both the core and this module need this common code. So I suppose it
belongs in the core.

>> +    { "DXVANV12",   MAKEFOURCC('N','V','1','2'),    VLC_CODEC_D3D9_OPAQUE,  0,0,0 },
>
> "DXVA" should be enough, no?

Or DXA9. Also, it may not be NV12 in some cases (YV12, IMC3) so it
should not be there.

>> -
>> -    /* Create a surface */
>> -    LPDIRECT3DSURFACE9 surface;
>> -    HRESULT hr = IDirect3DDevice9_CreateOffscreenPlainSurface(d3ddev,
>> -                                                              fmt->i_visible_width,
>> -                                                              fmt->i_visible_height,
>> -                                                              d3dfmt->format,
>> -                                                              D3DPOOL_DEFAULT,
>> -                                                              &surface,
>> -                                                              NULL);
>> -    if (FAILED(hr)) {
>> -        msg_Err(vd, "Failed to create picture surface. (hr=0x%lx)", hr);
>> -        return VLC_EGENERIC;
>> -    }
>> +    if ( fmt->i_chroma != VLC_CODEC_D3D9_OPAQUE )
>
> Most of the code that follow seems to be just a reindentation, in this

Yes

> case, until the end of function,
> Why not do if ( fmt->i_chroma == VLC_CODEC_D3D9_OPAQUE ) return; ?

OK

>>      /* Copy picture surface into texture surface
>>       * color space conversion happen here */
>> -    RECT cropSource;
>> -    cropSource.left = 0;
>> -    cropSource.top = 0;
>> -    cropSource.right = vd->fmt.i_visible_width;
>> -    cropSource.bottom = vd->fmt.i_visible_height;
>> -    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &cropSource, destination, NULL, D3DTEXF_LINEAR);
>> +    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, NULL, destination, NULL, D3DTEXF_LINEAR);
>
> Why don't you need the crop anymore?


I checked what the code was doing before and the D3D9 surface passed
(coming from the display pool) had the visible dimensions, not the
codec one. So I did the same with the DXVA decoder pool (the vout one,
not the internal codec one).



More information about the vlc-devel mailing list