| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding. <br>File to Include: <multimedia/player_framework/native_avcodec_audiodecoder.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime)(const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname)(const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. |
| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. |
| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. |
| [OH_AudioDecoder_Start](#oh_audiodecoder_start)(OH_AVCodec\*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop)(OH_AVCodec\*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. |
| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset)(OH_AVCodec\*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. |
| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. |
| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. |
| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of an audio decoder. |
## Function Description
### OH_AudioDecoder_Configure()
```
OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**.
Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process.
Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**.
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_SetParameter()
```
OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again.
| [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding. <br>File to Include: <multimedia/player_framework/native_avcodec_audioencoder.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime)(const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname)(const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. |
| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. |
| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Configure](#oh_audioencoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. |
| [OH_AudioEncoder_Start](#oh_audioencoder_start)(OH_AVCodec\*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioEncoder_Stop](#oh_audioencoder_stop)(OH_AVCodec\*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. |
| [OH_AudioEncoder_Flush](#oh_audioencoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioEncoder_Reset](#oh_audioencoder_reset)(OH_AVCodec\*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. |
| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. |
| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. |
| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of an audio encoder. |
## Function Description
### OH_AudioEncoder_Configure()
```
OH_AVErrCode OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**.
Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback.
Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**.
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_SetParameter()
```
OH_AVErrCode OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure.
Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances. <br>File to Include: <multimedia/player_framework/native_avcodec_base.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. |
| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)\*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
| [OH_MediaType](#oh_mediatype) | Enumerates the media types. |
| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. |
| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. |
| [OH_AVCodecBufferAttr::pts](#pts) | Presentation timestamp of the buffer, in microseconds. |
| [OH_AVCodecBufferAttr::size](#size) | Size of the data contained in the buffer, in bytes. |
| [OH_AVCodecBufferAttr::offset](#offset) | Start offset of valid data in the buffer. |
| [OH_AVCodecBufferAttr::flags](#flags) | Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). |
| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). |
| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). |
| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. |
| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. |
| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. |
| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string. |
| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t. |
| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. |
| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. |
| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. |
| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. |
| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). |
| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. |
| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. |
| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). |
| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). |
| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. |
| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. |
| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. |
| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. |
Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.
| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror). |
| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged). |
| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata). |
| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata). |
Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance.
Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
Character descriptor of the number of audio channels. The value type is uint32_t.
### OH_MD_KEY_AUD_SAMPLE_RATE
```
const char* OH_MD_KEY_AUD_SAMPLE_RATE
```
**Description**<br>
Character descriptor of the audio sampling rate. The value type is uint32_t.
### OH_MD_KEY_AUDIO_SAMPLE_FORMAT
```
const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT
```
**Description**<br>
Character descriptor of the audio sample format. The value type is uint32_t.
### OH_MD_KEY_BITRATE
```
const char* OH_MD_KEY_BITRATE
```
**Description**<br>
Character descriptor of the bit rate. The value type is uint32_t.
### OH_MD_KEY_CODEC_MIME
```
const char* OH_MD_KEY_CODEC_MIME
```
**Description**<br>
Character descriptor of the MIME type. The value type is string.
### OH_MD_KEY_DURATION
```
const char* OH_MD_KEY_DURATION
```
**Description**<br>
Character descriptor of duration. The value type is int64_t.
### OH_MD_KEY_FRAME_RATE
```
const char* OH_MD_KEY_FRAME_RATE
```
**Description**<br>
Character descriptor of the video frame rate. The value type is double.
### OH_MD_KEY_HEIGHT
```
const char* OH_MD_KEY_HEIGHT
```
**Description**<br>
Character descriptor of the video height. The value type is uint32_t.
### OH_MD_KEY_I_FRAME_INTERVAL
```
const char* OH_MD_KEY_I_FRAME_INTERVAL
```
**Description**<br>
Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms.
### OH_MD_KEY_MAX_INPUT_SIZE
```
const char* OH_MD_KEY_MAX_INPUT_SIZE
```
**Description**<br>
Character descriptor of the maximum input size. The value type is uint32_t.
### OH_MD_KEY_PIXEL_FORMAT
```
const char* OH_MD_KEY_PIXEL_FORMAT
```
**Description**<br>
Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).
### OH_MD_KEY_PROFILE
```
const char* OH_MD_KEY_PROFILE
```
**Description**<br>
Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).
### OH_MD_KEY_ROTATION
```
const char* OH_MD_KEY_ROTATION
```
**Description**<br>
Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0.
### OH_MD_KEY_TRACK_TYPE
```
const char* OH_MD_KEY_TRACK_TYPE
```
**Description**<br>
Provides unified character descriptors for the media playback framework.
Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).
### OH_MD_KEY_WIDTH
```
const char* OH_MD_KEY_WIDTH
```
**Description**<br>
Character descriptor of the video width. The value type is uint32_t.
### pts
```
int64_t OH_AVCodecBufferAttr::pts
```
**Description**<br>
Presentation timestamp of the buffer, in microseconds.
### size
```
int32_t OH_AVCodecBufferAttr::size
```
**Description**<br>
Size of the data contained in the buffer, in bytes.
Provides the basic backbone capabilities for the media playback framework, including functions related to the memory, error code, and format carrier.
\@syscap SystemCapability.Multimedia.Media.Core
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media playback framework. <br>File to Include: <multimedia/player_framework/native_averrors.h> |
| [native_avformat.h](native__avformat_8h.md) | Declares the format-related functions and enums. <br>File to Include: <multimedia/player_framework/native_avformat.h> |
| [native_avmemory.h](native__avmemory_8h.md) | Declares the memory-related functions. <br>File to Include: <multimedia/player_framework/native_avmemory.h> |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AVErrCode](#oh_averrcode) | Enumerates the audio and video error codes. |
| [OH_AVPixelFormat](#oh_avpixelformat) | Enumerates the audio and video pixel formats. |
| [OH_AVPixelFormat](#oh_avpixelformat) {<br/>AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,<br/>AV_PIXEL_FORMAT_RGBA = 5<br/>} | Enumerates the audio and video pixel formats. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AVFormat_Create](#oh_avformat_create)(void) | Creates an **OH_AVFormat** instance for reading and writing data. |
| [OH_AVFormat_Destroy](#oh_avformat_destroy)(struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. |
| [OH_AVFormat_Copy](#oh_avformat_copy)(struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. |
| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue)(struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue)(struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue)(struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue)(struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue)(struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer)(struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. |
| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue)(struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue)(struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue)(struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue)(struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue)(struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer)(struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. |
| [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo)(struct OH_AVFormat \*format) | Dumps the information contained in an**OH_AVFormat** instance as a string. |
| [OH_AVMemory_GetAddr](#oh_avmemory_getaddr)(struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. |
| [OH_AVMemory_GetSize](#oh_avmemory_getsize)(struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. |
Reads data with a specified size from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| addr | Indicates the double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. |
| size | Indicates the pointer to the size of the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetDoubleValue()
```
bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat * format, const char * key, double * out )
```
**Description**<br>
Reads data of the double type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetFloatValue()
```
bool OH_AVFormat_GetFloatValue (struct OH_AVFormat * format, const char * key, float * out )
```
**Description**<br>
Reads data of the float type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetIntValue()
```
bool OH_AVFormat_GetIntValue (struct OH_AVFormat * format, const char * key, int32_t * out )
```
**Description**<br>
Reads data of the int type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetLongValue()
```
bool OH_AVFormat_GetLongValue (struct OH_AVFormat * format, const char * key, int64_t * out )
```
**Description**<br>
Reads data of the long type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetStringValue()
```
bool OH_AVFormat_GetStringValue (struct OH_AVFormat * format, const char * key, const char ** out )
```
**Description**<br>
Reads data of the double type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the double pointer to the data read. The data read is updated when **GetString** is called and destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. |
| [drawing_bitmap.h](drawing__bitmap_8h.md) | Declares functions related to the **bitmap** object in the drawing module. <br>File to Include: <native_drawing/drawing_bitmap.h> |
| [drawing_brush.h](drawing__brush_8h.md) | Declares functions related to the **brush** object in the drawing module. <br>File to Include: <native_drawing/drawing_brush.h> |
| [drawing_canvas.h](drawing__canvas_8h.md) | Declares functions related to the **canvas** object in the drawing module. <br>File to Include: <native_drawing/drawing_canvas.h> |
| [drawing_color.h](drawing__color_8h.md) | Declares functions related to the **color** object in the drawing module. <br>File to Include: <native_drawing/drawing_color.h> |
| [drawing_font_collection.h](drawing__font__collection_8h.md) | Declares functions related to **FontCollection** in the drawing module. <br>File to Include: <native_drawing/drawing_font_collection.h> |
| [drawing_path.h](drawing__path_8h.md) | Declares functions related to the **path** object in the drawing module. <br>File to Include: <native_drawing/drawing_path.h> |
| [drawing_pen.h](drawing__pen_8h.md) | Declares functions related to the **pen** object in the drawing module. <br>File to Include: <native_drawing/drawing_pen.h> |
| [drawing_text_declaration.h](drawing__text__declaration_8h.md) | Declares the data structure related to text in 2D drawing. <br>File to Include: <native_drawing/drawing_text_declaration.h> |
| [drawing_text_typography.h](drawing__text__typography_8h.md) | Declares functions related to **typography** in the drawing module. <br>File to Include: <native_drawing/drawing_text_typography.h> |
| [drawing_types.h](drawing__types_8h.md) | Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path. <br>File to Include: <native_drawing/drawing_types.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Defines the pixel format of a bitmap, including the color type and alpha type. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_Drawing_FontCollection](#oh_drawing_fontcollection) | Defines an **OH_Drawing_FontCollection**, which is used to load fonts. |
| [OH_Drawing_Typography](#oh_drawing_typography) | Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. |
| [OH_Drawing_TextStyle](#oh_drawing_textstyle) | Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. |
| [OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) | Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. |
| [OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) | Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. |
| [OH_Drawing_Canvas](#oh_drawing_canvas) | Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. |
| [OH_Drawing_Pen](#oh_drawing_pen) | Defines a pen, which is used to describe the style and color to outline a shape. |
| [OH_Drawing_Brush](#oh_drawing_brush) | Defines as a brush, which is used to describe the style and color to fill in a shape. |
| [OH_Drawing_Path](#oh_drawing_path) | Defines a path, which is used to customize various shapes. |
| [OH_Drawing_Bitmap](#oh_drawing_bitmap) | Defines a bitmap, which is a memory that contains the pixel data of a shape. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) { LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP } | Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. |
| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) { LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN } | Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. |
| [OH_Drawing_BitmapCreate](#oh_drawing_bitmapcreate)(void) | Creates an **OH_Drawing_Bitmap** object. |
| [OH_Drawing_BitmapDestroy](#oh_drawing_bitmapdestroy)([OH_Drawing_Bitmap](#oh_drawing_bitmap)\*) | Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. |
| [OH_Drawing_BitmapBuild](#oh_drawing_bitmapbuild)([OH_Drawing_Bitmap](#oh_drawing_bitmap)\*, const uint32_t width, const uint32_t height, const [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)\*) | Initializes the width and height of an **OH_Drawing_Bitmap** object and sets the pixel format for the bitmap. |
| [OH_Drawing_BitmapGetWidth](#oh_drawing_bitmapgetwidth)([OH_Drawing_Bitmap](#oh_drawing_bitmap)\*) | Obtains the width of a bitmap. |
| [OH_Drawing_BitmapGetHeight](#oh_drawing_bitmapgetheight)([OH_Drawing_Bitmap](#oh_drawing_bitmap)\*) | Obtains the height of a bitmap. |
| [OH_Drawing_BitmapGetPixels](#oh_drawing_bitmapgetpixels)([OH_Drawing_Bitmap](#oh_drawing_bitmap)\*) | Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. |
| [OH_Drawing_BrushCreate](#oh_drawing_brushcreate)(void) | Creates an **OH_Drawing_Brush** object. |
| [OH_Drawing_BrushDestroy](#oh_drawing_brushdestroy)([OH_Drawing_Brush](#oh_drawing_brush)\*) | Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. |
| [OH_Drawing_BrushIsAntiAlias](#oh_drawing_brushisantialias)(const[OH_Drawing_Brush](#oh_drawing_brush) \*) | Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_BrushSetAntiAlias](#oh_drawing_brushsetantialias)([OH_Drawing_Brush](#oh_drawing_brush)\*, bool) | Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_BrushGetColor](#oh_drawing_brushgetcolor)(const[OH_Drawing_Brush](#oh_drawing_brush) \*) | Obtains the color of a brush. The color is used by the brush to fill in a shape. |
| [OH_Drawing_BrushSetColor](#oh_drawing_brushsetcolor)([OH_Drawing_Brush](#oh_drawing_brush)\*, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape. |
| [OH_Drawing_CanvasCreate](#oh_drawing_canvascreate)(void) | Creates an **OH_Drawing_Canvas** object. |
| [OH_Drawing_CanvasDestroy](#oh_drawing_canvasdestroy)([OH_Drawing_Canvas](#oh_drawing_canvas)\*) | Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. |
| [OH_Drawing_CanvasBind](#oh_drawing_canvasbind)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, [OH_Drawing_Bitmap](#oh_drawing_bitmap)\*) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering). |
| [OH_Drawing_CanvasAttachPen](#oh_drawing_canvasattachpen)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, const [OH_Drawing_Pen](#oh_drawing_pen)\*) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. |
| [OH_Drawing_CanvasDetachPen](#oh_drawing_canvasdetachpen)([OH_Drawing_Canvas](#oh_drawing_canvas)\*) | Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. |
| [OH_Drawing_CanvasAttachBrush](#oh_drawing_canvasattachbrush)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, const [OH_Drawing_Brush](#oh_drawing_brush)\*) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. |
| [OH_Drawing_CanvasDetachBrush](#oh_drawing_canvasdetachbrush)([OH_Drawing_Canvas](#oh_drawing_canvas)\*) | Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. |
| [OH_Drawing_CanvasSave](#oh_drawing_canvassave)([OH_Drawing_Canvas](#oh_drawing_canvas)\*) | Saves the current canvas status (canvas matrix) to the top of the stack. |
| [OH_Drawing_CanvasRestore](#oh_drawing_canvasrestore)([OH_Drawing_Canvas](#oh_drawing_canvas)\*) | Restores the canvas status (canvas matrix) saved on the top of the stack. |
| [OH_Drawing_CanvasDrawLine](#oh_drawing_canvasdrawline)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, float x1, float y1, float x2, float y2) | Draws a line segment. |
| [OH_Drawing_CanvasDrawPath](#oh_drawing_canvasdrawpath)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, const [OH_Drawing_Path](#oh_drawing_path)\*) | Draws a path. |
| [OH_Drawing_CanvasClear](#oh_drawing_canvasclear)([OH_Drawing_Canvas](#oh_drawing_canvas)\*, uint32_t color) | Clears a canvas by using a specified color. |
| [OH_Drawing_ColorSetArgb](#oh_drawing_colorsetargb)(uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) | Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. |
| [OH_Drawing_CreateFontCollection](#oh_drawing_createfontcollection)(void) | Creates an **OH_Drawing_FontCollection** object. |
| [OH_Drawing_DestroyFontCollection](#oh_drawing_destroyfontcollection)([OH_Drawing_FontCollection](#oh_drawing_fontcollection)\*) | Releases the memory occupied by an **OH_Drawing_FontCollection** object. |
| [OH_Drawing_PathCreate](#oh_drawing_pathcreate)(void) | Creates an **OH_Drawing_Path** object. |
| [OH_Drawing_PathDestroy](#oh_drawing_pathdestroy)([OH_Drawing_Path](#oh_drawing_path)\*) | Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. |
| [OH_Drawing_PathMoveTo](#oh_drawing_pathmoveto)([OH_Drawing_Path](#oh_drawing_path)\*, float x, float y) | Sets the start point of a path. |
| [OH_Drawing_PathLineTo](#oh_drawing_pathlineto)([OH_Drawing_Path](#oh_drawing_path)\*, float x, float y) | Draws a line segment from the last point of a path to the target point. |
| [OH_Drawing_PathArcTo](#oh_drawing_patharcto)([OH_Drawing_Path](#oh_drawing_path)\*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) | Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. |
| [OH_Drawing_PathQuadTo](#oh_drawing_pathquadto)([OH_Drawing_Path](#oh_drawing_path)\*, float ctrlX, float ctrlY, float endX, float endY) | Draws a quadratic Bezier curve from the last point of a path to the target point. |
| [OH_Drawing_PathCubicTo](#oh_drawing_pathcubicto)([OH_Drawing_Path](#oh_drawing_path)\*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) | Draws a cubic Bezier curve from the last point of a path to the target point. |
| [OH_Drawing_PathClose](#oh_drawing_pathclose)([OH_Drawing_Path](#oh_drawing_path)\*) | Closes a path. A line segment from the start point to the last point of the path is added. |
| [OH_Drawing_PenCreate](#oh_drawing_pencreate)(void) | Creates an **OH_Drawing_Pen** object. |
| [OH_Drawing_PenDestroy](#oh_drawing_pendestroy)([OH_Drawing_Pen](#oh_drawing_pen)\*) | Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. |
| [OH_Drawing_PenIsAntiAlias](#oh_drawing_penisantialias)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_PenSetAntiAlias](#oh_drawing_pensetantialias)([OH_Drawing_Pen](#oh_drawing_pen)\*, bool) | Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_PenGetColor](#oh_drawing_pengetcolor)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the color of a pen. The color is used by the pen to outline a shape. |
| [OH_Drawing_PenSetColor](#oh_drawing_pensetcolor)([OH_Drawing_Pen](#oh_drawing_pen)\*, uint32_t color) | Sets the color for a pen. The color is used by the pen to outline a shape. |
| [OH_Drawing_PenGetWidth](#oh_drawing_pengetwidth)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. |
| [OH_Drawing_PenSetWidth](#oh_drawing_pensetwidth)([OH_Drawing_Pen](#oh_drawing_pen)\*, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape. |
| [OH_Drawing_PenGetMiterLimit](#oh_drawing_pengetmiterlimit)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. |
| [OH_Drawing_PenSetMiterLimit](#oh_drawing_pensetmiterlimit)([OH_Drawing_Pen](#oh_drawing_pen)\*, float miter) | Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. |
| [OH_Drawing_PenGetCap](#oh_drawing_pengetcap)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line cap style of a pen. |
| [OH_Drawing_PenSetCap](#oh_drawing_pensetcap)([OH_Drawing_Pen](#oh_drawing_pen)\*, [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle)) | Sets the line cap style for a pen. |
| [OH_Drawing_PenGetJoin](#oh_drawing_pengetjoin)(const[OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line join style of a pen. |
| [OH_Drawing_PenSetJoin](#oh_drawing_pensetjoin)([OH_Drawing_Pen](#oh_drawing_pen)\*, [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle)) | Sets the line join style for a pen. |
| [OH_Drawing_CreateTypographyStyle](#oh_drawing_createtypographystyle)(void) | Creates an **OH_Drawing_TypographyStyle** object. |
| [OH_Drawing_DestroyTypographyStyle](#oh_drawing_destroytypographystyle)([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle)\*) | Releases the memory occupied by an **OH_Drawing_TypographyStyle** object. |
| [OH_Drawing_SetTypographyTextDirection](#oh_drawing_settypographytextdirection)([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle)\*, int) | Sets the text direction. |
| [OH_Drawing_SetTypographyTextAlign](#oh_drawing_settypographytextalign)([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle)\*, int) | Sets the text alignment mode. |
| [OH_Drawing_SetTypographyTextMaxLines](#oh_drawing_settypographytextmaxlines)([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle)\*, int) | Sets the maximum number of lines in a text file. |
| [OH_Drawing_CreateTextStyle](#oh_drawing_createtextstyle)(void) | Creates an **OH_Drawing_TextStyle** object. |
| [OH_Drawing_DestroyTextStyle](#oh_drawing_destroytextstyle)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*) | Releases the memory occupied by an **OH_Drawing_TextStyle** object. |
| [OH_Drawing_SetTextStyleColor](#oh_drawing_settextstylecolor)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, uint32_t) | Sets the text color. |
| [OH_Drawing_SetTextStyleFontSize](#oh_drawing_settextstylefontsize)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, double) | Sets the font size. |
| [OH_Drawing_SetTextStyleFontWeight](#oh_drawing_settextstylefontweight)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, int) | Sets the font weight. |
| [OH_Drawing_SetTextStyleBaseLine](#oh_drawing_settextstylebaseline)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, int) | Sets the text baseline. |
| [OH_Drawing_SetTextStyleDecoration](#oh_drawing_settextstyledecoration)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, int) | Sets the text decoration. |
| [OH_Drawing_SetTextStyleDecorationColor](#oh_drawing_settextstyledecorationcolor)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, uint32_t) | Sets the color for the text decoration. |
| [OH_Drawing_SetTextStyleFontHeight](#oh_drawing_settextstylefontheight)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, double) | Sets the font height. |
| [OH_Drawing_SetTextStyleFontFamilies](#oh_drawing_settextstylefontfamilies)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, int, const char \*fontFamilies[]) | Sets the font families. |
| [OH_Drawing_SetTextStyleFontStyle](#oh_drawing_settextstylefontstyle)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, int) | Sets the font style. |
| [OH_Drawing_SetTextStyleLocale](#oh_drawing_settextstylelocale)([OH_Drawing_TextStyle](#oh_drawing_textstyle)\*, const char \*) | Sets the locale. |
| [OH_Drawing_CreateTypographyHandler](#oh_drawing_createtypographyhandler)([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle)\*, [OH_Drawing_FontCollection](#oh_drawing_fontcollection)\*) | Creates a pointer to an **OH_Drawing_TypographyCreate** object. |
| [OH_Drawing_DestroyTypographyHandler](#oh_drawing_destroytypographyhandler)([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate)\*) | Releases the memory occupied by an **OH_Drawing_TypographyCreate** object. |
| [OH_Drawing_TypographyHandlerPushTextStyle](#oh_drawing_typographyhandlerpushtextstyle)([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate)\*, [OH_Drawing_TextStyle](#oh_drawing_textstyle)\*) | Sets the text style. |
| [OH_Drawing_TypographyHandlerAddText](#oh_drawing_typographyhandleraddtext)([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate)\*, const char \*) | Sets the text content. |
| [OH_Drawing_TypographyHandlerPopTextStyle](#oh_drawing_typographyhandlerpoptextstyle)([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate)\*) | Removes the topmost style in the stack, leaving the remaining styles in effect. |
| [OH_Drawing_CreateTypography](#oh_drawing_createtypography)([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate)\*) | Creates an **OH_Drawing_Typography** object. |
| [OH_Drawing_DestroyTypography](#oh_drawing_destroytypography)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Releases the memory occupied by an **OH_Drawing_Typography** object. |
| [OH_Drawing_TypographyLayout](#oh_drawing_typographylayout)([OH_Drawing_Typography](#oh_drawing_typography)\*, double) | Lays out the typography. |
| [OH_Drawing_TypographyPaint](#oh_drawing_typographypaint)([OH_Drawing_Typography](#oh_drawing_typography)\*, [OH_Drawing_Canvas](#oh_drawing_canvas)\*, double, double) | Paints text on the canvas. |
| [OH_Drawing_TypographyGetMaxWidth](#oh_drawing_typographygetmaxwidth)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the maximum width. |
| [OH_Drawing_TypographyGetHeight](#oh_drawing_typographygetheight)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the height. |
| [OH_Drawing_TypographyGetLongestLine](#oh_drawing_typographygetlongestline)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the longest line. |
| [OH_Drawing_TypographyGetMinIntrinsicWidth](#oh_drawing_typographygetminintrinsicwidth)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the minimum intrinsic width. |
| [OH_Drawing_TypographyGetMaxIntrinsicWidth](#oh_drawing_typographygetmaxintrinsicwidth)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the maximum intrinsic width. |
| [OH_Drawing_TypographyGetAlphabeticBaseline](#oh_drawing_typographygetalphabeticbaseline)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the alphabetic baseline. |
| [OH_Drawing_TypographyGetIdeographicBaseline](#oh_drawing_typographygetideographicbaseline)([OH_Drawing_Typography](#oh_drawing_typography)\*) | Obtains the ideographic baseline. |
## Type Description
### OH_Drawing_Bitmap
```
typedef struct OH_Drawing_BitmapOH_Drawing_Bitmap
```
**Description**<br>
Defines a bitmap, which is a memory that contains the pixel data of a shape.
### OH_Drawing_Brush
```
typedef struct OH_Drawing_BrushOH_Drawing_Brush
```
**Description**<br>
Defines as a brush, which is used to describe the style and color to fill in a shape.
### OH_Drawing_Canvas
```
typedef struct OH_Drawing_CanvasOH_Drawing_Canvas
```
**Description**<br>
Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen.
Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction.
## Enum Description
### OH_Drawing_AlphaFormat
```
enum OH_Drawing_AlphaFormat
```
**Description**<br>
Enumerates alpha formats of bitmap pixels.
| Name | Description |
| -------- | -------- |
| ALPHA_FORMAT_UNKNOWN | Unknown format. |
| ALPHA_FORMAT_OPAQUE | The bitmap does not have the alpha component. |
| ALPHA_FORMAT_PREMUL | The color component of each pixel is premultiplied by the alpha component. |
| ALPHA_FORMAT_UNPREMUL | The color component of each pixel is not premultiplied by the alpha component. |
### OH_Drawing_ColorFormat
```
enum OH_Drawing_ColorFormat
```
**Description**<br>
Enumerates storage formats of bitmap pixels.
| Name | Description |
| -------- | -------- |
| COLOR_FORMAT_UNKNOWN | Unknown format. |
| COLOR_FORMAT_ALPHA_8 | Each pixel is represented by 8 bits, which together indicate alpha. |
| COLOR_FORMAT_RGB_565 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue. |
| COLOR_FORMAT_ARGB_4444 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, every 4 bits indicate alpha, red, green, and blue, respectively. |
| COLOR_FORMAT_RGBA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate alpha, red, green, and blue, respectively. |
| COLOR_FORMAT_BGRA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate blue, green, red, and alpha, respectively. |
### OH_Drawing_FontStyle
```
enum OH_Drawing_FontStyle
```
**Description**<br>
Enumerates font styles.
| Name | Description |
| -------- | -------- |
| FONT_STYLE_NORMAL | Normal style |
| FONT_STYLE_ITALIC | Italic style |
### OH_Drawing_FontWeight
```
enum OH_Drawing_FontWeight
```
**Description**<br>
Enumerates font weights.
| Name | Description |
| -------- | -------- |
| FONT_WEIGHT_100 | Thin |
| FONT_WEIGHT_200 | Extra-light |
| FONT_WEIGHT_300 | Light |
| FONT_WEIGHT_400 | Normal/Regular |
| FONT_WEIGHT_500 | Medium |
| FONT_WEIGHT_600 | Semi-bold |
| FONT_WEIGHT_700 | Bold |
| FONT_WEIGHT_800 | Extra-bold |
| FONT_WEIGHT_900 | Black |
### OH_Drawing_PenLineCapStyle
```
enum OH_Drawing_PenLineCapStyle
```
**Description**<br>
Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen.
| Name | Description |
| -------- | -------- |
| LINE_FLAT_CAP | There is no cap style. Both ends of the line segment are cut off square. |
| LINE_SQUARE_CAP | Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width. |
| LINE_ROUND_CAP | Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment. |
### OH_Drawing_PenLineJoinStyle
```
enum OH_Drawing_PenLineJoinStyle
```
**Description**<br>
Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen.
| Name | Description |
| -------- | -------- |
| LINE_MITER_JOIN | Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. In this case, you need to use the miter limit to limit the miter length. |
| LINE_ROUND_JOIN | Round corner. |
| LINE_BEVEL_JOIN | Beveled corner. |
### OH_Drawing_TextAlign
```
enum OH_Drawing_TextAlign
```
**Description**<br>
Enumerates text alignment modes.
| Name | Description |
| -------- | -------- |
| TEXT_ALIGN_LEFT | Left-aligned |
| TEXT_ALIGN_RIGHT | Right-aligned |
| TEXT_ALIGN_CENTER | Center-aligned |
| TEXT_ALIGN_JUSTIFY | Justified, which means that each line (except the last line) is stretched so that every line has equal width, and the left and right margins are straight. |
| TEXT_ALIGN_START | **TEXT_ALIGN_START** achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**. |
| TEXT_ALIGN_END | **TEXT_ALIGN_END** achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**. |
### OH_Drawing_TextBaseline
```
enum OH_Drawing_TextBaseline
```
**Description**<br>
Enumerates text baselines.
| Name | Description |
| -------- | -------- |
| TEXT_BASELINE_ALPHABETIC | Alphabetic, where the letters in alphabets like English sit on. |
| TEXT_BASELINE_IDEOGRAPHIC | Ideographic. The baseline is at the bottom of the text area. |
### OH_Drawing_TextDecoration
```
enum OH_Drawing_TextDecoration
```
**Description**<br>
Enumerates text decorations.
| Name | Description |
| -------- | -------- |
| TEXT_DECORATION_NONE | No decoration. |
| TEXT_DECORATION_UNDERLINE | A underline is used for decoration. |
| TEXT_DECORATION_OVERLINE | An overline is used for decoration. |
| TEXT_DECORATION_LINE_THROUGH | A strikethrough is used for decoration. |
| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. |
| width | Indicates the width of the bitmap to be initialized. |
| height | Indicates the height of the bitmap to be initialized. |
| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Indicates the pixel format of the bitmap to be initialized, including the pixel color type and alpha type. |
Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added.
Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.
Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.
For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level.
\@syscap SystemCapability.HiviewDFX.HiLog
**Since:**
8
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>File to Include: <hilog/log.h> |
### Macros
| Name | Description |
| -------- | -------- |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file. |
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service. |
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. |
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. |
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. |
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. |
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. |
| [OH_LOG_IsLoggable](#oh_log_isloggable)(unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. |
## Macro Description
### LOG_DOMAIN
```
#define LOG_DOMAIN 0
```
**Description**<br>
Defines the service domain for a log file.
The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated.
### LOG_TAG
```
#define LOG_TAG NULL
```
**Description**<br>
Defines a string constant used to identify the class, file, or service.
Outputs DEBUG logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
Outputs ERROR logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
Outputs FATAL logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
## Enum Description
### LogLevel
```
enum LogLevel
```
**Description**<br>
Enumerates log levels.
You are advised to select log levels based on their respective use cases:
DEBUG: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
INFO: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
WARN: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
ERROR: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
FATAL: indicates that a program or functionality is about to crash and the fault cannot be rectified.
| Name | Description |
| -------- | -------- |
| LOG_DEBUG | DEBUG level to be used by OH_LOG_DEBUG |
| LOG_INFO | INFO level to be used by OH_LOG_INFO |
| LOG_WARN | WARN level to be used by OH_LOG_WARN |
| LOG_ERROR | ERROR level to be used by OH_LOG_ERROR |
| LOG_FATAL | FATAL level to be used by OH_LOG_FATAL |
### LogType
```
enum LogType
```
**Description**<br>
Enumerates log types.
Currently, only LOG_APP is available.
| Name | Description |
| -------- | -------- |
| LOG_APP | Application log |
## Function Description
### OH_LOG_IsLoggable()
```
int bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level )
```
**Description**<br>
Checks whether logs of the specified service domain, log tag, and log level can be output.
**Parameters**
| Name | Description |
| -------- | -------- |
| domain | Indicates the service domain of logs. |
| tag | Indicates the log tag. |
| level | Indicates the log level. |
**Returns**
Returns **true** if the specified logs can be output; returns **false** otherwise.
### OH_LOG_Print()
```
int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... )
```
**Description**<br>
Outputs logs.
You can use this function to output logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| level | Indicates the log level, which can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**. |
| domain | Indicates the service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. |
| tag | Indicates the log tag, which is a string used to identify the class, file, or service. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**Returns**
Returns **0** or a larger value if the operation is successful; returns a value smaller than **0** otherwise.
Describes the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and cryptography operations, provided for applications. The keys managed by HUKS can be imported by applications or generated by calling the HUKS APIs.
\@syscap SystemCapability.Security.Huks
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_huks_api.h](native__huks__api_8h.md) | Declares the APIs used to access the HUKS. <br>File to Include: <huks/native_huks/api.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Huks_GetSdkVersion](#oh_huks_getsdkversion)(struct[OH_Huks_Blob](_o_h___huks___blob.md) \*sdkVersion) | Obtains the current HUKS SDK version. |
| [OH_Huks_InitSession](#oh_huks_initsession)(const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*challenge) | Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). |
| [OH_Huks_UpdateSession](#oh_huks_updatesession)(const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*outData) | Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. |
| keyAlias | Indicates the pointer to the alias of the key to generate. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| paramSetIn | Indicates the pointer to the parameter set for generating the key. |
| paramSetOut | Indicates the pointer to a temporary key generated. If the generated key is not of a temporary type, this parameter is a null pointer. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| paramSet | Indicates the pointer to the parameters of the key to import. |
| key | Indicates the pointer to the key to import. The key must be in the format required by the HUKS. For details, see [HuksTypeApi](_huks_type_api.md). |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| wrappingKeyAlias | Indicates the pointer to the alias of the wrapping key, which is obtained through key agreement and used to decrypt the key to import. |
| paramSet | Indicates the pointer to the parameters of the wrapped key to import. |
| wrappedKeyData | Indicates the pointer to the wrapped key to import. The key must be in the format required by the HUKS. For details, see [OH_Huks_AlgSuite](_huks_type_api.md#oh_huks_algsuite). |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional).
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the target key. |
| paramSet | Indicates the pointer to the parameters for the initialization operation. |
| handle | Indicates the pointer to the handle of the key session obtained. This handle is required for subsequent operations, including [OH_Huks_UpdateSession](#oh_huks_updatesession), [OH_Huks_FinishSession](#oh_huks_finishsession), and [OH_Huks_AbortSession](#oh_huks_abortsession). |
| challenge | Indicates the pointer to the challenge value obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. The HUKS APIs can be used to perform parameter set lifecycle management, including initializing a parameter set, adding parameters to a parameter set, constructing a parameter set, and destroying a parameter set. They can also be used to obtain parameters, copy parameter sets, and check parameter validity.
\@syscap SystemCapability.Security.Huks
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_huks_param.h](native__huks__param_8h.md) | Provides APIs for constructing, using, and destroying parameter sets. <br>File to Include: <huks/native_huks/native_huks_param.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Huks_InitParamSet](#oh_huks_initparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. |
| [OH_Huks_AddParams](#oh_huks_addparams)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md)\*params, uint32_t paramCnt) | Adds parameters to a parameter set. |
| [OH_Huks_BuildParamSet](#oh_huks_buildparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. |
| [OH_Huks_FreeParamSet](#oh_huks_freeparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. |
| [OH_Huks_CopyParamSet](#oh_huks_copyparamset)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*\*paramSet) | Copies a parameter set (deep copy). |
| [OH_Huks_GetParam](#oh_huks_getparam)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md)\*\*param) | Obtains parameters from a parameter set. |
| [OH_Huks_FreshParamSet](#oh_huks_freshparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. |
| [OH_Huks_isParamSetTagValid](#oh_huks_isparamsettagvalid)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet) | Checks whether the parameters in a parameter set are valid. |
| [OH_Huks_isParamSetValid](#oh_huks_isparamsetvalid)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. |
| [OH_Huks_CheckParamMatch](#oh_huks_checkparammatch)(const struct [OH_Huks_Param](_o_h___huks___param.md)\*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md)\*param) | Checks whether two parameters are the same. |
Refreshes data of the **Blob** type in a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the target parameter set. |
| isCopy | Specifies whether to copy the data of the **Blob** type to the parameter set. If yes, the data of the **Blob** type will be copied to the parameter set. Otherwise, only the address of the **Blob** data will be refreshed. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if operation is successful; returns an error code otherwise.
Checks whether the parameters in a parameter set are valid.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the parameter set to check. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameters in the parameter set are valid; returns other values if the parameter set has invalid, duplicate, or incorrect parameters.
Defines the macros, enumerated values, data structures, and error codes used by OpenHarmony Universal KeyStore (HUKS) APIs.
\@syscap SystemCapability.Security.Huks
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_huks_type.h](native__huks__type_8h.md) | Defines the enumerated variables, structures, and macros used in the HUKS APIs. <br>File to Include: <huks/native_huks/native_huks_type.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_Huks_Result](_o_h___huks___result.md) | Defines the return data, including the result code and message. |
| [OH_Huks_Blob](_o_h___huks___blob.md) | Defines the structure for storing data. |
| [OH_Huks_Param](_o_h___huks___param.md) | Defines the parameter structure in a parameter set. |
| [OH_Huks_ParamSet](_o_h___huks___param_set.md) | Defines the structure of the parameter set. |
| [OH_Huks_CertChain](_o_h___huks___cert_chain.md) | Defines the structure of the certificate chain. |
| [OH_Huks_KeyInfo](_o_h___huks___key_info.md) | Defines the key information structure. |
| [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md) | Defines the structure of a public key. |
| [OH_Huks_KeyMaterialRsa](_o_h___huks___key_material_rsa.md) | Defines the structure of an RSA key. |
| [OH_Huks_KeyMaterialEcc](_o_h___huks___key_material_ecc.md) | Defines the structure of an ECC key. |
| [OH_Huks_KeyMaterialDsa](_o_h___huks___key_material_dsa.md) | Defines the structure of a DSA key. |
| [OH_Huks_KeyMaterialDh](_o_h___huks___key_material_dh.md) | Defines the structure of a DH key. |
| [OH_Huks_KeyMaterial25519](_o_h___huks___key_material25519.md) | Defines the structure of a 25519 key. |
| [OH_Huks_ImportKeyType](#oh_huks_importkeytype) { OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, OH_HUKS_KEY_TYPE_KEY_PAIR = 2 } | Enumerates the types of keys to import. By default, a public key is imported. This field is not required when a symmetric key is imported. |
| [OH_Huks_ChallengeType](#oh_huks_challengetype) { OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, OH_HUKS_CHALLENGE_TYPE_NONE = 2 } | Enumerates the types of the challenges generated when a key is used. |
| [OH_Huks_ChallengePosition](#oh_huks_challengeposition) { OH_HUKS_CHALLENGE_POS_0 = 0, OH_HUKS_CHALLENGE_POS_1, OH_HUKS_CHALLENGE_POS_2, OH_HUKS_CHALLENGE_POS_3 } | Enumerates the positions of the 8-byte valid value in a custom challenge generated. |
| [OH_Huks_SecureSignType](#oh_huks_securesigntype) { OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 } | Enumerates the signature types of the keys generated or imported. |
| OH_HUKS_CHALLENGE_TYPE_NORMAL | Normal challenge, which is of 32 bytes by default. |
| OH_HUKS_CHALLENGE_TYPE_CUSTOM | Custom challenge, which supports only one authentication for multiple keys. The valid value of a custom challenge is of 8 bytes. |
| OH_HUKS_CHALLENGE_TYPE_NONE | Challenge is not required. |
| OH_HUKS_ECC_KEY_SIZE_256 | ECC key of 256 bits. |
| OH_HUKS_ECC_KEY_SIZE_384 | ECC key of 384 bits. |
| OH_HUKS_ECC_KEY_SIZE_521 | ECC key of 521 bits. |
| OH_HUKS_AES_KEY_SIZE_128 | Advanced Encryption Standard (AES) key of 128 bits. |
| OH_HUKS_AES_KEY_SIZE_192 | AES key of 192 bits. |
| OH_HUKS_AES_KEY_SIZE_256 | AES key of 256 bits. |
| OH_HUKS_AES_KEY_SIZE_512 | AES key of 512 bits. |
| OH_HUKS_CURVE25519_KEY_SIZE_256 | Curve25519 key of 256 bits. |
| OH_HUKS_DH_KEY_SIZE_2048 | Diffie-Hellman (DH) key of 2048 bits. |
| OH_HUKS_DH_KEY_SIZE_3072 | DH key of 3072 bits. |
| OH_HUKS_DH_KEY_SIZE_4096 | DH key of 4096 bits. |
| OH_HUKS_SM2_KEY_SIZE_256 | ShangMi2 (SM2) key of 256 bits. |
| OH_HUKS_SM4_KEY_SIZE_128 | ShangMi4 (SM4) key of 128 bits. |
### OH_Huks_KeyStorageType
```
enum OH_Huks_KeyStorageType
```
**Description**<br>
Enumerates the key storage modes.
| Name | Description |
| -------- | -------- |
| OH_HUKS_STORAGE_TEMP | The key is managed locally. |
| OH_HUKS_STORAGE_PERSISTENT | The key is managed by the HUKS service. |
### OH_Huks_SecureSignType
```
enum OH_Huks_SecureSignType
```
**Description**<br>
Enumerates the signature types of the keys generated or imported.
| Name | Description |
| -------- | -------- |
| OH_HUKS_SECURE_SIGN_WITH_AUTHINFO | The signature carries authentication information. This field is specified when a key is generated or imported. When the key is used to sign data, the data will be added with the authentication information and then be signed. |
### OH_Huks_Tag
```
enum OH_Huks_Tag
```
**Description**<br>
Enumerates the tag values used in parameter sets.
| Name | Description |
| -------- | -------- |
| OH_HUKS_TAG_ALGORITHM | Tags for key parameters. The value range is 1 to 200. Algorithm. |
| OH_HUKS_TAG_NONCE | Field for key encryption and decryption. |
| OH_HUKS_TAG_IV | Initialized vector (IV). |
| OH_HUKS_TAG_INFO | Information generated during key derivation. |
| OH_HUKS_TAG_SALT | Salt value used for key derivation. |
| OH_HUKS_TAG_ITERATION | Number of iterations for key derivation. |
| OH_HUKS_TAG_KEY_GENERATE_TYPE | Type of the generated key. For details, see [OH_Huks_KeyGenerateType](#oh_huks_keygeneratetype). |
| OH_HUKS_TAG_AGREE_ALG | Algorithm used in key agreement. |
| OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | Alias of the public key used for key agreement. |
| OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | Alias of the private key used for key agreement. |
| OH_HUKS_TAG_AGREE_PUBLIC_KEY | Public key used for key agreement. |
| OH_HUKS_TAG_KEY_ALIAS | Alias of the key. |
| OH_HUKS_TAG_DERIVE_KEY_SIZE | Size of the derived key. |
| OH_HUKS_TAG_IMPORT_KEY_TYPE | Type of the key to import. For details, see [OH_Huks_ImportKeyType](#oh_huks_importkeytype). |
| OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE | Algorithm suite required for encrypted imports. |
| OH_HUKS_TAG_ALL_USERS | Tags for access control and user authentication. The value range is 301 to 500. All users in the multi-user scenario. |
| OH_HUKS_TAG_USER_ID | Multi-user ID. |
| OH_HUKS_TAG_NO_AUTH_REQUIRED | Specifies whether key access control is required. |
| OH_HUKS_TAG_USER_AUTH_TYPE | User authentication type in key access control. |
| OH_HUKS_TAG_AUTH_TIMEOUT | Timeout duration for key access. |
| OH_HUKS_TAG_AUTH_TOKEN | Authentication token for the key. |
| OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE | Access control type. For details, see [OH_Huks_AuthAccessType](#oh_huks_authaccesstype). This parameter must be set together with the user authentication type. |
| OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE | Signature type for the key to be generated or imported. |
| OH_HUKS_TAG_CHALLENGE_TYPE | Challenge type. For details, see [OH_Huks_ChallengeType](#oh_huks_challengetype). |
| OH_HUKS_TAG_CHALLENGE_POS | Position of the 8-byte valid value in a custom challenge. For details, see [OH_Huks_ChallengePosition](#oh_huks_challengeposition). |
| OH_HUKS_TAG_ATTESTATION_CHALLENGE | Tags for key attestation. The value range is 501 to 600. Challenge value used in the attestation. |
| OH_HUKS_TAG_ATTESTATION_APPLICATION_ID | Application ID used in the attestation. |
| OH_HUKS_TAG_ATTESTATION_ID_ALIAS | Alias of the key. |
| OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | Security level used in the attestation. |
| OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO | Version information used in the attestation. |
| OH_HUKS_TAG_IS_KEY_ALIAS | 601 to 1000 are reserved for other tags.<br/>Extended tags. The value range is 1001 to 9999. Specifies whether it is a key alias. |
| OH_HUKS_TAG_KEY_STORAGE_FLAG | Key storage mode. For details, see [OH_Huks_KeyStorageType](#oh_huks_keystoragetype). |
| OH_HUKS_TAG_IS_ALLOWED_WRAP | Specifies whether to allow the key to be wrapped. |
| OH_HUKS_TAG_KEY_WRAP_TYPE | Key wrap type. |
| OH_HUKS_TAG_KEY_AUTH_ID | Authentication ID. |
| OH_HUKS_TAG_KEY_ROLE | Role of the key. |
| OH_HUKS_TAG_KEY_FLAG | Key flag. For details, see [OH_Huks_KeyFlag](#oh_huks_keyflag). |
| OH_HUKS_TAG_IS_ASYNCHRONIZED | Specifies whether this API is asynchronous. |
| OH_HUKS_TAG_KEY_DOMAIN | Key domain. |
| OH_HUKS_TAG_SYMMETRIC_KEY_DATA | 11000 to 12000 are reserved.<br/>20001 to N are reserved for other tags. Symmetric key data. |
| OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | Public key data of the asymmetric key pair. |
| OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | Private key data of the asymmetric key pair. |
Provides APIs related to MindSpore Lite model inference.
Copyright 2021 Huawei Technologies Co., Ltd
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\@Syscap SystemCapability.Ai.MindSpore
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information. <br>File to Include: <mindspore/context.h> |
| [data_type.h](data__type_8h.md) | Declares tensor data types. <br>File to Include: <mindspore/data_type.h> |
| [format.h](format_8h.md) | Declares tensor data formats. <br>File to Include: <mindspore/format.h> |
| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference. <br>File to Include: <mindspore/model.h> |
| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite. <br>File to Include: <mindspore/status.h> |
| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information. <br>File to Include: <mindspore/tensor.h> |
| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite. <br>File to Include: <mindspore/types.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. |
| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. |
### Macros
| Name | Description |
| -------- | -------- |
| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. |
| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. |
| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. |
| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. |
| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. |
| **OH_AI_ShapeInfo** | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. |
| [OH_AI_KernelCallBack](#oh_ai_kernelcallback)) (const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) outputs, const [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) kernel_Info) | Defines the pointer to a callback. |
| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. |
| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. |
| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. |
| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. |
| [OH_AI_ContextCreate](#oh_ai_contextcreate)() | Creates a context object. |
| [OH_AI_ContextDestroy](#oh_ai_contextdestroy)([OH_AI_ContextHandle](#oh_ai_contexthandle)\*context) | Destroys a context object. |
| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum)([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. |
| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum)(const[OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. |
| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode)([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. |
| [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode)(const[OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. |
| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist)([OH_AI_ContextHandle](#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. |
| [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist)(const[OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. |
| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel)([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. |
| [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel)(const[OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. |
| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo)([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. |
| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate)([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. |
| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy)([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle)\*device_info) | Destroys a device information instance. |
| [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider)([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. |
| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider)(const[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. |
| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice)([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. |
| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice)(const[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. |
| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype)(const[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. |
| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16)([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16)(const[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency)([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency)(const[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_ModelCreate](#oh_ai_modelcreate)() | Creates a model object. |
| [OH_AI_ModelDestroy](#oh_ai_modeldestroy)([OH_AI_ModelHandle](#oh_ai_modelhandle)\*model) | Destroys a model object. |
| [OH_AI_ModelBuild](#oh_ai_modelbuild)([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. |
| [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile)([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. |
| [OH_AI_ModelResize](#oh_ai_modelresize)([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md)\*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. |
| [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs)(const[OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. |
| [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs)(const[OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. |
| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname)(const[OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. |
| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname)(const[OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. |
| [OH_AI_TensorDestroy](#oh_ai_tensordestroy)([OH_AI_TensorHandle](#oh_ai_tensorhandle)\*tensor) | Destroys a tensor object. |
| [OH_AI_TensorClone](#oh_ai_tensorclone)([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. |
| [OH_AI_TensorSetName](#oh_ai_tensorsetname)([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. |
| [OH_AI_TensorGetName](#oh_ai_tensorgetname)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. |
| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype)([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. |
| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. |
| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape)([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. |
| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. |
| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat)([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. |
| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. |
| [OH_AI_TensorGetData](#oh_ai_tensorgetdata)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. |
| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. |
| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. |
| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize)(const[OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. |
## Macro Description
### OH_AI_MAX_SHAPE_NUM
```
#define OH_AI_MAX_SHAPE_NUM 32
```
**Description**<br>
Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**.
This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#oh_ai_modelpredict). Each callback function must contain three parameters, where **inputs** and **outputs** indicate the input and output tensors of the operator, and **kernel_Info** indicates information about the current operator. You can use the callback functions to monitor the operator execution status, for example, operator execution time and the operator correctness.
Checks whether parallelism between operators is supported.
**Parameters**
| Name | Description |
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. |
**Returns**
Whether parallelism between operators is supported. The value **true** means that parallelism between operators is supported, and the value **false** means the opposite.
Sets whether to enable parallelism between operators.
**Parameters**
| Name | Description |
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. |
| is_parallel | Whether to enable parallelism between operators. The value **true** means to enable parallelism between operators, and the value **false** means the opposite. |
Sets the list of CPU cores bound to a runtime thread.
For example, if **core_list** is set to **[2,6,8]**, threads run on the 2nd, 6th, and 8th CPU cores. If [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) and [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) are called for the same context object, the **core_list** parameter of [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) takes effect, but the **mode** parameter of [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) does not.
**Parameters**
| Name | Description |
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. |
| core_list | List of bound CPU cores. |
| core_num | Number of cores, which indicates the length of **core_list**. |
### OH_AI_ContextSetThreadAffinityMode()
```
OH_AI_API void OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode )
```
**Description**<br>
Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency.
**Parameters**
| Name | Description |
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. |
| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first |
Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices.
**Parameters**
| Name | Description |
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
**Returns**
Whether float16 inference is enabled.
### OH_AI_DeviceInfoGetFrequency()
```
OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info)
```
**Description**<br>
Obtains the NPU frequency type. This function is available only for NPU devices.
**Parameters**
| Name | Description |
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
**Returns**
Frequency type of the NPU. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance
Sets whether to enable float16 inference. This function is available only for CPU/GPU devices.
**Parameters**
| Name | Description |
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
| is_fp16 | Whether to enable float16 inference. |
### OH_AI_DeviceInfoSetFrequency()
```
OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency )
```
**Description**<br>
Sets the NPU frequency type. This function is available only for NPU devices.
**Parameters**
| Name | Description |
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance |
Loads and builds a MindSpore model from the memory buffer.
Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the model object. |
| model_data | Address of the loaded model data in the memory. |
| data_size | Length of the model data. |
| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). |
| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). |
**Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
Loads and builds a MindSpore model from a model file.
Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the model object. |
| model_path | Path of the model file. |
| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). |
| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). |
**Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
| inputs | Tensor array structure corresponding to the model input. |
| shape_infos | Input shape array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence. |
| shape_info_num | Length of the input shape array. |
**Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
| [external_window.h](external__window_8h.md) | Defines the functions for obtaining and using a native window. <br>File to Include: <native_window/external_window.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [Region](_region.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window. |
| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Defines the HDR metadata. |
| [OHExtDataHandle](_o_h_ext_data_handle.md) | Defines the extended data handle. |
### Types
| Name | Description |
| -------- | -------- |
| OHNativeWindow | Provides the function of accessing the **NativeWindow**. |
| OHNativeWindowBuffer | Provides the function of accessing the **NativeWindowBuffer**. |
| Region | Defines the rectangle (dirty region) where the content is to be updated in the local native window. |
### Enums
| Name | Description |
| -------- | -------- |
| [NativeWindowOperation](#nativewindowoperation) {<br/>SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT,<br/>GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE,<br/>SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT,<br/>SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM,<br/>SET_UI_TIMESTAMP<br/>} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. |
| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow)(void\*pSurface) | Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. |
| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow)(OHNativeWindow\*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. |
| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer)(void\*pSurfaceBuffer) | Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. |
| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer)(OHNativeWindowBuffer\*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. |
| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer)(OHNativeWindow\*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. |
| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer)(OHNativeWindow\*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. |
| [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer)(OHNativeWindow\*window, OHNativeWindowBuffer \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. |
| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt)(OHNativeWindow\*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format. |
| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative)(OHNativeWindowBuffer\*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. |
| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference)(void\*obj) | Adds the reference count of a native object. |
| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference)(void\*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. |
| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic)(void\*obj) | Obtains the magic ID of a native object. |
| [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode)(OHNativeWindow\*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. |
| [OH_NativeWindow_NativeWindowSetMetaData](#oh_nativewindow_nativewindowsetmetadata)(OHNativeWindow\*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md)\*metaData) | Sets the metadata for a native window. |
| [OH_NativeWindow_NativeWindowSetMetaDataSet](#oh_nativewindow_nativewindowsetmetadataset)(OHNativeWindow\*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. |
| [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle)(OHNativeWindow\*window, const [OHExtDataHandle](_o_h_ext_data_handle.md)\*handle) | Sets a tunnel handle for a native window. |
## Enum Description
### NativeWindowOperation
```
enum NativeWindowOperation
```
**Description**<br>
Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function.
| Name | Description |
| -------- | -------- |
| SET_BUFFER_GEOMETRY | Setting the geometry for the local window buffer. Variable arguments in the function: [Input] int32_t height and [Input] int32_t width. |
| GET_BUFFER_GEOMETRY | Obtaining the geometry of the local window buffer. Variable arguments in the function: [Output] int32_t \*height and [Output] int32_t \*width. |
| GET_FORMAT | Obtaining the format of the local window buffer. Variable argument in the function: [Output] int32_t \*format. |
| SET_FORMAT | Setting the format for the local window buffer. Variable argument in the function: [Input] int32_t format. |
| GET_USAGE | Obtaining the usage mode of the local window buffer. Variable argument in the function: [Output] int32_t \*usage. |
| SET_USAGE | Setting the usage mode for the local window buffer. Variable argument in the function: [Input] int32_t usage. |
| SET_STRIDE | Setting the stride for the local window buffer. Variable argument in the function: [Input] int32_t stride. |
| GET_STRIDE | Obtaining the stride of the local window buffer. Variable argument in the function: [Output] int32_t \*stride. |
| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer. Variable argument in the function: [Input] int32_t interval. |
| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer. Variable argument in the function: [Output] int32_t \*interval. |
| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer. Variable argument in the function: [Input] int32_t timeout. |
| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer. Variable argument in the function: [Output] int32_t \*timeout. |
| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer. Variable argument in the function: [Input] int32_t colorGamut. |
| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer. Variable argument in the function: [out int32_t \*colorGamut]. |
| SET_TRANSFORM | Setting the transform for the local window buffer. Variable argument in the function: [Input] int32_t transform. |
| GET_TRANSFORM | Obtaining the transform of the local window buffer. Variable argument in the function: [Output] int32_t \*transform. |
| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer. Variable argument in the function: [Input] uint64_t uiTimestamp. |
### OHHDRMetadataKey
```
enum OHHDRMetadataKey
```
**Description**<br>
Enumerates the HDR metadata keys.
| Name | Description |
| -------- | -------- |
| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color. |
| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color. |
| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color. |
| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color. |
| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color. |
| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color. |
| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point. |
| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point. |
| OH_METAKEY_MAX_LUMINANCE | Maximum luminance. |
| OH_METAKEY_MIN_LUMINANCE | Minimum luminance. |
| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL). |
| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL). |
| OH_METAKEY_HDR10_PLUS | HDR10+. |
| OH_METAKEY_HDR_VIVID | Vivid. |
### OHScalingMode
```
enum OHScalingMode
```
**Description**<br>
Enumerates the scaling modes.
| Name | Description |
| -------- | -------- |
| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received. |
| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size. |
| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size. |
| OH_SCALING_MODE_NO_SCALE_CROP | The window is cropped to the size of the buffer's cropping rectangle. Pixels outside the cropping rectangle are considered completely transparent. |
Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request.
Provides APIs of Neural Network Runtime for accelerating the model inference.
Provides APIs for accelerating the Neural Network Runtime model inference.
\@Syscap SystemCapability.Ai.NeuralNetworkRuntime
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [neural_network_runtime.h](neural__network__runtime_8h.md) | Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime to construct and compile models and perform inference and computing on acceleration hardware. Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling. <br>File to Include: <neural_network_runtime/neural_network_runtime.h> |
| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Defines the structure and enumeration for Neural Network Runtime. <br>File to Include: <neural_network_runtime/neural_network_runtime_type.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) | This structure is used to store a 32-bit unsigned integer array. |
| [OH_NNModel_Construct](#oh_nnmodel_construct)(void) | Creates a model instance of the [OH_NNModel](#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance. |
| [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)([OH_NNModel](#oh_nnmodel)\*model, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor) | Adds a tensor to a model instance. |
| [OH_NNModel_AddOperation](#oh_nnmodel_addoperation)([OH_NNModel](#oh_nnmodel)\*model, [OH_NN_OperationType](#oh_nn_operationtype) op, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*paramIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*outputIndices) | Adds an operator to a model instance. |
| [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)([OH_NNModel](#oh_nnmodel)\*model, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*outputIndices) | Specifies the inputs and outputs of a model. |
| [OH_NNModel_Finish](#oh_nnmodel_finish)([OH_NNModel](#oh_nnmodel)\*model) | Completes model composition. |
| [OH_NNModel_Destroy](#oh_nnmodel_destroy)([OH_NNModel](#oh_nnmodel)\*\*model) | Releases a model instance. |
| [OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations)([OH_NNModel](#oh_nnmodel)\*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. |
| [OH_NNCompilation_Construct](#oh_nncompilation_construct)(const[OH_NNModel](#oh_nnmodel) \*model) | Creates a compilation instance of the [OH_NNCompilation](#oh_nncompilation) type. |
| [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice)([OH_NNCompilation](#oh_nncompilation)\*compilation, size_t deviceID) | Specifies the device for model compilation and computing. |
| [OH_NNCompilation_SetCache](#oh_nncompilation_setcache)([OH_NNCompilation](#oh_nncompilation)\*compilation, const char \*cachePath, uint32_t version) | Set the cache directory and version of the compiled model. |
| [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode)([OH_NNCompilation](#oh_nncompilation)\*compilation, [OH_NN_PerformanceMode](#oh_nn_performancemode) performanceMode) | Sets the performance mode for model computing. |
| [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority)([OH_NNCompilation](#oh_nncompilation)\*compilation, [OH_NN_Priority](#oh_nn_priority) priority) | Sets the model computing priority. |
| [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16)([OH_NNCompilation](#oh_nncompilation)\*compilation, bool enableFloat16) | Enables float16 for computing. |
| [OH_NNCompilation_Build](#oh_nncompilation_build)([OH_NNCompilation](#oh_nncompilation)\*compilation) | Compiles a model. |
| [OH_NNCompilation_Destroy](#oh_nncompilation_destroy)([OH_NNCompilation](#oh_nncompilation)\*\*compilation) | Releases the **Compilation** object. |
| [OH_NNExecutor_Construct](#oh_nnexecutor_construct)([OH_NNCompilation](#oh_nncompilation)\*compilation) | [OH_NNExecutor](#oh_nnexecutor)\*<br/>Creates an executor instance of the [OH_NNExecutor](#oh_nnexecutor) type. |
| [OH_NNExecutor_SetInput](#oh_nnexecutor_setinput)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor, const void \*dataBuffer, size_t length) | Sets the single input data for a model. |
| [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | Sets the buffer for a single output of a model. |
| [OH_NNExecutor_GetOutputShape](#oh_nnexecutor_getoutputshape)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | Obtains the dimension information about the output tensor. |
| [OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t inputIndex, size_t length) | Allocates shared memory to a single input on a device. |
| [OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t outputIndex, size_t length) | Allocates shared memory to a single output on a device. |
| [OH_NNExecutor_DestroyInputMemory](#oh_nnexecutor_destroyinputmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t inputIndex, [OH_NN_Memory](_o_h___n_n___memory.md)\*\*memory) | Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. |
| [OH_NNExecutor_DestroyOutputMemory](#oh_nnexecutor_destroyoutputmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t outputIndex, [OH_NN_Memory](_o_h___n_n___memory.md)\*\*memory) | Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. |
| [OH_NNExecutor_SetInputWithMemory](#oh_nnexecutor_setinputwithmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor, const [OH_NN_Memory](_o_h___n_n___memory.md)\*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input. |
| [OH_NNExecutor_SetOutputWithMemory](#oh_nnexecutor_setoutputwithmemory)([OH_NNExecutor](#oh_nnexecutor)\*executor, uint32_t outputIndex, const [OH_NN_Memory](_o_h___n_n___memory.md)\*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output. |
| [OH_NNExecutor_Destroy](#oh_nnexecutor_destroy)([OH_NNExecutor](#oh_nnexecutor)\*\*executor) | Destroys an executor instance to release the memory occupied by the executor. |
| [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid)(const size_t \*\*allDevicesID, uint32_t \*deviceCount) | Obtains the ID of the device connected to Neural Network Runtime. |
| [OH_NNDevice_GetName](#oh_nndevice_getname)(size_t deviceID, const char \*\*name) | Obtains the name of the specified device. |
| [OH_NNDevice_GetType](#oh_nndevice_gettype)(size_t deviceID, [OH_NN_DeviceType](#oh_nn_devicetype)\*deviceType) | Obtains the type information of the specified device. |
## Type Description
### OH_NN_Memory
```
typedef struct OH_NN_MemoryOH_NN_Memory
```
**Description**<br>
Defines the memory structure.
### OH_NN_QuantParam
```
typedef struct OH_NN_QuantParamOH_NN_QuantParam
```
**Description**<br>
Quantization information.
In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula:
s and z are quantization parameters, which are stored by **scale** and **zeroPoint** in [OH_NN_QuantParam](_o_h___n_n___quant_param.md). r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and q_max is an upper bound of a quantization result. The calculation method is as follows:
The clamp function is defined as follows:
### OH_NN_Tensor
```
typedef struct OH_NN_TensorOH_NN_Tensor
```
**Description**<br>
Defines the tensor structure.
It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, you need to specify the data type, number of dimensions, dimension information, and quantization information.
### OH_NN_UInt32Array
```
typedef struct OH_NN_UInt32ArrayOH_NN_UInt32Array
```
**Description**<br>
This structure is used to store a 32-bit unsigned integer array.
### OH_NNCompilation
```
typedef struct OH_NNCompilationOH_NNCompilation
```
**Description**<br>
Defines the compiler handle for Neural Network Runtime.
### OH_NNExecutor
```
typedef struct OH_NNExecutorOH_NNExecutor
```
**Description**<br>
Defines the executor handle for Neural Network Runtime.
### OH_NNModel
```
typedef struct OH_NNModelOH_NNModel
```
**Description**<br>
Defines the handles of models for Neural Network Runtime.
## Enum Description
### OH_NN_DataType
```
enum OH_NN_DataType
```
**Description**<br>
Defines tensor data types supported by Neural Network Runtime.
| Name | Description |
| -------- | -------- |
| OH_NN_UNKNOWN | Unknown type |
| OH_NN_BOOL | bool |
| OH_NN_INT8 | int8 |
| OH_NN_INT16 | int16 |
| OH_NN_INT32 | int32 |
| OH_NN_INT64 | int64 |
| OH_NN_UINT8 | uint8 |
| OH_NN_UINT16 | uint16 |
| OH_NN_UINT32 | uint32 |
| OH_NN_UINT64 | uint64 |
| OH_NN_FLOAT16 | float16 |
| OH_NN_FLOAT32 | float32 |
| OH_NN_FLOAT64 | float64 |
### OH_NN_DeviceType
```
enum OH_NN_DeviceType
```
**Description**<br>
Defines device types supported by Neural Network Runtime.
| Name | Description |
| -------- | -------- |
| OH_NN_OTHERS | Devices that are not CPU, GPU, or dedicated accelerator |
| OH_NN_FORMAT_NONE | The tensor does not have a specific layout type (such as scalar or vector). |
| OH_NN_FORMAT_NCHW | The tensor arranges data in NCHW format. |
| OH_NN_FORMAT_NHWC | The tensor arranges data in NHWC format. |
### OH_NN_FuseType
```
enum OH_NN_FuseType : int8_t
```
**Description**<br>
Defines activation function types in the fusion operator for Neural Network Runtime.
| Name | Description |
| -------- | -------- |
| OH_NN_FUSED_NONE | The fusion activation function is not specified. |
| OH_NN_FUSED_RELU | Fusion relu activation function |
| OH_NN_FUSED_RELU6 | Fusion relu6 activation function |
### OH_NN_OperationType
```
enum OH_NN_OperationType
```
**Description**<br>
Defines operator types supported by Neural Network Runtime.
| Name | Description |
| -------- | -------- |
| OH_NN_OPS_ADD | Returns the tensor of the sum of the elements corresponding to two input tensors.<br/>Inputs:<br/>- **input1**: first input tensor, of the Boolean or number type.<br/>- **input2**: second input tensor, whose data type must be the same as that of the first tensor.<br/>Parameters:<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: sum of **input1** and **input2**. The data shape is the same as that of the input after broadcasting, and the data type is the same as that of the input with a higher precision. |
| OH_NN_OPS_AVG_POOL | Apply 2D average pooling to the input tensor, which now must be in NHWC format. The int8 quantization input is supported.<br/>If the input contains the **padMode** parameter:<br/>Inputs:<br/>- **input**: tensor.<br/>Parameters:<br/>- **kernelSize** indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.<br/>- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.<br/>- **padMode**: padding mode, which is optional. The value is of the int type and can be **0** (same) or **1** (valid). The nearest neighbor value is used for padding. **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right. **1** (valid): The possible maximum height and width of the output will be returned in case of no padding. Excessive pixels will be discarded.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>If the input contains the **padList** parameter:<br/>Inputs:<br/>- **input**: tensor.<br/>Parameters:<br/>- **kernelSize** indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.<br/>- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.<br/>- **padList**: padding around **input**. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: average pooling result of the input. |
| OH_NN_OPS_BATCH_NORM | Batch normalization is performed on a tensor to scale and shift tensor elements, relieving potential covariate shift in a batch of data.<br/>Inputs:<br/>- **input**: n-dimensional tensor of shape [N, ..., C]. The nth dimension is the number of channels.<br/>- **scale**: 1D tensor of the scaling factor used to scale the first normalized tensor.<br/>- **offset**: 1D tensor used to move to the first normalized tensor.<br/>- **mean**: 1D tensor of the overall mean value. It is used only for inference. In case of training, this parameter must be left empty.<br/>- **variance**: 1D tensor used for the overall variance. It is used only for inference. In case of training, this parameter must be left empty.<br/>Parameters:<br/>- **epsilon**: fixed small additional value.<br/>Outputs:<br/>- **output**: n-dimensional output tensor whose shape and data type are the same as those of the input. |
| OH_NN_OPS_BATCH_TO_SPACE_ND | Divides the batch dimension of a 4D tensor into small blocks by **block_shape**, and interleaves these blocks back into the spatial dimension.<br/>Parameters:<br/>- **input**: input tensor. The dimension will be divided into small blocks, and these blocks will be interleaved into the spatial dimension.<br/>Outputs:<br/>- **blockSize**: size of each block to be interleaved into the spatial dimension. The value is an array [height_block, width_block].<br/>- **crops**: elements truncated from the spatial dimension of the output. The value is a 2D array [[crop0_start, crop0_end], [crop1_start, crop1_end]] with the shape of (2, 2).<br/>Outputs:<br/>- **output**. Assume that the shape of **input** is (n,h,w,c) and the shape of **output** is (n',h',w',c'): n' = n / (block_shape[0] \* block_shape[1]) h' = h \* block_shape[0] - crops[0][0] - crops[0][1] w' = w \* block_shape[1] - crops[1][0] - crops[1][1] c'= c |
| OH_NN_OPS_BIAS_ADD | Offsets the data in each dimension of the input tensor.<br/>Inputs:<br/>- **input**: input tensor, which can have two to five dimensions.<br/>- **bias**: offset of the number of input dimensions.<br/>Outputs:<br/>- **output**: sum of the input tensor and the bias in each dimension. |
| OH_NN_OPS_CAST | Converts the data type in the input tensor.<br/>Inputs:<br/>- **input**: input tensor.<br/>- **type**: converted data type.<br/>Outputs:<br/>- **output**: converted tensor. |
| OH_NN_OPS_CONCAT | Connects tensors in a specified dimension.<br/>Inputs:<br/>- **input**: N input tensors.<br/>Parameters:<br/>- **axis**: dimension for connecting tensors.<br/>Outputs:<br/>- **output**: result of connecting N tensors along the axis. |
| OH_NN_OPS_CONV2D | 2D convolutional layer.<br/>If the input contains the **padMode** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.<br/>**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.<br/>- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>If the input contains the **padList** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padList**: padding around **input**. It is an int array [top, bottom, left, right].<br/>- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is **in_channel**, it is depthwiseConv2d. In this case, group==in_channel==out_channel. If **group** is greater than **1** and less than **in_channel**, it is a group convolution. In this case, out_channel==group.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: convolution computing result. |
| OH_NN_OPS_CONV2D_TRANSPOSE | 2D convolution transposition.<br/>If the input contains the **padMode** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>Parameters:<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right. **1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.<br/>- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.<br/>- **outputPads**: padding along the height and width of the output tensor. The value is an int or a tuple. It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding along a dimension must be less than the stride along this dimension.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>If the input contains the **padList** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padList**: padding around **input**. It is an int array [top, bottom, left, right].<br/>- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.<br/>- **outputPads**: padding along the height and width of the output tensor. The value is an int or a tuple. It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding along a dimension must be less than the stride along this dimension.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>**output**: computing result after convolution and transposition. |
| OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE | 2D depthwise separable convolution.<br/>If the input contains the **padMode** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. **outChannel** is equal to **channelMultiplier** multiplied by **inChannel**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.<br/>**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>If the input contains the **padList** parameter:<br/>Inputs:<br/>- **input**: input tensor.<br/>- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. **outChannel** is equal to **channelMultiplier** multiplied by **inChannel**.<br/>- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].<br/>- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.<br/>- **padList**: padding around **input**. It is an int array [top, bottom, left, right].<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: convolution computing result. |
| OH_NN_OPS_DIV | Divides two input scalars or tensors.<br/>Inputs:<br/>- **input1**: first input, which is a number, a bool, or a tensor whose data type is number or Boolean.<br/>- **input2**: second input, which must meet the following requirements: If the first input is a tensor, the second input can be a real number, a Boolean value, or a tensor whose data type is real number or Boolean value. If the first input is a real number or Boolean value, the second input must be a tensor whose data type is real number or Boolean value.<br/>Parameters:<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: result of dividing **input1** by **input2**. |
| OH_NN_OPS_ELTWISE | Sets parameters to perform product (dot product), sum (addition and subtraction), or max (larger value) on the input.<br/>Inputs:<br/>- **input1**: first input tensor.<br/>- **input2**: second input tensor.<br/>Parameters:<br/>- **mode**: operation mode. The value is an enumerated value.<br/>Outputs:<br/>- **output**: computing result, which has the same data type and shape of **output** and **input1**. |
| OH_NN_OPS_EXPAND_DIMS | Adds an additional dimension to a tensor in the given dimension.<br/>Inputs:<br/>- **input**: input tensor.<br/>- **axis**: index of the dimension to be added. The value is of the int32_t type and must be a constant in the range [-dim-1, dim].<br/>Outputs:<br/>- **output**: tensor after dimension expansion. |
| OH_NN_OPS_FILL | Creates a tensor of the specified dimensions and fills it with a scalar.<br/>Inputs:<br/>- **value**: scalar used to fill the tensor.<br/>- **shape**: dimensions of the tensor to be created.<br/>Outputs:<br/>- **output**: generated tensor, which has the same data type as **value**. The tensor shape is specified by the **shape** parameter. |
| OH_NN_OPS_FULL_CONNECTION | Full connection. The entire input is used as the feature map for feature extraction.<br/>Inputs:<br/>- **input**: full-connection input tensor.<br/>- **weight**: weight tensor for a full connection.<br/>- **bias**: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: computed tensor.<br/>If the input contains the **axis** parameter:<br/>Inputs:<br/>- **input**: full-connection input tensor.<br/>- **weight**: weight tensor for a full connection.<br/>- **bias**: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters are determined by **input** and **weight**.<br/>Parameters:<br/>- **axis**: axis in which the full connection is applied. The specified axis and its following axes are converted into a 1D tensor for applying the full connection.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: computed tensor. |
| OH_NN_OPS_GATHER | Returns the slice of the input tensor based on the specified index and axis.<br/>Inputs:<br/>- **input**: tensor to be sliced.<br/>- **inputIndices**: indices of the specified input on the axis. The value is an array of the int type and must be in the range [0,input.shape[axis]).<br/>- **axis**: axis on which **input** is sliced. The value is an array with one element of the int32_t type.<br/>Outputs:<br/>- **output**: sliced tensor. |
| OH_NN_OPS_HSWISH | Calculate the **Hswish** activation value of the input.<br/>Inputs:<br/>- An n-dimensional input tensor.<br/>Outputs:<br/>- n-dimensional **Hswish** activation value. The data type is the same as that of **shape** and **input**. |
| OH_NN_OPS_LESS_EQUAL | For **input1** and **input2**, calculate the result of input1[i]<=input2[i] for each pair of elements, where i is the index of each element in the input tensor.<br/>Inputs:<br/>- **input1**, which can be a real number, Boolean value, or tensor whose data type is real number or NN_BOOL.<br/>- **input2**, which can be a real number or a Boolean value if **input1** is a tensor and must be a tensor with the data type of real number or NN_BOOL if **input1** is not a tensor.<br/>Outputs:<br/>- A tensor of the data type NN_BOOL. When a quantization model is used, the quantization parameters of the output cannot be omitted. However, values of the quantization parameters do not affect the result. |
| OH_NN_OPS_MATMUL | Calculate the inner product of **input1** and **input2**.<br/>Inputs:<br/>- **input1**: n-dimensional input tensor.<br/>- **input2**: n-dimensional input tensor.<br/>Parameters:<br/>- **TransposeX**: Boolean value indicating whether to transpose **input1**.<br/>- **TransposeY**: Boolean value indicating whether to transpose **input2**.<br/>Outputs:<br/>- **output**: inner product obtained after calculation. In case of type!=NN_UNKNOWN, the output data type is determined by **type**. In case of type==NN_UNKNOWN, the output data type depends on the data type converted during computing of **inputX** and **inputY**. |
| OH_NN_OPS_MAXIMUM | Calculates the maximum of **input1** and **input2** element-wise. The inputs of **input1** and **input2** comply with the implicit type conversion rules to make the data types consistent. \* The inputs must be two tensors or one tensor and one scalar. When the inputs are two tensors, their data types cannot be both NN_BOOL. Their shapes can be broadcast to the same size. When the inputs are one tensor and one scalar, the scalar must be a constant.<br/>Inputs:<br/>- **input1**: n-dimensional input tensor of the real number or NN_BOOL type.<br/>- **input2**: n-dimensional input tensor of the real number or NN_BOOL type.<br/>Outputs:<br/>- **output**: n-dimensional output tensor. The **shape** and data type of **output** are the same as those of the two inputs with a higher precision. |
| OH_NN_OPS_MAX_POOL | Applies 2D maximum pooling to the input tensor.<br/>If the input contains the **padMode** parameter:<br/>Inputs:<br/>- **input**: tensor.<br/>Parameters:<br/>- **kernelSize**: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.<br/>- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.<br/>- **padMode**: padding mode, which is optional. The value is of the int type and can be **0** (same) or **1** (valid). The nearest neighbor value is used for padding. **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.<br/>**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>If the input contains the **padList** parameter:<br/>Inputs:<br/>- **input**: tensor.<br/>Parameters:<br/>- **kernelSize**: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.<br/>- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.<br/>- **padList**: padding around **input**. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: tensor obtained after maximum pooling is applied to the input. |
| OH_NN_OPS_MUL | Multiplies elements in the same positions of **inputX** and **inputY** to obtain the output. If **inputX** and **inputY** have different shapes, expand them to the same shape through broadcast and then perform multiplication.<br/>Inputs:<br/>- **input1**: n-dimensional tensor.<br/>- **input2**: n-dimensional tensor.<br/>Parameters:<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- Product of each element of **input1** and **input2**. |
| OH_NN_OPS_ONE_HOT | Generates a one-hot tensor based on the positions specified by **indices**. The positions specified by **indices** are determined by **on_value**, and other positions are determined by **off_value**.<br/>Inputs:<br/>- **indices**: n-dimensional tensor. Each element in **indices** determines the position of **on_value** in each one-hot vector.<br/>- **depth**: integer scalar that determines the depth of the one-hot vector. The value of **depth** must be greater than **0**.<br/>- **on_value**: scalar that specifies a valid value in the one-hot vector.<br/>- **off_value**: scalar that specifies the values of other posistions in the one-hot vector except the valid value.<br/>Parameters:<br/>- **axis**: integer scalar that specifies the dimension for inserting the one-hot. Assume that the shape of **indices** is [N, C], and the value of **depth** is D. When **axis** is **0**, the shape of the output is [D, N, C]. When **axis** is **-1**, the shape of the output is [N, C, D]. When **axis** is **1**, the shape of the output is [N, D, C].<br/>Outputs:<br/>- **output**: (n+1)-dimensional tensor if **indices** is an n-dimensional tensor. The output shape is determined by **indices** and **axis**. |
| OH_NN_OPS_PAD | Pads **inputX** in the specified dimensions.<br/>Inputs:<br/>- **inputX**: n-dimensional tensor in [BatchSize, ...] format.<br/>- **paddings**: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. For example, **paddings[i][0]** indicates the number of paddings to be added preceding **inputX** in the ith dimension. **paddings[i][1]** indicates the number of paddings to be added following **inputX** in the ith dimension.<br/>Parameters:<br/>- **padValues**: value to be added to the pad operation. The value is a constant with the same data type as **inputX**.<br/>Outputs:<br/>- **output**: n-dimensional tensor after padding, with the same dimensions and data type as **inputX**. The shape is determined by **inputX** and **paddings**. output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1] |
| OH_NN_OPS_POW | Calculates the **y** power of each element in **input**. The inputs must be two tensors or one tensor and one scalar. When the inputs are two tensors, their data types cannot be both NN_BOOL, and their shapes must be the same. When the inputs are one tensor and one scalar, the scalar must be a constant.<br/>Inputs:<br/>- **input**: real number, Boolean value, or tensor whose data type is real number or NN_BOOL.<br/>- **y**: real number, Boolean value, or tensor whose data type is real number or NN_BOOL.<br/>Outputs:<br/>- **output**: tensor, whose shape is determined by the shape of **input** and **y** after broadcasting. |
| OH_NN_OPS_SCALE | Scales a tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>- **scale**: scaling tensor.<br/>- **bias**: bias tensor.<br/>Parameters:<br/>- **axis**: dimensions to be scaled.<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: scaled n-dimensional tensor, whose data type is the same as that of **input** and shape is determined by **axis**. |
| OH_NN_OPS_SHAPE | Calculates the shape of the input tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Outputs:<br/>- **output**: integer array representing the dimensions of the input tensor. |
| OH_NN_OPS_SIGMOID | Applies the **sigmoid** operation to the input tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Outputs:<br/>- **output**: result of the **sigmoid** operation. It is an n-dimensional tensor with the same data type and shape as **input**. |
| OH_NN_OPS_SLICE | Slices a tensor of the specified size from the input in each dimension.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>- **begin**: start of the slice, which is an array of integers greater than or equal to 0.<br/>- **size**: slice length, which is an array of integers greater than or equal to 0. Assume that a dimension is **i** and 1<=size[i]<=input.shape[i]-begin[i].<br/>Outputs:<br/>- **output**: n-dimensional tensor obtained by slicing. The **TensorType**, shape, and size of the output are the same as those of the input. |
| OH_NN_OPS_SOFTMAX | Applies the **softmax** operation to the input tensor.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>Parameters:<br/>- **axis**: dimension in which the **softmax** operation is performed. The value is of the int64 type. It is an integer in the range [-n, n).<br/>Outputs:<br/>- **output**: result of the **softmax** operation. It is an n-dimensional tensor with the same data type and shape as **input**. |
| OH_NN_OPS_SPACE_TO_BATCH_ND | Divides a 4D tensor into small blocks and combines these blocks in the original batch. The number of blocks is **blockShape[0]** multiplied by **blockShape[1]**.<br/>Inputs:<br/>- **input**: 4D tensor.<br/>Parameters:<br/>- **blockShape**: a pair of integers. Each of them is greater than or equal to **1**.<br/>- **paddings**: a pair of arrays. Each of them consists of two integers. The four integers that form **paddings** must be greater than or equal to **0**. **paddings[0][0]** and **paddings[0][1]** specify the number of paddings in the third dimension, and **paddings[1][0]** and **paddings[1][1]** specify the number of paddings in the fourth dimension.<br/>Outputs:<br/>- **output**: 4D tensor with the same data type as **input**. The shape is determined by **input**, **blockShape**, and **paddings**. Assume that the input shape is [n,c,h,w], then: output.shape[0] = n \* blockShape[0] \* blockShape[1] output.shape[1] = c output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]) is exactly divisible by (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]). |
| OH_NN_OPS_SPLIT | Splits the input into multiple tensors along the axis dimension. The number of tensors is specified by **outputNum**.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Parameters:<br/>- **outputNum**: number of output tensors. The data type is long.<br/>- **size_splits**: size of each tensor split from the input. The value is a 1D tensor of the int type. If **size_splits** is empty, the input will be evenly split into tensors of the same size. In this case, **input.shape[axis]** can be exactly divisible by **outputNum**. If **size_splits** is not empty, the sum of all its elements must be equal to **input.shape[axis]**.<br/>- **axis**: splitting dimension of the int type.<br/>Outputs:<br/>- **outputs**: array of n-dimensional tensors, with the same data type and dimensions. The data type of each tensor is the same as that of **input**. |
| OH_NN_OPS_SQRT | Calculates the square root of a tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Outputs:<br/>- **output**: square root of the input. It is an n-dimensional tensor with the same data type and shape as **input**. |
| OH_NN_OPS_SQUARED_DIFFERENCE | Calculates the square of the difference between two tensors. The **SquaredDifference** operator supports tensor and tensor subtraction. If two tensors have different **TensorTypes**, the Sub operator converts the low-precision tensor to a high-precision one. If two tensors have different shapes, the two tensors can be extended to tensors with the same shape through broadcast.<br/>Inputs:<br/>- **input1**: minuend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type.<br/>- **input2**: subtrahend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type.<br/>Outputs:<br/>- **output**: square of the difference between two inputs. The output shape is determined by**input1** and **input2**. If they have the same shape, the output tensor has the same shape as them. If they have different shapes, perform the broadcast operation on **input1** and **input2** and perform subtraction. **TensorType** of the output is the same as that of the input tensor with higher precision. |
| OH_NN_OPS_SQUEEZE | Removes the dimension with a length of 1 from the specified axis. The int8 quantization input is supported. Assume that the input shape is [2, 1, 1, 2, 2] and axis is [0,1], the output shape is [2, 1, 2, 2], which means the dimension whose length is 0 between dimensions 0 and dimension 1 is removed.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Parameters:<br/>- **axis**: dimension to be removed. The value is of int64_t type and can be an integer in the range [-n, n) or an array.<br/>Outputs:<br/>- **output**: output tensor. |
| OH_NN_OPS_STACK | Stacks multiple tensors along the specified axis. If each tensor has n dimensions before stacking, the output tensor will have n+1 dimensions.<br/>Inputs:<br/>- **input**: input for stacking, which can contain multiple n-dimensional tensors. Each of them must have the same shape and type.<br/>Parameters:<br/>- **axis**: dimension for tensor stacking, which is an integer. The value range is [-(n+1),(n+1)), which means a negative number is allowed.<br/>Outputs:<br/>- **output**: stacking result of the input along the axis dimension. The value is an n+1-dimensional tensor and has the same **TensorType** as the input. |
| OH_NN_OPS_STRIDED_SLICE | Slices a tensor with the specified stride.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>- **begin**: start of slicing, which is a 1D tensor. The length of **begin** is n. **begin[i]** specifies the start of slicing in the ith dimension.<br/>- **end**: end of slicing, which is a 1D tensor. The length of **end** is n. **end[i]** specifies the end of slicing in the ith dimension.<br/>- **strides**: slicing stride, which is a 1D tensor. The length of **strides** is n. strides[i] specifies the stride at which the tensor is sliced in the ith dimension.<br/>Parameters:<br/>- **beginMask**: an integer used to mask **begin**. **beginMask** is represented in binary code. In case of binary(beginMask)[i]==1, for the ith dimension, elements are sliced from the first element at **strides[i]** until the end[i]-1 element.<br/>- **endMask**: an integer used to mask **end**. **endMask** is represented in binary code. In case of binary(endMask)[i]==1, elements are sliced from the element at the **begin[i]** position in the ith dimension until the tensor boundary at **strides[i]**.<br/>- **ellipsisMask**: integer used to mask **begin** and **end**. **ellipsisMask** is represented in binary code. In case of binary(ellipsisMask)[i]==1, elements are sliced from the first element at **strides[i]** in the ith dimension until the tensor boundary. Only one bit of **binary(ellipsisMask)** can be a non-zero value.<br/>- **newAxisMask**: new dimension, which is an integer. **newAxisMask** is represented in binary code. In case of binary(newAxisMask)[i]==1, a new dimension whose length is 1 is inserted into the ith dimension.<br/>- **shrinkAxisMask**: shrinking dimension, which is an integer. \***shrinkAxisMask** is represented in binary code. In the case of binary(shrinkAxisMask)[i]==1, all elements in the ith dimension will be discarded, and the length of the ith dimension is shrunk to **1**.<br/>Outputs:<br/>- A tensor, with the same data type as **input**. The number of dimensions of the output tensor is rank(input[0])+1. |
| OH_NN_OPS_SUB | Calculates the difference between two tensors.<br/>Inputs:<br/>- **input1**: minuend, which is a tensor.<br/>- **input2**: subtrahend, which is a tensor.<br/>Parameters:<br/>- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.<br/>Outputs:<br/>- **output**: difference between the two tensors. The output shape is determined by**input1** and **input2**. If they have the same shape, the output tensor has the same shape as them. If they have different shapes, perform the broadcast operation on **input1** and **input2** and perform subtraction. **TensorType** of the output is the same as that of the input tensor with higher precision. |
| OH_NN_OPS_TANH | Computes hyperbolic tangent of the input tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Outputs:<br/>- **output**: hyperbolic tangent of the input. The **TensorType** and tensor shape are the same as those of the input. |
| OH_NN_OPS_TILE | Copies a tensor the specified times.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>- **multiples**: number of times that the input tensor is copied in each dimension. The value is a 1D tensor. The length m is not less than the number of dimensions, that is, n.<br/>Outputs:<br/>- An m-dimensional tensor whose **TensorType** is the same as that of the input. If **input** and **multiples** have the same length, **input** and **output** have the same number of dimensions. If the length of **multiples** is greater than n, 1 is used to fill the input dimension, and then the input is copied in each dimension the specified times to obtain the m-dimensional tensor. |
| OH_NN_OPS_TRANSPOSE | Transposes data of **input 0** based on **permutation**.<br/>Inputs:<br/>- **input**: n-dimensional tensor to be transposed.<br/>- **permutation**: The value is a 1D tensor whose length is the same as the number of dimensions of **input 0**.<br/>Outputs:<br/>- **output**: n-dimensional tensor. **TensorType** of **output 0** is the same as that of **input 0**, and the output shape is determined by the shape and **permutation** of **input 0**. |
| OH_NN_OPS_REDUCE_MEAN | Calculates the average value in the specified dimension. If **keepDims** is set to **false**, the number of dimensions is reduced for the input; if **keepDims** is set to **true**, the number of dimensions is retained.<br/>Inputs:<br/>- **input**: n-dimensional input tensor, where n is less than 8.<br/>- **axis**: dimension used to calculate the average value. The value is a 1D tensor. The value range of each element in **axis** is [–n, n).<br/>Parameters:<br/>- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value.<br/>Outputs:<br/>- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. |
| OH_NN_OPS_RESIZE_BILINEAR | The Bilinear method is used to deform the input based on the given parameters.<br/>Inputs:<br/>- **input**: 4D input tensor. Each element in the input cannot be less than 0. The input layout must be [batchSize, height, width, channels].<br/>Parameters:<br/>- **newHeight**: resized height of the 4D tensor.<br/>- **newWidth**: resized width of the 4D tensor.<br/>- **preserveAspectRatio**: indicates whether to maintain the height/width ratio of **input** after resizing.<br/>- **coordinateTransformMode**: coordinate transformation method used by the resize operation. The value is an int32 integer. Currently, the following methods are supported:<br/>- **excludeOutside**: an int64 floating point number. When its value is **1**, the sampling weight of the part that exceeds the boundary of **input** is set to **0**, and other weights are normalized.<br/>Outputs:<br/>- **output**: n-dimensional tensor, with the same shape and data type as **input**. |
| OH_NN_OPS_RSQRT | Calculates the reciprocal of the square root of a tensor.<br/>Inputs:<br/>- **input**: n-dimensional tensor, where n is less than 8. Each element of the tensor cannot be less than 0.<br/>Outputs:<br/>- **output**: n-dimensional tensor, with the same shape and data type as **input**. |
| OH_NN_OPS_RESHAPE | Reshapes a tensor.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>- **InputShape**: shape of the output tensor. The value is a 1D constant tensor.<br/>Outputs:<br/>- **output**: tensor whose data type is the same as that of **input** and shape is determined by **InputShape**. |
| OH_NN_OPS_PRELU | Calculates the PReLU activation value of **input** and **weight**.<br/>Inputs:<br/>- **input**: n-dimensional tensor. If n is greater than or equal to 2, **inputX** must be [BatchSize, ..., Channels]. The second dimension is the number of channels.<br/>- **weight**: 1D tensor. The length of **weight** must be 1 or equal to the number of channels. If the length of **weight** is 1, all channels share the same weight. If the length of **weight** is equal to the number of channels, each channel exclusively has a weight. If n is less than 2 for **inputX**, the **weight** length must be 1.<br/>Outputs:<br/>**output**: PReLU activation value of **x**, with the same shape and data type as **inputX**. |
| OH_NN_OPS_RELU | Calculates the Relu activation value of **input**.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>Outputs:<br/>- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. |
| OH_NN_OPS_RELU6 | Calculates the Relu6 activation value of the input, that is, calculate min(max(x, 0), 6) for each element x in the input.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>Outputs:<br/>- **output**: n-dimensional Relu6 tensor, with the same data type and shape as the input tensor. |
| OH_NN_OPS_LAYER_NORM | Applies layer normalization for a tensor from the specified axis.<br/>Inputs:<br/>- **input**: n-dimensional input tensor.<br/>- **gamma**: m-dimensional tensor. The dimensions of **gamma** must be the same as the shape of the part of the input tensor to normalize.<br/>- **beta**: m-dimensional tensor with the same shape as **gamma**.<br/>Parameters:<br/>- **beginAxis** is an NN_INT32 scalar that specifies the axis from which normalization starts. The value range is [1, rank(input)).<br/>- **epsilon** is a scalar of NN_FLOAT32. It is a tiny amount in the normalization formula. The common value is 1e-7.<br/>Outputs:<br/>- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. |
| OH_NN_OPS_REDUCE_PROD | Calculates the accumulated value for a tensor along the specified dimension.<br/>Inputs:<br/>- **input**: n-dimensional input tensor, where n is less than 8.<br/>- **axis**: dimension used to calculate the product. The value is a 1D tensor. The value range of each element in **axis** is [–n, n).<br/>Parameters:<br/>- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value. When its value is **true**, the number of output dimensions is the same as that of the input. When its value is **false**, the number of output dimensions is reduced.<br/>Outputs:<br/>- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. |
| OH_NN_OPS_REDUCE_ALL | Operates the logical OR in the specified dimension. If **keepDims** is set to **false**, the number of dimensions is reduced for the input; if **keepDims** is set to **true**, the number of dimensions is retained.<br/>Inputs:<br/>- A n-dimensional input tensor, where n is less than 8.<br/>- A 1D tensor specifying the dimension used to operate the logical OR. The value range of each element in **axis** is [–n, n).<br/>Parameters:<br/>- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value.<br/>Outputs:<br/>- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. |
| OH_NN_OPS_QUANT_DTYPE_CAST | Converts the data type.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Parameters:<br/>- **src_t**: data type of the input.<br/>- **dst_t**: data type of the output.<br/>Outputs:<br/>- **output**: n-dimensional tensor. The data type is determined by **input2**. The output shape is the same as the input shape. |
| OH_NN_OPS_TOP_K | Obtains the values and indices of the largest k entries in the last dimension.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>- **input** k: first k records of data and their indices.<br/>Parameters:<br/>- **sorted**: order of sorting. The value **true** means descending and **false** means ascending.<br/>Outputs:<br/>- **output0**: largest k elements in each slice of the last dimension.<br/>- **output1**: index of the value in the last dimension of the input. |
| OH_NN_OPS_ARG_MAX | Returns the index of the maximum tensor value across axes.<br/>Inputs:<br/>- **input**: n-dimensional tensor (N, ∗), where ∗ means any number of additional dimensions.<br/>Parameters:<br/>- **axis**: dimension for calculating the index of the maximum.<br/>- **keep_dims**: indicates whether to maintain the input tensor dimension. The value is a Boolean value.<br/>Outputs:<br/>- **output**: index of the maximum input tensor on the axis. The value is a tensor. |
| OH_NN_OPS_UNSQUEEZE | Adds a dimension based on the value of **axis**.<br/>Inputs:<br/>- **input**: n-dimensional tensor.<br/>Parameters:<br/>- **axis**: dimension to be added. The value of **axis** can be an integer or an array of integers. The value range of the integer is [-n, n).<br/>Outputs:<br/>- **output**: output tensor. |
| OH_NN_OPS_GELU | Gaussian error linear unit activation function. The int quantization input is not supported. output=0.5∗input∗(1+tanh(input/2))<br/>Inputs:<br/>- An n-dimensional input tensor.<br/>Outputs:<br/>- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. |
### OH_NN_PerformanceMode
```
enum OH_NN_PerformanceMode
```
**Description**<br>
Defines the hardware performance mode.
| Name | Description |
| -------- | -------- |
| OH_NN_PERFORMANCE_NONE | No performance mode preference |
| OH_NN_PERFORMANCE_LOW | Low power consumption mode |
| OH_NN_PERFORMANCE_MEDIUM | Medium performance mode |
| OH_NN_PERFORMANCE_HIGH | High performance mode |
| OH_NN_UNAVALIDABLE_DEVICE | A hardware error occurs, for example, HDL service crash. |
| OH_NN_INVALID_PATH | Invalid path. |
### OH_NN_TensorType
```
enum OH_NN_TensorType
```
**Description**<br>
Enumerates the tensor data types.
Tensors are usually used to set the input, output, and operator parameters of a model. When a tensor is used as the input or output of a model (or operator), set the tensor type to OH_NN_TENSOR. When the tensor is used as an operator parameter, select an enumerated value other than OH_NN_TENSOR as the tensor type. Assume that the **pad** parameter of the OH_NN_OPS_CONV2D operator is being set. You need to set the **type** attribute of the [OH_NN_Tensor](_o_h___n_n___tensor.md) instance to OH_NN_CONV2D_PAD. The settings of other operator parameters are similar. The enumerated values are named in the format OH_NN_{Operator name}_{Attribute name}.
| Name | Description |
| -------- | -------- |
| OH_NN_TENSOR | This enumerated value is used when the tensor is used as the input or output of a model (or operator). |
| OH_NN_ADD_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Add operator. |
| OH_NN_AVG_POOL_KERNEL_SIZE | This enumerated value is used when the tensor is used as the **kernel_size** parameter of the AvgPool operator. |
| OH_NN_AVG_POOL_STRIDE | This enumerated value is used when the tensor is used as the **stride** parameter of the AvgPool operator. |
| OH_NN_AVG_POOL_PAD_MODE | This enumerated value is used when the tensor is used as the **pad_mode** parameter of the AvgPool operator. |
| OH_NN_AVG_POOL_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the AvgPool operator. |
| OH_NN_AVG_POOL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activation_type** parameter of the AvgPool operator. |
| OH_NN_BATCH_NORM_EPSILON | This enumerated value is used when the tensor is used as the **eosilon** parameter of the BatchNorm operator. |
| OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE | This enumerated value is used when the tensor is used as the **blockSize** parameter of the BatchToSpaceND operator. |
| OH_NN_BATCH_TO_SPACE_ND_CROPS | This enumerated value is used when the tensor is used as the **crops** parameter of the BatchToSpaceND operator. |
| OH_NN_CONCAT_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Concat operator. |
| OH_NN_CONV2D_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the Conv2D operator. |
| OH_NN_CONV2D_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the Conv2D operator. |
| OH_NN_CONV2D_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the Conv2D operator. |
| OH_NN_CONV2D_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the Conv2D operator. |
| OH_NN_CONV2D_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Conv2D operator. |
| OH_NN_CONV2D_GROUP | This enumerated value is used when the tensor is used as the **group** parameter of the Conv2D operator. |
| OH_NN_CONV2D_TRANSPOSE_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS | This enumerated value is used when the tensor is used as the **outputPaddings** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Conv2DTranspose operator. |
| OH_NN_CONV2D_TRANSPOSE_GROUP | This enumerated value is used when the tensor is used as the **group** parameter of the Conv2DTranspose operator. |
| OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the DepthwiseConv2dNative operator. |
| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the DepthwiseConv2dNative operator. |
| OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the DepthwiseConv2dNative operator. |
| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the DepthwiseConv2dNative operator. |
| OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the DepthwiseConv2dNative operator. |
| OH_NN_DIV_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Div operator. |
| OH_NN_ELTWISE_MODE | This enumerated value is used when the tensor is used as the **mode** parameter of the Eltwise operator. |
| OH_NN_FULL_CONNECTION_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the FullConnection operator. |
| OH_NN_FULL_CONNECTION_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the FullConnection operator. |
| OH_NN_MATMUL_TRANSPOSE_A | This enumerated value is used when the tensor is used as the **transposeA** parameter of the Matmul operator. |
| OH_NN_MATMUL_TRANSPOSE_B | This enumerated value is used when the tensor is used as the **transposeB** parameter of the Matmul operator. |
| OH_NN_MATMUL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Matmul operator. |
| OH_NN_MAX_POOL_KERNEL_SIZE | This enumerated value is used when the tensor is used as the **kernel_size** parameter of the MaxPool operator. |
| OH_NN_MAX_POOL_STRIDE | This enumerated value is used when the tensor is used as the **stride** parameter of the MaxPool operator. |
| OH_NN_MAX_POOL_PAD_MODE | This enumerated value is used when the tensor is used as the **pad_mode** parameter of the MaxPool operator. |
| OH_NN_MAX_POOL_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the MaxPool operator. |
| OH_NN_MAX_POOL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activation_type** parameter of the MaxPool operator. |
| OH_NN_MUL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Mul operator. |
| OH_NN_ONE_HOT_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the OneHot operator. |
| OH_NN_PAD_CONSTANT_VALUE | This enumerated value is used when the tensor is used as the **constant_value** parameter of the Pad operator. |
| OH_NN_SCALE_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Scale operator. |
| OH_NN_SCALE_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Scale operator. |
| OH_NN_SOFTMAX_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Softmax operator. |
| OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE | This enumerated value is used when the tensor is used as the **BlockShape** parameter of the SpaceToBatchND operator. |
| OH_NN_SPACE_TO_BATCH_ND_PADDINGS | This enumerated value is used when the tensor is used as the **Paddings** parameter of the SpaceToBatchND operator. |
| OH_NN_SPLIT_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Split operator. |
| OH_NN_SPLIT_OUTPUT_NUM | This enumerated value is used when the tensor is used as the **OutputNum** parameter of the Split operator. |
| OH_NN_SPLIT_SIZE_SPLITS | This enumerated value is used when the tensor is used as the **SizeSplits** parameter of the Split operator. |
| OH_NN_SQUEEZE_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Squeeze operator. |
| OH_NN_STACK_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Stack operator. |
| OH_NN_STRIDED_SLICE_BEGIN_MASK | This enumerated value is used when the tensor is used as the **BeginMask** parameter of the StridedSlice operator. |
| OH_NN_STRIDED_SLICE_END_MASK | This enumerated value is used when the tensor is used as the **EndMask** parameter of the StridedSlice operator. |
| OH_NN_STRIDED_SLICE_ELLIPSIS_MASK | This enumerated value is used when the tensor is used as the **EllipsisMask** parameter of the StridedSlice operator. |
| OH_NN_STRIDED_SLICE_NEW_AXIS_MASK | This enumerated value is used when the tensor is used as the **NewAxisMask** parameter of the StridedSlice operator. |
| OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK | This enumerated value is used when the tensor is used as the **ShrinkAxisMask** parameter of the StridedSlice operator. |
| OH_NN_SUB_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **ActivationType** parameter of the Sub operator. |
| OH_NN_REDUCE_MEAN_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceMean operator. |
| OH_NN_RESIZE_BILINEAR_NEW_HEIGHT | This enumerated value is used when the tensor is used as the **new_height** parameter of the ResizeBilinear operator. |
| OH_NN_RESIZE_BILINEAR_NEW_WIDTH | This enumerated value is used when the tensor is used as the **new_width** parameter of the ResizeBilinear operator. |
| OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO | This enumerated value is used when the tensor is used as the **preserve_aspect_ratio** parameter of the ResizeBilinear operator. |
| OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE | This enumerated value is used when the tensor is used as the **coordinate_transform_mode** parameter of the ResizeBilinear operator. |
| OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE | This enumerated value is used when the tensor is used as the **exclude_outside** parameter of the ResizeBilinear operator. |
| OH_NN_LAYER_NORM_BEGIN_NORM_AXIS | This enumerated value is used when the tensor is used as the **beginNormAxis** parameter of the LayerNorm operator. |
| OH_NN_LAYER_NORM_EPSILON | This enumerated value is used when the tensor is used as the **epsilon** parameter of the LayerNorm operator. |
| OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS | This enumerated value is used when the tensor is used as the **beginParamsAxis** parameter of the LayerNorm operator. |
| OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE | This enumerated value is used when the tensor is used as the **elementwiseAffine** parameter of the LayerNorm operator. |
| OH_NN_REDUCE_PROD_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceProd operator. |
| OH_NN_REDUCE_ALL_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceAll operator. |
| OH_NN_QUANT_DTYPE_CAST_SRC_T | This enumerated value is used when the tensor is used as the **src_t** parameter of the QuantDTypeCast operator. |
| OH_NN_QUANT_DTYPE_CAST_DST_T | This enumerated value is used when the tensor is used as the **dst_t** parameter of the QuantDTypeCast operator. |
| OH_NN_TOP_K_SORTED | This enumerated value is used when the tensor is used as the **Sorted** parameter of the Topk operator. |
| OH_NN_ARG_MAX_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the ArgMax operator. |
| OH_NN_ARG_MAX_KEEPDIMS | This enumerated value is used when the tensor is used as the **keepDims** parameter of the ArgMax operator. |
| OH_NN_UNSQUEEZE_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Unsqueeze operator. |
After the compilation configuration is complete, call this method to return the compilation result. The compilation instance pushes the model and compilation options to the device for compilation. After this method is called, additional compilation operations cannot be performed. If the [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice), [OH_NNCompilation_SetCache](#oh_nncompilation_setcache), [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode), [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority), and [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) methods are called, OH_NN_OPERATION_FORBIDDEN is returned.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Creates a compilation instance of the [OH_NNCompilation](#oh_nncompilation) type.
After the OH_NNModel module completes model construction, APIs provided by the OH_NNCompilation module pass the model to underlying device for compilation. This method creates a [OH_NNCompilation](#oh_nncompilation) instance based on the passed [OH_NNModel](#oh_nnmodel) instance. The [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice) method is called
to set the device to compile on, and [OH_NNCompilation_Build](#oh_nncompilation_build) is then called to complete compilation.
In addition to computing device selection, the OH_NNCompilation module supports features such as model caching, performance preference, priority setting, and float16 computing, which can be implemented by the following methods:
This method needs to be called to release the compilation instance created by calling [OH_NNCompilation_Construct](#oh_nncompilation_construct). Otherwise, memory leak will occur.
If **compilation** or **\*compilation** is a null pointer, this method only prints warning logs and does not execute the release logic.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Level-2 pointer to the [OH_NNCompilation](#oh_nncompilation) instance. After a compilation instance is destroyed, this method sets **\*compilation** to a null pointer. |
Currently, Neural Network Runtime supports only float32 and int8. If this method is called on a device that supports float16, float16 will be used for computing the float32 model to reduce memory usage and execution time.
If this method is called on the device that does not support float16, the OH_NN_UNAVALIDABLE_DEVICE error code is returned.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
| enableFloat16 | Indicates whether to enable float16. If this parameter is set to **true**, float16 inference is performed. If this parameter is set to **false**, float32 inference is performed. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Set the cache directory and version of the compiled model.
On the device that supports caching, a model can be saved as a cache file after being compiled at the device driver layer. The model can be directly read from the cache file in the next compilation, saving recompilation time. This method performs different operations based on the passed cache directory and version:
- No file exists in the cache directory: Caches the compiled model to the directory and sets the cache version to **version**.
- A complete cache file exists in the cache directory, and its version is **version**: Reads the cache file in the path and passes the data to the underlying device for conversion into executable model instances.
- A complete cache file exists in the cache directory, and its version is earlier than **version**: When model compilation is complete on the underlying device, overwrites the cache file and changes the version number to **version**.
- A complete cache file exists in the cache directory, and its version is later than **version**: Returns the OH_NN_INVALID_PARAMETER error code without reading the cache file.
- The cache file in the cache directory is incomplete or you do not have the permission to access the cache file. Returns the OH_NN_INVALID_FILE error code.
- The cache directory does not exist or you do not have the access permission. Returns the OH_NN_INVALID_PATH error code.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
| cachePath | Directory for storing model cache files. This method creates directories for different devices in the **cachePath** directory. You are advised to use a separate cache directory for each model. |
| version | Cache version. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Specifies the device for model compilation and computing.
In the compilation phase, you need to specify the device for model compilation and computing. Call [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid) to obtain available device IDs. Call [OH_NNDevice_GetType](#oh_nndevice_gettype) and [OH_NNDevice_GetName](#oh_nndevice_getname) to obtain device information and pass target device IDs to this method for setting.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
| deviceID | Device ID. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Neural Network Runtime allows you to set the performance mode for model computing to meet the requirements of low power consumption and ultimate performance. If this method is not called to set the performance mode in the compilation phase, the compilation instance assigns the OH_NN_PERFORMANCE_NONE mode for the model by default. In this case, the device performs computing in the default performance mode.
If this method is called on the device that does not support the setting of the performance mode, the OH_NN_UNAVALIDABLE_DEVICE error code is returned.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
| performanceMode | Performance mode. For details about the available performance modes, see [OH_NN_PerformanceMode](#oh_nn_performancemode). |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Neural Network Runtime allows you to set computing priorities for models.
The priorities apply only to models created by the process with the same UID. The settings will not affect models created by processes with different UIDs on different devices.
If this method is called on the device that does not support the priority setting, the OH_NN_UNAVALIDABLE_DEVICE error code is returned.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
| priority | Priority. For details about the optional priorities, see [OH_NN_Priority](#oh_nn_priority). |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Obtains the ID of the device connected to Neural Network Runtime.
Each device has a unique and fixed ID in Neural Network Runtime. This method returns device IDs on the current device through the uint32_t array.
Device IDs are returned through the size_t array. Each element of the array is the ID of a single device. The array memory is managed by Neural Network Runtime. The data pointer is valid before this method is called next time.
**Parameters**
| Name | Description |
| -------- | -------- |
| allDevicesID | Pointer to the size_t array. The input **\*allDevicesID** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. |
| deviceCount | Pointer of the uint32_t type, which is used to return the length of **(\*allDevicesID)**. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
### OH_NNDevice_GetName()
```
OH_NN_ReturnCode OH_NNDevice_GetName (size_t deviceID, const char ** name )
```
**Description**<br>
Obtains the name of the specified device.
**deviceID** specifies the device whose name will be obtained. The device ID needs to be obtained by calling [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid).
**Parameters**
| Name | Description |
| -------- | -------- |
| deviceID | Device ID. |
| name | Pointer to the char array. The passed **(\*char)** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. The value of **(\*name)** is a C-style string ended with **'\0'**. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
| deviceType | Pointer to the [OH_NN_DeviceType](#oh_nn_devicetype) instance. The device type information is returned. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Allocates shared memory to a single input on a device.
Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and input index value, this method allocates shared memory whose size is specified by **length** on the device associated with a single input and returns the operation result through the [OH_NN_Memory](_o_h___n_n___memory.md) instance.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In the memory input application, the index value for the three inputs is **{0, 1, 2}**. |
| length | Memory size to be applied for, in bytes. |
**Returns**
Pointer to a [OH_NN_Memory](_o_h___n_n___memory.md) instance.
Allocates shared memory to a single output on a device.
Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and output index value, this method allocates shared memory whose size is specified by **length** on the device associated with a single output and returns the operation result through the [OH_NN_Memory](_o_h___n_n___memory.md) instance.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output memory application, the index value for the three outputs is **{0, 1, 2}**. |
| length | Memory size to be applied for, in bytes. |
**Returns**
Pointer to a [OH_NN_Memory](_o_h___n_n___memory.md) instance.
Creates an executor instance of the [OH_NNExecutor](#oh_nnexecutor) type.
This method constructs a model inference executor associated with the device based on the passed compiler. Use [OH_NNExecutor_SetInput](#oh_nnexecutor_setinput) to set the model input data. After the input data is set, call [OH_NNExecutor_Run](#oh_nnexecutor_run) to perform inference and then call [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput) to obtain the computing result.
After calling this method to create the [OH_NNExecutor](#oh_nnexecutor) instance, you can release the [OH_NNCompilation](#oh_nncompilation) instance if you do not need to create any other executors.
**Parameters**
| Name | Description |
| -------- | -------- |
| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. |
**Returns**
Pointer to a [OH_NNExecutor](#oh_nnexecutor) instance.
Destroys an executor instance to release the memory occupied by the executor.
This method needs to be called to release the executor instance created by calling [OH_NNExecutor_Construct](#oh_nnexecutor_construct). Otherwise, memory leak will occur.
If **executor** or **\*executor** is a null pointer, this method only prints warning logs and does not execute the release logic.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Level-2 pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points.
This method needs to be called to release the memory instance created by calling [OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory). Otherwise, memory leak will occur. The mapping between **inputIndex** and **memory** must be the same as that in memory instance creation.
If **memory** or **\*memory** is a null pointer, this method only prints warning logs and does not execute the release logic.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In memory input release, the index value for the three inputs is **{0, 1, 2}**. |
| memory | Level-2 pointer to the [OH_NN_Memory](_o_h___n_n___memory.md) instance. After shared memory is destroyed, this method sets **\*memory** to a null pointer. |
Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points.
This method needs to be called to release the memory instance created by calling [OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory). Otherwise, memory leak will occur. The mapping between **outputIndex** and **memory** must be the same as that in memory instance creation.
If **memory** or **\*memory** is a null pointer, this method only prints warning logs and does not execute the release logic.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output memory release, the index value for the three outputs is **{0, 1, 2}**. |
| memory | Level-2 pointer to the [OH_NN_Memory](_o_h___n_n___memory.md) instance. After shared memory is destroyed, this method sets **\*memory** to a null pointer. |
Obtains the dimension information about the output tensor.
After [OH_NNExecutor_Run](#oh_nnexecutor_run) is called to complete a single inference, call this method to obtain the specified output dimension information and number of dimensions. It is commonly used in dynamic shape input and output scenarios.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When [OH_NNExecutor_GetOutputShape](#oh_nnexecutor_getoutputshape) is called to obtain dimension information about the output tensor, **outputIndices** is **{0, 1, 2}**. |
| shape | Pointer to the int32_t array. The value of each element in the array is the length of the output tensor in each dimension. |
| shapeLength | Pointer to the uint32_t type. The number of output dimensions is returned. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Performs end-to-end inference and computing of the model on the device associated with the executor.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
This method copies the data whose length is specified by **length** (in bytes) in **dataBuffer** to the shared memory of the underlying device. **inputIndex** specifies the input to be set and **tensor** sets information such as the input shape, type, and quantization parameters.
Neural Network Runtime supports models with dynamical shape input. For fixed shape input and dynamic shape input scenarios, this method uses different processing policies.
- Fixed shape input: The attributes of **tensor** must be the same as those of the tensor added by calling [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) in the composition phase.
- Dynamic shape input: In the composition phase, because the shape is not fixed, each value in **tensor.dimensions** must be greater than **0** in the method calls to determine the shape input in the calculation phase. When setting the shape, you can modify only the dimension whose value is **-1**. Assume that **[-1, 224, 224, 3]** is input as the the dimension of A in the composition phase. When this method is called, only the size of the first dimension can be modified, for example, to **[3, 224, 224, 3]**. If other dimensions are adjusted, OH_NN_INVALID_PARAMETER is returned.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In input settings, the index value for the three inputs is **{0, 1, 2}**. |
| tensor | Sets the tensor corresponding to the input data. |
| dataBuffer | Pointer to the input data. |
| length | Length of the data buffer, in bytes. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input.
In scenarios where memory needs to be managed by yourself, this method binds the execution input to the [OH_NN_Memory](_o_h___n_n___memory.md) memory instance. During computing, the underlying device reads the input data from the shared memory pointed to by the memory instance. By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When the input shared memory is specified, the index value for the three inputs is **{0, 1, 2}**. |
| tensor | Pointer to [OH_NN_Tensor](_o_h___n_n___tensor.md), used to set the tensor corresponding to a single input. |
| memory | Pointer to [OH_NN_Memory](_o_h___n_n___memory.md). |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
This method binds the buffer to which **dataBuffer** points to the output specified by **outputIndex**. The length of the buffer is specified by **length**.
After [OH_NNExecutor_Run](#oh_nnexecutor_run) is called to complete a single model inference, Neural Network Runtime compares the length of the buffer to which **dataBuffer** points with the length of the output data and returns different results based on the actual situation.
- If the buffer length is greater than or equal to the data length, the inference result is copied to the buffer and OH_NN_SUCCESS is returned. You can read the inference result from **dataBuffer**.
- If the buffer length is smaller than the data length, [OH_NNExecutor_Run](#oh_nnexecutor_run) returns OH_NN_INVALID_PARAMETER and generates a log indicating that the buffer is too small.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. |
| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output buffer settings, the index value for the three outputs is **{0, 1, 2}**. |
| dataBuffer | Pointer to the output data. |
| length | Length of the data buffer, in bytes. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output.
In scenarios where memory needs to be managed by yourself, this method binds the execution output to the [OH_NN_Memory](_o_h___n_n___memory.md) memory instance. When computing is performed, the underlying hardware directly writes the computing result to the shared memory to which the memory instance points. By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow.
**Parameters**
| Name | Description |
| -------- | -------- |
| executor | Executor. |
| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When output shared memory is specified, the index value for the three outputs is **{0, 1, 2}**. |
| memory | Pointer to [OH_NN_Memory](_o_h___n_n___memory.md). |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
This method is used to add an operator to a model instance. The operator type is specified by **op**, and the operator parameters, inputs, and outputs are specified by **paramIndices**, **inputIndices**, and **outputIndices** respectively. This method verifies the attributes of operator parameters and the number of input and output parameters. These attributes must be correctly set when [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) is called to add tensors. For details about the expected parameters, input attributes, and output attributes of each operator, see [OH_NN_OperationType](#oh_nn_operationtype).
**paramIndices**, **inputIndices**, and **outputIndices** store index values of tensors. Index values are determined by the sequence in which tensors are added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor).
If unnecessary parameters are added for adding an operator, this method returns OH_NN_INVALID_PARAMETER. If no operator parameter is set, the operator uses the default parameter value. For details about the default values, see [OH_NN_OperationType](#oh_nn_operationtype).
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
| op | Specifies the type of an operator to be added. For details, see the enumerated values of [OH_NN_OperationType](#oh_nn_operationtype). |
| paramIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set operator parameters. |
| inputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator input. |
| outputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator output. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
The data node and operator parameters in the Neural Network Runtime model are composed of tensors of the model. This method is used to add tensors to a model instance based on the **tensor** parameter. The sequence of adding tensors is specified by the index value recorded in the model. The [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), and [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) methods specifies tensors based on the index value.
Neural Network Runtime supports inputs and outputs of the dynamic shape. When adding a data node with a dynamic shape, you need to set the dimensions that support dynamic changes in **tensor.dimensions** to **-1**. For example, if **tensor.dimensions** of a four-dimensional tensor is set to **[1, -1, 2, 2]**, the second dimension supports dynamic changes.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
| tensor | Pointer to the [OH_NN_Tensor](_o_h___n_n___tensor.md) tensor. The tensor specifies the attributes of the tensor added to the model instance. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
### OH_NNModel_Construct()
```
OH_NNModel* OH_NNModel_Construct (void )
```
**Description**<br>
Creates a model instance of the [OH_NNModel](#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance.
Before composition, call [OH_NNModel_Construct](#oh_nnmodel_construct) to create a model instance. Based on the model topology, call the [OH_NNModel_AddTensor](#oh_nnmodel_addtensor), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), and [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata) methods to fill in the data and operator nodes of the model, and then call [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) to specify the inputs and outputs of the model. After the model topology is constructed, call [OH_NNModel_Finish](#oh_nnmodel_finish) to build the model.
After a model instance is used, you need to destroy it by calling [OH_NNModel_Destroy](#oh_nnmodel_destroy) to avoid memory leak.
**Returns**
Returns the pointer to a [OH_NNModel](#oh_nnmodel) instance.
### OH_NNModel_Destroy()
```
void OH_NNModel_Destroy (OH_NNModel ** model)
```
**Description**<br>
Releases a model instance.
This method needs to be called to release the model instance created by calling [OH_NNModel_Construct](#oh_nnmodel_construct). Otherwise, memory leak will occur.
If **model** or **\*model** is a null pointer, this method only prints warning logs and does not execute the release logic.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Level-2 pointer to the [OH_NNModel](#oh_nnmodel) instance. After a model instance is destroyed, this method sets **\*model** to a null pointer. |
After the model topology is set up, call this method to indicate that the composition is complete. After this method is called, additional composition operations cannot be performed. If [OH_NNModel_AddTensor](#oh_nnmodel_addtensor), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata), and [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) are called, OH_NN_OPERATION_FORBIDDEN is returned.
Before calling [OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations) and [OH_NNCompilation_Construct](#oh_nncompilation_construct), you must call this method to complete composition.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Queries whether the device supports operators in the model. The support status is indicated by the Boolean value.
Queries whether underlying device supports operators in a model instance. The device is specified by **deviceID**, and the result is represented by the array pointed by **isSupported**. If the ith operator is supported, the value of **(\*isSupported)**[i] is **true**. Otherwise, the value is **false**.
After this method is successfully executed, **(\*isSupported)** points to the bool array that records the operator support status. The operator quantity for the array length is the same as that for the model instance. The memory corresponding to this array is managed by Neural Network Runtime and is automatically destroyed after the model instance is destroyed or this method is called again.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
| deviceID | Device ID to be queried, which can be obtained by using [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid). |
| isSupported | Pointer to the bool array. When this method is called, **(\*isSupported)** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. |
| opCount | Number of operators in a model instance, corresponding to the length of the **(\*isSupported)** array. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
For tensors with constant values (such as model weights), you need to use this method in the composition phase. The index value of a tensor is determined by the sequence in which the tensor is added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor).
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
| index | Index value of a tensor. |
| dataBuffer | Pointer to real data. |
| length | Length of the data buffer. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
A tensor must be specified as the end-to-end inputs and outputs of a model instance. This type of tensor cannot be set using [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata). The **OH_NNExecutor** method needs to be called in the execution phase to set the input and output data.
The index value of a tensor is determined by the sequence in which the tensor is added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor).
Currently, the model inputs and outputs cannot be set asynchronously.
**Parameters**
| Name | Description |
| -------- | -------- |
| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. |
| inputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator input. |
| outputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator output. |
**Returns**
Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode).
Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.
| **onError** | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror) |
| **onStreamChanged** | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged) |
| **onNeedInputData** | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) |
| **onNeedOutputData** | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata) |
Defines the parameter structure in a parameter set.
**Since:**
9
**Related Modules:**
[HuksTypeApi](_huks_type_api.md)
## Summary
### Member Variables
| Name | Description |
| -------- | -------- |
| [tag](#tag) | Tag value. |
| union { <br> bool [boolParam](#boolparam)<br> int32_t [int32Param](#int32param)<br> uint32_t [uint32Param](#uint32param)<br> uint64_t [uint64Param](#uint64param)<br> struct [OH_Huks_Blob](_o_h___huks___blob.md)[blob](#blob) <br> }; | boolParam:Parameter of the Boolean type.<br>int32Param:Parameter of the int32_t type.<br>uint32Param:Parameter of the uint32_t type.<br>Parameter of the uint64_t type.<br>blob:Parameter of the struct [OH_Huks_Blob](_o_h___huks___blob.md) type.|
## Member Variable Description
### blob
```
struct OH_Huks_Blob OH_Huks_Param::blob
```
**Description**<br>
Parameter of the struct [OH_Huks_Blob](_o_h___huks___blob.md) type.
In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula:
s and z are quantization parameters, which are stored by **scale** and **zeroPoint** in OH_NN_QuantParam. r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and q_max is an upper bound of a quantization result. The calculation method is as follows:
The clamp function is defined as follows:
**Since:**
9
**Related Modules:**
[NeuralNeworkRuntime](_neural_nework_runtime.md)
## Summary
### Member Variables
| Name | Description |
| -------- | -------- |
| [quantCount](#quantcount) | Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, **quantCount** is usually set to **1**. That is, all channels of a tensor share a set of quantization parameters. In the per-channel quantization scenario, **quantCount** is usually the same as the number of tensor channels, and each channel uses its own quantization parameters. |
| [numBits](#numbits) | Number of quantization bits |
| [scale](#scale) | Pointer to the scale data in the quantization formula |
| [zeroPoint](#zeropoint) | Pointer to the zero point data in the quantization formula |
## Member Variable Description
### numBits
```
const uint32_t* OH_NN_QuantParam::numBits
```
**Description**<br>
Number of quantization bits
### quantCount
```
uint32_t OH_NN_QuantParam::quantCount
```
**Description**<br>
Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, **quantCount** is usually set to **1**. That is, all channels of a tensor share a set of quantization parameters. In the per-channel quantization scenario, **quantCount** is usually the same as the number of tensor channels, and each channel uses its own quantization parameters.
### scale
```
const double* OH_NN_QuantParam::scale
```
**Description**<br>
Pointer to the scale data in the quantization formula
### zeroPoint
```
const int32_t* OH_NN_QuantParam::zeroPoint
```
**Description**<br>
Pointer to the zero point data in the quantization formula
It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, you need to specify the data type, number of dimensions, dimension information, and quantization information.
**Since:**
9
**Related Modules:**
[NeuralNeworkRuntime](_neural_nework_runtime.md)
## Summary
### Member Variables
| Name | Description |
| -------- | -------- |
| [dataType](#datatype) | Data type of the specified tensor. The value must be an enumerated value of [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype). |
| [dimensionCount](#dimensioncount) | Number of dimensions of the specified tensor |
| [dimensions](#dimensions) | Dimension information (shape) of the specified tensor |
| [quantParam](#quantparam) | Quantization information of the specified tensor. The data type must be [OH_NN_QuantParam](_o_h___n_n___quant_param.md). |
| [type](#type) | Specifies the tensor type. The value of **type** is related to the tensor usage. When the tensor is used as the input or output of the model, set **type** to [OH_NN_TENSOR](_neural_nework_runtime.md). When a tensor is used as an operator parameter, select any enumerated value except [OH_NN_TENSOR](_neural_nework_runtime.md) from [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype). |
## Member Variable Description
### dataType
```
OH_NN_DataType OH_NN_Tensor::dataType
```
**Description**<br>
Data type of the specified tensor. The value must be an enumerated value of [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype).
### dimensionCount
```
uint32_t OH_NN_Tensor::dimensionCount
```
**Description**<br>
Number of dimensions of the specified tensor
### dimensions
```
const int32_t* OH_NN_Tensor::dimensions
```
**Description**<br>
Dimension information (shape) of the specified tensor
### quantParam
```
const OH_NN_QuantParam* OH_NN_Tensor::quantParam
```
**Description**<br>
Quantization information of the specified tensor. The data type must be [OH_NN_QuantParam](_o_h___n_n___quant_param.md).
### type
```
OH_NN_TensorType OH_NN_Tensor::type
```
**Description**<br>
Specifies the tensor type. The value of **type** is related to the tensor usage. When the tensor is used as the input or output of the model, set **type** to [OH_NN_TENSOR](_neural_nework_runtime.md). When a tensor is used as an operator parameter, select any enumerated value except [OH_NN_TENSOR](_neural_nework_runtime.md) from [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype).
Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES and media data input and displayed on the ArkUI XComponent.
**Since:**
8
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) | Declare the APIs used to access the native XComponent.<br>File to Include: <ace/xcomponent/native_interface_xcomponent.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) | Describes the touch point of the touch event. |
| [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) | Describes the touch event. |
| [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) | Describes the mouse event. |
| [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) | Registers a callback for the surface lifecycle and touch event. |
| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) | Registers a callback for the mouse event. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_NativeXComponent](#oh_nativexcomponent) | Provides an encapsulated OH_NativeXComponent instance. |
| [OH_NativeXComponent_Callback](#oh_nativexcomponent_callback) | Registers a callback for the surface lifecycle and touch event. |
| [OH_NativeXComponent_MouseEvent_Callback](#oh_nativexcomponent_mouseevent_callback) | Registers a callback for the mouse event. |
### Enums
| Name | Description |
| -------- | -------- |
| {OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, <br>OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, <br/>OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 } | [Enumerates](#anonymous-enum) the API access states. |
| [OH_NativeXComponent_GetXComponentId](#oh_nativexcomponent_getxcomponentid)([OH_NativeXComponent](#oh_nativexcomponent)\*component, char \*id, uint64_t \*size) | Obtains the ID of the ArkUI XComponent. |
| [OH_NativeXComponent_GetXComponentSize](#oh_nativexcomponent_getxcomponentsize)([OH_NativeXComponent](#oh_nativexcomponent)\*component, const void \*window, uint64_t \*width, uint64_t \*height) | Obtains the size of the surface held by the ArkUI XComponent. |
| [OH_NativeXComponent_GetXComponentOffset](#oh_nativexcomponent_getxcomponentoffset)([OH_NativeXComponent](#oh_nativexcomponent)\*component, const void \*window, double \*x, double \*y) | Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. |
| [OH_NativeXComponent_GetTouchEvent](#oh_nativexcomponent_gettouchevent)([OH_NativeXComponent](#oh_nativexcomponent)\*component, const void \*window, [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md)\*touchEvent) | Obtains the touch event scheduled by the ArkUI XComponent. |
| [OH_NativeXComponent_GetTouchPointToolType](#oh_nativexcomponent_gettouchpointtooltype)([OH_NativeXComponent](#oh_nativexcomponent)\*component, uint32_t pointIndex, [OH_NativeXComponent_TouchPointToolType](#oh_nativexcomponent_touchpointtooltype)\*toolType) | Obtains the ArkUI XComponent touch point tool type. |
| [OH_NativeXComponent_GetTouchPointTiltX](#oh_nativexcomponent_gettouchpointtiltx)([OH_NativeXComponent](#oh_nativexcomponent)\*component, uint32_t pointIndex, float \*tiltX) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the x-axis. |
| [OH_NativeXComponent_GetTouchPointTiltY](#oh_nativexcomponent_gettouchpointtilty)([OH_NativeXComponent](#oh_nativexcomponent)\*component, uint32_t pointIndex, float \*tiltY) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the y-axis. |
| [OH_NativeXComponent_GetMouseEvent](#oh_nativexcomponent_getmouseevent)([OH_NativeXComponent](#oh_nativexcomponent)\*component, const void \*window, [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md)\*mouseEvent) | Obtains the mouse event scheduled by ArkUI XComponent. |
| [OH_NativeXComponent_RegisterCallback](#oh_nativexcomponent_registercallback)([OH_NativeXComponent](#oh_nativexcomponent)\*component, [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md)\*callback) | Registers a callback for this **OH_NativeXComponent** instance. |
| [OH_NativeXComponent_RegisterMouseEventCallback](#oh_nativexcomponent_registermouseeventcallback)([OH_NativeXComponent](#oh_nativexcomponent)\*component, [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md)\*callback) | Registers a mouse event callback for this **OH_NativeXComponent** instance. |
### Variables
| Name | Description |
| -------- | -------- |
| [OH_XCOMPONENT_ID_LEN_MAX](#oh_xcomponent_id_len_max) = 128 | Maximum length of an ArkUI XComponent ID. |
| [OH_MAX_TOUCH_POINTS_NUMBER](#oh_max_touch_points_number) = 10 | Maximum number of identifiable touch points in a touch event. |
| [OH_NativeXComponent_TouchPoint::id](#id-12) = 0 | Unique identifier of the finger. |
| [OH_NativeXComponent_TouchPoint::screenX](#screenx-13) = 0.0 | X coordinate of the touch point relative to the left edge of the screen. |
| [OH_NativeXComponent_TouchPoint::screenY](#screeny-13) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen. |
| [OH_NativeXComponent_TouchPoint::x](#x-13) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. |
| [OH_NativeXComponent_TouchPoint::y](#y-13) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. |
| [OH_NativeXComponent_TouchPoint::type](#type-12) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. |
| [OH_NativeXComponent_TouchPoint::size](#size-12) = 0.0 | Contact area between the finger pad and the screen. |
| [OH_NativeXComponent_TouchPoint::force](#force-12) = 0.0 | Pressure of the current touch event. |
| [OH_NativeXComponent_TouchPoint::timeStamp](#timestamp-12) = 0 | Timestamp of the current touch event. |
| [OH_NativeXComponent_TouchPoint::isPressed](#ispressed) = false | Whether the current point is pressed. |
| [OH_NativeXComponent_TouchEvent::id](#id-22) = 0 | Unique identifier of the finger. |
| [OH_NativeXComponent_TouchEvent::screenX](#screenx-23) = 0.0 | X coordinate of the touch point relative to the left edge of the screen. |
| [OH_NativeXComponent_TouchEvent::screenY](#screeny-23) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen. |
| [OH_NativeXComponent_TouchEvent::x](#x-23) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. |
| [OH_NativeXComponent_TouchEvent::y](#y-23) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. |
| [OH_NativeXComponent_TouchEvent::type](#type-22) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. |
| [OH_NativeXComponent_TouchEvent::size](#size-22) = 0.0 | Contact area between the finger pad and the screen. |
| [OH_NativeXComponent_TouchEvent::force](#force-22) = 0.0 | Pressure of the current touch event. |
| [OH_NativeXComponent_TouchEvent::deviceId](#deviceid) = 0 | ID of the device where the current touch event is triggered. |
| [OH_NativeXComponent_TouchEvent::timeStamp](#timestamp-22) = 0 | Timestamp of the current touch event. |
| [OH_NativeXComponent_TouchEvent::touchPoints](#touchpoints)[OH_MAX_TOUCH_POINTS_NUMBER] | Array of the current touch points. |
| [OH_NativeXComponent_TouchEvent::numPoints](#numpoints) = 0 | Number of current touch points. |
| [OH_NativeXComponent_MouseEvent::x](#x-33) = 0.0 | X coordinate of the clicked point relative to the upper left corner of the component. |
| [OH_NativeXComponent_MouseEvent::y](#y-33) = 0.0 | Y coordinate of the clicked point relative to the upper left corner of the component. |
| [OH_NativeXComponent_MouseEvent::screenX](#screenx-33) = 0.0 | X coordinate of the clicked point relative to the upper left corner of the screen. |
| [OH_NativeXComponent_MouseEvent::screenY](#screeny-33) = 0.0 | Y coordinate of the clicked point relative to the upper left corner of the screen. |
| [OH_NativeXComponent_MouseEvent::timestamp](#timestamp) = 0 | Timestamp of the current mouse event. |
| [OH_NativeXComponent_MouseEvent::action](#action) = [OH_NativeXComponent_MouseEventAction::OH_NATIVEXCOMPONENT_MOUSE_NONE](#oh_nativexcomponent_mouseeventaction) | Current mouse event action. |
| component | Indicates the pointer to an **OH_NativeXComponent** instance. |
| id | Indicates the pointer to the character buffer used to hold the ID of the OH_NativeXComponent instance.<br>Note that the null terminator is attached to the character buffer, so the size of the character buffer should be at least one unit greater than the length of the real ID.<br>The recommended size of the character buffer is [OH_XCOMPONENT_ID_LEN_MAX + 1]. |
| size | Indicates the pointer to the length of the ID. |
| [id](_o_h___native_x_component.md#id-12) = 0 | Unique identifier of the finger. |
| [screenX](_o_h___native_x_component.md#screenx-13) = 0.0 | X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. |
| [screenY](_o_h___native_x_component.md#screeny-13) = 0.0 | Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. |
| [x](_o_h___native_x_component.md#x-13) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. |
| [y](_o_h___native_x_component.md#y-13) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. |
| [type](_o_h___native_x_component.md#type-12) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. |
| [size](_o_h___native_x_component.md#size-12) = 0.0 | Contact area between the finger pad and the screen. |
| [force](_o_h___native_x_component.md#force-12) = 0.0 | Pressure of the current touch event. |
| [timeStamp](_o_h___native_x_component.md#timestamp-12) = 0 | Timestamp of the current touch event. |
| [isPressed](_o_h___native_x_component.md#ispressed) = false | Whether the current point is pressed. |
**RawFileDescriptor** is an output parameter of [OH_ResourceManager_GetRawFileDescriptor](rawfile.md#oh_resourcemanager_getrawfiledescriptor). It provides information including the rawfile descriptor and the start position and length of the rawfile in the HAP package.
**Since:**
8
**Related Modules:**
[Rawfile](rawfile.md)
## Summary
### Member Variables
| Name | Description |
| -------- | -------- |
| [fd](#fd) |rawfile descriptor |
| [start](#start) | Start position of rawfile in the HAP package |
| [length](#length) | Length of rawfile in the HAP package |
| [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) | Declares the native APIs used for video decoding. <br>File to Include: <multimedia/player_framework/native_avcodec_videodecoder.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime)(const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname)(const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. |
| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. |
| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface)(OH_AVCodec\*codec, [OHNativeWindow](_native_window.md)\*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_Configure](#oh_videodecoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. |
| [OH_VideoDecoder_Start](#oh_videodecoder_start)(OH_AVCodec\*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_VideoDecoder_Stop](#oh_videodecoder_stop)(OH_AVCodec\*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. |
| [OH_VideoDecoder_Flush](#oh_videodecoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_VideoDecoder_Reset](#oh_videodecoder_reset)(OH_AVCodec\*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. |
| [OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. |
| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. |
| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. |
| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. |
| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video decoder. |
## Function Description
### OH_VideoDecoder_Configure()
```
OH_AVErrCode OH_VideoDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**.
Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed.
Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process.
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an input buffer. |
| attr | Indicates the attributes of the data contained in the buffer. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_VideoDecoder_RenderOutputData()
```
OH_AVErrCode OH_VideoDecoder_RenderOutputData (OH_AVCodec * codec, uint32_t index )
```
**Description**<br>
Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer.
Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**.
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_VideoDecoder_SetParameter()
```
OH_AVErrCode OH_VideoDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again.
| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding. <br>File to Include: <multimedia/player_framework/native_avcodec_videoencoder.h> |
### Types
| Name | Description |
| -------- | -------- |
| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime)(const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname)(const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. |
| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. |
| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_Configure](#oh_videoencoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. |
| [OH_VideoEncoder_Start](#oh_videoencoder_start)(OH_AVCodec\*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_VideoEncoder_Stop](#oh_videoencoder_stop)(OH_AVCodec\*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. |
| [OH_VideoEncoder_Flush](#oh_videoencoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_VideoEncoder_Reset](#oh_videoencoder_reset)(OH_AVCodec\*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. |
| [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. |
| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. |
| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface)(OH_AVCodec\*codec, [OHNativeWindow](_native_window.md)\*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video encoder. |
| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream)(OH_AVCodec\*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. |
OH_AVErrCode OH_VideoEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**.
Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed.
Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**.
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_VideoEncoder_SetParameter()
```
OH_AVErrCode OH_VideoEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure.
Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
Provides **Context** APIs for configuring runtime information.
**Since:**
9
**Related Modules:**
[MindSpore](_mind_spore.md)
## Summary
### Types
| Name | Description |
| -------- | -------- |
| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate)() | Creates a context object. |
| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle)\*context) | Destroys a context object. |
| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. |
| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum)(const[OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads. |
| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. |
| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode)(const[OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. |
| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. |
| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist)(const[OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. |
| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. |
| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel)(const[OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. |
| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo)([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. |
| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate)([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object. |
| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy)([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle)\*device_info) | Destroys a device information instance. |
| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider)([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. |
| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider)(const[OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. |
| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice)([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. |
| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice)(const[OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. |
| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype)(const[OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. |
| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16)([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16)(const[OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency)([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency)(const[OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. |
Declares functions related to the **bitmap** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Structs
| Name | Description |
| -------- | -------- |
| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Defines the pixel format of a bitmap, including the color type and alpha type. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_BitmapCreate](_drawing.md#oh_drawing_bitmapcreate)(void) | Creates an **OH_Drawing_Bitmap** object. |
| [OH_Drawing_BitmapDestroy](_drawing.md#oh_drawing_bitmapdestroy)([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*) | Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. |
| [OH_Drawing_BitmapBuild](_drawing.md#oh_drawing_bitmapbuild)([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*, const uint32_t width, const uint32_t height, const [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)\*) | Initializes the width and height of an **OH_Drawing_Bitmap** object and sets the pixel format for the bitmap. |
| [OH_Drawing_BitmapGetWidth](_drawing.md#oh_drawing_bitmapgetwidth)([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*) | Obtains the width of a bitmap. |
| [OH_Drawing_BitmapGetHeight](_drawing.md#oh_drawing_bitmapgetheight)([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*) | Obtains the height of a bitmap. |
| [OH_Drawing_BitmapGetPixels](_drawing.md#oh_drawing_bitmapgetpixels)([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*) | Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. |
Declares functions related to the **brush** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_BrushCreate](_drawing.md#oh_drawing_brushcreate)(void) | Creates an **OH_Drawing_Brush** object. |
| [OH_Drawing_BrushDestroy](_drawing.md#oh_drawing_brushdestroy)([OH_Drawing_Brush](_drawing.md#oh_drawing_brush)\*) | Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. |
| [OH_Drawing_BrushIsAntiAlias](_drawing.md#oh_drawing_brushisantialias)(const[OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_BrushSetAntiAlias](_drawing.md#oh_drawing_brushsetantialias)([OH_Drawing_Brush](_drawing.md#oh_drawing_brush)\*, bool) | Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_BrushGetColor](_drawing.md#oh_drawing_brushgetcolor)(const[OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Obtains the color of a brush. The color is used by the brush to fill in a shape. |
| [OH_Drawing_BrushSetColor](_drawing.md#oh_drawing_brushsetcolor)([OH_Drawing_Brush](_drawing.md#oh_drawing_brush)\*, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape. |
Declares functions related to the **canvas** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_CanvasCreate](_drawing.md#oh_drawing_canvascreate)(void) | Creates an **OH_Drawing_Canvas** object. |
| [OH_Drawing_CanvasDestroy](_drawing.md#oh_drawing_canvasdestroy)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*) | Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. |
| [OH_Drawing_CanvasBind](_drawing.md#oh_drawing_canvasbind)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, [OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap)\*) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering). |
| [OH_Drawing_CanvasAttachPen](_drawing.md#oh_drawing_canvasattachpen)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. |
| [OH_Drawing_CanvasDetachPen](_drawing.md#oh_drawing_canvasdetachpen)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*) | Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. |
| [OH_Drawing_CanvasAttachBrush](_drawing.md#oh_drawing_canvasattachbrush)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, const [OH_Drawing_Brush](_drawing.md#oh_drawing_brush)\*) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. |
| [OH_Drawing_CanvasDetachBrush](_drawing.md#oh_drawing_canvasdetachbrush)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*) | Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. |
| [OH_Drawing_CanvasSave](_drawing.md#oh_drawing_canvassave)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*) | Saves the current canvas status (canvas matrix) to the top of the stack. |
| [OH_Drawing_CanvasRestore](_drawing.md#oh_drawing_canvasrestore)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*) | Restores the canvas status (canvas matrix) saved on the top of the stack. |
| [OH_Drawing_CanvasDrawLine](_drawing.md#oh_drawing_canvasdrawline)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, float x1, float y1, float x2, float y2) | Draws a line segment. |
| [OH_Drawing_CanvasDrawPath](_drawing.md#oh_drawing_canvasdrawpath)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, const [OH_Drawing_Path](_drawing.md#oh_drawing_path)\*) | Draws a path. |
| [OH_Drawing_CanvasClear](_drawing.md#oh_drawing_canvasclear)([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, uint32_t color) | Clears a canvas by using a specified color. |
Declares functions related to the **color** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_ColorSetArgb](_drawing.md#oh_drawing_colorsetargb)(uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) | Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. |
Declares functions related to **FontCollection** in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_CreateFontCollection](_drawing.md#oh_drawing_createfontcollection)(void) | Creates an **OH_Drawing_FontCollection** object. |
| [OH_Drawing_DestroyFontCollection](_drawing.md#oh_drawing_destroyfontcollection)([OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection)\*) | Releases the memory occupied by an **OH_Drawing_FontCollection** object. |
Declares functions related to the **path** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_PathCreate](_drawing.md#oh_drawing_pathcreate)(void) | Creates an **OH_Drawing_Path** object. |
| [OH_Drawing_PathDestroy](_drawing.md#oh_drawing_pathdestroy)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*) | Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. |
| [OH_Drawing_PathMoveTo](_drawing.md#oh_drawing_pathmoveto)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*, float x, float y) | Sets the start point of a path. |
| [OH_Drawing_PathLineTo](_drawing.md#oh_drawing_pathlineto)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*, float x, float y) | Draws a line segment from the last point of a path to the target point. |
| [OH_Drawing_PathArcTo](_drawing.md#oh_drawing_patharcto)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) | Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. |
| [OH_Drawing_PathQuadTo](_drawing.md#oh_drawing_pathquadto)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*, float ctrlX, float ctrlY, float endX, float endY) | Draws a quadratic Bezier curve from the last point of a path to the target point. |
| [OH_Drawing_PathCubicTo](_drawing.md#oh_drawing_pathcubicto)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) | Draws a cubic Bezier curve from the last point of a path to the target point. |
| [OH_Drawing_PathClose](_drawing.md#oh_drawing_pathclose)([OH_Drawing_Path](_drawing.md#oh_drawing_path)\*) | Closes a path. A line segment from the start point to the last point of the path is added. |
Declares functions related to the **pen** object in the drawing module.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Enums
| Name | Description |
| -------- | -------- |
| [OH_Drawing_PenLineCapStyle](_drawing.md#oh_drawing_penlinecapstyle) { [LINE_FLAT_CAP](_drawing.md), [LINE_SQUARE_CAP](_drawing.md), [LINE_ROUND_CAP](_drawing.md) } | Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. |
| [OH_Drawing_PenLineJoinStyle](_drawing.md#oh_drawing_penlinejoinstyle) { [LINE_MITER_JOIN](_drawing.md), [LINE_ROUND_JOIN](_drawing.md), [LINE_BEVEL_JOIN](_drawing.md) } | Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Drawing_PenCreate](_drawing.md#oh_drawing_pencreate)(void) | Creates an **OH_Drawing_Pen** object. |
| [OH_Drawing_PenDestroy](_drawing.md#oh_drawing_pendestroy)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*) | Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. |
| [OH_Drawing_PenIsAntiAlias](_drawing.md#oh_drawing_penisantialias)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_PenSetAntiAlias](_drawing.md#oh_drawing_pensetantialias)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, bool) | Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. |
| [OH_Drawing_PenGetColor](_drawing.md#oh_drawing_pengetcolor)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the color of a pen. The color is used by the pen to outline a shape. |
| [OH_Drawing_PenSetColor](_drawing.md#oh_drawing_pensetcolor)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, uint32_t color) | Sets the color for a pen. The color is used by the pen to outline a shape. |
| [OH_Drawing_PenGetWidth](_drawing.md#oh_drawing_pengetwidth)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. |
| [OH_Drawing_PenSetWidth](_drawing.md#oh_drawing_pensetwidth)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape. |
| [OH_Drawing_PenGetMiterLimit](_drawing.md#oh_drawing_pengetmiterlimit)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. |
| [OH_Drawing_PenSetMiterLimit](_drawing.md#oh_drawing_pensetmiterlimit)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, float miter) | Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. |
| [OH_Drawing_PenGetCap](_drawing.md#oh_drawing_pengetcap)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the line cap style of a pen. |
| [OH_Drawing_PenSetCap](_drawing.md#oh_drawing_pensetcap)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, [OH_Drawing_PenLineCapStyle](_drawing.md#oh_drawing_penlinecapstyle)) | Sets the line cap style for a pen. |
| [OH_Drawing_PenGetJoin](_drawing.md#oh_drawing_pengetjoin)(const[OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the line join style of a pen. |
| [OH_Drawing_PenSetJoin](_drawing.md#oh_drawing_pensetjoin)([OH_Drawing_Pen](_drawing.md#oh_drawing_pen)\*, [OH_Drawing_PenLineJoinStyle](_drawing.md#oh_drawing_penlinejoinstyle)) | Sets the line join style for a pen. |
Declares the data structure related to text in 2D drawing.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Types
| Name | Description |
| -------- | -------- |
| [OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection) | Defines an **OH_Drawing_FontCollection**, which is used to load fonts. |
| [OH_Drawing_Typography](_drawing.md#oh_drawing_typography) | Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. |
| [OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) | Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. |
| [OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) | Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. |
| [OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) | Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. |
| [OH_Drawing_CreateTypographyStyle](_drawing.md#oh_drawing_createtypographystyle)(void) | Creates an **OH_Drawing_TypographyStyle** object. |
| [OH_Drawing_DestroyTypographyStyle](_drawing.md#oh_drawing_destroytypographystyle)([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle)\*) | Releases the memory occupied by an **OH_Drawing_TypographyStyle** object. |
| [OH_Drawing_SetTypographyTextDirection](_drawing.md#oh_drawing_settypographytextdirection)([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle)\*, int) | Sets the text direction. |
| [OH_Drawing_SetTypographyTextAlign](_drawing.md#oh_drawing_settypographytextalign)([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle)\*, int) | Sets the text alignment mode. |
| [OH_Drawing_SetTypographyTextMaxLines](_drawing.md#oh_drawing_settypographytextmaxlines)([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle)\*, int) | Sets the maximum number of lines in a text file. |
| [OH_Drawing_CreateTextStyle](_drawing.md#oh_drawing_createtextstyle)(void) | Creates an **OH_Drawing_TextStyle** object. |
| [OH_Drawing_DestroyTextStyle](_drawing.md#oh_drawing_destroytextstyle)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*) | Releases the memory occupied by an **OH_Drawing_TextStyle** object. |
| [OH_Drawing_SetTextStyleColor](_drawing.md#oh_drawing_settextstylecolor)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, uint32_t) | Sets the text color. |
| [OH_Drawing_SetTextStyleFontSize](_drawing.md#oh_drawing_settextstylefontsize)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, double) | Sets the font size. |
| [OH_Drawing_SetTextStyleFontWeight](_drawing.md#oh_drawing_settextstylefontweight)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, int) | Sets the font weight. |
| [OH_Drawing_SetTextStyleBaseLine](_drawing.md#oh_drawing_settextstylebaseline)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, int) | Sets the text baseline. |
| [OH_Drawing_SetTextStyleDecoration](_drawing.md#oh_drawing_settextstyledecoration)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, int) | Sets the text decoration. |
| [OH_Drawing_SetTextStyleDecorationColor](_drawing.md#oh_drawing_settextstyledecorationcolor)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, uint32_t) | Sets the color for the text decoration. |
| [OH_Drawing_SetTextStyleFontHeight](_drawing.md#oh_drawing_settextstylefontheight)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, double) | Sets the font height. |
| [OH_Drawing_SetTextStyleFontFamilies](_drawing.md#oh_drawing_settextstylefontfamilies)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, int, const char \*fontFamilies[]) | Sets the font families. |
| [OH_Drawing_SetTextStyleFontStyle](_drawing.md#oh_drawing_settextstylefontstyle)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, int) | Sets the font style. |
| [OH_Drawing_SetTextStyleLocale](_drawing.md#oh_drawing_settextstylelocale)([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*, const char \*) | Sets the locale. |
| [OH_Drawing_CreateTypographyHandler](_drawing.md#oh_drawing_createtypographyhandler)([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle)\*, [OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection)\*) | Creates a pointer to an **OH_Drawing_TypographyCreate** object. |
| [OH_Drawing_DestroyTypographyHandler](_drawing.md#oh_drawing_destroytypographyhandler)([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate)\*) | Releases the memory occupied by an **OH_Drawing_TypographyCreate** object. |
| [OH_Drawing_TypographyHandlerPushTextStyle](_drawing.md#oh_drawing_typographyhandlerpushtextstyle)([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate)\*, [OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle)\*) | Sets the text style. |
| [OH_Drawing_TypographyHandlerAddText](_drawing.md#oh_drawing_typographyhandleraddtext)([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate)\*, const char \*) | Sets the text content. |
| [OH_Drawing_TypographyHandlerPopTextStyle](_drawing.md#oh_drawing_typographyhandlerpoptextstyle)([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate)\*) | Removes the topmost style in the stack, leaving the remaining styles in effect. |
| [OH_Drawing_CreateTypography](_drawing.md#oh_drawing_createtypography)([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate)\*) | Creates an **OH_Drawing_Typography** object. |
| [OH_Drawing_DestroyTypography](_drawing.md#oh_drawing_destroytypography)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Releases the memory occupied by an **OH_Drawing_Typography** object. |
| [OH_Drawing_TypographyLayout](_drawing.md#oh_drawing_typographylayout)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*, double) | Lays out the typography. |
| [OH_Drawing_TypographyPaint](_drawing.md#oh_drawing_typographypaint)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*, [OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas)\*, double, double) | Paints text on the canvas. |
| [OH_Drawing_TypographyGetMaxWidth](_drawing.md#oh_drawing_typographygetmaxwidth)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the maximum width. |
| [OH_Drawing_TypographyGetHeight](_drawing.md#oh_drawing_typographygetheight)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the height. |
| [OH_Drawing_TypographyGetLongestLine](_drawing.md#oh_drawing_typographygetlongestline)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the longest line. |
| [OH_Drawing_TypographyGetMinIntrinsicWidth](_drawing.md#oh_drawing_typographygetminintrinsicwidth)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the minimum intrinsic width. |
| [OH_Drawing_TypographyGetMaxIntrinsicWidth](_drawing.md#oh_drawing_typographygetmaxintrinsicwidth)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the maximum intrinsic width. |
| [OH_Drawing_TypographyGetAlphabeticBaseline](_drawing.md#oh_drawing_typographygetalphabeticbaseline)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the alphabetic baseline. |
| [OH_Drawing_TypographyGetIdeographicBaseline](_drawing.md#oh_drawing_typographygetideographicbaseline)([OH_Drawing_Typography](_drawing.md#oh_drawing_typography)\*) | Obtains the ideographic baseline. |
Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path.
**Since:**
8
**Related Modules:**
[Drawing](_drawing.md)
## Summary
### Types
| Name | Description |
| -------- | -------- |
| [OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) | Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. |
| [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) | Defines a pen, which is used to describe the style and color to outline a shape. |
| [OH_Drawing_Brush](_drawing.md#oh_drawing_brush) | Defines as a brush, which is used to describe the style and color to fill in a shape. |
| [OH_Drawing_Path](_drawing.md#oh_drawing_path) | Defines a path, which is used to customize various shapes. |
| [OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) | Defines a bitmap, which is a memory that contains the pixel data of a shape. |
| [OH_NativeWindow_CreateNativeWindow](_native_window.md#oh_nativewindow_createnativewindow)(void\*pSurface) | [OHNativeWindow](_native_window.md)\*<br/>Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. |
| [OH_NativeWindow_DestroyNativeWindow](_native_window.md#oh_nativewindow_destroynativewindow)([OHNativeWindow](_native_window.md)\*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. |
| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](_native_window.md#oh_nativewindow_createnativewindowbufferfromsurfacebuffer)(void\*pSurfaceBuffer) | [OHNativeWindowBuffer](_native_window.md)\*<br/>Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. |
| [OH_NativeWindow_DestroyNativeWindowBuffer](_native_window.md#oh_nativewindow_destroynativewindowbuffer)([OHNativeWindowBuffer](_native_window.md)\*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. |
| [OH_NativeWindow_NativeWindowRequestBuffer](_native_window.md#oh_nativewindow_nativewindowrequestbuffer)([OHNativeWindow](_native_window.md)\*window, [OHNativeWindowBuffer](_native_window.md)\*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. |
| [OH_NativeWindow_NativeWindowFlushBuffer](_native_window.md#oh_nativewindow_nativewindowflushbuffer)([OHNativeWindow](_native_window.md)\*window, [OHNativeWindowBuffer](_native_window.md)\*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. |
| [OH_NativeWindow_NativeWindowAbortBuffer](_native_window.md#oh_nativewindow_nativewindowabortbuffer)([OHNativeWindow](_native_window.md)\*window, [OHNativeWindowBuffer](_native_window.md)\*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. |
| [OH_NativeWindow_NativeWindowHandleOpt](_native_window.md#oh_nativewindow_nativewindowhandleopt)([OHNativeWindow](_native_window.md)\*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format. |
| [OH_NativeWindow_GetBufferHandleFromNative](_native_window.md#oh_nativewindow_getbufferhandlefromnative)([OHNativeWindowBuffer](_native_window.md)\*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. |
| [OH_NativeWindow_NativeObjectReference](_native_window.md#oh_nativewindow_nativeobjectreference)(void\*obj) | Adds the reference count of a native object. |
| [OH_NativeWindow_NativeObjectUnreference](_native_window.md#oh_nativewindow_nativeobjectunreference)(void\*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. |
| [OH_NativeWindow_GetNativeObjectMagic](_native_window.md#oh_nativewindow_getnativeobjectmagic)(void\*obj) | Obtains the magic ID of a native object. |
| [OH_NativeWindow_NativeWindowSetScalingMode](_native_window.md#oh_nativewindow_nativewindowsetscalingmode)([OHNativeWindow](_native_window.md)\*window, uint32_t sequence, [OHScalingMode](_native_window.md#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. |
| [OH_NativeWindow_NativeWindowSetMetaData](_native_window.md#oh_nativewindow_nativewindowsetmetadata)([OHNativeWindow](_native_window.md)\*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md)\*metaData) | Sets the metadata for a native window. |
| [OH_NativeWindow_NativeWindowSetMetaDataSet](_native_window.md#oh_nativewindow_nativewindowsetmetadataset)([OHNativeWindow](_native_window.md)\*window, uint32_t sequence, [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. |
| [OH_NativeWindow_NativeWindowSetTunnelHandle](_native_window.md#oh_nativewindow_nativewindowsettunnelhandle)([OHNativeWindow](_native_window.md)\*window, const [OHExtDataHandle](_o_h_ext_data_handle.md)\*handle) | Sets a tunnel handle for a native window. |
Provides APIs for obtaining pixel map data and information.
\@Syscap SystemCapability.Multimedia.Image
**Since:**
8
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock pixel map data. <br>File to Include: <multimedia/image_framework/image_pixel_map_napi.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information. |
| [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) | Defines the options used for creating a pixel map. |
### Types
| Name | Description |
| -------- | -------- |
| [NativePixelMap](#nativepixelmap) | Defines the data type name of the native pixel map. |
### Enums
| Name | Description |
| -------- | -------- |
| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by a function. |
| [OH_GetImageInfo](#oh_getimageinfo)(napi_env env, napi_value value, [OhosPixelMapInfo](_ohos_pixel_map_info.md)\*info) | Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure. |
| [OH_AccessPixels](#oh_accesspixels)(napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of the **PixelMap** object data and locks the memory. |
| [OH_UnAccessPixels](#oh_unaccesspixels)(napi_env env, napi_value value) | Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. |
| [OH_PixelMap_GetBytesNumberPerRow](#oh_pixelmap_getbytesnumberperrow)(const[NativePixelMap](#nativepixelmap) \*native, int32_t \*num) | Obtains the number of bytes per row of a **PixelMap** object. |
| [OH_PixelMap_GetIsEditable](#oh_pixelmap_getiseditable)(const[NativePixelMap](#nativepixelmap) \*native, int32_t \*[editable](image__pixel__map__napi_8h.md#editable)) | Checks whether a **PixelMap** object is editable. |
| [OH_PixelMap_SetAlphaAble](#oh_pixelmap_setalphaable)(const[NativePixelMap](#nativepixelmap) \*native, int32_t alpha) | Sets an alpha channel for a **PixelMap** object. |
| [OH_PixelMap_GetDensity](#oh_pixelmap_getdensity)(const[NativePixelMap](#nativepixelmap) \*native, int32_t \*density) | Obtains the pixel density of a **PixelMap** object. |
| [OH_PixelMap_SetDensity](#oh_pixelmap_setdensity)(const[NativePixelMap](#nativepixelmap) \*native, int32_t density) | Sets the pixel density for a **PixelMap** object. |
| [OH_PixelMap_SetOpacity](#oh_pixelmap_setopacity)(const[NativePixelMap](#nativepixelmap) \*native, float opacity) | Sets the opacity for a **PixelMap** object. |
| OHOS_PIXEL_MAP_FORMAT_RGBA_8888 | 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). The data is stored from the most significant bit to the least significant bit. |
| OHOS_PIXEL_MAP_FORMAT_RGB_565 | 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. The storage sequence is from the most significant bit to the least significant bit. |
Obtains the memory address of the **PixelMap** object data and locks the memory.
After the function is executed successfully, **\*addrPtr** is the address of the memory to be accessed. After the access operation is complete, you must use [OH_UnAccessPixels](#oh_unaccesspixels) to unlock the memory. Otherwise, the resources in the memory cannot be released. After being unlocked, the memory address cannot be accessed or operated.
**Parameters**
| Name | Description |
| -------- | -------- |
| env | Indicates the NAPI environment pointer. |
| value | Indicates the **PixelMap** object at the application layer. |
| addrPtr | Indicates the double pointer to the memory address. |
**See**
UnAccessPixels
**Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise.
### OH_GetImageInfo()
```
int32_t OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info )
```
**Description**<br>
Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure.
**Parameters**
| Name | Description |
| -------- | -------- |
| env | Indicates the NAPI environment pointer. |
| value | Indicates the **PixelMap** object at the application layer. |
| info | Indicates the pointer to the object that stores the information obtained. For details, see [OhosPixelMapInfo](_ohos_pixel_map_info.md). |
**Returns**
Returns **0** if the information is obtained and stored successfully; returns an error code otherwise.
**See**
[OhosPixelMapInfo](_ohos_pixel_map_info.md)
### OH_UnAccessPixels()
```
int32_t OH_UnAccessPixels (napi_env env, napi_value value )
```
**Description**<br>
Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.
**Parameters**
| Name | Description |
| -------- | -------- |
| env | Indicates the NAPI environment pointer. |
| value | Indicates the **PixelMap** object at the application layer. |
**Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise.
| native | Indicates the pointer to a **NativePixelMap** object. |
| editable | Indicates the pointer to the editing type of the **PixelMap** object. |
**Returns**
Returns an enumerated value that indicates the editing type of the **PixelMap** object if the operation is successful; returns an error code otherwise.
| [OH_GetImageInfo](image.md#oh_getimageinfo)(napi_env env, napi_value value, [OhosPixelMapInfo](_ohos_pixel_map_info.md)\*info) | Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure. |
| [OH_AccessPixels](image.md#oh_accesspixels)(napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of the **PixelMap** object data and locks the memory. |
| [OH_UnAccessPixels](image.md#oh_unaccesspixels)(napi_env env, napi_value value) | Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](image.md#oh_accesspixels) in pairs. |
### Variables
| Name | Description |
| -------- | -------- |
| [width](#width) | Image width, in pixels. |
| [height](#height) | Image height, in pixels. |
| [pixelFormat](#pixelformat) | Image format. |
| [editable](#editable) | Editing type of the image. |
| [alphaType](#alphatype) | Alpha type of the image. |
| [scaleMode](#scalemode) | Scale mode of the image. |
Defines the logging functions of the HiLog module.
Before outputting logs, you must define the service domain, and log tag, use the function with the specified log type and level, and specify the privacy identifier.
Service domain: service domain of logs. You can define the value as required. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.
Log tag: a string used to identify the class, file, or service behavior.
Log level: DEBUG, INFO, WARN, ERROR, or FATAL
Parameter format: printf format string, which starts with a % character, including a parameter type identifier and a variable parameter.
Privacy identifier: **{public}** or **{private}** added between the % character and the parameter type identifier in each parameter. If no privacy identifier is added, the parameter is considered to be **private**.
Sample code:
Defining the service domain and log tag:
\#define LOG_DOMAIN 0x0201
\#define LOG_TAG "MY_TAG"
Outputting logs:
HILOG_WARN([LOG_APP](_hi_log.md), "Failed to visit %{private}s, reason:%{public}d.", url, errno);
Output:
05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit <private>, reason:503.
**Since:**
8
**Related Modules:**
[HiLog](_hi_log.md)
## Summary
### Macros
| Name | Description |
| -------- | -------- |
| [LOG_DOMAIN](_hi_log.md#log_domain) 0 | Defines the service domain for a log file. |
| [LOG_TAG](_hi_log.md#log_tag) NULL | Defines a string constant used to identify the class, file, or service. |
| [OH_LOG_DEBUG](_hi_log.md#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_DEBUG](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. |
| [OH_LOG_INFO](_hi_log.md#oh_log_info)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_INFO](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. |
| [OH_LOG_WARN](_hi_log.md#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_WARN](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. |
| [OH_LOG_ERROR](_hi_log.md#oh_log_error)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_ERROR](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. |
| [OH_LOG_FATAL](_hi_log.md#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), [LOG_FATAL](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. |
| [OH_LOG_IsLoggable](_hi_log.md#oh_log_isloggable)(unsigned int domain, const char \*tag, [LogLevel](_hi_log.md#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. |
Provides model-related APIs for model creation and inference.
**Since:**
9
**Related Modules:**
[MindSpore](_mind_spore.md)
## Summary
### Structs
| Name | Description |
| -------- | -------- |
| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. |
| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. |
### Macros
| Name | Description |
| -------- | -------- |
| [OH_AI_MAX_SHAPE_NUM](_mind_spore.md#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) | Defines the pointer to a model object. |
| [OH_AI_TensorHandleArray](_mind_spore.md#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. |
| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](_mind_spore.md#oh_ai_callbackparam) | Defines the operator information passed in a callback. |
| [OH_AI_KernelCallBack](_mind_spore.md#oh_ai_kernelcallback)) (const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) outputs, const [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) kernel_Info) | Defines the pointer to a callback. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AI_ModelCreate](_mind_spore.md#oh_ai_modelcreate)() | Creates a model object. |
| [OH_AI_ModelDestroy](_mind_spore.md#oh_ai_modeldestroy)([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle)\*model) | Destroys a model object. |
| [OH_AI_ModelBuild](_mind_spore.md#oh_ai_modelbuild)([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. |
| [OH_AI_ModelBuildFromFile](_mind_spore.md#oh_ai_modelbuildfromfile)([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. |
| [OH_AI_ModelResize](_mind_spore.md#oh_ai_modelresize)([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md)\*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. |
| [OH_AI_ModelGetInputs](_mind_spore.md#oh_ai_modelgetinputs)(const[OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. |
| [OH_AI_ModelGetOutputs](_mind_spore.md#oh_ai_modelgetoutputs)(const[OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. |
| [OH_AI_ModelGetInputByTensorName](_mind_spore.md#oh_ai_modelgetinputbytensorname)(const[OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. |
| [OH_AI_ModelGetOutputByTensorName](_mind_spore.md#oh_ai_modelgetoutputbytensorname)(const[OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. |
| [OH_AudioDecoder_CreateByMime](_audio_decoder.md#oh_audiodecoder_createbymime)(const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioDecoder_CreateByName](_audio_decoder.md#oh_audiodecoder_createbyname)(const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. |
| [OH_AudioDecoder_Destroy](_audio_decoder.md#oh_audiodecoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. |
| [OH_AudioDecoder_SetCallback](_audio_decoder.md#oh_audiodecoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Configure](_audio_decoder.md#oh_audiodecoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Prepare](_audio_decoder.md#oh_audiodecoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. |
| [OH_AudioDecoder_Start](_audio_decoder.md#oh_audiodecoder_start)(OH_AVCodec\*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioDecoder_Stop](_audio_decoder.md#oh_audiodecoder_stop)(OH_AVCodec\*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. |
| [OH_AudioDecoder_Flush](_audio_decoder.md#oh_audiodecoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioDecoder_Reset](_audio_decoder.md#oh_audiodecoder_reset)(OH_AVCodec\*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. |
| [OH_AudioDecoder_GetOutputDescription](_audio_decoder.md#oh_audiodecoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioDecoder_SetParameter](_audio_decoder.md#oh_audiodecoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. |
| [OH_AudioDecoder_PushInputData](_audio_decoder.md#oh_audiodecoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. |
| [OH_AudioDecoder_FreeOutputData](_audio_decoder.md#oh_audiodecoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of an audio decoder. |
| [OH_AudioEncoder_CreateByMime](_audio_encoder.md#oh_audioencoder_createbymime)(const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioEncoder_CreateByName](_audio_encoder.md#oh_audioencoder_createbyname)(const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. |
| [OH_AudioEncoder_Destroy](_audio_encoder.md#oh_audioencoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. |
| [OH_AudioEncoder_SetCallback](_audio_encoder.md#oh_audioencoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Configure](_audio_encoder.md#oh_audioencoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Prepare](_audio_encoder.md#oh_audioencoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. |
| [OH_AudioEncoder_Start](_audio_encoder.md#oh_audioencoder_start)(OH_AVCodec\*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioEncoder_Stop](_audio_encoder.md#oh_audioencoder_stop)(OH_AVCodec\*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. |
| [OH_AudioEncoder_Flush](_audio_encoder.md#oh_audioencoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioEncoder_Reset](_audio_encoder.md#oh_audioencoder_reset)(OH_AVCodec\*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. |
| [OH_AudioEncoder_GetOutputDescription](_audio_encoder.md#oh_audioencoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioEncoder_SetParameter](_audio_encoder.md#oh_audioencoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. |
| [OH_AudioEncoder_PushInputData](_audio_encoder.md#oh_audioencoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. |
| [OH_AudioEncoder_FreeOutputData](_audio_encoder.md#oh_audioencoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of an audio encoder. |
Declares the common structs, character constants, and enums for running **OH_AVCodec** instances.
**Since:**
9
**Related Modules:**
[CodecBase](_codec_base.md)
## Summary
### Structs
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. |
| [OH_AVCodecBufferAttr](_codec_base.md#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)\*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecAsyncCallback](_codec_base.md#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
| [OH_MediaType](_codec_base.md#oh_mediatype) | Enumerates the media types. |
| [OH_AVCProfile](_codec_base.md#oh_avcprofile) | Enumerates the AVC profiles. |
| [OH_AACProfile](_codec_base.md#oh_aacprofile) | Enumerates the AAC profiles. |
| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). |
| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). |
| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. |
| [OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.|
| [OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. |
| [OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string.|
| [OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t.|
| [OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. |
| [OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. |
| [OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. |
| [OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. |
| [OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. |
| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. |
| [OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. |
| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. |
| [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. |
| [OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. |
| [OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. |
| [OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. |
| [OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. |
| [OH_VideoDecoder_CreateByMime](_video_decoder.md#oh_videodecoder_createbymime)(const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_VideoDecoder_CreateByName](_video_decoder.md#oh_videodecoder_createbyname)(const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. |
| [OH_VideoDecoder_Destroy](_video_decoder.md#oh_videodecoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. |
| [OH_VideoDecoder_SetCallback](_video_decoder.md#oh_videodecoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_SetSurface](_video_decoder.md#oh_videodecoder_setsurface)(OH_AVCodec\*codec, [OHNativeWindow](_native_window.md)\*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_Configure](_video_decoder.md#oh_videodecoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. |
| [OH_VideoDecoder_Prepare](_video_decoder.md#oh_videodecoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. |
| [OH_VideoDecoder_Start](_video_decoder.md#oh_videodecoder_start)(OH_AVCodec\*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_VideoDecoder_Stop](_video_decoder.md#oh_videodecoder_stop)(OH_AVCodec\*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. |
| [OH_VideoDecoder_Flush](_video_decoder.md#oh_videodecoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_VideoDecoder_Reset](_video_decoder.md#oh_videodecoder_reset)(OH_AVCodec\*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. |
| [OH_VideoDecoder_GetOutputDescription](_video_decoder.md#oh_videodecoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. |
| [OH_VideoDecoder_SetParameter](_video_decoder.md#oh_videodecoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. |
| [OH_VideoDecoder_PushInputData](_video_decoder.md#oh_videodecoder_pushinputdata)(OH_AVCodec\*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. |
| [OH_VideoDecoder_RenderOutputData](_video_decoder.md#oh_videodecoder_renderoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. |
| [OH_VideoDecoder_FreeOutputData](_video_decoder.md#oh_videodecoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video decoder. |
| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_VideoEncoder_CreateByMime](_video_encoder.md#oh_videoencoder_createbymime)(const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_VideoEncoder_CreateByName](_video_encoder.md#oh_videoencoder_createbyname)(const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. |
| [OH_VideoEncoder_Destroy](_video_encoder.md#oh_videoencoder_destroy)(OH_AVCodec\*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. |
| [OH_VideoEncoder_SetCallback](_video_encoder.md#oh_videoencoder_setcallback)(OH_AVCodec\*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_Configure](_video_encoder.md#oh_videoencoder_configure)(OH_AVCodec\*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_Prepare](_video_encoder.md#oh_videoencoder_prepare)(OH_AVCodec\*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. |
| [OH_VideoEncoder_Start](_video_encoder.md#oh_videoencoder_start)(OH_AVCodec\*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_VideoEncoder_Stop](_video_encoder.md#oh_videoencoder_stop)(OH_AVCodec\*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. |
| [OH_VideoEncoder_Flush](_video_encoder.md#oh_videoencoder_flush)(OH_AVCodec\*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_VideoEncoder_Reset](_video_encoder.md#oh_videoencoder_reset)(OH_AVCodec\*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. |
| [OH_VideoEncoder_GetOutputDescription](_video_encoder.md#oh_videoencoder_getoutputdescription)(OH_AVCodec\*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. |
| [OH_VideoEncoder_SetParameter](_video_encoder.md#oh_videoencoder_setparameter)(OH_AVCodec\*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. |
| [OH_VideoEncoder_GetSurface](_video_encoder.md#oh_videoencoder_getsurface)(OH_AVCodec\*codec, [OHNativeWindow](_native_window.md)\*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. |
| [OH_VideoEncoder_FreeOutputData](_video_encoder.md#oh_videoencoder_freeoutputdata)(OH_AVCodec\*codec, uint32_t index) | Frees an output buffer of a video encoder. |
| [OH_VideoEncoder_NotifyEndOfStream](_video_encoder.md#oh_videoencoder_notifyendofstream)(OH_AVCodec\*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. |
| [OH_AVPixelFormat](_core.md#oh_avpixelformat) | Enumerates the audio and video pixel formats. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_AVPixelFormat](_core.md#oh_avpixelformat) {<br/>AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,<br/>AV_PIXEL_FORMAT_RGBA = 5<br/>} | Enumerates the audio and video pixel formats. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AVFormat_Create](_core.md#oh_avformat_create)(void) | Creates an **OH_AVFormat** instance for reading and writing data. |
| [OH_AVFormat_Destroy](_core.md#oh_avformat_destroy)(struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. |
| [OH_AVFormat_Copy](_core.md#oh_avformat_copy)(struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. |
| [OH_AVFormat_SetIntValue](_core.md#oh_avformat_setintvalue)(struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetLongValue](_core.md#oh_avformat_setlongvalue)(struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetFloatValue](_core.md#oh_avformat_setfloatvalue)(struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetDoubleValue](_core.md#oh_avformat_setdoublevalue)(struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetStringValue](_core.md#oh_avformat_setstringvalue)(struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetBuffer](_core.md#oh_avformat_setbuffer)(struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. |
| [OH_AVFormat_GetIntValue](_core.md#oh_avformat_getintvalue)(struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetLongValue](_core.md#oh_avformat_getlongvalue)(struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetFloatValue](_core.md#oh_avformat_getfloatvalue)(struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetDoubleValue](_core.md#oh_avformat_getdoublevalue)(struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetStringValue](_core.md#oh_avformat_getstringvalue)(struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetBuffer](_core.md#oh_avformat_getbuffer)(struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. |
| [OH_AVFormat_DumpInfo](_core.md#oh_avformat_dumpinfo)(struct OH_AVFormat \*format) | Dumps the information contained in an **OH_AVFormat** instance as a string. |
| [OH_Huks_InitSession](_huks_key_api.md#oh_huks_initsession)(const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*challenge) | Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). |
| [OH_Huks_UpdateSession](_huks_key_api.md#oh_huks_updatesession)(const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md)\*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md)\*outData) | Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. |
Provides APIs for constructing, using, and destroying parameter sets.
**Since:**
9
**Related Modules:**
[HuksParamSetApi](_huks_param_set_api.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Huks_InitParamSet](_huks_param_set_api.md#oh_huks_initparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. |
| [OH_Huks_AddParams](_huks_param_set_api.md#oh_huks_addparams)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md)\*params, uint32_t paramCnt) | Adds parameters to a parameter set. |
| [OH_Huks_BuildParamSet](_huks_param_set_api.md#oh_huks_buildparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. |
| [OH_Huks_FreeParamSet](_huks_param_set_api.md#oh_huks_freeparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. |
| [OH_Huks_CopyParamSet](_huks_param_set_api.md#oh_huks_copyparamset)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*\*paramSet) | Copies a parameter set (deep copy). |
| [OH_Huks_GetParam](_huks_param_set_api.md#oh_huks_getparam)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md)\*\*param) | Obtains parameters from a parameter set. |
| [OH_Huks_FreshParamSet](_huks_param_set_api.md#oh_huks_freshparamset)(struct[OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. |
| [OH_Huks_isParamSetTagValid](_huks_param_set_api.md#oh_huks_isparamsettagvalid)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet) | Checks whether the parameters in a parameter set are valid. |
| [OH_Huks_isParamSetValid](_huks_param_set_api.md#oh_huks_isparamsetvalid)(const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md)\*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. |
| [OH_Huks_CheckParamMatch](_huks_param_set_api.md#oh_huks_checkparammatch)(const struct [OH_Huks_Param](_o_h___huks___param.md)\*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md)\*param) | Checks whether two parameters are the same. |
| [OH_Huks_ImportKeyType](_huks_type_api.md#oh_huks_importkeytype) { OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, OH_HUKS_KEY_TYPE_KEY_PAIR = 2 } | Enumerates the types of keys to import. By default, a public key is imported. This field is not required when a symmetric key is imported. |
| [OH_Huks_ChallengeType](_huks_type_api.md#oh_huks_challengetype) { OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, OH_HUKS_CHALLENGE_TYPE_NONE = 2 } | Enumerates the types of the challenges generated when a key is used. |
| [OH_Huks_ChallengePosition](_huks_type_api.md#oh_huks_challengeposition) { OH_HUKS_CHALLENGE_POS_0 = 0, OH_HUKS_CHALLENGE_POS_1, OH_HUKS_CHALLENGE_POS_2, OH_HUKS_CHALLENGE_POS_3 } | Enumerates the positions of the 8-byte valid value in a custom challenge generated. |
| [OH_Huks_SecureSignType](_huks_type_api.md#oh_huks_securesigntype) { OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 } | Enumerates the signature types of the keys generated or imported. |
Declares the APIs used to access the native XComponent.
**Since:**
8
**Related Modules:**
[Native XComponent](_o_h___native_x_component.md)
## Summary
### Structs
| Name | Description |
| -------- | -------- |
| [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) | Describes the touch point of the touch event. |
| [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) | Describes the touch event. |
| [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) | Describes the mouse event.|
| [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) | Registers a callback for the surface lifecycle and touch event. |
| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) | Registers a callback for the mouse event. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) | Provides an encapsulated OH_NativeXComponent instance. |
| [OH_NativeXComponent_Callback](_o_h___native_x_component.md#oh_nativexcomponent_callback) | Registers a callback for the surface lifecycle and touch event. |
| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component.md#oh_nativexcomponent_mouseevent_callback) | Registers a callback for the mouse event. |
### Enums
| Name | Description |
| -------- | -------- |
| { OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, <br/>OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, <br/>OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2} | [Enumerates](_o_h___native_x_component.md#anonymous-enum)the API access states. |
| [OH_NativeXComponent_GetXComponentId](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentid)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, char \*id, uint64_t \*size) | Obtains the ID of the ArkUI XComponent. |
| [OH_NativeXComponent_GetXComponentSize](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentsize)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, const void \*window, uint64_t \*width, uint64_t \*height) | Obtains the size of the surface held by the ArkUI XComponent. |
| [OH_NativeXComponent_GetXComponentOffset](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentoffset)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, const void \*window, double \*x, double \*y) | Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. |
| [OH_NativeXComponent_GetTouchEvent](_o_h___native_x_component.md#oh_nativexcomponent_gettouchevent)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, const void \*window, [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md)\*touchEvent) | Obtains the touch event scheduled by the ArkUI XComponent. |
| [OH_NativeXComponent_GetMouseEvent](_o_h___native_x_component.md#oh_nativexcomponent_getmouseevent)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, const void \*window, [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md)\*mouseEvent) | Obtains the mouse event scheduled by ArkUI XComponent. |
| [OH_NativeXComponent_RegisterCallback](_o_h___native_x_component.md#oh_nativexcomponent_registercallback)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md)\*callback) | Registers a callback for this **OH_NativeXComponent** instance. |
| [OH_NativeXComponent_RegisterMouseEventCallback](_o_h___native_x_component.md#oh_nativexcomponent_registermouseeventcallback)([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent)\*component, [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md)\*callback) | Registers a mouse event callback for this **OH_NativeXComponent** instance. |
### Variables
| Name | Description |
| -------- | -------- |
| **OH_XCOMPONENT_ID_LEN_MAX** = 128 | Maximum length of an ArkUI XComponent ID. |
| **OH_MAX_TOUCH_POINTS_NUMBER** = 10 | Maximum number of identifiable touch points in a touch event. |
Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime to construct and compile models and perform inference and computing on acceleration hardware. Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling.
**Since:**
9
**Related Modules:**
[NeuralNeworkRuntime](_neural_nework_runtime.md)
## Summary
### Functions
| Name | Description |
| -------- | -------- |
| [OH_NNModel_Construct](_neural_nework_runtime.md#oh_nnmodel_construct)(void) | Creates a model instance of the [OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance. |
| [OH_NNModel_AddTensor](_neural_nework_runtime.md#oh_nnmodel_addtensor)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*model, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor) | Adds a tensor to a model instance. |
| [OH_NNModel_AddOperation](_neural_nework_runtime.md#oh_nnmodel_addoperation)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*model, [OH_NN_OperationType](_neural_nework_runtime.md#oh_nn_operationtype) op, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*paramIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*outputIndices) | Adds an operator to a model instance. |
| [OH_NNModel_SpecifyInputsAndOutputs](_neural_nework_runtime.md#oh_nnmodel_specifyinputsandoutputs)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*model, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)\*outputIndices) | Specifies the inputs and outputs of a model. |
| [OH_NNModel_Finish](_neural_nework_runtime.md#oh_nnmodel_finish)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*model) | Completes model composition. |
| [OH_NNModel_Destroy](_neural_nework_runtime.md#oh_nnmodel_destroy)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*\*model) | Releases a model instance. |
| [OH_NNModel_GetAvailableOperations](_neural_nework_runtime.md#oh_nnmodel_getavailableoperations)([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)\*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. |
| [OH_NNCompilation_Construct](_neural_nework_runtime.md#oh_nncompilation_construct)(const[OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model) | Creates a compilation instance of the [OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) type. |
| [OH_NNCompilation_SetDevice](_neural_nework_runtime.md#oh_nncompilation_setdevice)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation, size_t deviceID) | Specifies the device for model compilation and computing. |
| [OH_NNCompilation_SetCache](_neural_nework_runtime.md#oh_nncompilation_setcache)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation, const char \*cachePath, uint32_t version) | Set the cache directory and version of the compiled model. |
| [OH_NNCompilation_SetPerformanceMode](_neural_nework_runtime.md#oh_nncompilation_setperformancemode)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation, [OH_NN_PerformanceMode](_neural_nework_runtime.md#oh_nn_performancemode) performanceMode) | Sets the performance mode for model computing. |
| [OH_NNCompilation_SetPriority](_neural_nework_runtime.md#oh_nncompilation_setpriority)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation, [OH_NN_Priority](_neural_nework_runtime.md#oh_nn_priority) priority) | Sets the model computing priority. |
| [OH_NNCompilation_EnableFloat16](_neural_nework_runtime.md#oh_nncompilation_enablefloat16)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation, bool enableFloat16) | Enables float16 for computing. |
| [OH_NNCompilation_Build](_neural_nework_runtime.md#oh_nncompilation_build)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation) | Compiles a model. |
| [OH_NNCompilation_Destroy](_neural_nework_runtime.md#oh_nncompilation_destroy)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*\*compilation) | Releases the **Compilation** object. |
| [OH_NNExecutor_Construct](_neural_nework_runtime.md#oh_nnexecutor_construct)([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)\*compilation) | [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*<br/>Creates an executor instance of the [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) type. |
| [OH_NNExecutor_SetInput](_neural_nework_runtime.md#oh_nnexecutor_setinput)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor, const void \*dataBuffer, size_t length) | Sets the single input data for a model. |
| [OH_NNExecutor_SetOutput](_neural_nework_runtime.md#oh_nnexecutor_setoutput)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | Sets the buffer for a single output of a model. |
| [OH_NNExecutor_GetOutputShape](_neural_nework_runtime.md#oh_nnexecutor_getoutputshape)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | Obtains the dimension information about the output tensor. |
| [OH_NNExecutor_AllocateInputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateinputmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t inputIndex, size_t length) | Allocates shared memory to a single input on a device. |
| [OH_NNExecutor_AllocateOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateoutputmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t outputIndex, size_t length) | Allocates shared memory to a single output on a device. |
| [OH_NNExecutor_DestroyInputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyinputmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t inputIndex, [OH_NN_Memory](_o_h___n_n___memory.md)\*\*memory) | Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. |
| [OH_NNExecutor_DestroyOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyoutputmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t outputIndex, [OH_NN_Memory](_o_h___n_n___memory.md)\*\*memory) | Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. |
| [OH_NNExecutor_SetInputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setinputwithmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md)\*tensor, const [OH_NN_Memory](_o_h___n_n___memory.md)\*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input. |
| [OH_NNExecutor_SetOutputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setoutputwithmemory)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*executor, uint32_t outputIndex, const [OH_NN_Memory](_o_h___n_n___memory.md)\*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output. |
| [OH_NNExecutor_Destroy](_neural_nework_runtime.md#oh_nnexecutor_destroy)([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)\*\*executor) | Destroys an executor instance to release the memory occupied by the executor. |
| [OH_NNDevice_GetAllDevicesID](_neural_nework_runtime.md#oh_nndevice_getalldevicesid)(const size_t \*\*allDevicesID, uint32_t \*deviceCount) | Obtains the ID of the device connected to Neural Network Runtime. |
| [OH_NNDevice_GetName](_neural_nework_runtime.md#oh_nndevice_getname)(size_t deviceID, const char \*\*name) | Obtains the name of the specified device. |
| [OH_NNDevice_GetType](_neural_nework_runtime.md#oh_nndevice_gettype)(size_t deviceID, [OH_NN_DeviceType](_neural_nework_runtime.md#oh_nn_devicetype)\*deviceType) | Obtains the type information of the specified device. |
Provides functions for operating rawfile directories.
These functions include traversing and closing rawfile directories.
**Since:**
8
**Related Modules:**
[Rawfile](rawfile.md)
## Summary
### Types
| Name | Description |
| -------- | -------- |
| [RawDir](rawfile.md#rawdir) | Provides the function of accessing rawfile directories. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_ResourceManager_GetRawFileName](rawfile.md#oh_resourcemanager_getrawfilename)([RawDir](rawfile.md#rawdir)\*rawDir, int index) | Obtains the rawfile name via an index. |
| [OH_ResourceManager_GetRawFileCount](rawfile.md#oh_resourcemanager_getrawfilecount)([RawDir](rawfile.md#rawdir)\*rawDir) |Obtains the number of rawfiles in [RawDir](rawfile.md#rawdir). |
| [OH_ResourceManager_CloseRawDir](rawfile.md#oh_resourcemanager_closerawdir)([RawDir](rawfile.md#rawdir)\*rawDir) | Closes an opened [RawDir](rawfile.md#rawdir) and releases all associated resources. |
| [OH_ResourceManager_SeekRawFile](rawfile.md#oh_resourcemanager_seekrawfile)(const[RawFile](rawfile.md#rawfile) \*rawFile, long offset, int whence) |Seeks for the data read/write position in the rawfile based on the specified offset. |
| [OH_ResourceManager_GetRawFileSize](rawfile.md#oh_resourcemanager_getrawfilesize)([RawFile](rawfile.md#rawfile)\*rawFile) | Obtains the length of a rawfile in int32_t. |
| [OH_ResourceManager_CloseRawFile](rawfile.md#oh_resourcemanager_closerawfile)([RawFile](rawfile.md#rawfile)\*rawFile) | Closes an opened [RawFile](rawfile.md#rawfile) and releases all associated resources. |
| [OH_ResourceManager_GetRawFileOffset](rawfile.md#oh_resourcemanager_getrawfileoffset)(const[RawFile](rawfile.md#rawfile) \*rawFile) | Obtains the current offset of the rawfile in int32_t. |
| [OH_ResourceManager_GetRawFileDescriptor](rawfile.md#oh_resourcemanager_getrawfiledescriptor)(const[RawFile](rawfile.md#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md)&descriptor) | Opens a rawfile descriptor. |
| [OH_ResourceManager_ReleaseRawFileDescriptor](rawfile.md#oh_resourcemanager_releaserawfiledescriptor)(const[RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Closes a rawfile descriptor. |
| [RawDir](#rawdir) | Provides the function of accessing rawfile directories. |
| [RawFile](#rawfile) | Provides the function of accessing rawfiles. |
| [NativeResourceManager](#nativeresourcemanager) | Implements the resource manager. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename)([RawDir](#rawdir)\*rawDir, int index) | Obtains the rawfile name via an index. |
| [OH_ResourceManager_GetRawFileCount](#oh_resourcemanager_getrawfilecount)([RawDir](#rawdir)\*rawDir) |Obtains the number of rawfiles in [RawDir](#rawdir). |
| [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir)([RawDir](#rawdir)\*rawDir) | Closes an opened [RawDir](#rawdir) and releases all associated resources. |
| [OH_ResourceManager_SeekRawFile](#oh_resourcemanager_seekrawfile)(const[RawFile](#rawfile) \*rawFile, long offset, int whence) |Seeks for the data read/write position in the rawfile based on the specified offset. |
| [OH_ResourceManager_GetRawFileSize](#oh_resourcemanager_getrawfilesize)([RawFile](#rawfile)\*rawFile) | Obtains the length of a rawfile in int32_t. |
| [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile)([RawFile](#rawfile)\*rawFile) | Closes an opened [RawFile](#rawfile) and releases all associated resources. |
| [OH_ResourceManager_GetRawFileOffset](#oh_resourcemanager_getrawfileoffset)(const[RawFile](#rawfile) \*rawFile) | Obtains the current offset of the rawfile in int32_t. |
| [OH_ResourceManager_GetRawFileDescriptor](#oh_resourcemanager_getrawfiledescriptor)(const[RawFile](#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md)&descriptor) | Opens a rawfile descriptor. |
| [OH_ResourceManager_ReleaseRawFileDescriptor](#oh_resourcemanager_releaserawfiledescriptor)(const[RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Closes a rawfile descriptor. |
| [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)(napi_env env, napi_value jsResMgr) | Obtains the native resource manager based on JavaScipt resource manager. |
| [OH_ResourceManager_ReleaseNativeResourceManager](#oh_resourcemanager_releasenativeresourcemanager)([NativeResourceManager](#nativeresourcemanager)\*resMgr) | Releases a native resource manager. |
This class encapsulates the native implementation of the JavaScript resource manager. You can obtain the pointer to **ResourceManager** by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).
### RawDir
```
typedef struct RawDirRawDir
```
**Description**<br>
Provides the function of accessing rawfile directories.
After the descriptor is opened, you can use it to read the rawfile based on the offset (in int32_t) and file length.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawFile | Indicates the pointer to [RawFile](#rawfile). |
| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. |
**Returns**
Returns **true** if the rawfile descriptor is opened successfully; returns **false** if the rawfile cannot be accessed.
### OH_ResourceManager_GetRawFileName()
```
const char* OH_ResourceManager_GetRawFileName (RawDir * rawDir, int index )
```
**Description**<br>
Obtains the rawfile name via an index.
You can use this function to traverse a rawfile directory.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawDir | Indicates the pointer to [RawDir](#rawdir). |
| index | Indicates the index of the file in [RawDir](#rawdir). |
**Returns**
Returns the rawfile name via an index. The return value can be used as the input parameter of [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile). If no rawfile is found after all rawfiles are traversed, **NULL** will be returned.
After opening a rawfile directory, you can traverse all the rawfile files in it.
**Parameters**
| Name | Description |
| -------- | -------- |
| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). |
| dirName | Indicates the name of the rawfile directory to open. If this field is left empty, the root directory of rawfile will be opened. |
**Returns**
Returns the pointer to [RawDir](#rawdir). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) to release it.
After a rawfile is opened, you can read the data in it.
**Parameters**
| Name | Description |
| -------- | -------- |
| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). |
| fileName | Indicates the file name in the relative path of the rawfile root directory. |
**Returns**
Returns the pointer to [RawFile](#rawfile). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) to release it.
To prevent file descriptor leakage, you are advised to release a rawfile descriptor after use.
**Parameters**
| Name | Description |
| -------- | -------- |
| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. |
**Returns**
Returns **true** if the rawfile descriptor is closed successfully; returns **false** otherwise.
### OH_ResourceManager_SeekRawFile()
```
int OH_ResourceManager_SeekRawFile (const RawFile * rawFile, long offset, int whence )
```
**Description**<br>
Seeks for the data read/write position in the rawfile based on the specified offset.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawFile | Indicates the pointer to [RawFile](#rawfile). |
| offset | Indicates the specified offset. |
| whence | Indicates the data read/write position. The options are as follows:<br/>**0**: The read/write position is **offset**.<br/>**1**: The read/write position is the current position plus **offset**.<br/>**2**: The read/write position is the end of the file (EOF) plus **offset**. |
**Returns**
Returns the new data read/write position if the operation is successful; returns **(long) -1** otherwise.
| [OH_AI_TensorDestroy](_mind_spore.md#oh_ai_tensordestroy)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle)\*tensor) | Destroys a tensor object. |
| [OH_AI_TensorClone](_mind_spore.md#oh_ai_tensorclone)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Clones a tensor. |
| [OH_AI_TensorSetName](_mind_spore.md#oh_ai_tensorsetname)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. |
| [OH_AI_TensorGetName](_mind_spore.md#oh_ai_tensorgetname)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. |
| [OH_AI_TensorSetDataType](_mind_spore.md#oh_ai_tensorsetdatatype)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_DataType](_mind_spore.md#oh_ai_datatype) type) | Sets the data type of a tensor. |
| [OH_AI_TensorGetDataType](_mind_spore.md#oh_ai_tensorgetdatatype)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. |
| [OH_AI_TensorSetShape](_mind_spore.md#oh_ai_tensorsetshape)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. |
| [OH_AI_TensorGetShape](_mind_spore.md#oh_ai_tensorgetshape)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. |
| [OH_AI_TensorSetFormat](_mind_spore.md#oh_ai_tensorsetformat)([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_Format](_mind_spore.md#oh_ai_format) format) | Sets the tensor data format. |
| [OH_AI_TensorGetFormat](_mind_spore.md#oh_ai_tensorgetformat)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. |
| [OH_AI_TensorGetData](_mind_spore.md#oh_ai_tensorgetdata)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. |
| [OH_AI_TensorGetMutableData](_mind_spore.md#oh_ai_tensorgetmutabledata)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. |
| [OH_AI_TensorGetElementNum](_mind_spore.md#oh_ai_tensorgetelementnum)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. |
| [OH_AI_TensorGetDataSize](_mind_spore.md#oh_ai_tensorgetdatasize)(const[OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. |