+typedef struct
+{
+ const char *name;
+ D3DFORMAT format; /* D3D format */
+ vlc_fourcc_t fourcc; /* VLC fourcc */
+ uint32_t rmask;
+ uint32_t gmask;
+ uint32_t bmask;
+} d3d_format_t;
+
+static const d3d_format_t d3d_formats[] = {
+ /* YV12 is always used for planar 420, the planes are then swapped in Lock() */
+ { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_YV12, 0,0,0 },
+ { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_I420, 0,0,0 },
+ { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_J420, 0,0,0 },
+ { "UYVY", D3DFMT_UYVY, VLC_CODEC_UYVY, 0,0,0 },
+ { "YUY2", D3DFMT_YUY2, VLC_CODEC_YUYV, 0,0,0 },
+ { "X8R8G8B8", D3DFMT_X8R8G8B8,VLC_CODEC_RGB32, 0xff0000, 0x00ff00, 0x0000ff },
+ { "A8R8G8B8", D3DFMT_A8R8G8B8,VLC_CODEC_RGB32, 0xff0000, 0x00ff00, 0x0000ff },
+ { "8G8B8", D3DFMT_R8G8B8, VLC_CODEC_RGB24, 0xff0000, 0x00ff00, 0x0000ff },
+ { "R5G6B5", D3DFMT_R5G6B5, VLC_CODEC_RGB16, 0x1f<<11, 0x3f<<5, 0x1f<<0 },
+ { "X1R5G5B5", D3DFMT_X1R5G5B5,VLC_CODEC_RGB15, 0x1f<<10, 0x1f<<5, 0x1f<<0 },
+
+ { NULL, 0, 0, 0,0,0}
+};
+
+/**
+ * It returns the format (closest to chroma) that can be converted to target */
+static const d3d_format_t *Direct3DFindFormat(vout_display_t *vd, vlc_fourcc_t chroma, D3DFORMAT target)
+{
+ vout_display_sys_t *sys = vd->sys;