Commit 77742c75 authored by Steve Lhomme's avatar Steve Lhomme Committed by Michael Niedermayer

dxva2: use a single macro to test if the DXVA context is valid

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 367cac78
...@@ -450,9 +450,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, ...@@ -450,9 +450,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
AVDXVAContext *ctx = avctx->hwaccel_context; AVDXVAContext *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || if (!DXVA_CONTEXT_VALID(avctx, ctx))
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1; return -1;
assert(ctx_pic); assert(ctx_pic);
......
...@@ -364,9 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, ...@@ -364,9 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
AVDXVAContext *ctx = avctx->hwaccel_context; AVDXVAContext *ctx = avctx->hwaccel_context;
struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || if (!DXVA_CONTEXT_VALID(avctx, ctx))
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1; return -1;
av_assert0(ctx_pic); av_assert0(ctx_pic);
......
...@@ -76,6 +76,9 @@ typedef union { ...@@ -76,6 +76,9 @@ typedef union {
#define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
#define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
#define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
#define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \
DXVA_CONTEXT_CFG(avctx, ctx) && \
DXVA_CONTEXT_COUNT(avctx, ctx))
#elif CONFIG_DXVA2 #elif CONFIG_DXVA2
#define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
#define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
...@@ -85,6 +88,7 @@ typedef union { ...@@ -85,6 +88,7 @@ typedef union {
#define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw)
#define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
#define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
#elif CONFIG_D3D11VA #elif CONFIG_D3D11VA
#define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
#define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
...@@ -94,6 +98,7 @@ typedef union { ...@@ -94,6 +98,7 @@ typedef union {
#define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw)
#define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
#define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
#endif #endif
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
......
...@@ -262,9 +262,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, ...@@ -262,9 +262,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->hwaccel_picture_private; s->current_picture_ptr->hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || if (!DXVA_CONTEXT_VALID(avctx, ctx))
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1; return -1;
assert(ctx_pic); assert(ctx_pic);
......
...@@ -317,9 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, ...@@ -317,9 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
AVDXVAContext *ctx = avctx->hwaccel_context; AVDXVAContext *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || if (!DXVA_CONTEXT_VALID(avctx, ctx))
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1; return -1;
assert(ctx_pic); assert(ctx_pic);
......
...@@ -261,9 +261,7 @@ static int dxva2_vp9_start_frame(AVCodecContext *avctx, ...@@ -261,9 +261,7 @@ static int dxva2_vp9_start_frame(AVCodecContext *avctx,
AVDXVAContext *ctx = avctx->hwaccel_context; AVDXVAContext *ctx = avctx->hwaccel_context;
struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || if (!DXVA_CONTEXT_VALID(avctx, ctx))
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1; return -1;
av_assert0(ctx_pic); av_assert0(ctx_pic);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment