summaryrefslogtreecommitdiff
path: root/libavcodec/dxva2_internal.h
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2017-06-07 17:11:17 +0200
committerDiego Biurrun <diego@biurrun.de>2017-06-08 21:20:18 +0200
commitf9e7a2f95a7194a8736cc1416a03a1a0155a3e9f (patch)
tree838be3f83c9fe4cc5a4be77cc51bc38bac134120 /libavcodec/dxva2_internal.h
parent831cfe10b40414915fe7b6088158421fe02e2b2d (diff)
dxva: add support for new dxva2 and d3d11 hwaccel APIs
This also adds support to avconv (which is trivial due to the new hwaccel API being generic enough). The new decoder setup code in dxva2.c is significantly based on work by Steve Lhomme <robux4@gmail.com>, but with heavy changes/rewrites. Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavcodec/dxva2_internal.h')
-rw-r--r--libavcodec/dxva2_internal.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index af0d607487..901cc11144 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -32,9 +32,11 @@
#if CONFIG_DXVA2
#include "dxva2.h"
+#include "libavutil/hwcontext_dxva2.h"
#endif
#if CONFIG_D3D11VA
#include "d3d11va.h"
+#include "libavutil/hwcontext_d3d11va.h"
#endif
#if HAVE_DXVA_H
/* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h
@@ -46,7 +48,10 @@
#include <dxva.h>
#endif
+#include "libavutil/hwcontext.h"
+
#include "avcodec.h"
+#include "internal.h"
typedef void DECODER_BUFFER_DESC;
@@ -59,7 +64,39 @@ typedef union {
#endif
} AVDXVAContext;
-#define DXVA_CONTEXT(avctx) ((AVDXVAContext *)(avctx)->hwaccel_context)
+typedef struct FFDXVASharedContext {
+ AVBufferRef *decoder_ref;
+
+ // FF_DXVA2_WORKAROUND_* flags
+ uint64_t workaround;
+
+ // E.g. AV_PIX_FMT_D3D11 (same as AVCodecContext.pix_fmt, except during init)
+ enum AVPixelFormat pix_fmt;
+
+ AVHWDeviceContext *device_ctx;
+
+#if CONFIG_D3D11VA
+ ID3D11VideoDecoder *d3d11_decoder;
+ D3D11_VIDEO_DECODER_CONFIG d3d11_config;
+ ID3D11VideoDecoderOutputView **d3d11_views;
+ int nb_d3d11_views;
+ ID3D11Texture2D *d3d11_texture;
+#endif
+
+#if CONFIG_DXVA2
+ IDirectXVideoDecoder *dxva2_decoder;
+ IDirectXVideoDecoderService *dxva2_service;
+ DXVA2_ConfigPictureDecode dxva2_config;
+#endif
+
+ // Legacy (but used by code outside of setup)
+ // In generic mode, DXVA_CONTEXT() will return a pointer to this.
+ AVDXVAContext ctx;
+} FFDXVASharedContext;
+
+#define DXVA_SHARED_CONTEXT(avctx) ((FFDXVASharedContext *)((avctx)->internal->hwaccel_priv_data))
+
+#define DXVA_CONTEXT(avctx) (AVDXVAContext *)((avctx)->hwaccel_context ? (avctx)->hwaccel_context : (&(DXVA_SHARED_CONTEXT(avctx)->ctx)))
#define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
#define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
@@ -115,6 +152,10 @@ int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
DECODER_BUFFER_DESC *bs,
DECODER_BUFFER_DESC *slice));
+int ff_dxva2_decode_init(AVCodecContext *avctx);
+
+int ff_dxva2_decode_uninit(AVCodecContext *avctx);
+
int ff_dxva2_is_d3d11(const AVCodecContext *avctx);
#endif /* AVCODEC_DXVA2_INTERNAL_H */