# Steps to create `srnet` module

Source: [https://docs.qualcomm.com/doc/80-70015-15B/topic/steps-to-create-srnet-module.html](https://docs.qualcomm.com/doc/80-70015-15B/topic/steps-to-create-srnet-module.html)

1. Create module header
                    “gst-plugins-qti-oss/gst-plugin-base/gst/ml/ml-module-video-super-resolution.h”
    - Reference from existing plugin: [gst-plugin-base/gst/ml/ml-module-video-super-resolution.h ·
                            imsdk.lnx.2.0.0.r2-rel · CodeLinaro / le / platform / vendor /
                            qcom-opensource / gst-plugins-qti-oss · GitLab](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-plugin-base/gst/ml/ml-module-video-super-resolution.h?ref_type=heads)
    - Import required gst headers
    - Create

            GST_API gboolean gst_ml_module_video_super_resolution_execute (GstMLModule * module,
                                                                           GstMLFrame * mlframe,
                                                                           GstVideoFrame * vframe);Copy to clipboard

        - This function is required to call post-processing function
                                (gst\_ml\_module\_process) which will be defined in
                                ml-vsuperresolution-&lt;module-name&gt;.c
2. Create module
                    "gst-plugins-mlvsuperresolution/modules/ml-vsuperresolution-srnet.c"
    - Reference from existing plugin: [gst-plugin-mlvsegmentation/modules/ml-vsegmentation-deeplab-argmax.c ·
                            imsdk.lnx.2.0.0.r1-rel · CodeLinaro / le / platform / vendor /
                            qcom-opensource / gst-plugins-qti-oss · GitLab](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r1-rel/gst-plugin-mlvsegmentation/modules/ml-vsegmentation-deeplab-argmax.c?ref_type=heads)

    - Import "modules/ml-video-superresolution-module.h" header
    - Define model output caps

            #define GST_ML_MODULE_CAPS \
                "neural-network/tensors, " \
                "type = (string) { INT8, UINT8, INT32, FLOAT32 }, " \
                "dimensions = (int) < <1, [32, 4096], [32, 4096]> >; " \
                "neural-network/tensors, " \
                "type = (string) { INT8, UINT8, INT32, FLOAT32 }, " \
                "dimensions = (int) < <1, [32, 4096], [32, 4096], [1, 3]> >"Copy to clipboard

        **For                                Example**

        - Download [QuickSRNetLarge-Quantized-
                                    Qualcomm AI Hub](https://aihub.qualcomm.com/iot/models/quicksrnetlarge_quantized) model from AI Hub
        - Check output dimensions of the TFLite model (Refer to [Integrate AI Hub models in an application](https://docs.qualcomm.com/doc/80-70015-15B/topic/integrate-aihub-model.html))
            - Format: dtype[N x H X W X C]

        - In the above module output caps &lt;1, [32, 4096], [32, 4096], [1,
                                    3]&gt;
            - N = 1 -&gt; Model Output Batch size
            - H = [32,4096] -&gt; Model Output Height should be in this
                                        range
            - W= [32,4096] -&gt; Model Output Width should be in this
                                        range
            - C = [1,3] -&gt; Model Output Channels should be in this
                                        range
            - dtype = int8 for quantized models | float32 for
                                        non-quantized models

        - For Quantized models, Check output node for scale and offset
            - Format: scale\*(q-offset)
    - Implement following functions
        - Init
            - `gpointer gst_ml_module_open (void);`

        - De-init
            - `void gst_ml_module_close (gpointer
                                            instance);`

        - Caps
            - `GstCaps *gst_ml_module_caps (void);`

        - Configure
            - `gboolean gst_ml_module_configure (gpointer instance,
                                            GstStructure * settings);`
                - Check for module dtype, scale, and offset

        - De-quantize

                gdouble gst_ml_tensor_extract_value (GstMLType mltype, 
                                                     gpointer data, 
                                                     guint idx,
                                                     gdouble offset, 
                                                     gdouble scale)Copy to clipboard

            - Scale and offset values need to passed for quantized
                                        models

        - Post-process
            - `gboolean gst_ml_module_process (gpointer instance,
                                                GstMLFrame*mlframe, gpointer
                                                output);`
        - Inferenced buffer

            - `indata = GST_ML_FRAME_BLOCK_DATA (mlframe,
                                            0);`

            Output buffer to be filled with post-processed data

            - `outdata = GST_VIDEO_FRAME_PLANE_DATA (vframe,
                                            0);`

            Data type of model

            - `mltype = GST_ML_FRAME_TYPE (mlframe);`

            Post-process (for super resolution)

                  for (row = 0; row < GST_VIDEO_FRAME_HEIGHT (vframe); row++) {
                    for (column = 0; column < GST_VIDEO_FRAME_WIDTH (vframe); column++) {
                      // Calculate the destination index.
                      idx = (((row * GST_VIDEO_FRAME_WIDTH (vframe)) + column) * bpp) +
                          (row * padding);
                
                      outdata[idx] = gst_ml_tensor_extract_value (mltype, indata, idx,
                            submodule->qoffsets[0], submodule->qscales[0]);
                      outdata[idx + 1] = gst_ml_tensor_extract_value (mltype, indata, (idx + 1),
                            submodule->qoffsets[0], submodule->qscales[0]);
                      outdata[idx + 2] = gst_ml_tensor_extract_value (mltype, indata, (idx + 2),
                            submodule->qoffsets[0], submodule->qscales[0]);
                
                      // If output has an alpha channel set it to opaque.
                      if (bpp == 4)
                        outdata[idx + 3] = 0xFF;
                    }
                  }Copy to clipboard

    - Update module name
                            "gst-plugins-mlvsuperresolution/modules/CMakeLists.txt"
        - Reference from existing plugin: [gst-plugin-mlvsegmentation/modules/CMakeLists.txt ·
                                    imsdk.lnx.2.0.0.r1-rel · CodeLinaro / le / platform / vendor /
                                    qcom-opensource / gst-plugins-qti-oss · GitLab](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r1-rel/gst-plugin-mlvsegmentation/modules/CMakeLists.txt?ref_type=heads)

Last Published: Jan 21, 2026

[Previous Topic
Overview of Module](https://docs.qualcomm.com/bundle/publicresource/80-70015-15B/topics/overview-of-module.md) [Next Topic
Steps to update BitBake files for plugin compilation](https://docs.qualcomm.com/bundle/publicresource/80-70015-15B/topics/steps-to-update-bitbake-for-compilation.md)