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.

157 lines
5.2KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav 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. * Libav 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 Libav; 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_derive)(AVHWDeviceContext *dst_ctx,
  61. AVHWDeviceContext *src_ctx, int flags);
  62. int (*device_init)(AVHWDeviceContext *ctx);
  63. void (*device_uninit)(AVHWDeviceContext *ctx);
  64. int (*frames_get_constraints)(AVHWDeviceContext *ctx,
  65. const void *hwconfig,
  66. AVHWFramesConstraints *constraints);
  67. int (*frames_init)(AVHWFramesContext *ctx);
  68. void (*frames_uninit)(AVHWFramesContext *ctx);
  69. int (*frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame);
  70. int (*transfer_get_formats)(AVHWFramesContext *ctx,
  71. enum AVHWFrameTransferDirection dir,
  72. enum AVPixelFormat **formats);
  73. int (*transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst,
  74. const AVFrame *src);
  75. int (*transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst,
  76. const AVFrame *src);
  77. int (*map_to)(AVHWFramesContext *ctx, AVFrame *dst,
  78. const AVFrame *src, int flags);
  79. int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst,
  80. const AVFrame *src, int flags);
  81. } HWContextType;
  82. struct AVHWDeviceInternal {
  83. const HWContextType *hw_type;
  84. void *priv;
  85. /**
  86. * For a derived device, a reference to the original device
  87. * context it was derived from.
  88. */
  89. AVBufferRef *source_device;
  90. };
  91. struct AVHWFramesInternal {
  92. const HWContextType *hw_type;
  93. void *priv;
  94. AVBufferPool *pool_internal;
  95. /**
  96. * For a derived context, a reference to the original frames
  97. * context it was derived from.
  98. */
  99. AVBufferRef *source_frames;
  100. };
  101. typedef struct HWMapDescriptor {
  102. /**
  103. * A reference to the original source of the mapping.
  104. */
  105. AVFrame *source;
  106. /**
  107. * A reference to the hardware frames context in which this
  108. * mapping was made. May be the same as source->hw_frames_ctx,
  109. * but need not be.
  110. */
  111. AVBufferRef *hw_frames_ctx;
  112. /**
  113. * Unmap function.
  114. */
  115. void (*unmap)(AVHWFramesContext *ctx,
  116. struct HWMapDescriptor *hwmap);
  117. /**
  118. * Hardware-specific private data associated with the mapping.
  119. */
  120. void *priv;
  121. } HWMapDescriptor;
  122. int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
  123. AVFrame *dst, const AVFrame *src,
  124. void (*unmap)(AVHWFramesContext *ctx,
  125. HWMapDescriptor *hwmap),
  126. void *priv);
  127. extern const HWContextType ff_hwcontext_type_cuda;
  128. extern const HWContextType ff_hwcontext_type_dxva2;
  129. extern const HWContextType ff_hwcontext_type_qsv;
  130. extern const HWContextType ff_hwcontext_type_vaapi;
  131. extern const HWContextType ff_hwcontext_type_vdpau;
  132. #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */