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_DXVA_INTERNAL_H
24 #define AVCODEC_DXVA_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 #include "mpegvideo.h"
52 
53 typedef void DECODER_BUFFER_DESC;
54 
55 typedef union {
56 #if CONFIG_D3D11VA
57  struct AVD3D11VAContext d3d11va;
58 #endif
59 #if CONFIG_DXVA2
60  struct dxva_context dxva2;
61 #endif
63 
64 #if CONFIG_D3D11VA
65 #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
66 #endif
67 #if CONFIG_DXVA2
68 #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
69 #endif
70 
71 #if CONFIG_D3D11VA && CONFIG_DXVA2
72 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround)
73 #define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
74 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i])
75 #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
76 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
77 #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
78 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
79 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
80 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
81 #elif CONFIG_DXVA2
82 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
83 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
84 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->dxva2.surface[i])
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 #elif CONFIG_D3D11VA
92 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
93 #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
94 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->d3d11va.surface[i])
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 #endif
102 
103 void *ff_dxva2_get_surface(const AVFrame *frame);
104 
105 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
106  const AVDXVAContext *,
107  const AVFrame *frame);
108 
111  unsigned type, const void *data, unsigned size,
112  unsigned mb_count);
113 
114 
116  const void *pp, unsigned pp_size,
117  const void *qm, unsigned qm_size,
118  int (*commit_bs_si)(AVCodecContext *,
120  DECODER_BUFFER_DESC *slice));
121 
122 #endif /* AVCODEC_DXVA_INTERNAL_H */
This structure is used to provides the necessary configurations and data to the Direct3D11 FFmpeg HWA...
Definition: d3d11va.h:57
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *, DECODER_BUFFER_DESC *, unsigned type, const void *data, unsigned size, unsigned mb_count)
Definition: dxva2.c:53
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
mpegvideo header.
Public libavcodec D3D11VA header.
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *, const AVFrame *frame)
Definition: dxva2.c:38
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:126
static AVFrame * frame
void * ff_dxva2_get_surface(const AVFrame *frame)
Definition: dxva2.c:33
ptrdiff_t size
Definition: opengl_enc.c:101
Libavcodec external API header.
Public libavcodec DXVA2 header.
main external API structure.
Definition: avcodec.h:1502
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