FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dxva2_internal.h
Go to the documentation of this file.
1 /*
2  * DXVA2 HW acceleration
3  *
4  * copyright (c) 2010 Laurent Aimar
5  *
6  * This file is part of FFmpeg.
7  *
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.
12  *
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.
17  *
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
21  */
22 
23 #ifndef AVCODEC_DXVA2_INTERNAL_H
24 #define AVCODEC_DXVA2_INTERNAL_H
25 
26 #define COBJMACROS
27 
28 #include "config.h"
29 
30 /* define the proper COM entries before forcing desktop APIs */
31 #include <objbase.h>
32 
33 #if CONFIG_DXVA2
34 #include "dxva2.h"
35 #endif
36 #if CONFIG_D3D11VA
37 #include "d3d11va.h"
38 #endif
39 
40 #if HAVE_DXVA_H
41 /* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h
42  * defines nothing. Force the struct definitions to be visible. */
43 #undef WINAPI_FAMILY
44 #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
45 #undef _CRT_BUILD_DESKTOP_APP
46 #define _CRT_BUILD_DESKTOP_APP 0
47 #include <dxva.h>
48 #endif
49 
50 #include "avcodec.h"
51 
52 typedef void DECODER_BUFFER_DESC;
53 
54 typedef union {
55 #if CONFIG_D3D11VA
56  struct AVD3D11VAContext d3d11va;
57 #endif
58 #if CONFIG_DXVA2
59  struct dxva_context dxva2;
60 #endif
62 
63 #if CONFIG_D3D11VA
64 #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
65 #endif
66 #if CONFIG_DXVA2
67 #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
68 #endif
69 
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_SURFACE(avctx, ctx, i) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i])
74 #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
75 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
76 #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
77 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
78 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
79 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
80 #elif CONFIG_DXVA2
81 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
82 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
83 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->dxva2.surface[i])
84 #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder)
85 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id))
86 #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg)
87 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw)
88 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
89 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
90 #elif CONFIG_D3D11VA
91 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
92 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
93 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->d3d11va.surface[i])
94 #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder)
95 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id))
96 #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg)
97 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw)
98 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
99 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
100 #endif
101 
102 void *ff_dxva2_get_surface(const AVFrame *frame);
103 
104 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
105  const AVDXVAContext *,
106  const AVFrame *frame);
107 
110  unsigned type, const void *data, unsigned size,
111  unsigned mb_count);
112 
113 
115  const void *pp, unsigned pp_size,
116  const void *qm, unsigned qm_size,
117  int (*commit_bs_si)(AVCodecContext *,
119  DECODER_BUFFER_DESC *slice));
120 
121 #endif /* AVCODEC_DXVA2_INTERNAL_H */
This structure is used to provides the necessary configurations and data to the Direct3D11 FFmpeg HWA...
Definition: d3d11va.h:59
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *, DECODER_BUFFER_DESC *, unsigned type, const void *data, unsigned size, unsigned mb_count)
Definition: dxva2.c:52
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
Public libavcodec D3D11VA header.
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *, const AVFrame *frame)
Definition: dxva2.c:37
int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice))
Definition: dxva2.c:125
static AVFrame * frame
void * ff_dxva2_get_surface(const AVFrame *frame)
Definition: dxva2.c:32
ptrdiff_t size
Definition: opengl_enc.c:101
Public libavcodec DXVA2 header.
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1649
GLint GLenum type
Definition: opengl_enc.c:105
void DECODER_BUFFER_DESC
This structure is used to provides the necessary configurations and data to the DXVA2 FFmpeg HWAccel ...
Definition: dxva2.h:57