[FFmpeg-devel] [PATCH 13/16] lavc: Remove old vaapi decode infrastructure
Mark Thompson
sw at jkqxz.net
Sun Jan 8 20:14:25 EET 2017
Deprecates struct vaapi_context and the installed header vaapi.h,
to be removed at the next version bump.
(cherry picked from commit 851960f6f8cf1f946fe42fa36cf6598fac68072c)
---
doc/APIchanges | 4 +++
libavcodec/Makefile | 5 ++-
libavcodec/vaapi.h | 11 +++++++
libavcodec/vaapi_decode.c | 78 ++++++++++++++++++++++++++++-------------------
libavcodec/vaapi_decode.h | 6 ++++
libavcodec/version.h | 5 ++-
6 files changed, 73 insertions(+), 36 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 3279563d47..33c2f33581 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2015-08-28
API changes, most recent first:
+2017-01-xx - xxxxxxx - lavc 57.72.100 - vaapi.h
+ Deprecate struct vaapi_context and the vaapi.h installed header.
+ Callers should set AVCodecContext.hw_frames_ctx instead.
+
2017-01-06 - xxxxxxx - lavf 57.62.100- avio.h
Add avio_get_dyn_buf()
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index bd4b2315da..70784b74fb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -769,7 +769,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcmenc.o adpcm_data.o
# hardware accelerators
OBJS-$(CONFIG_D3D11VA) += dxva2.o
OBJS-$(CONFIG_DXVA2) += dxva2.o
-OBJS-$(CONFIG_VAAPI) += vaapi.o vaapi_decode.o
+OBJS-$(CONFIG_VAAPI) += vaapi_decode.o
OBJS-$(CONFIG_VDA) += vda.o videotoolbox.o
OBJS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
@@ -1000,8 +1000,7 @@ SKIPHEADERS-$(CONFIG_QSV) += qsv.h qsv_internal.h
SKIPHEADERS-$(CONFIG_QSVDEC) += qsvdec.h
SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h
SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
-SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_encode.h \
- vaapi_internal.h
+SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_encode.h
SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_vt_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h
diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h
index 7a29f6f881..ab6110ba9c 100644
--- a/libavcodec/vaapi.h
+++ b/libavcodec/vaapi.h
@@ -34,6 +34,12 @@
#include "libavutil/attributes.h"
#include "version.h"
+#include "libavutil/attributes.h"
+
+#include "version.h"
+
+#if FF_API_STRUCT_VAAPI_CONTEXT
+
/**
* @defgroup lavc_codec_hwaccel_vaapi VA API Decoding
* @ingroup lavc_codec_hwaccel
@@ -48,7 +54,10 @@
* during initialization or through each AVCodecContext.get_buffer()
* function call. In any case, they must be valid prior to calling
* decoding functions.
+ *
+ * Deprecated: use AVCodecContext.hw_frames_ctx instead.
*/
+attribute_deprecated
struct vaapi_context {
/**
* Window system dependent data
@@ -186,4 +195,6 @@ struct vaapi_context {
/* @} */
+#endif /* FF_API_STRUCT_VAAPI_CONTEXT */
+
#endif /* AVCODEC_VAAPI_H */
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 878e8ed3d1..da9e4aedde 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -427,6 +427,7 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
ctx->va_config = VA_INVALID_ID;
ctx->va_context = VA_INVALID_ID;
+#if FF_API_STRUCT_VAAPI_CONTEXT
if (avctx->hwaccel_context) {
av_log(avctx, AV_LOG_WARNING, "Using deprecated struct "
"vaapi_context in decode.\n");
@@ -453,7 +454,9 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
ctx->hwctx->driver_quirks =
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS;
- } else if (avctx->hw_frames_ctx) {
+ } else
+#endif
+ if (avctx->hw_frames_ctx) {
// This structure has a shorter lifetime than the enclosing
// AVCodecContext, so we inherit the references from there
// and do not need to make separate ones.
@@ -471,6 +474,7 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
goto fail;
}
+#if FF_API_STRUCT_VAAPI_CONTEXT
if (ctx->have_old_context) {
ctx->va_config = ctx->old_context->config_id;
ctx->va_context = ctx->old_context->context_id;
@@ -478,27 +482,31 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "Using user-supplied decoder "
"context: %#x/%#x.\n", ctx->va_config, ctx->va_context);
} else {
- err = vaapi_decode_make_config(avctx);
- if (err)
- goto fail;
+#endif
- vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
- avctx->coded_width, avctx->coded_height,
- VA_PROGRESSIVE,
- ctx->hwfc->surface_ids,
- ctx->hwfc->nb_surfaces,
- &ctx->va_context);
- if (vas != VA_STATUS_SUCCESS) {
- av_log(avctx, AV_LOG_ERROR, "Failed to create decode "
- "context: %d (%s).\n", vas, vaErrorStr(vas));
- err = AVERROR(EIO);
- goto fail;
- }
+ err = vaapi_decode_make_config(avctx);
+ if (err)
+ goto fail;
- av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: "
- "%#x/%#x.\n", ctx->va_config, ctx->va_context);
+ vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
+ avctx->coded_width, avctx->coded_height,
+ VA_PROGRESSIVE,
+ ctx->hwfc->surface_ids,
+ ctx->hwfc->nb_surfaces,
+ &ctx->va_context);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to create decode "
+ "context: %d (%s).\n", vas, vaErrorStr(vas));
+ err = AVERROR(EIO);
+ goto fail;
}
+ av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: "
+ "%#x/%#x.\n", ctx->va_config, ctx->va_context);
+#if FF_API_STRUCT_VAAPI_CONTEXT
+ }
+#endif
+
return 0;
fail:
@@ -511,26 +519,32 @@ int ff_vaapi_decode_uninit(AVCodecContext *avctx)
VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data;
VAStatus vas;
+#if FF_API_STRUCT_VAAPI_CONTEXT
if (ctx->have_old_context) {
av_buffer_unref(&ctx->device_ref);
} else {
- if (ctx->va_context != VA_INVALID_ID) {
- vas = vaDestroyContext(ctx->hwctx->display, ctx->va_context);
- if (vas != VA_STATUS_SUCCESS) {
- av_log(avctx, AV_LOG_ERROR, "Failed to destroy decode "
- "context %#x: %d (%s).\n",
- ctx->va_context, vas, vaErrorStr(vas));
- }
+#endif
+
+ if (ctx->va_context != VA_INVALID_ID) {
+ vas = vaDestroyContext(ctx->hwctx->display, ctx->va_context);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to destroy decode "
+ "context %#x: %d (%s).\n",
+ ctx->va_context, vas, vaErrorStr(vas));
}
- if (ctx->va_config != VA_INVALID_ID) {
- vas = vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
- if (vas != VA_STATUS_SUCCESS) {
- av_log(avctx, AV_LOG_ERROR, "Failed to destroy decode "
- "configuration %#x: %d (%s).\n",
- ctx->va_config, vas, vaErrorStr(vas));
- }
+ }
+ if (ctx->va_config != VA_INVALID_ID) {
+ vas = vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to destroy decode "
+ "configuration %#x: %d (%s).\n",
+ ctx->va_config, vas, vaErrorStr(vas));
}
}
+#if FF_API_STRUCT_VAAPI_CONTEXT
+ }
+#endif
+
return 0;
}
diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h
index f1caa54eca..5ac3069ef3 100644
--- a/libavcodec/vaapi_decode.h
+++ b/libavcodec/vaapi_decode.h
@@ -26,7 +26,11 @@
#include "libavutil/hwcontext_vaapi.h"
#include "avcodec.h"
+
+#include "version.h"
+#if FF_API_STRUCT_VAAPI_CONTEXT
#include "vaapi.h"
+#endif
static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
{
@@ -54,9 +58,11 @@ typedef struct VAAPIDecodeContext {
VAConfigID va_config;
VAContextID va_context;
+#if FF_API_STRUCT_VAAPI_CONTEXT
int have_old_context;
struct vaapi_context *old_context;
AVBufferRef *device_ref;
+#endif
AVHWDeviceContext *device;
AVVAAPIDeviceContext *hwctx;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c5a8f55897..5008d50bae 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 71
+#define LIBAVCODEC_VERSION_MINOR 72
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -226,5 +226,8 @@
#ifndef FF_API_NVENC_OLD_NAME
#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_STRUCT_VAAPI_CONTEXT
+#define FF_API_STRUCT_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */
--
2.11.0
More information about the ffmpeg-devel
mailing list