vx_khr_ix.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (c) 2012-2017 The Khronos Group Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _OPENVX_IMPORT_EXPORT_H_
  17. #define _OPENVX_IMPORT_EXPORT_H_
  18. /*!
  19. * \file
  20. * \brief The OpenVX Export and Import extension API.
  21. */
  22. #define OPENVX_KHR_IX "vx_khr_ix"
  23. #include <VX/vx_import.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /*=============================================================================
  28. Export to host memory
  29. =============================================================================*/
  30. /*! \brief Exports selected objects to memory in a vendor-specific format.\n
  31. *
  32. * \details A list of references in the given context is supplied to this function, and all information
  33. * required to re-create these is stored in memory in such a way that those objects may be re-created
  34. * with the corresponding import function, according to the usage specified by the *uses* parameter[*REQ*].\n
  35. * The information must be context independent in that it may be written to external storage for later
  36. * retreival with another instantiation of a compatible implementation[*REQ*].\n
  37. * The list of objects to export may contain only valid references (i.e. vxGetStatus() will return VX_SUCCESS)
  38. * to vx_graph and non-virtual data objects or the function will fail[*REQ*].
  39. * (Specifically not vx_context, vx_import, vx_node, vx_kernel, vx_parameter or vx_meta_format)\n
  40. * Some node creation functions take C parameters rather than OpenVX data objects (such as the *gradient_size*
  41. * parameter of <tt>\ref vxHarrisCornersNode</tt> that is provided as a vx_int32), because these are intended
  42. * to be fixed at node creation time; nevertheless OpenVX data objects may be assigned to them, for example if
  43. * the <tt>\ref vxCreateGenericNode</tt> API is used.
  44. * A data object corresponding to a node parameter that is intended to be fixed at node creation time must not be
  45. * in the list of exported objects nor attached as a graph parameter or the export operation will fail[*REQ*].\n
  46. * The *uses* array specifies how the objects in the corresponding *refs* array will be exported. A data object
  47. * will always have its meta-data (e.g. dimensions and format of an image) exported, and optionally
  48. * may have its data (e.g. pixel values) exported, and additionally you can decide whether the importing
  49. * application will create data objects to replace those attached to graphs, or if the implementation will
  50. * automatically create them:
  51. * - <tt>\ref VX_IX_USE_APPLICATION_CREATE</tt> \n
  52. * Export sufficient data to check that an application-supplied
  53. * object is compatible when the data is later imported[*REQ*].
  54. * \note This value must be given for images created from handles, or the the export operation
  55. * will fail[*REQ*]
  56. * - <tt>\ref VX_IX_USE_EXPORT_VALUES</tt>\n
  57. * Export complete information (for example image data or value of a
  58. * scalar)[*REQ*].
  59. * - <tt>\ref VX_IX_USE_NO_EXPORT_VALUES</tt>\n
  60. * Export meta-data only; the importing application will set values
  61. * as applicable[*REQ*]
  62. *
  63. * The values in *uses* are applicable only for data objects and are ignored for vx_graph objects[*REQ*].\n
  64. * If the list *refs* contains vx_graph objects, these graphs will be verified during the export operation and the export operation will fail if verification fails; when successfully exported graphs are subsequently imported they will appear as verified [*REQ*].\n
  65. * \note The implementation may also choose to re-verify any previously verified graphs and apply
  66. * optimisations based upon which references are to be exported and how.\n
  67. * Any data objects attached to a graph that are hidden, i.e. their references are not in the list *refs*,
  68. * may be treated by the implementation as virtual objects, since they can never be visible when the graph is
  69. * subsequently imported.\n
  70. * Note that imported graphs cannot become unverified. Attempts to change the
  71. * graph that might normally cause the graph to be unverified, e.g. calling
  72. * vxSetGraphParameterByIndex with an object with different metadata, will fail.\n
  73. * The implementation should make sure that all permissible changes of exported objects are possible
  74. * without re-verification. For example:
  75. * - A uniform image may be swapped for a non-uniform image, so corresponding optimisations should be
  76. * inhibited if a uniform image appears in the *refs* list
  77. * - An image that is a region of interest of another image may be similarly replaced by any other image of
  78. * matching size and format, and vice-versa
  79. *
  80. * If a graph is exported that has delays registered for auto-aging, then this information is also
  81. * exported[*REQ*].\n
  82. * If the function is called with NULL for any of its parameters, this is an error [*REQ*].\n
  83. * The reference counts of objects as visible to the calling application will not be affected
  84. * by calling this function [*REQ*].\n
  85. * The export operation will fail if more than one object whose reference is listed at *refs*
  86. * has been given the same non-zero length name (via <tt>\ref vxSetReferenceName</tt>)[*REQ*].\n
  87. * If a graph listed for export has any graph parameters not listed at *refs*, then the
  88. * export operation will fail[*REQ*].
  89. * \note The order of the references supplied in the *refs* array will be the order in which the
  90. * framwork will supply references for the corresponding import operation with <tt>\ref vxImportObjectsFromMemory</tt>.\n
  91. * The same length of *uses* array, containing the same values, and the same value of *numrefs*, must be supplied
  92. * for the corresponding import operation.
  93. *
  94. * For objects not listed in *refs*, the following rules apply:
  95. * 1. In any one graph, if an object is not connected as an output of a node in a graph being exported
  96. * then its data values will be exported (for subsequent import)[*REQ*].
  97. * 2. Where the object in (1) is a composite object (such as a pyramid) then rule (1) applies to
  98. * all of its sub-objects[*REQ*].
  99. * 3. Where the object in (1) is a sub-object such as a region of interest, and the composite object
  100. * (in this case the parent image) does not meet the conditions of rule (1), then rule (1) applies
  101. * to the sub-object only[*REQ*].
  102. * \param [in] context context from which to export objects, must be valid [*REQ*].
  103. * \param [in] numrefs number of references to export [*REQ*].
  104. * \param [in] refs references to export. This is an array of length numrefs populated with
  105. * the references to export[*REQ*].
  106. * \param [in] uses how to export the references. This is an array of length numrefs containing
  107. * values as described above[*REQ*].
  108. * \param [out] ptr returns pointer to binary buffer. On error this is set to NULL[*REQ*].
  109. * \param [out] length number of bytes at \*ptr. On error this is set to zero[*REQ*].
  110. * \return A <tt>\ref vx_status</tt> value.
  111. * \retval VX_SUCCESS If no errors occurred and the objects were sucessfully exported[*REQ*].
  112. * An error is indicated when the return value is not VX_SUCCESS.\n
  113. * An implementation may provide several different return values to give useful diagnostic
  114. * information in the event of failure to export, but these are not required to indicate
  115. * possible recovery mechanisms, and for safety critical use assume errors are not recoverable.
  116. * \post <tt>\ref vxReleaseExportedMemory</tt> is used to deallocate the memory.
  117. * \ingroup group_import
  118. */
  119. VX_API_ENTRY vx_status VX_API_CALL vxExportObjectsToMemory(
  120. vx_context context,
  121. vx_size numrefs,
  122. const vx_reference *refs,
  123. const vx_enum * uses,
  124. const vx_uint8 ** ptr,
  125. vx_size * length);
  126. /*! \brief Releases memory allocated for a binary export when it is no longer required.
  127. * \details This function releases memory allocated by <tt>\ref vxExportObjectsToMemory</tt>[*REQ*].
  128. * \param [in] context The context for which <tt>\ref vxExportObjectsToMemory</tt> was called[*REQ*].
  129. * \param [in,out] ptr A pointer previously set by calling <tt>\ref vxExportObjectsToMemory</tt>[*REQ*].
  130. * The function will fail if <code>*ptr</code> does not contain an address of memory previously
  131. * allocated by <tt>\ref vxExportObjectsToMemory</tt>[*REQ*].
  132. * \post After returning from sucessfully from this function \*ptr is set to NULL[*REQ*].
  133. * \return A <tt>\ref vx_status</tt> value.
  134. * \retval VX_SUCCESS If no errors occurred and the memory was sucessfully released[*REQ*].\n
  135. * An error is indicated when the return value is not VX_SUCCESS[*REQ*].\n
  136. * An implementation may provide several different return values to give useful diagnostic
  137. * information in the event of failure to export, but these are not required to indicate
  138. * possible recovery mechanisms, and for safety critical use assume errors are not recoverable.
  139. * \pre <tt>\ref vxExportObjectsToMemory</tt> is used to allocate the memory.
  140. * \ingroup group_import
  141. */
  142. VX_API_ENTRY vx_status VX_API_CALL vxReleaseExportedMemory(
  143. vx_context context, const vx_uint8 ** ptr);
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif