[vlc-commits] avcodec: get the vlc_video_context created by the VA
Steve Lhomme
git at videolan.org
Fri Oct 18 09:47:21 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep 23 16:50:42 2019 +0200| [1798f25add0dae0fc7c3be5e0aca179af0ba9218] | committer: Steve Lhomme
avcodec: get the vlc_video_context created by the VA
For now they don't create one.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1798f25add0dae0fc7c3be5e0aca179af0ba9218
---
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 | 15 +++++++--------
modules/hw/vdpau/avcodec.c | 3 ++-
7 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 9d4fb2fbc8..aef8db5552 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -62,7 +62,7 @@ struct d3d11va_pic_context
#include "directx_va.h"
static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, 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"))
@@ -317,7 +317,8 @@ static const struct vlc_va_operations ops = { Get, Close, };
static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
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 ad53b44764..97b3fbba67 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 *, 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"))
@@ -255,7 +255,8 @@ static const struct vlc_va_operations ops = { Get, Close, };
static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
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 af73b1b7d2..634f0f0e28 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -103,16 +103,17 @@ 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, src_desc, pix_fmt, fmt, device);
+ return open(va, ctx, src_desc, pix_fmt, fmt, device, vtcx_out);
}
vlc_va_t *vlc_va_New(vlc_object_t *obj,
AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,
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))
@@ -121,7 +122,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj,
char *modlist = var_InheritString(obj, "avcodec-hw");
if (vlc_module_load(va, "hw decoder", modlist, true,
- vlc_va_Start, va, avctx, src_desc, pix_fmt, fmt, device) == NULL)
+ vlc_va_Start, va, avctx, src_desc, 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 5031b2b55a..b10cab7e0b 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -29,6 +29,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);
@@ -44,7 +45,7 @@ struct vlc_va_t {
typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
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) \
{ \
@@ -71,7 +72,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
*/
vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,
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 f8110d656d..ef003cf381 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -148,7 +148,8 @@ static const struct vlc_va_operations ops = { Get, Delete, };
static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
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)
{
VLC_UNUSED(desc);
if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL ||
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 1e1da6e96c..0c0b539cdc 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -368,13 +368,10 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
dec->fmt_out.video.mastering = dec->fmt_in.video.mastering;
dec->fmt_out.video.lighting = dec->fmt_in.video.lighting;
- vlc_decoder_device *dec_dev = decoder_GetDecoderDevice(dec);
- if (dec_dev)
+ if (pp_dec_device)
{
- if (pp_dec_device)
- *pp_dec_device = dec_dev;
- else
- vlc_decoder_device_Release(dec_dev);
+ *pp_dec_device = decoder_GetDecoderDevice(dec);
+ return *pp_dec_device == NULL;
}
return 0;
}
@@ -1749,16 +1746,18 @@ no_reuse:
continue; /* Unsupported brand of hardware acceleration */
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, hwfmt,
&p_dec->fmt_in,
- init_device);
+ init_device, &vctx_out);
if (init_device)
vlc_decoder_device_Release(init_device);
vlc_mutex_lock(&p_sys->lock);
if (va == NULL)
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 0f6a50f1ff..b42075d4ba 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -135,7 +135,8 @@ static const struct vlc_va_operations ops = { Lock, Close, };
static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
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_VDPAU|| dec_device == NULL ||
dec_device->type != VLC_DECODER_DEVICE_VDPAU)
More information about the vlc-commits
mailing list