<html><head></head><body>Hi,<br><br>Why does the decoder need to care? Isn't that a hassle for the RGB conversion shader rather than the decoding??<br><br><div class="gmail_quote">Le 4 octobre 2019 16:15:52 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">The codec profile alone doesn't always give information on the bit depth or<br>chroma subsampling (see HEVC Range Extension).<br><br>The pixel format description is read in the lavc module rather than each VA so<br>they don't have to link with libavutil.<hr> modules/codec/avcodec/d3d11va.c | 7 ++++---<br> modules/codec/avcodec/directx_va.c | 11 +++++++----<br> modules/codec/avcodec/directx_va.h | 3 ++-<br> modules/codec/avcodec/dxva2.c | 7 ++++---<br> modules/codec/avcodec/va.c | 8 +++++---<br> modules/codec/avcodec/va.h | 6 ++++--<br> modules/codec/avcodec/vaapi.c | 4 +++-<br> modules/codec/avcodec/video.c | 4 +++-<br> modules/hw/vdpau/avcodec.c | 4 +++-<br> 9 files changed, 35 insertions(+), 19 deletions(-)<br><br>diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c<br>index d6477cfaca2..c34430bed66 100644<br>--- a/modules/codec/avcodec/d3d11va.c<br>+++ b/modules/codec/avcodec/d3d11va.c<br>@@ -55,7 +55,7 @@ typedef picture_sys_d3d11_t VA_PICSYS;<br> <br> #include "directx_va.h"<br> <br>-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,<br>+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,<br> const es_format_t *, void *);<br> <br> vlc_module_begin()<br>@@ -302,7 +302,8 @@ static void Close(vlc_va_t *va)<br> <br> static const struct vlc_va_operations ops = { Get, Close, };<br> <br>-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,<br>+static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,<br>+ enum PixelFormat pix_fmt,<br> const es_format_t *fmt, void *picsys)<br> {<br> int err = VLC_EGENERIC;<br>@@ -383,7 +384,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,<br> <br> video_format_t fmt_out;<br> static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };<br>- err = directx_va_Setup(va, &dx_sys, ctx, fmt, isXboxHardware(sys->d3d_dev.d3ddevice), &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);<br>+ err = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, isXboxHardware(sys->d3d_dev.d3ddevice), &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);<br> if (err != VLC_SUCCESS)<br> goto error;<br> <br>diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c<br>index 9f6ce7520cc..51a729630d4 100644<br>--- a/modules/codec/avcodec/directx_va.c<br>+++ b/modules/codec/avcodec/directx_va.c<br>@@ -267,7 +267,8 @@ static const directx_va_mode_t DXVA_MODES[] = {<br> { NULL, NULL, 0, NULL }<br> };<br> <br>-static int FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out, const AVCodecContext *, GUID *found_guid);<br>+static int FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out,<br>+ const AVCodecContext *, const AVPixFmtDescriptor *, GUID *found_guid);<br> <br> char *directx_va_GetDecoderName(const GUID *guid)<br> {<br>@@ -283,7 +284,8 @@ char *directx_va_GetDecoderName(const GUID *guid)<br> }<br> <br> /* */<br>-int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys, const AVCodecContext *avctx,<br>+int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys,<br>+ const AVCodecContext *avctx, const AVPixFmtDescriptor *desc,<br> const es_format_t *fmt, int flag_xbox,<br> video_format_t *fmt_out, unsigned *surfaces, GUID *found_guid)<br> {<br>@@ -344,7 +346,7 @@ int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys, const AVCodecCon<br> fmt_out->i_frame_rate_base = avctx->framerate.den;<br> <br> /* */<br>- if (FindVideoServiceConversion(va, dx_sys, fmt, fmt_out, avctx, found_guid)) {<br>+ if (FindVideoServiceConversion(va, dx_sys, fmt, fmt_out, avctx, desc, found_guid)) {<br> msg_Err(va, "FindVideoServiceConversion failed");<br> return VLC_EGENERIC;<br> }<br>@@ -390,7 +392,8 @@ static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *<br> * Find the best suited decoder mode GUID and render format.<br> */<br> static int FindVideoServiceConversion(vlc_va_t *va, const directx_sys_t *dx_sys,<br>- const es_format_t *fmt, video_format_t *fmt_out, const AVCodecContext *avctx,<br>+ const es_format_t *fmt, video_format_t *fmt_out,<br>+ const AVCodecContext *avctx, const AVPixFmtDescriptor *desc,<br> GUID *found_guid)<br> {<br> input_list_t p_list = { 0 };<br>diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h<br>index 4e94a95a13a..e3cfea9e37c 100644<br>--- a/modules/codec/avcodec/directx_va.h<br>+++ b/modules/codec/avcodec/directx_va.h<br>@@ -64,7 +64,8 @@ typedef struct<br> <br> } directx_sys_t;<br> <br>-int directx_va_Setup(vlc_va_t *, const directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox,<br>+int directx_va_Setup(vlc_va_t *, const directx_sys_t *, const AVCodecContext *, const AVPixFmtDescriptor *,<br>+ const es_format_t *, int flag_xbox,<br> video_format_t *fmt_out, unsigned *surface_count, GUID *found_guid);<br> char *directx_va_GetDecoderName(const GUID *guid);<br> bool directx_va_canUseDecoder(vlc_va_t *, UINT VendorId, UINT DeviceId, const GUID *pCodec, UINT driverBuild);<br>diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c<br>index 24eb59415c3..68e8727e696 100644<br>--- a/modules/codec/avcodec/dxva2.c<br>+++ b/modules/codec/avcodec/dxva2.c<br>@@ -42,7 +42,7 @@ typedef picture_sys_d3d9_t VA_PICSYS;<br> <br> #include "directx_va.h"<br> <br>-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,<br>+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,<br> const es_format_t *, void *);<br> <br> vlc_module_begin()<br>@@ -243,7 +243,8 @@ static void Close(vlc_va_t *va)<br> <br> static const struct vlc_va_operations ops = { Get, Close, };<br> <br>-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,<br>+static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,<br>+ enum PixelFormat pix_fmt,<br> const es_format_t *fmt, void *picsys)<br> {<br> int err = VLC_EGENERIC;<br>@@ -309,7 +310,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,<br> <br> video_format_t fmt_out;<br> static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };<br>- err = directx_va_Setup(va, &dx_sys, ctx, fmt, 0, &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);<br>+ err = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, 0, &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);<br> if (err != VLC_SUCCESS)<br> goto error;<br> <br>diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c<br>index 7558b2b6874..ac4bd75db88 100644<br>--- a/modules/codec/avcodec/va.c<br>+++ b/modules/codec/avcodec/va.c<br>@@ -92,16 +92,18 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)<br> {<br> vlc_va_t *va = va_arg(ap, vlc_va_t *);<br> AVCodecContext *ctx = va_arg(ap, AVCodecContext *);<br>+ const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);<br> enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);<br> const es_format_t *fmt = va_arg(ap, const es_format_t *);<br> void *p_sys = va_arg(ap, void *);<br> vlc_va_open open = func;<br> <br> (void) forced;<br>- return open(va, ctx, pix_fmt, fmt, p_sys);<br>+ return open(va, ctx, src_desc, pix_fmt, fmt, p_sys);<br> }<br> <br>-vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,<br>+vlc_va_t *vlc_va_New(vlc_object_t *obj,<br>+ AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,<br> enum PixelFormat pix_fmt, const es_format_t *fmt,<br> void *sys)<br> {<br>@@ -112,7 +114,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,<br> char *modlist = var_InheritString(obj, "avcodec-hw");<br> <br> if (vlc_module_load(va, "hw decoder", modlist, true,<br>- vlc_va_Start, va, avctx, pix_fmt, fmt, sys) == NULL)<br>+ vlc_va_Start, va, avctx, src_desc, pix_fmt, fmt, sys) == NULL)<br> {<br> vlc_object_delete(va);<br> va = NULL;<br>diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h<br>index 3e6b827c8f2..7011124baaf 100644<br>--- a/modules/codec/avcodec/va.h<br>+++ b/modules/codec/avcodec/va.h<br>@@ -24,6 +24,7 @@<br> #define VLC_AVCODEC_VA_H 1<br> <br> #include "avcommon_compat.h"<br>+#include <libavutil/pixdesc.h><br> <br> typedef struct vlc_va_t vlc_va_t;<br> typedef struct vlc_va_sys_t vlc_va_sys_t;<br>@@ -40,7 +41,8 @@ struct vlc_va_t {<br> const struct vlc_va_operations *ops;<br> };<br> <br>-typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,<br>+typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,<br>+ enum PixelFormat,<br> const es_format_t *, void *);<br> <br> #define set_va_callback(activate, priority) \<br>@@ -66,7 +68,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);<br> * @param fmt VLC format of the content to decode<br> * @return a new VLC object on success, NULL on error.<br> */<br>-vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,<br>+vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,<br> enum PixelFormat, const es_format_t *fmt,<br> void *p_sys);<br> <br>diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c<br>index 7e8329bf888..be0a321b0e5 100644<br>--- a/modules/codec/avcodec/vaapi.c<br>+++ b/modules/codec/avcodec/vaapi.c<br>@@ -145,9 +145,11 @@ static void Delete(vlc_va_t *va)<br> <br> static const struct vlc_va_operations ops = { Get, Delete, };<br> <br>-static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,<br>+static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,<br>+ enum PixelFormat pix_fmt,<br> const es_format_t *fmt, void *p_sys)<br> {<br>+ VLC_UNUSED(desc);<br> if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || p_sys == NULL)<br> return VLC_EGENERIC;<br> <br>diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c<br>index d69abd7419c..b9fa684290f 100644<br>--- a/modules/codec/avcodec/video.c<br>+++ b/modules/codec/avcodec/video.c<br>@@ -1704,6 +1704,8 @@ no_reuse:<br> AV_PIX_FMT_NONE,<br> };<br> <br>+ const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(swfmt);<br>+<br> for( size_t i = 0; hwfmts[i] != AV_PIX_FMT_NONE; i++ )<br> {<br> enum PixelFormat hwfmt = AV_PIX_FMT_NONE;<br>@@ -1730,7 +1732,7 @@ no_reuse:<br> <br> picture_t *test_pic = decoder_NewPicture(p_dec);<br> assert(!test_pic || test_pic->format.i_chroma == p_dec->fmt_out.video.i_chroma);<br>- vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,<br>+ vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, src_desc, hwfmt,<br> &p_dec->fmt_in,<br> test_pic ? test_pic->p_sys : NULL);<br> if (test_pic)<br>diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c<br>index 599e86cc06e..e0b94ec55e5 100644<br>--- a/modules/hw/vdpau/avcodec.c<br>+++ b/modules/hw/vdpau/avcodec.c<br>@@ -132,7 +132,8 @@ static void Close(vlc_va_t *va)<br> <br> static const struct vlc_va_operations ops = { Lock, Close, };<br> <br>-static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,<br>+static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,<br>+ enum PixelFormat pix_fmt,<br> const es_format_t *fmt, void *p_sys)<br> {<br> if (pix_fmt != AV_PIX_FMT_VDPAU)<br>@@ -140,6 +141,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,<br> <br> (void) fmt;<br> (void) p_sys;<br>+ (void) desc;<br> void *func;<br> VdpStatus err;<br> VdpChromaType type;</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>