hwcontext_opencl.h 3.0 KB

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