[vlc-commits] [Git][videolan/vlc][master] 4 commits: d3d9_fmt: share the d3d9_format_t structure
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Oct 23 12:19:14 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
2e582357 by Steve Lhomme at 2023-10-23T13:58:41+02:00
d3d9_fmt: share the d3d9_format_t structure
- - - - -
56feea61 by Steve Lhomme at 2023-10-23T13:59:34+02:00
d3d9_fmt: map common D3DFORMAT values to matching VLC chromas
- - - - -
b8ff1cfc by Steve Lhomme at 2023-10-23T13:59:34+02:00
dxva2: use D3D9FormatFourcc to find matching D3DFORMAT
- - - - -
7d20112d by Steve Lhomme at 2023-10-23T13:59:34+02:00
direct3d9: fix parenthesis for NVIDIA range hack
There was a warning following 87f265b0dbdb7e08e0afcf7e8a7e22143724d7fe.
- - - - -
4 changed files:
- modules/codec/avcodec/dxva2.c
- modules/video_chroma/d3d9_fmt.c
- modules/video_chroma/d3d9_fmt.h
- modules/video_output/win32/direct3d9.c
Changes:
=====================================
modules/codec/avcodec/dxva2.c
=====================================
@@ -60,34 +60,6 @@ vlc_module_end()
/* */
-typedef struct {
- const char *name;
- D3DFORMAT format;
- vlc_fourcc_t codec;
-} d3d9_format_t;
-/* XXX Preferred format must come first */
-static const d3d9_format_t d3d_formats[] = {
- { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_YV12 },
- { "NV12", MAKEFOURCC('N','V','1','2'), VLC_CODEC_NV12 },
- //{ "IMC3", MAKEFOURCC('I','M','C','3'), VLC_CODEC_YV12 },
- { "P010", MAKEFOURCC('P','0','1','0'), VLC_CODEC_P010 },
- { "AYUV", MAKEFOURCC('A','Y','U','V'), VLC_CODEC_YUVA },
- { "YUY2", MAKEFOURCC('Y','U','Y','2'), VLC_CODEC_YUYV },
- { "Y410", MAKEFOURCC('Y','4','1','0'), VLC_CODEC_Y410 },
- { "Y210", MAKEFOURCC('Y','2','1','0'), VLC_CODEC_Y210 },
-
- { NULL, 0, 0 }
-};
-
-static const d3d9_format_t *D3dFindFormat(D3DFORMAT format)
-{
- for (unsigned i = 0; d3d_formats[i].name; i++) {
- if (d3d_formats[i].format == format)
- return &d3d_formats[i];
- }
- return NULL;
-}
-
typedef struct
{
/* Direct3D */
@@ -440,7 +412,7 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
for (unsigned j = 0; j < output_count; j++) {
const D3DFORMAT f = output_list[j];
- const d3d9_format_t *format = D3dFindFormat(f);
+ const d3d9_format_t *format = D3D9FormatFourcc(f);
if (format) {
msg_Dbg(va, "%s is supported for output", format->name);
} else {
@@ -470,24 +442,20 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
/* */
for (unsigned pass = 0; pass < 2 && err != VLC_SUCCESS; ++pass)
{
- for (unsigned j = 0; d3d_formats[j].name; j++) {
- const d3d9_format_t *format = &d3d_formats[j];
-
- /* */
- bool is_supported = false;
- for (unsigned k = 0; !is_supported && k < output_count; k++) {
- is_supported = format->format == output_list[k];
- }
- if (!is_supported)
- continue;
- if (pass == 0 && format->format != preferredOutput)
+ for (unsigned k = 0; k < output_count; k++)
+ {
+ if (pass == 0 && output_list[k] != preferredOutput)
continue;
- /* We have our solution */
- msg_Dbg(va, "Using decoder output '%s'", format->name);
- sys->render = format->format;
- err = VLC_SUCCESS;
- break;
+ const d3d9_format_t *format = D3D9FormatFourcc(output_list[k]);
+ if (format != NULL)
+ {
+ /* We have our solution */
+ msg_Dbg(va, "Using decoder output '%s'", format->name);
+ sys->render = format->format;
+ err = VLC_SUCCESS;
+ break;
+ }
}
}
CoTaskMemFree(output_list);
=====================================
modules/video_chroma/d3d9_fmt.c
=====================================
@@ -332,3 +332,32 @@ picture_context_t *d3d9_pic_context_copy(picture_context_t *ctx)
AcquireD3D9PictureSys(&pic_ctx->picsys);
return &pic_ctx->s;
}
+
+/* XXX Preferred format must come first */
+static const d3d9_format_t d3d_formats[] = {
+ { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_YV12 },
+ { "NV12", MAKEFOURCC('N','V','1','2'), VLC_CODEC_NV12 },
+ //{ "IMC3", MAKEFOURCC('I','M','C','3'), VLC_CODEC_YV12 },
+ { "P010", MAKEFOURCC('P','0','1','0'), VLC_CODEC_P010 },
+ { "AYUV", MAKEFOURCC('A','Y','U','V'), VLC_CODEC_YUVA },
+ { "YUY2", MAKEFOURCC('Y','U','Y','2'), VLC_CODEC_YUYV },
+ { "Y410", MAKEFOURCC('Y','4','1','0'), VLC_CODEC_Y410 },
+ { "Y210", MAKEFOURCC('Y','2','1','0'), VLC_CODEC_Y210 },
+ { "UYVY", D3DFMT_UYVY, VLC_CODEC_UYVY },
+ { "YUY2", D3DFMT_YUY2, VLC_CODEC_YUYV },
+ { "X8R8G8B8", D3DFMT_X8R8G8B8, VLC_CODEC_BGRX },
+ { "A8R8G8B8", D3DFMT_A8R8G8B8, VLC_CODEC_BGRA },
+ { "R8G8B8", D3DFMT_R8G8B8, VLC_CODEC_BGR24 },
+ { "R5G6B5", D3DFMT_R5G6B5, VLC_CODEC_RGB565LE },
+ { "X1R5G5B5", D3DFMT_X1R5G5B5, VLC_CODEC_RGB555LE },
+};
+
+const d3d9_format_t *D3D9FormatFourcc(D3DFORMAT d3dfmt)
+{
+ for (size_t i = 0; i < ARRAY_SIZE(d3d_formats); i++)
+ {
+ if (d3d_formats[i].format == d3dfmt)
+ return &d3d_formats[i];
+ }
+ return NULL;
+}
=====================================
modules/video_chroma/d3d9_fmt.h
=====================================
@@ -144,4 +144,12 @@ int D3D9_ResetDevice(vlc_object_t *, d3d9_decoder_device_t *);
void d3d9_pic_context_destroy(picture_context_t *);
picture_context_t *d3d9_pic_context_copy(picture_context_t *);
+typedef struct {
+ const char *name;
+ D3DFORMAT format;
+ vlc_fourcc_t vlc_chroma;
+} d3d9_format_t;
+
+const d3d9_format_t *D3D9FormatFourcc(D3DFORMAT);
+
#endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */
=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -119,13 +119,6 @@ static const vlc_fourcc_t d3d_subpicture_chromas[] = {
0
};
-typedef struct
-{
- const char *name;
- D3DFORMAT format; /* D3D format */
- vlc_fourcc_t fourcc; /* VLC fourcc */
-} d3d9_format_t;
-
typedef struct vout_display_sys_t
{
display_win32_area_t area;
@@ -1397,7 +1390,7 @@ static const d3d9_format_t *Direct3DFindFormat(vout_display_t *vd, const video_f
for (unsigned j = 0; d3d_formats[j].name; j++) {
const d3d9_format_t *format = &d3d_formats[j];
- if (format->fourcc != list[i])
+ if (format->vlc_chroma != list[i])
continue;
if (decoder_format != D3DFMT_UNKNOWN && format->format != decoder_format)
continue; // not the Hardware format we prefer
@@ -1634,8 +1627,8 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt, vlc_video_cont
bool force_dxva_hd = var_InheritBool(vd, "direct3d9-dxvahd");
if (force_dxva_hd || (dst_format && vd->source->color_range != COLOR_RANGE_FULL &&
- sys->d3d9_device->d3ddev.identifier.VendorId == GPU_MANUFACTURER_NVIDIA) &&
- !vlc_fourcc_IsYUV(dst_format->fourcc) && vlc_fourcc_IsYUV(d3dfmt->fourcc))
+ sys->d3d9_device->d3ddev.identifier.VendorId == GPU_MANUFACTURER_NVIDIA &&
+ !vlc_fourcc_IsYUV(dst_format->vlc_chroma) && vlc_fourcc_IsYUV(d3dfmt->vlc_chroma)))
{
// NVIDIA bug, YUV to RGB internal conversion in StretchRect always converts from limited to limited range
msg_Dbg(vd, "init DXVA-HD processor from %s to %s", d3dfmt->name, dst_format?dst_format->name:"unknown");
@@ -1660,7 +1653,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt, vlc_video_cont
/* */
*fmt = *vd->source;
- fmt->i_chroma = d3dfmt->fourcc;
+ fmt->i_chroma = d3dfmt->vlc_chroma;
sys->sw_texture_fmt = d3dfmt;
if (Direct3D9CreateResources(vd, fmt)) {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/97e504e0e94fbb335648a6fb9c2885b92b204ad0...7d20112d56f8859d23c585622b71f5b98ba7c205
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/97e504e0e94fbb335648a6fb9c2885b92b204ad0...7d20112d56f8859d23c585622b71f5b98ba7c205
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list