vx_import.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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_H_
  17. #define _OPENVX_IMPORT_H_
  18. /*!
  19. * \file
  20. * \brief The OpenVX Import API
  21. * part of the OpenVX Export and Import extension API
  22. * and also part of the OpenVX SC deployment feature set.
  23. */
  24. /*! \brief An enumeration of export uses. See <tt>\ref vxExportObjectsToMemory</tt> and
  25. * <tt>\ref vxImportObjectsFromMemory</tt>
  26. * \ingroup vx_enum_e
  27. */
  28. #define VX_ENUM_IX_USE 0x18
  29. /*! \brief How to export and import an object
  30. * \ingroup group_import
  31. */
  32. #define VX_IX_USE_APPLICATION_CREATE (VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_IX_USE) + 0x0) /*!< \brief The application will create the object before import. */
  33. /*! \brief How to export and import an object
  34. * \ingroup group_import
  35. */
  36. #define VX_IX_USE_EXPORT_VALUES (VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_IX_USE) + 0x1) /*!< \brief Data values are exported and restored upon import. */
  37. /*! \brief How to export and import an object
  38. * \ingroup group_import
  39. */
  40. #define VX_IX_USE_NO_EXPORT_VALUES (VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_IX_USE) + 0x2) /*!< \brief Data values are not exported. */
  41. /*=============================================================================
  42. IMPORT
  43. =============================================================================*/
  44. /*! \brief The Import Object. Import is a container of OpenVX objects, which may be retreived
  45. * by name
  46. * \ingroup group_import
  47. */
  48. typedef struct _vx_import *vx_import;
  49. /*! \brief The Object Type Enumeration for import.
  50. * \ingroup group_import
  51. */
  52. #define VX_TYPE_IMPORT 0x814/*!< \brief A <tt>\ref vx_import</tt>. */
  53. /*! \brief Imports objects into a context from a vendor-specific format in memory.\n
  54. *
  55. * \details This function imports objects from a memory blob previously created using <tt>\ref vxExportObjectsToMemory</tt>[*REQ*].\n
  56. * A pointer to memory is given where a list of references is stored, together with the list
  57. * of uses which describes how the references are used. The number of references given and the
  58. * list of uses must match that given upon export, or this function will not be sucessful[*REQ*].\n
  59. * The *uses* array specifies how the objects in the corresponding *refs* array will be imported:
  60. * - <tt>\ref VX_IX_USE_APPLICATION_CREATE</tt>\n
  61. * The application must create the object and supply the reference; the
  62. * meta-data of the object must match exactly the meta-data of the object when it was exported,
  63. * except that the name need not match[*REQ*].\n
  64. * If the supplied reference has a different name to that stored, the supplied name is used[*REQ*].
  65. * - <tt>\ref VX_IX_USE_EXPORT_VALUES</tt>\n
  66. * The implementation will create the object and set the data in it[*REQ*].\n
  67. * Any data not defined at the time of export of the object will be set to a default value (zero in the
  68. * absence of any other definition) upon import[*REQ*].
  69. * - <tt>\ref VX_IX_USE_NO_EXPORT_VALUES</tt>\n
  70. * The implementation will create the object and the importing application will set values as applicable[*REQ*].
  71. *
  72. * References are obtained from the import API for those objects whose references were listed at the time of export.
  73. * These are not the same objects; they are equivalent objects created by the framework at import time.
  74. * The implementation guarantees that references will be available and valid for all objects listed at the time
  75. * of export, or the import will fail[*REQ*].\n
  76. * The import operation will fail if more than one object whose reference is listed at *refs*
  77. * has been given the same non-zero length name (via <tt>\ref vxSetReferenceName</tt>)[*REQ*].\n
  78. * The import will be unsuccessful if any of the parameters supplied is NULL[*REQ*].\n
  79. * After completion of the function the memory at *ptr* may be deallocated by the application as it will
  80. * not be used by any of the created objects[*REQ*].\n
  81. * Any delays imported with graphs for which they are registered for auto-aging remain registered
  82. * for auto-aging[*REQ*].\n
  83. * After import, a graph must execute with exactly the same effect with respect to its visible parameters
  84. * as before export[*REQ*].
  85. * \note The *refs* array must be the correct length to hold all references of the import; this will be the same length
  86. * that was supplied at the time of export. Only references for objects created by the application, where the
  87. * corresponding *uses* entry is <tt>\ref VX_IX_USE_APPLICATION_CREATE</tt> should be filled in by the application;
  88. * all other entries will be supplied by the framework and may be initialised by the application to NULL. The *uses* array
  89. * must have the identical length and content as given at the time of export, and the value of *numrefs* must also match;
  90. * these measures increase confidence that the import contains the correct data.
  91. * \note Graph parameters may be changed after import by using the <tt>\ref vxSetGraphParameterByIndex</tt> API, and
  92. * images may also be changed by using the <tt>\ref vxSwapImageHandle</tt> API.
  93. * When <tt>\ref vxSetGraphParameterByIndex</tt> is used, the framework will check that the new parameter is of the
  94. * correct type to run with the graph, which cannot be re-verified. If the reference supplied is not suitable, an error
  95. * will be returned, but there may be circumstances where changing graph parameters for unsuitable ones is not detected
  96. * and could lead to implementation-dependent behaviour; one such circumstance is when the new parameters are images
  97. * corresponding to overlapping regions of interest. The user should avoid these circumstances.
  98. * In other words,
  99. * - The meta data of the new graph parameter must match the meta data of the graph parameter it replaces [*REQ*].
  100. * - A graph parameter must not be NULL [*REQ*].
  101. * \param [in] context context into which to import objects, must be valid [*REQ*].
  102. * \param [in] numrefs number of references to import, must match export[*REQ*].
  103. * \param [in,out] refs references imported or application-created data which must match
  104. * meta-data of the export[*REQ*]
  105. * \param [in] uses how to import the references, must match export values[*REQ*]
  106. * \param [in] ptr pointer to binary buffer containing a valid binary export[*REQ*]
  107. * \param [in] length number of bytes at \*ptr, i.e. the length of the export[*REQ*]
  108. * \return A <tt>\ref vx_import</tt>[*REQ*].
  109. * Calling <tt>\ref vxGetStatus</tt> with the vx_import as a parameter will return VX_SUCCESS if the
  110. * function was successful[*REQ*].\n
  111. * Another value is given to indicate that there was an error[*REQ*].\n
  112. * An implementation may provide several different error codes to give useful diagnostic information
  113. * in the event of failure to import objects, but these are not required to indicate
  114. * possibly recovery mechanisms, and for safety critical use assume errors are not recoverable.
  115. * \post <tt>\ref vxReleaseImport</tt> is used to release the import object.
  116. * \post Use <tt>\ref vxReleaseReference</tt> or an appropriate specific release function to release
  117. * the references in the array refs when they are no longer required.
  118. * \ingroup group_import
  119. */
  120. VX_API_ENTRY vx_import VX_API_CALL vxImportObjectsFromMemory(
  121. vx_context context,
  122. vx_size numrefs,
  123. vx_reference *refs,
  124. const vx_enum * uses,
  125. const vx_uint8 * ptr,
  126. vx_size length);
  127. /*! \brief Releases an import object when no longer required.\n
  128. * \details This function releases the reference to the import object [*REQ*].\n
  129. * Other objects including those imported at the time of creation of the import object are unaffected[*REQ*].\n
  130. * \param [in,out] import The pointer to the reference to the import object[*REQ*].
  131. * \post After returning sucessfully from this function the reference is zeroed[*REQ*].
  132. * \return A <tt>\ref vx_status</tt> value.
  133. * \retval VX_SUCCESS If no errors occurred and the import was sucessfully released[*REQ*].\n
  134. * An error is indicated when the return value is not VX_SUCCESS[*REQ*].\n
  135. * An implementation may provide several different return values to give useful diagnostic
  136. * information in the event of failure to export, but these are not required to indicate
  137. * possibly recovery mechanisms, and for safety critical use assume errors are not recoverable.
  138. * \pre <tt>\ref vxImportObjectsFromMemory</tt> is used to create an import object.
  139. * \ingroup group_import
  140. */
  141. VX_API_ENTRY vx_status VX_API_CALL vxReleaseImport(vx_import *import);
  142. /*! \brief Get a reference from the import object by name.\n
  143. *
  144. * \details All accessible references of the import object created using <tt>\ref vxImportObjectsFromMemory</tt> are
  145. * in the array *refs*, which is populated partly by the application before import, and partly by the
  146. * framework. However, it may be more convenient to access the references in the import object without
  147. * referring to this array, for example if the import object is passed as a parameter to another function.
  148. * In this case, references may be retreived by name, assuming that <tt>\ref vxSetReferenceName</tt>
  149. * was called to assign a name to the reference.
  150. * This function searches the given import for the given name and returns the associated reference[*REQ*].\n
  151. * The reference may have been named either before export or after import[*REQ*].\n
  152. * If more than one reference exists in the import with the given name, this is an error[*REQ*].\n
  153. * Only references in the array *refs* after calling <tt>\ref vxImportObjectsFromMemory</tt> may be retrieved
  154. * using this function[*REQ*].\n
  155. * A reference to a named object may be obtained from a valid import object using this API even if all other
  156. * references to the object have been released[*REQ*].
  157. * \param [in] import The import object in which to find the name; the function will fail if this parameter
  158. * is not valid[*REQ*].
  159. * \param [in] name The name to find, points to a string of at least one and less than VX_MAX_REFERENCE_NAME bytes
  160. * followed by a zero byte; the function will fail if this is not valid[*REQ*].
  161. * \return A <tt>\ref vx_reference</tt>[*REQ*].\n
  162. * Calling <tt>\ref vxGetStatus</tt> with the reference as a parameter will return VX_SUCCESS if the function
  163. * was successful[*REQ*].\n
  164. * Another value is given to indicate that there was an error[*REQ*].\n
  165. * On success, the reference count of the object in question is incremented[*REQ*].\n
  166. * An implementation may provide several different error codes to give useful diagnostic information
  167. * in the event of failure to retrieve a reference, but these are not required to indicate
  168. * possibly recovery mechanisms, and for safety critical use assume errors are not recoverable.
  169. * \pre <tt>\ref vxSetReferenceName</tt> was used to name the reference.
  170. * \post use <tt>ref vxReleaseReference</tt> or appropriate specific release function to release a reference
  171. * obtained by this method.
  172. * \ingroup group_import
  173. */
  174. VX_API_ENTRY vx_reference VX_API_CALL vxGetImportReferenceByName(vx_import import, const vx_char *name);
  175. #endif