You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
5.1KB

  1. /*
  2. * DXVA2 HW acceleration
  3. *
  4. * copyright (c) 2010 Laurent Aimar
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_DXVA_INTERNAL_H
  23. #define AVCODEC_DXVA_INTERNAL_H
  24. #define COBJMACROS
  25. #include "config.h"
  26. #if CONFIG_DXVA2
  27. #include "dxva2.h"
  28. #endif
  29. #if CONFIG_D3D11VA
  30. #include "d3d11va.h"
  31. #endif
  32. #if HAVE_DXVA_H
  33. #include <dxva.h>
  34. #endif
  35. #include "avcodec.h"
  36. #include "mpegvideo.h"
  37. typedef void DECODER_BUFFER_DESC;
  38. typedef union {
  39. #if CONFIG_D3D11VA
  40. struct AVD3D11VAContext d3d11va;
  41. #endif
  42. #if CONFIG_DXVA2
  43. struct dxva_context dxva2;
  44. #endif
  45. } AVDXVAContext;
  46. #if CONFIG_D3D11VA
  47. #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
  48. #endif
  49. #if CONFIG_DXVA2
  50. #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
  51. #endif
  52. #if CONFIG_D3D11VA && CONFIG_DXVA2
  53. #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround)
  54. #define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
  55. #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i])
  56. #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
  57. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
  58. #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
  59. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
  60. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
  61. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
  62. #elif CONFIG_DXVA2
  63. #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
  64. #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
  65. #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->dxva2.surface[i])
  66. #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder)
  67. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id))
  68. #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg)
  69. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw)
  70. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
  71. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
  72. #elif CONFIG_D3D11VA
  73. #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
  74. #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
  75. #define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->d3d11va.surface[i])
  76. #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder)
  77. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id))
  78. #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg)
  79. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw)
  80. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
  81. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
  82. #endif
  83. void *ff_dxva2_get_surface(const AVFrame *frame);
  84. unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
  85. const AVDXVAContext *,
  86. const AVFrame *frame);
  87. int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *,
  88. DECODER_BUFFER_DESC *,
  89. unsigned type, const void *data, unsigned size,
  90. unsigned mb_count);
  91. int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
  92. const void *pp, unsigned pp_size,
  93. const void *qm, unsigned qm_size,
  94. int (*commit_bs_si)(AVCodecContext *,
  95. DECODER_BUFFER_DESC *bs,
  96. DECODER_BUFFER_DESC *slice));
  97. #endif /* AVCODEC_DXVA_INTERNAL_H */