]> git.sesse.net Git - ffmpeg/blob - libavcodec/dxva2_internal.h
Merge commit '72cebae0d981dde144340cf51f3c323f01e215e5'
[ffmpeg] / libavcodec / dxva2_internal.h
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 #include "dxva2.h"
31
32 #if CONFIG_D3D11VA
33 #include "d3d11va.h"
34 #endif
35
36 #if HAVE_DXVA_H
37 #include <dxva.h>
38 #endif
39
40 #include "avcodec.h"
41 #include "mpegvideo.h"
42
43 typedef void DECODER_BUFFER_DESC;
44
45 typedef union {
46 #if CONFIG_D3D11VA
47     struct AVD3D11VAContext  d3d11va;
48 #endif
49     struct dxva_context      dxva2;
50 } AVDXVAContext;
51
52 #define DXVA2_CONTEXT(ctx)   (&ctx->dxva2)
53
54 #if CONFIG_D3D11VA
55 #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
56 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround)
57 #define DXVA_CONTEXT_COUNT(avctx, ctx)          (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
58 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i)     (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i])
59 #define DXVA_CONTEXT_DECODER(avctx, ctx)        (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
60 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx)      (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
61 #define DXVA_CONTEXT_CFG(avctx, ctx)            (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
62 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
63 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
64 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
65 #else
66 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->dxva2.workaround)
67 #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->dxva2.surface_count)
68 #define DXVA_CONTEXT_SURFACE(avctx, ctx, i)     (ctx->dxva2.surface[i])
69 #define DXVA_CONTEXT_DECODER(avctx, ctx)        (ctx->dxva2.decoder)
70 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx)      (*(&ctx->dxva2.report_id))
71 #define DXVA_CONTEXT_CFG(avctx, ctx)            (ctx->dxva2.cfg)
72 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->dxva2.cfg->ConfigBitstreamRaw)
73 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
74 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
75 #endif
76
77 void *ff_dxva2_get_surface(const AVFrame *frame);
78
79 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
80                                     const AVDXVAContext *,
81                                     const AVFrame *frame);
82
83 int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *,
84                            DECODER_BUFFER_DESC *,
85                            unsigned type, const void *data, unsigned size,
86                            unsigned mb_count);
87
88
89 int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
90                               const void *pp, unsigned pp_size,
91                               const void *qm, unsigned qm_size,
92                               int (*commit_bs_si)(AVCodecContext *,
93                                                   DECODER_BUFFER_DESC *bs,
94                                                   DECODER_BUFFER_DESC *slice));
95
96 #endif /* AVCODEC_DXVA_INTERNAL_H */