hwcontext_internal.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVUTIL_HWCONTEXT_INTERNAL_H
  19. #define AVUTIL_HWCONTEXT_INTERNAL_H
  20. #include <stddef.h>
  21. #include "buffer.h"
  22. #include "hwcontext.h"
  23. #include "frame.h"
  24. #include "pixfmt.h"
  25. typedef struct HWContextType {
  26. enum AVHWDeviceType type;
  27. const char *name;
  28. /**
  29. * An array of pixel formats supported by the AVHWFramesContext instances
  30. * Terminated by AV_PIX_FMT_NONE.
  31. */
  32. const enum AVPixelFormat *pix_fmts;
  33. /**
  34. * size of the public hardware-specific context,
  35. * i.e. AVHWDeviceContext.hwctx
  36. */
  37. size_t device_hwctx_size;
  38. /**
  39. * size of the private data, i.e.
  40. * AVHWDeviceInternal.priv
  41. */
  42. size_t device_priv_size;
  43. /**
  44. * Size of the hardware-specific device configuration.
  45. * (Used to query hwframe constraints.)
  46. */
  47. size_t device_hwconfig_size;
  48. /**
  49. * size of the public frame pool hardware-specific context,
  50. * i.e. AVHWFramesContext.hwctx
  51. */
  52. size_t frames_hwctx_size;
  53. /**
  54. * size of the private data, i.e.
  55. * AVHWFramesInternal.priv
  56. */
  57. size_t frames_priv_size;
  58. int (*device_create)(AVHWDeviceContext *ctx, const char *device,
  59. AVDictionary *opts, int flags);
  60. int (*device_init)(AVHWDeviceContext *ctx);
  61. void (*device_uninit)(AVHWDeviceContext *ctx);
  62. int (*frames_get_constraints)(AVHWDeviceContext *ctx,
  63. const void *hwconfig,
  64. AVHWFramesConstraints *constraints);
  65. int (*frames_init)(AVHWFramesContext *ctx);
  66. void (*frames_uninit)(AVHWFramesContext *ctx);
  67. int (*frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame);
  68. int (*transfer_get_formats)(AVHWFramesContext *ctx,
  69. enum AVHWFrameTransferDirection dir,
  70. enum AVPixelFormat **formats);
  71. int (*transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst,
  72. const AVFrame *src);
  73. int (*transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst,
  74. const AVFrame *src);
  75. } HWContextType;
  76. struct AVHWDeviceInternal {
  77. const HWContextType *hw_type;
  78. void *priv;
  79. };
  80. struct AVHWFramesInternal {
  81. const HWContextType *hw_type;
  82. void *priv;
  83. AVBufferPool *pool_internal;
  84. };
  85. extern const HWContextType ff_hwcontext_type_cuda;
  86. extern const HWContextType ff_hwcontext_type_dxva2;
  87. extern const HWContextType ff_hwcontext_type_qsv;
  88. extern const HWContextType ff_hwcontext_type_vaapi;
  89. extern const HWContextType ff_hwcontext_type_vdpau;
  90. #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */