[vlc-devel] [PATCH 27/31] avcodec: get the vlc_video_context created by the VA
Steve Lhomme
robux4 at ycbcr.xyz
Mon Sep 23 17:01:32 CEST 2019
For now they don't create one.
---
modules/codec/avcodec/d3d11va.c | 5 +++--
modules/codec/avcodec/dxva2.c | 5 +++--
modules/codec/avcodec/va.c | 7 ++++---
modules/codec/avcodec/va.h | 5 +++--
modules/codec/avcodec/vaapi.c | 3 ++-
modules/codec/avcodec/video.c | 6 ++++--
modules/hw/vdpau/avcodec.c | 3 ++-
7 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index a89f66f5c39..0e564e6afcf 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -56,7 +56,7 @@ typedef picture_sys_d3d11_t VA_PICSYS;
#include "directx_va.h"
static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
- const es_format_t *, vlc_decoder_device *);
+ const es_format_t *, vlc_decoder_device *, vlc_video_context **);
vlc_module_begin()
set_description(N_("Direct3D11 Video Acceleration"))
@@ -303,7 +303,8 @@ 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, enum PixelFormat pix_fmt,
- const es_format_t *fmt, vlc_decoder_device *dec_device)
+ const es_format_t *fmt, vlc_decoder_device *dec_device,
+ vlc_video_context **vtcx_out)
{
int err = VLC_EGENERIC;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 4c8cf03e15f..b13e339fc32 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -43,7 +43,7 @@ typedef picture_sys_d3d9_t VA_PICSYS;
#include "directx_va.h"
static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
- const es_format_t *, vlc_decoder_device *);
+ const es_format_t *, vlc_decoder_device *, vlc_video_context **);
vlc_module_begin()
set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
@@ -244,7 +244,8 @@ 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, enum PixelFormat pix_fmt,
- const es_format_t *fmt, vlc_decoder_device *dec_device)
+ const es_format_t *fmt, vlc_decoder_device *dec_device,
+ vlc_video_context **vtcx_out)
{
int err = VLC_EGENERIC;
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index ee7d5084e40..dbd9aa9d115 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -95,15 +95,16 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);
const es_format_t *fmt = va_arg(ap, const es_format_t *);
vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
+ vlc_video_context **vtcx_out = va_arg(ap, vlc_video_context **);
vlc_va_open open = func;
(void) forced;
- return open(va, ctx, pix_fmt, fmt, device);
+ return open(va, ctx, pix_fmt, fmt, device, vtcx_out);
}
vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
enum PixelFormat pix_fmt, const es_format_t *fmt,
- vlc_decoder_device *device)
+ vlc_decoder_device *device, vlc_video_context **vtcx_out)
{
struct vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
if (unlikely(va == NULL))
@@ -112,7 +113,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
char *modlist = var_InheritString(obj, "avcodec-hw");
if (vlc_module_load(va, "hw decoder", modlist, true,
- vlc_va_Start, va, avctx, pix_fmt, fmt, device) == NULL)
+ vlc_va_Start, va, avctx, pix_fmt, fmt, device, vtcx_out) == NULL)
{
vlc_object_delete(va);
va = NULL;
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 7c82facb23e..99a3812a549 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -28,6 +28,7 @@
typedef struct vlc_va_t vlc_va_t;
typedef struct vlc_va_sys_t vlc_va_sys_t;
typedef struct vlc_decoder_device vlc_decoder_device;
+typedef struct vlc_video_context vlc_video_context;
struct vlc_va_operations {
int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
@@ -42,7 +43,7 @@ struct vlc_va_t {
};
typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
- const es_format_t *, vlc_decoder_device *);
+ const es_format_t *, vlc_decoder_device *, vlc_video_context **);
#define set_va_callback(activate, priority) \
{ \
@@ -69,7 +70,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
*/
vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
enum PixelFormat, const es_format_t *fmt,
- vlc_decoder_device *device);
+ vlc_decoder_device *device, vlc_video_context **vtcx_out);
/**
* Get a hardware video surface for a libavcodec frame.
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index aa80cb85211..5402c5fc9dc 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -149,7 +149,8 @@ static void Delete(vlc_va_t *va)
static const struct vlc_va_operations ops = { Get, Delete, };
static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
- const es_format_t *fmt, vlc_decoder_device *dec_device)
+ const es_format_t *fmt, vlc_decoder_device *dec_device,
+ vlc_video_context **vtcx_out)
{
if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL)
return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 15284026a0f..0bf207dfb78 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1737,9 +1737,10 @@ no_reuse:
continue; /* Unsupported brand of hardware acceleration */
post_mt(p_sys);
+ vlc_video_context *vctx_out;
vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,
&p_dec->fmt_in,
- init_device);
+ init_device, &vctx_out);
if (init_device)
vlc_decoder_device_Release(init_device);
if (va == NULL)
@@ -1747,8 +1748,9 @@ no_reuse:
wait_mt(p_sys);
continue; /* Unsupported codec profile or such */
}
+ assert(vctx_out != NULL);
- if (decoder_UpdateVideoOutput(p_dec, NULL))
+ if (decoder_UpdateVideoOutput(p_dec, vctx_out))
{
vlc_va_Delete(va);
p_context->hwaccel_context = NULL;
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 31a5bd6e21e..839da61d01a 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -133,7 +133,8 @@ static void Close(vlc_va_t *va)
static const struct vlc_va_operations ops = { Lock, Close, };
static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
- const es_format_t *fmt, vlc_decoder_device *device)
+ const es_format_t *fmt, vlc_decoder_device *device,
+ vlc_video_context **vtcx_out)
{
if (pix_fmt != AV_PIX_FMT_VDPAU)
return VLC_EGENERIC;
--
2.17.1
More information about the vlc-devel
mailing list