diff options
author | Steve Lhomme <robux4@gmail.com> | 2017-01-13 14:01:05 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-01-16 02:54:04 +0100 |
commit | 77742c75c5503c848447814a96f16abc6b9aa5f4 (patch) | |
tree | ceb6726437589c4b6b7a6fa24c0d533b22e34010 /libavcodec | |
parent | 367cac7827870054ae3bd6d4517e7b13f4f3f72c (diff) | |
download | ffmpeg-77742c75c5503c848447814a96f16abc6b9aa5f4.tar.gz |
dxva2: use a single macro to test if the DXVA context is valid
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/dxva2_h264.c | 4 | ||||
-rw-r--r-- | libavcodec/dxva2_hevc.c | 4 | ||||
-rw-r--r-- | libavcodec/dxva2_internal.h | 5 | ||||
-rw-r--r-- | libavcodec/dxva2_mpeg2.c | 4 | ||||
-rw-r--r-- | libavcodec/dxva2_vc1.c | 4 | ||||
-rw-r--r-- | libavcodec/dxva2_vp9.c | 4 |
6 files changed, 10 insertions, 15 deletions
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 82a772d38b..59fa5e3769 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -450,9 +450,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; - if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || - DXVA_CONTEXT_CFG(avctx, ctx) == NULL || - DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) + if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 5a312eaf23..981c8883ac 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -364,9 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; - if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || - DXVA_CONTEXT_CFG(avctx, ctx) == NULL || - DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) + if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; av_assert0(ctx_pic); diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index c962810238..e5322efd54 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -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_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_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ + DXVA_CONTEXT_CFG(avctx, ctx) && \ + DXVA_CONTEXT_COUNT(avctx, ctx)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -85,6 +88,7 @@ typedef union { #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_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 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) @@ -94,6 +98,7 @@ typedef union { #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_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index c2f0b58bee..14ac48f5ad 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -262,9 +262,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; - if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || - DXVA_CONTEXT_CFG(avctx, ctx) == NULL || - DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) + if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 36bf1bad77..cc97d7b6c6 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -317,9 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; - if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || - DXVA_CONTEXT_CFG(avctx, ctx) == NULL || - DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) + if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c index 0c4996c020..d53b32764a 100644 --- a/libavcodec/dxva2_vp9.c +++ b/libavcodec/dxva2_vp9.c @@ -261,9 +261,7 @@ static int dxva2_vp9_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; - if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || - DXVA_CONTEXT_CFG(avctx, ctx) == NULL || - DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) + if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; av_assert0(ctx_pic); |