# Steps to create `srnet` module

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

1. Create module header
                "gst-plugins-mlvsuperresolution/modules/ml-video-superresolution-module.h"
    - Reference from existing plugin: [gst-plugin-mlvsegmentation/modules/ml-video-segmentation-module.h ·
                            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-video-segmentation-module.h?ref_type=heads)
    - Import required gst headers
    - Create gst\_ml\_video\_ superresolution \_module\_execute (GstMLModule \* module,
                        GstMLFrame \* mlframe, GstVideoFrame \* vframe)
        - 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], [1, 3]> > "
            struct _GstMLSubModule {
                              GstMLInfo  mlinfo;
                              gdouble    qoffsets[GST_ML_MAX_TENSORS];
                              gdouble    qscales[GST_ML_MAX_TENSORS];
            };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 application](https://docs.qualcomm.com/doc/80-70014-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
            - `static inline gdouble
                                            gst_ml_module_get_dequant_value (void``
                                            *data, GstMLType mltype, guint idx, gdouble offset,
                                            gdouble scale);`
                - 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 `srnet`, we need to multiply output RGB
                                        pixels with
                                        255

                    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_module_get_dequant_value(indata, mltype, idx, submodule->qoffsets[0], submodule->qscales[0]) * 255;
                            outdata[idx + 1] = gst_ml_module_get_dequant_value(indata, mltype, idx + 1, submodule->qoffsets[0], submodule->qscales[0]) * 255;
                            outdata[idx + 2] = gst_ml_module_get_dequant_value(indata, mltype, idx + 2, submodule->qoffsets[0], submodule->qscales[0]) * 255;
                            if (bpp == 4)
                                outdata[idx + 3] = 0;
                        }
                    }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-70014-15B/topics/overview-of-module.md) [Next Topic
Steps to update BitBake files for plugin compilation](https://docs.qualcomm.com/bundle/publicresource/80-70014-15B/topics/steps-to-update-bitbake-for-compilation.md)