# 机器学习 API

Source: [https://docs.qualcomm.com/doc/80-70022-50SC/topic/machine-learning-apis.html](https://docs.qualcomm.com/doc/80-70022-50SC/topic/machine-learning-apis.html)

配置特定于张量的要求和机器学习属性。

## GstMLType

下表列出了描述张量格式的可能值：

| 枚举 | 说明 |
| --- | --- |
| GST\_ML\_TYPE\_UNKNOWN | 无效数据 |
| GST\_ML\_TYPE\_INT8 | 数据表示为有符号整数值的 1 个字节 |
| GST\_ML\_TYPE\_UINT8 | 数据表示为无符号整数值的 1 个字节 |
| GST\_ML\_TYPE\_INT32 | 数据表示为有符号整数值的 4 个字节 |
| GST\_ML\_TYPE\_UINT32 | 数据表示为无符号整数值的 4 个字节 |
| GST\_ML\_TYPE\_FLOAT16 | 数据表示为 2 个字节的浮点值 |
| GST\_ML\_TYPE\_FLOAT32 | 数据表示为 4 个字节的浮点值 |

以下列表提供了有关每个GstMLType API的信息：

- **gst\_ml\_type\_get\_size**
    返回 GstMLType 的大小（以字节为单位）

    **原型**

        guint
        gst_ml_type_get_size (GstMLType type)
        Copy to clipboard

    **参数**

| [in] | `type` | 一个 GstMLType |
    | :--- | :--- | :--- |

    **返回结果**

    大小（以字节为单位）。
- **gst\_ml\_type\_from\_string**
                    
    根据其字符串版本返回 GstMLType。

    **原型**

        GstMLType
        gst_ml_type_from_string (const gchar * type)
        Copy to clipboard

    **参数**

| [in] | `type` | GstMLType 的字符字符串版本 |
    | :--- | :--- | :--- |

    **返回结果**

    一个 GstMLType
- **gst\_ml\_type\_to\_string**
    返回 GstMLType 的字符字符串版本

        const gchar *
        gst_ml_type_to_string (GstMLType type)
        Copy to clipboard

    **参数**

| [in] | `type` | GstMLType 的字符串版本 |
    | :--- | :--- | :--- |

    **返回结果**

    GstMLType 的新字符字符串版本

## GstMLInfo

gst\_ml\_info\_from\_caps()用于添加 GstCaps 中的 ML 属性信息。

Table : 描述 ML 属性的信息结构

| 字段 | 说明 |
| --- | --- |
| `type (GstMLType)` | 张量的类型 |
| `n_tensors (guint)` | 张量数 |
| `n_dimensions (guint)` | 每个张量的维数 |
| `tensors (guint)` | 具有张量维度的数组 |

以下列表提供了有关每个 GstMLInfo API 的信息：

- **gst\_ml\_info\_init**
    初始化 GstMLInfo 字段。

    **原型**

        void
                 gst_ml_info_init (GstMLInfo * info)
        Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |

    **返回结果**

    无
- **gst\_ml\_info\_new**
    复制 GstMLInfo 结构。

    **原型**

        GstMLInfo *
                 gst_ml_info_new (void)Copy to clipboard

    **返回结果**

    一个新的 GstMLInfo。免费使用gst\_ml\_info\_free()。
- gst\_ml\_info\_copy：复制 GstMLInfo 结构。
    **原型**

        GstMLInfo *
        gst_ml_info_copy (const GstMLInfo * info)
                                Copy to clipboard

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |

    **返回结果**

    一个新的 GstMLInfo。免费使用gst\_ml\_info\_free()。
- **gst\_ml\_info\_free**
    释放先前使用 gst\_ml\_info\_new()或 gst\_ml\_info\_copy() 分配的 GstMLInfo 结构。

    **原型**

        void
        gst_ml_info_free (const GstMLInfo * info)
                                    Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |

    **返回结果**

    无
- **gst\_ml\_info\_from\_caps**
    解析功能 (caps) 并更新 `caps`信息。

    **原型**

        gboolean 
        gst_ml_info_from_caps (GstMLInfo * info, const GstCaps  * caps)
                                    Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |
    | [in] | `caps` | 一个 GstCaps |

    **返回结果**

    如果操作成功，则为 TRUE
- **gst\_ml\_info\_to\_caps**
    将 info 的值转换为 GstCaps。

    **原型**

        GstCaps *  
        gst_ml_info_to_caps (const GstMLInfo * info)
                                    Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |

    **返回结果**

    包含信息的新 [GstCaps](https://gstreamer.freedesktop.org/documentation/gstreamer/gstcaps.html)。
- **gst\_ml\_info\_is\_equal**
                    
    比较两个 GstMLInfo 并返回二者是否相等。

    **原型**

        gboolean
        gst_ml_info_is_equal (const GstMLInfo * l_info, const GstMLInfo * r_info)
                                    Copy to clipboard

    **参数**

| [in] | `l_info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |
    | [in] | `r_info` | 一个 GstMLInfo |

    **返回结果**

    如果操作成功，则为 TRUE。
- **gst\_ml\_info\_tensor\_size**
    从 GstMLInfo 计算其索引指定的张量的大小。

**原型**

        gsize
        gst_ml_info_tensor_size (const GstMLInfo * info, guint index)
                                Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | :--- | :--- | :--- |
    | [in] | `index` | 张量索引 |

    **返回结果**

    大小（以字节为单位）。
- **gst\_ml\_info\_size**
    计算 GstMLInfo 中所有张量的总大小。

    **原型**

        gsize
        gst_ml_info_size (const GstMLInfo * info)
        Copy to clipboard

    **参数**

| [in] | `info` | 一个 GstMLInfo |
    | --- | --- | --- |

    **返回结果**

    大小（以字节为单位）。

## GstMLTensorMeta

这些 API 基于 [GstMeta](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmeta.html?gi-language=c)，它是 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) 元数据结构的成员。

Table : GstMLTensorMeta 信息结构

| 字段 | 说明 |
| --- | --- |
| meta ([GstMeta](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmeta.html?gi-language=c)) | GstMeta 是父级 |
| id (guint) | 与 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) 中的内存索引对应的 ID |
| type (GstMLType) | 张量类型 |
| n\_dimensions (guint) | 张量维数 |
| dimensions (Guint) | 张量维数组 |

以下列表提供了有关每个 GstMLTensorMeta API 的信息：

- **gst\_buffer\_add\_ml\_tensor\_meta**
    使用给定参数将 GstMLTensorMeta 元数据附加至缓存。

    **原型**

        GstMLTensorMeta *
        gst_buffer_add_ml_tensor_meta (GstBuffer * buffer, const GstMLType type, const guint n_dimensions, const guint dimensions[GST_ML_TENSOR_MAX_DIMS])Copy to clipboard

    **参数**

| [in] | `buffer` | 一个 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) |
    | :--- | :--- | :--- |
    | [in] | `type` | 张量类型。 |
    | [in] | `n_dimensions` | 张量维数。 |
    | [in] | `dimensions` | 包含张量维度的数组。 |

    **返回结果**

    缓存的 GstMLTensorMeta。代码运行后不要释放。
- **gst\_buffer\_get\_ml\_tensor\_meta**
    获取缓存上的第一个 GstMLTensorMeta

    **原型**

        GstMLTensorMeta *
        gst_buffer_get_ml_tensor_meta (GstBuffer * buffer)Copy to clipboard

    **参数**

| [in] | `buffer` | 一个 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) |
    | :--- | :--- | :--- |

    **返回结果**

    缓存的 GstMLTensorMeta。代码运行后不要释放。
- **gst\_buffer\_get\_ml\_tensor\_meta\_id**
    在具有给定 ID 的缓存上查找 GstMLTensorMeta。

    **原型**

        GstMLTensorMeta *
        gst_buffer_get_ml_tensor_meta_id (GstBuffer * buffer, guint id)
        Copy to clipboard

    **参数**

| [in] | `buffer` | 一个 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) |
    | :--- | :--- | :--- |
    | [in] | `id` | 一个元数据 ID |

    **返回结果**

    缓存的 GstMLTensorMeta。代码运行后不要释放。
- **gst\_ml\_meta\_tensor\_size**
    获取张量的总大小（以字节为单位），该大小是根据维度和张量类型计算的。

    **原型**

        gsize
        gst_ml_meta_tensor_size (const GstMLTensorMeta * meta)Copy to clipboard

**参数**

| [in] | `meta` | 一个 GstMLTensorMeta |
    | :--- | :--- | :--- |

    **返回结果**

    大小（以字节为单位）。

## GstMLFrame

GstMLFrame 是从 gst\_ml\_frame\_map()中获得的结构。

Table : GstMLFrame 的结构

| 字段 | 说明 |
| --- | --- |
| info（GstMLInfo） | GstMLInfo |
| buffer（[GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c)） | 包含张量内存块的映射缓存 |
| map（[GstMapInfo](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmemory.html?gi-language=c#GstMapInfo)） | 张量内存块的映射 |

以下列表提供了有关每个 GstMLFrame API 的信息：

- **gst\_ml\_frame\_map**
    使用 [GstMLInfo](https://docs.qualcomm.com/doc/80-70022-50SC/topic/machine-learning-apis.html#machine-learning-apis__section_qqy_3ng_tcc) 和 GstBuffer 更新帧值。

    1. 该地址被传递给在协议栈上分配的 GstMLFrame 结构。
    2. gst\_ml\_frame\_map()函数使用 ML 张量特定信息填充 GstMLFrame 结构，以访问 ML 缓存数据。所有缓存视频张量都已映射，指针已设置在帧数据中。

**原型**

        gboolean
        gst_ml_frame_map (GstMLFrame * frame, const GstMLInfo * info, GstBuffer * buffer, GstMapFlags flags)
        Copy to clipboard

    **参数**

| [in] | `frame` | 指向 GstMLFrame 的指针 |
    | :--- | :--- | :--- |
    | [in] | `info` | 一个 GstMLInfo |
    | [in] | `buffer` | 一个 GstBuffer |
    | [in] | `flags` | 一个 GstMap 标志 |

    **返回结果**

    如果映射操作成功，则为 TRUE。
- **gst\_ml\_frame\_unmap**： 
    解除之前使用 gst\_ml\_frame\_map()映射的内存的映射。

    **原型**

        void
        gst_ml_frame_unmap (GstMLFrame * frame)Copy to clipboard

    **参数**

| [in] | `frame` | 指向 GstMLFrame 的指针 |
    | :--- | :--- | :--- |

    **返回结果**

    无

## GstMLBufferPool

使用 GstMLBufferPool API 配置以下内容：

- 张量特定要求，例如单个 [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) 中的多个 [GstMemory](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmemory.html?gi-language=c) 块
    用于分配的内存类型。
- 将 GstMLTensorMeta 添加到缓存。

Figure : ML 的 GstBufferPool 子类
                
                <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

<!-- Generated by Microsoft Visio, SVG Export gstbufferpool_subclass_ML.svg Layer_1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="10.625in" height="5.625in" viewbox="0 0 765 405" xml:space="preserve" color-interpolation-filters="sRGB" class="st12"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-1 .st1 { fill: #fafafa; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st2 { fill: #d2d7e1; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st3 { fill: #000000; font-family: Roboto; font-size: 1.00001em; font-weight: bold }
.svg-1 .st4 { fill: none; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st5 { fill: #000000; font-family: Symbol; font-size: 1.00001em; letter-spacing: -0.00833327em }
.svg-1 .st6 { font-size: 1em }
.svg-1 .st7 { font-family: Roboto; font-size: 1em }
.svg-1 .st8 { stroke: #b3b7bf; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st9 { fill: #000000; font-family: Symbol; font-size: 1.00001em }
.svg-1 .st10 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st11 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st12 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Layer_1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape2-1" v:mid="2" v:groupcontext="shape" transform="translate(0.374931,-0.375004)">		<title>Sheet.2</title>		<path d="M0 399.37 A5.62513 5.62513 -180 0 0 5.62 405 L758.63 405 A5.62513 5.62513 -180 0 0 764.25 399.37 L764.25 6.37					 A5.62513 5.62513 -180 0 0 758.63 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 -0 6.37 L0 399.37 Z" class="st1"></path>	</g>	<g id="shape3-3" v:mid="3" v:groupcontext="shape" transform="translate(2.28882E-05,-3.77341E-06)">		<title>Sheet.3</title>		<path d="M759 0.75 C761.89 0.75 764.25 3.11 764.25 6 L764.25 399 C764.25 401.89 761.89 404.25 759 404.25 L6 404.25 C3.11					 404.25 0.75 401.89 0.75 399 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L759 0.75 ZM759 0 L6 0 C2.69 0 0 2.69 0					 6 L0 399 C0 402.31 2.69 405 6 405 L759 405 C762.31 405 765 402.31 765 399 L765 6 C765 2.69 762.31 0 759					 0 Z" class="st2"></path>	</g>	<g id="shape5-5" v:mid="5" v:groupcontext="shape" transform="translate(10.8631,-243.75)">		<title>Sheet.5</title>		<desc>GstMLBufferPool</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="106.713" cy="330" width="213.43" height="150"></v:textrect>		<path d="M0 402 A3.00007 3.00007 -180 0 0 3 405 L210.43 405 A3.00007 3.00007 -180 0 0 213.43 402 L213.43 258 A3.00007					 3.00007 -180 0 0 210.43 255 L3 255 A3.00007 3.00007 -180 0 0 0 258 L0 402 Z" class="st2"></path>		<text x="59.84" y="274.8" class="st3" v:langid="1033"><v:paragraph v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstMLBufferPool</text>		</g>	<g id="shape7-8" v:mid="7" v:groupcontext="shape" transform="translate(22.1131,-243)">		<title>Sheet.7</title>		<desc>parent: GstBufferPool priv: GstImageBufferPoolPrivate *</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="101.443" cy="349.965" width="202.89" height="110.069"></v:textrect>		<rect x="0" y="294.931" width="202.887" height="110.069" class="st4"></rect>		<text x="0" y="305.87" class="st5" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">parent: GstBufferPool<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">priv: GstImageBufferPoolPrivate *</tspan></text>		</g>	<g id="shape8-15" v:mid="8" v:groupcontext="shape" transform="translate(10.8631,-363.784)">		<title>Sheet.8</title>		<path d="M0 405 L213.43 405" class="st8"></path>	</g>	<g id="shape9-18" v:mid="9" v:groupcontext="shape" transform="translate(260.803,-243.75)">		<title>Sheet.9</title>		<desc>GstBufferPool</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="121.713" cy="330" width="243.43" height="150"></v:textrect>		<path d="M0 402 A3.00007 3.00007 -180 0 0 3 405 L240.43 405 A3.00007 3.00007 -180 0 0 243.43 402 L243.43 258 A3.00007					 3.00007 -180 0 0 240.43 255 L3 255 A3.00007 3.00007 -180 0 0 -0 258 L0 402 Z" class="st2"></path>		<text x="83.35" y="274.8" class="st3" v:langid="1033"><v:paragraph v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstBufferPool</text>		</g>	<g id="shape11-21" v:mid="11" v:groupcontext="shape" transform="translate(272.053,-243)">		<title>Sheet.11</title>		<desc>object: GstObject flushing: gint priv: GstBufferPoolPrivate *...</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="115.973" cy="349.965" width="231.95" height="110.069"></v:textrect>		<rect x="0" y="294.931" width="231.947" height="110.069" class="st4"></rect>		<text x="0" y="305.87" class="st9" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">object: GstObject<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">flushing: gint<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">priv: GstBufferPoolPrivate *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">started: gboolean<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">_gst_reserved: gpointer[GST_PADDING]</tspan></text>		</g>	<g id="shape12-34" v:mid="12" v:groupcontext="shape" transform="translate(260.803,-363.784)">		<title>Sheet.12</title>		<path d="M0 405 L243.43 405" class="st8"></path>	</g>	<g id="shape13-37" v:mid="13" v:groupcontext="shape" transform="translate(540.712,-243.75)">		<title>Sheet.13</title>		<desc>GstBuffer</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="106.713" cy="330" width="213.43" height="150"></v:textrect>		<path d="M0 402 A3.00007 3.00007 -180 0 0 3 405 L210.43 405 A3.00007 3.00007 -180 0 0 213.43 402 L213.43 258 A3.00007					 3.00007 -180 0 0 210.43 255 L3 255 A3.00007 3.00007 -180 0 0 0 258 L0 402 Z" class="st2"></path>		<text x="80.59" y="274.8" class="st3" v:langid="1033"><v:paragraph v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstBuffer</text>		</g>	<g id="shape15-40" v:mid="15" v:groupcontext="shape" transform="translate(551.962,-243)">		<title>Sheet.15</title>		<desc>mini_object: GstMiniObject pool: GstBufferPool * pts: GstCloc...</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="102.019" cy="349.965" width="204.04" height="110.069"></v:textrect>		<rect x="0" y="294.931" width="204.038" height="110.069" class="st4"></rect>		<text x="0" y="305.87" class="st9" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">mini_object: GstMiniObject<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">pool: GstBufferPool *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">pts: GstClockTime<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">dts: GstClockTime<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">duration: GstClockTime<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">offset: guint64<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">offset_end: guint64</tspan></text>		</g>	<g id="shape16-57" v:mid="16" v:groupcontext="shape" transform="translate(540.712,-363.784)">		<title>Sheet.16</title>		<path d="M0 405 L213.43 405" class="st8"></path>	</g>	<g id="shape17-60" v:mid="17" v:groupcontext="shape" transform="translate(10.8631,-11.25)">		<title>Sheet.17</title>		<desc>GstImageBufferPoolPrivate</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="106.713" cy="307.007" width="213.43" height="195.985"></v:textrect>		<path d="M-0 402 A3.00007 3.00007 -180 0 0 3 405 L210.43 405 A3.00007 3.00007 -180 0 0 213.43 402 L213.43 212.01 A3.00007					 3.00007 -180 0 0 210.43 209.01 L3 209.01 A3.00007 3.00007 -180 0 0 -0 212.01 L0 402 Z" class="st2"></path>		<text x="32.35" y="228.81" class="st3" v:langid="1033"><v:paragraph v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstImageBufferPoolPrivate</text>		</g>	<g id="shape19-63" v:mid="19" v:groupcontext="shape" transform="translate(22.1131,-9)">		<title>Sheet.19</title>		<desc>memtype: Gquark allocator: GstAllocator params: GstAllocation...</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="101.443" cy="326.223" width="202.89" height="157.554"></v:textrect>		<rect x="0" y="247.446" width="202.887" height="157.554" class="st4"></rect>		<text x="0" y="258.38" class="st9" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">memtype: Gquark<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">allocator: GstAllocator<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">params: GstAllocationParams<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">info: GstMLInfo<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">addmeta: gboolean<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">continuous: gboolean<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">devid: gint</tspan></text>		</g>	<g id="shape20-80" v:mid="20" v:groupcontext="shape" transform="translate(10.8631,-177.27)">		<title>Sheet.20</title>		<path d="M0 405 L213.43 405" class="st8"></path>	</g>	<g id="shape21-83" v:mid="21" v:groupcontext="shape" transform="translate(260.803,-11.25)">		<title>Sheet.21</title>		<desc>GstBufferPoolPrivate</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="121.713" cy="307.007" width="243.43" height="195.985"></v:textrect>		<path d="M0 402 A3.00007 3.00007 -180 0 0 3 405 L240.43 405 A3.00007 3.00007 -180 0 0 243.43 402 L243.43 212.01 A3.00007					 3.00007 -180 0 0 240.43 209.01 L3 209.01 A3.00007 3.00007 -180 0 0 -0 212.01 L0 402 Z" class="st2"></path>		<text x="64.18" y="228.81" class="st3" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="14.4" v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstBufferPoolPrivate</text>		</g>	<g id="shape23-86" v:mid="23" v:groupcontext="shape" transform="translate(272.053,-9)">		<title>Sheet.23</title>		<desc>queue: GstAtomicQueue poll: GstPoll * rec_lock: GRecMutex max...</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="115.973" cy="326.223" width="231.95" height="157.554"></v:textrect>		<rect x="0" y="247.446" width="231.947" height="157.554" class="st4"></rect>		<text x="0" y="258.38" class="st9" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">queue: GstAtomicQueue<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">poll: GstPoll *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">rec_lock: GRecMutex<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">maxsize: gsize<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">started: gboolean<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">active: gboolean<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">min_buffers: guint<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">cur_buffers: guint<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">allocator: GstAllocator *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">params: GstAllocationParams</tspan></text>		</g>	<g id="shape24-109" v:mid="24" v:groupcontext="shape" transform="translate(260.803,-177.27)">		<title>Sheet.24</title>		<path d="M0 405 L243.43 405" class="st8"></path>	</g>	<g id="shape25-112" v:mid="25" v:groupcontext="shape" transform="translate(540.712,-11.25)">		<title>Sheet.25</title>		<desc>GstMemory</desc>		<v:textblock v:margins="rect(7.2,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="106.713" cy="307.007" width="213.43" height="195.985"></v:textrect>		<path d="M-0 402 A3.00007 3.00007 -180 0 0 3 405 L210.43 405 A3.00007 3.00007 -180 0 0 213.43 402 L213.43 212.01 A3.00007					 3.00007 -180 0 0 210.43 209.01 L3 209.01 A3.00007 3.00007 -180 0 0 -0 212.01 L0 402 Z" class="st2"></path>		<text x="75.23" y="228.81" class="st3" v:langid="1033"><v:paragraph v:spline="-1.4" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>GstMemory</text>		</g>	<g id="shape27-115" v:mid="27" v:groupcontext="shape" transform="translate(551.962,-9)">		<title>Sheet.27</title>		<desc>mini_object: GstMiniObject allocator: GstAllocator * parent: ...</desc>		<v:textblock v:margins="rect(0,0,0,0)" v:verticalalign="0"></v:textblock>		<v:textrect cx="102.019" cy="326.223" width="204.04" height="157.554"></v:textrect>		<rect x="0" y="247.446" width="204.038" height="157.554" class="st4"></rect>		<text x="0" y="258.38" class="st9" v:langid="1033"><v:paragraph v:indentfirst="-28.8" v:indentleft="18" v:bullet="1"></v:paragraph><v:tablist></v:tablist><tspan class="st6" v:isbullet="true">·</tspan> <tspan class="st7">mini_object: GstMiniObject<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">allocator: GstAllocator *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">parent: GstMemory *<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">maxsize: gsize<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">align: gsize<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">offset: gsize<v:newlinechar></v:newlinechar></tspan><tspan x="0" dy="1.215em" class="st6" v:isbullet="true">·</tspan> <tspan class="st7">size: gsize</tspan></text>		</g>	<g id="shape28-132" v:mid="28" v:groupcontext="shape" transform="translate(540.712,-177.27)">		<title>Sheet.28</title>		<path d="M0 405 L213.43 405" class="st8"></path>	</g>	<g id="shape30-135" v:mid="30" v:groupcontext="shape" transform="translate(528.363,161.25) rotate(90)">		<title>Sheet.30</title>		<path d="M0 405 L30.42 405" class="st10"></path>	</g>	<g id="shape31-138" v:mid="31" v:groupcontext="shape" transform="translate(120.371,-209.021)">		<title>Sheet.31</title>		<path d="M0 399.82 L2.99 405 L5.98 399.82 L0 399.82 Z" class="st11"></path>	</g>	<g id="shape33-140" v:mid="33" v:groupcontext="shape" transform="translate(793.303,161.25) rotate(90)">		<title>Sheet.33</title>		<path d="M0 405 L30.42 405" class="st10"></path>	</g>	<g id="shape34-143" v:mid="34" v:groupcontext="shape" transform="translate(385.311,-209.021)">		<title>Sheet.34</title>		<path d="M0 399.82 L2.99 405 L5.98 399.82 L0 399.82 Z" class="st11"></path>	</g>	<g id="shape36-145" v:mid="36" v:groupcontext="shape" transform="translate(259.017,491.25) rotate(180)">		<title>Sheet.36</title>		<path d="M0 405 L30.42 405" class="st10"></path>	</g>	<g id="shape37-148" v:mid="37" v:groupcontext="shape" transform="translate(224.288,-315.758)">		<title>Sheet.37</title>		<path d="M5.18 399.02 L0 402.01 L5.18 405 L5.18 399.02 Z" class="st11"></path>	</g>	<g id="shape39-150" v:mid="39" v:groupcontext="shape" transform="translate(539.834,491.25) rotate(180)">		<title>Sheet.39</title>		<path d="M0 405 L30.42 405" class="st10"></path>	</g>	<g id="shape40-153" v:mid="40" v:groupcontext="shape" transform="translate(505.105,-315.758)">		<title>Sheet.40</title>		<path d="M5.18 399.02 L0 402.01 L5.18 405 L5.18 399.02 Z" class="st11"></path>	</g></g>
</svg>

- **原型**
    创建一个可以分配 ML 帧的缓存池。

        GstBufferPool *
        gst_ml_buffer_pool_new (const gchar * type)
        Copy to clipboard
- **参数**

| [in] | `type` | 该池分配缓存所用的内存。 |
    | :--- | :--- | :--- |
- **返回结果**
    - 用于分配 ML 帧新的 [GstBufferPool](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbufferpool.html?gi-language=c)。
    - [通过 gst_object_unref](https://gstreamer.freedesktop.org/documentation/gstreamer/gstobject.html#gst_object_unref) 释放。
- **参数**

下表列出了可传递给 gst\_ml\_buffer\_pool\_new() 以配置缓存内存的参数：

    | 参数 | 说明 | 用法 |
    | --- | --- | --- |
    | GST\_ML\_BUFFER\_POOL\_TYPE\_ION | 通过将缓存作为参数传递给 gst\_ml\_buffer\_pool\_new()来分配缓存 | #define GST_ML_BUFFER_POOL_TYPE_ION "GstMLBufferPoolTypeIonMemory"Copy to clipboard |
    | GST\_ML\_BUFFER\_POOL\_TYPE\_SYSTEM | 通过将缓存作为参数传递给 gst\_ml\_buffer\_pool\_new()来分配缓存 | #define GST_ML_BUFFER_POOL_TYPE_SYSTEM "GstMLBufferPoolTypeSystemMemory"Copy to clipboard |
    | GST\_ML\_BUFFER\_POOL\_OPTION\_TENSOR\_META | 从池中请求缓存上的 ML 张量元数据。 | #define GST_ML_BUFFER_POOL_OPTION_TENSOR_META "GstMLBufferPoolOptionTensorMeta"Copy to clipboard |
    | GST\_ML\_BUFFER\_POOL\_OPTION\_CONTINUOUS | 请求所有张量都进入连续的物理存储器。 | #define GST_ML_BUFFER_POOL_OPTION_CONTINUOUS "GstMLBufferPoolOptionContinuous"Copy to clipboard |
    |  |  |  |

**Parent Topic:** [GSt API](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gst-apis.html)

Last Published: Nov 05, 2025

[Previous Topic
视频 API](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/video-apis.md) [Next Topic
GSt 调试](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/imsdk_debug_gst.md)