2 * DXVA2 HW acceleration
4 * copyright (c) 2010 Laurent Aimar
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVCODEC_DXVA2_INTERNAL_H
24 #define AVCODEC_DXVA2_INTERNAL_H
30 /* define the proper COM entries before forcing desktop APIs */
41 /* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h
42 * defines nothing. Force the struct definitions to be visible. */
44 #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
45 #undef _CRT_BUILD_DESKTOP_APP
46 #define _CRT_BUILD_DESKTOP_APP 0
52 typedef void DECODER_BUFFER_DESC;
56 struct AVD3D11VAContext d3d11va;
59 struct dxva_context dxva2;
64 #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
67 #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
70 #if CONFIG_D3D11VA && CONFIG_DXVA2
71 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround)
72 #define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
73 #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
74 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
75 #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
76 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
77 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
78 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
79 #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \
80 DXVA_CONTEXT_CFG(avctx, ctx) && \
81 (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count))
83 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
84 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
85 #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder)
86 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id))
87 #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg)
88 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw)
89 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
90 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
91 #define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
93 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
94 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
95 #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder)
96 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id))
97 #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg)
98 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw)
99 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
100 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
101 #define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg)
104 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
105 const AVDXVAContext *,
106 const AVFrame *frame);
108 int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *,
109 DECODER_BUFFER_DESC *,
110 unsigned type, const void *data, unsigned size,
114 int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
115 const void *pp, unsigned pp_size,
116 const void *qm, unsigned qm_size,
117 int (*commit_bs_si)(AVCodecContext *,
118 DECODER_BUFFER_DESC *bs,
119 DECODER_BUFFER_DESC *slice));
121 #endif /* AVCODEC_DXVA2_INTERNAL_H */