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.

97 lines
3.0KB

  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_OPENCL_H
  19. #define AVUTIL_HWCONTEXT_OPENCL_H
  20. #include <CL/cl.h>
  21. #include "frame.h"
  22. /**
  23. * @file
  24. * API-specific header for AV_HWDEVICE_TYPE_OPENCL.
  25. *
  26. * Pools allocated internally are always dynamic, and are primarily intended
  27. * to be used in OpenCL-only cases. If interoperation is required, it is
  28. * typically required to allocate frames in the other API and then map the
  29. * frames context to OpenCL with av_hwframe_ctx_create_derived().
  30. */
  31. /**
  32. * OpenCL frame descriptor for pool allocation.
  33. *
  34. * In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
  35. * with the data pointer pointing at an object of this type describing the
  36. * planes of the frame.
  37. */
  38. typedef struct AVOpenCLFrameDescriptor {
  39. /**
  40. * Number of planes in the frame.
  41. */
  42. int nb_planes;
  43. /**
  44. * OpenCL image2d objects for each plane of the frame.
  45. */
  46. cl_mem planes[AV_NUM_DATA_POINTERS];
  47. } AVOpenCLFrameDescriptor;
  48. /**
  49. * OpenCL device details.
  50. *
  51. * Allocated as AVHWDeviceContext.hwctx
  52. */
  53. typedef struct AVOpenCLDeviceContext {
  54. /**
  55. * The primary device ID of the device. If multiple OpenCL devices
  56. * are associated with the context then this is the one which will
  57. * be used for all operations internal to FFmpeg.
  58. */
  59. cl_device_id device_id;
  60. /**
  61. * The OpenCL context which will contain all operations and frames on
  62. * this device.
  63. */
  64. cl_context context;
  65. /**
  66. * The default command queue for this device, which will be used by all
  67. * frames contexts which do not have their own command queue. If not
  68. * intialised by the user, a default queue will be created on the
  69. * primary device.
  70. */
  71. cl_command_queue command_queue;
  72. } AVOpenCLDeviceContext;
  73. /**
  74. * OpenCL-specific data associated with a frame pool.
  75. *
  76. * Allocated as AVHWFramesContext.hwctx.
  77. */
  78. typedef struct AVOpenCLFramesContext {
  79. /**
  80. * The command queue used for internal asynchronous operations on this
  81. * device (av_hwframe_transfer_data(), av_hwframe_map()).
  82. *
  83. * If this is not set, the command queue from the associated device is
  84. * used instead.
  85. */
  86. cl_command_queue command_queue;
  87. } AVOpenCLFramesContext;
  88. #endif /* AVUTIL_HWCONTEXT_OPENCL_H */