[vlc-devel] [PATCH 03/10] avcodec: va: pass the hardware lavc format to the module
Steve Lhomme
robux4 at ycbcr.xyz
Wed Dec 18 15:53:06 CET 2019
So it can tell if it's the proper module for the job. Rather than relying on a
guessed format from the generic va code.
---
modules/codec/avcodec/d3d11va.c | 7 +++----
modules/codec/avcodec/dxva2.c | 7 +++----
modules/codec/avcodec/va.c | 9 +++++----
modules/codec/avcodec/va.h | 6 ++++--
modules/codec/avcodec/vaapi.c | 5 ++---
modules/codec/avcodec/video.c | 2 +-
modules/hw/vdpau/avcodec.c | 7 ++-----
7 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index cc0385fcbdd..b130d4b081f 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -61,7 +61,7 @@ struct d3d11va_pic_context
#include "directx_va.h"
-static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
+static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
vlc_module_begin()
@@ -247,7 +247,7 @@ static void Close(vlc_va_t *va)
static const struct vlc_va_operations ops = { Get, Close, };
-static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
const es_format_t *fmt_in, vlc_decoder_device *dec_device,
video_format_t *fmt_out, vlc_video_context **vtcx_out)
{
@@ -255,8 +255,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
ctx->hwaccel_context = NULL;
- if ( fmt_out->i_chroma != VLC_CODEC_D3D11_OPAQUE &&
- fmt_out->i_chroma != VLC_CODEC_D3D11_OPAQUE_10B )
+ if ( hwfmt != AV_PIX_FMT_D3D11VA_VLD )
return VLC_EGENERIC;
d3d11_decoder_device_t *d3d11_device = GetD3D11OpaqueDevice( dec_device );
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 16f8f5714cc..a6e3f1ae471 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -49,7 +49,7 @@ struct dxva2_pic_context
#include "directx_va.h"
-static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
+static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
vlc_module_begin()
@@ -250,14 +250,13 @@ static void Close(vlc_va_t *va)
static const struct vlc_va_operations ops = { Get, Close, };
-static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
const es_format_t *fmt_in, vlc_decoder_device *dec_device,
video_format_t *fmt_out, vlc_video_context **vtcx_out)
{
int err = VLC_EGENERIC;
- if ( fmt_out->i_chroma != VLC_CODEC_D3D9_OPAQUE &&
- fmt_out->i_chroma != VLC_CODEC_D3D9_OPAQUE_10B )
+ if ( hwfmt != AV_PIX_FMT_DXVA2_VLD )
return VLC_EGENERIC;
d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueDevice( dec_device );
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index f045304efb5..46ff25814c7 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -156,6 +156,7 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
{
vlc_va_t *va = va_arg(ap, vlc_va_t *);
AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
+ enum PixelFormat hwfmt = va_arg(ap, enum PixelFormat);
const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);
const es_format_t *fmt_in = va_arg(ap, const es_format_t *);
vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
@@ -164,11 +165,11 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
vlc_va_open open = func;
(void) forced;
- return open(va, ctx, src_desc, fmt_in, device, fmt_out, vtcx_out);
+ return open(va, ctx, hwfmt, src_desc, fmt_in, device, fmt_out, vtcx_out);
}
-vlc_va_t *vlc_va_New(vlc_object_t *obj,
- AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,
+vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
+ enum PixelFormat hwfmt, const AVPixFmtDescriptor *src_desc,
const es_format_t *fmt_in, vlc_decoder_device *device,
video_format_t *fmt_out, vlc_video_context **vtcx_out)
{
@@ -178,7 +179,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj,
if (vlc_module_load(va, "hw decoder", NULL, true,
- vlc_va_Start, va, avctx, src_desc, fmt_in, device,
+ vlc_va_Start, va, avctx, hwfmt, src_desc, fmt_in, device,
fmt_out, vtcx_out) == NULL)
{
vlc_object_delete(va);
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 8ef429f4f96..5cec3c92852 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -43,7 +43,8 @@ struct vlc_va_t {
const struct vlc_va_operations *ops;
};
-typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
+typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *,
+ enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
const es_format_t *, vlc_decoder_device *,
video_format_t *, vlc_video_context **);
@@ -79,7 +80,8 @@ bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt);
* @param fmt VLC format of the content to decode
* @return a new VLC object on success, NULL on error.
*/
-vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,
+vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
+ enum PixelFormat hwfmt, const AVPixFmtDescriptor *,
const es_format_t *fmt, vlc_decoder_device *device,
video_format_t *, vlc_video_context **vtcx_out);
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index afe77d97c35..530f0b98225 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -237,13 +237,12 @@ static void VAAPISetupAVCodecContext(void *opaque, AVCodecContext *avctx)
avctx->hwaccel_context = &sys->hw_ctx;
}
-static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
const es_format_t *fmt_in, vlc_decoder_device *dec_device,
video_format_t *fmt_out, vlc_video_context **vtcx_out)
{
VLC_UNUSED(desc);
- if ( (fmt_out->i_chroma != VLC_CODEC_VAAPI_420 &&
- fmt_out->i_chroma != VLC_CODEC_VAAPI_420_10BPP) || dec_device == NULL ||
+ if ( hwfmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL ||
dec_device->type != VLC_DECODER_DEVICE_VAAPI)
return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 570b5dcdfe7..ddd8bbc1e24 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1753,7 +1753,7 @@ no_reuse:
vlc_mutex_unlock(&p_sys->lock);
vlc_video_context *vctx_out;
- vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, src_desc,
+ vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt, src_desc,
&p_dec->fmt_in, init_device,
&p_dec->fmt_out.video, &vctx_out);
if (init_device)
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 473caa090fa..16ce987d0af 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -150,14 +150,11 @@ const struct vlc_video_context_operations vdpau_vctx_ops = {
DestroyVDPAUVideoContext,
};
-static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
+static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat hwfmt, const AVPixFmtDescriptor *desc,
const es_format_t *fmt_in, vlc_decoder_device *dec_device,
video_format_t *fmt_out, vlc_video_context **vtcx_out)
{
- if ( ( fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_420 &&
- fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_422 &&
- fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_444 ) ||
- GetVDPAUOpaqueDevice(dec_device) == NULL)
+ if ( hwfmt != AV_PIX_FMT_VDPAU || GetVDPAUOpaqueDevice(dec_device) == NULL)
return VLC_EGENERIC;
(void) fmt_in;
--
2.17.1
More information about the vlc-devel
mailing list