[vlc-devel] [PATCH 06/16] avcodec: va: don't allocate pictures in the VA
Steve Lhomme
robux4 at ycbcr.xyz
Thu Oct 24 16:20:20 CEST 2019
In the end each VA module just needs to set the picture_context_t on the
outgoing picture. It doesn't need to allocate the picture itself for now.
The picture_context_t has destroy and copy callbacks which allow for
refcounting and detroying the resources when really not needed anymore.
Effectively reverts 2e4cd8756db3b396ddedbd7d622ebd67122a34e0.
---
modules/codec/avcodec/d3d11va.c | 2 +-
modules/codec/avcodec/dxva2.c | 2 +-
modules/codec/avcodec/va.h | 11 -----------
modules/codec/avcodec/vaapi.c | 2 +-
modules/codec/avcodec/video.c | 4 +---
modules/hw/vdpau/avcodec.c | 2 +-
6 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index a157c4c1e1b..70fc90f1f48 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -247,7 +247,7 @@ static void Close(vlc_va_t *va)
va_pool_Close(sys->va_pool);
}
-static const struct vlc_va_operations ops = { Get, NULL, Close, };
+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,
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index aa9a8abf31c..6e661a07076 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -245,7 +245,7 @@ static void Close(vlc_va_t *va)
va_pool_Close(sys->va_pool);
}
-static const struct vlc_va_operations ops = { Get, NULL, Close, };
+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,
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index d139d608b87..b10cab7e0be 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -33,7 +33,6 @@ typedef struct vlc_video_context vlc_video_context;
struct vlc_va_operations {
int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
- picture_t *(*get_picture)(vlc_va_t *, const video_format_t *);
void (*close)(vlc_va_t *);
};
@@ -98,16 +97,6 @@ static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, uint8_t **surface)
return va->ops->get(va, pic, surface);
}
-/**
- * Can be called from any thread
- */
-static inline picture_t *vlc_va_GetPicture(vlc_va_t *va, const video_format_t *fmt)
-{
- if (va->ops->get_picture)
- return va->ops->get_picture(va, fmt);
- return NULL;
-}
-
/**
* Destroys a libavcodec hardware acceleration back-end.
* All allocated surfaces shall have been released beforehand.
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 0c12d190205..c0049c814e0 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -182,7 +182,7 @@ static void Delete(vlc_va_t *va)
va_pool_Close(sys->va_pool);
}
-static const struct vlc_va_operations ops = { Get, NULL, Delete, };
+static const struct vlc_va_operations ops = { Get, Delete, };
static int VAAPICreateDevice(vlc_va_t *va)
{
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d1d331800e9..a6aff927889 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1472,9 +1472,7 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame)
vlc_va_t *va = p_sys->p_va;
picture_t *pic;
- pic = vlc_va_GetPicture(va, &dec->fmt_out.video);
- if (pic == NULL)
- pic = decoder_NewPicture(dec);
+ pic = decoder_NewPicture(dec);
if (pic == NULL)
return -1;
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 24c79d10201..3c43fcd74a9 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -133,7 +133,7 @@ static void Close(vlc_va_t *va)
free(sys);
}
-static const struct vlc_va_operations ops = { Lock, NULL, Close, };
+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,
--
2.17.1
More information about the vlc-devel
mailing list