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.

117 lines
5.5KB

  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_DXVA2_INTERNAL_H
  23. #define AVCODEC_DXVA2_INTERNAL_H
  24. #define COBJMACROS
  25. #include "config.h"
  26. /* define the proper COM entries before forcing desktop APIs */
  27. #include <objbase.h>
  28. #if CONFIG_DXVA2
  29. #include "dxva2.h"
  30. #endif
  31. #if CONFIG_D3D11VA
  32. #include "d3d11va.h"
  33. #endif
  34. #if HAVE_DXVA_H
  35. /* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h
  36. * defines nothing. Force the struct definitions to be visible. */
  37. #undef WINAPI_FAMILY
  38. #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
  39. #undef _CRT_BUILD_DESKTOP_APP
  40. #define _CRT_BUILD_DESKTOP_APP 0
  41. #include <dxva.h>
  42. #endif
  43. #include "avcodec.h"
  44. typedef void DECODER_BUFFER_DESC;
  45. typedef union {
  46. #if CONFIG_D3D11VA
  47. struct AVD3D11VAContext d3d11va;
  48. #endif
  49. #if CONFIG_DXVA2
  50. struct dxva_context dxva2;
  51. #endif
  52. } AVDXVAContext;
  53. #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
  54. #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
  55. #if CONFIG_D3D11VA && CONFIG_DXVA2
  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_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
  59. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
  60. #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
  61. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
  62. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
  63. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
  64. #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \
  65. DXVA_CONTEXT_CFG(avctx, ctx) && \
  66. (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count))
  67. #elif CONFIG_DXVA2
  68. #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
  69. #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
  70. #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder)
  71. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id))
  72. #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg)
  73. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw)
  74. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
  75. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
  76. #define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
  77. #elif CONFIG_D3D11VA
  78. #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
  79. #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
  80. #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder)
  81. #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id))
  82. #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg)
  83. #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw)
  84. #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
  85. #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
  86. #define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg)
  87. #endif
  88. unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
  89. const AVDXVAContext *,
  90. const AVFrame *frame);
  91. int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *,
  92. DECODER_BUFFER_DESC *,
  93. unsigned type, const void *data, unsigned size,
  94. unsigned mb_count);
  95. int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
  96. const void *pp, unsigned pp_size,
  97. const void *qm, unsigned qm_size,
  98. int (*commit_bs_si)(AVCodecContext *,
  99. DECODER_BUFFER_DESC *bs,
  100. DECODER_BUFFER_DESC *slice));
  101. #endif /* AVCODEC_DXVA2_INTERNAL_H */