# Steps to create `superresolution` plugin

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

1. Create plugin header "gst-plugins-mlvsuperresolution/mlvsuperresolution.h"
    - Reference from existing plugin: [gst-plugin-mlvsegmentation/mlvsegmentation.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-mlvsegmentation/mlvsegmentation.h?ref_type=heads)
    - Import required headers
    - Create a structure with data variables required for processing
        Example
                            for super resolution - Inheritance chain: GObject → GstObject →
                            GstElement → GstBaseTransform - GstBaseTransform is suitable for
                            elements where the output size and capabilities are entirely determined
                            by the input size and
                                capabilities

            struct _GstMLVideoSuperresolution {
                                  GstBaseTransform  parent;
                                  GstMLInfo          *mlinfo;
                                  GstVideoInfo      *vinfo;
                                  GstBufferPool     *outpool;
                                  GstMLModule    *module;
                                  gint                       mdlenum;
                                  GstStructure       *mlconstants;
            };
                      
            struct _GstMLVideoSuperresolutionClass {
                                  GstBaseTransformClass parent;
            };Copy to clipboard

        **Note:** The labels variable is not required
                            for superresolution. Make sure to remove the labels variable and its
                            usage in code.
2. Create plugin "gst-plugins-mlvsuperresolution/mlvsuperresolution.c"
    - Reference from existing plugin: [gst-plugin-mlvsegmentation/mlvsegmentation.c · 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-mlvsegmentation/mlvsegmentation.c?ref_type=heads)
    - Import mlvsuperresolution.h and other required headers
    - Define caps
        - video
                                formats

                #define GST_ML_VIDEO_SUPERRESOLUTION_VIDEO_FORMATS "{ RGBA,BGRA, ARGB, ABGR, RGBx, BGRx, xRGB, xBGR, RGB, BGR }"Copy to clipboard
        - src
                                caps

                #define GST_ML_VIDEO_SUPER_RESOLUTION_SRC_CAPS                            \
                    "video/x-raw, "                                                       \
                    "format = (string) " GST_ML_VIDEO_SUPER_RESOLUTION_VIDEO_FORMATS "; " \
                    "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GBM "), "                      \
                    "format = (string) " GST_ML_VIDEO_SUPER_RESOLUTION_VIDEO_FORMATSCopy to clipboard
        - sink
                                caps

                #define GST_ML_VIDEO_SUPER_RESOLUTION_SINK_CAPS \
                        "neural-network/tensors"Copy to clipboard
    - Implement following functions
        - Init

                static gboolean plugin_init(GstPlugin * plugin);Copy to clipboard

            - To register custom plugin, once registered we can access
                                        plugin in reference apps with
                                        gst\_element\_factory\_make("plugin-name","plugin-name");

                static void gst_ml_video_super_resolution_init (GstMLVideoSuperResolution * super_resolution)            Copy to clipboard

            - Initializes superresolution with default parameters, allows
                                        to control output buffers. On receiving an input buffer,
                                        gst\_ml\_video\_super\_resolution\_prepare\_output\_buffer will be
                                        called to allocate output buffer.

                static void gst_ml_video_super_resolution_class_init (GstMLVideoSuperResolutionClass * klass)Copy to clipboard

            - Initializes callback functions to function pointer, set caps
                                        and default properties
        - Buffer
                                    management

                static GstBufferPool * gst_ml_video_super_resolution_create_pool (GstMLVideoSuperResolution * super_resolution, 
                                                                                  GstCaps * caps)Copy to clipboard

            - Allocates either GBM(Graphics Buffer Manager) or ION
                                            Memory depending on negotiated caps

                gst_ml_video_super_resolution_decide_allocation (GstBaseTransform * base, GstQuery * query)Copy to clipboard

            - Ensures appropriate buffer pool configuration based on the
                                        caps.

                static GstFlowReturn gst_ml_video_super_resolution_prepare_output_buffer (GstBaseTransform * base,
                                                                                          GstBuffer * inbuffer, 
                                                                                          GstBuffer ** outbuffer)Copy to clipboard

            - Ensures output buffers is allocated from pool depending on
                                        caps
        - Caps

                static gboolean gst_ml_video_super_resolution_set_caps (GstBaseTransform * base, 
                                                                        GstCaps * incaps,
                                                                        GstCaps * outcaps)Copy to clipboard

            - First, the module is validated, and then the inputs and
                                        output capabilities are collected from module caps.

                static GstCaps * gst_ml_video_super_resolution_fixate_caps (GstBaseTransform * base,
                                                                            GstPadDirection direction, 
                                                                            GstCaps * incaps, 
                                                                            GstCaps * outcaps)Copy to clipboard

            - Negotiated caps are fixed

                static gboolean caps_has_feature (const GstCaps * caps, 
                                                  const gchar * feature)Copy to clipboard

            - Checks whether specified caps are valid or not like
                                        video/x-raw, video/x-text, format, height and width

                static GstCaps * gst_ml_video_super_resolution_src_caps (void)Copy to clipboard

            - Convert static caps to regular caps

                static GstCaps * gst_ml_video_super_resolution_sink_caps (void)Copy to clipboard

            - Convert static caps to regular caps
        - Transform

                static GstCaps * gst_ml_video_super_resolution_transform_caps (GstBaseTransform * base,
                                                                               GstPadDirection direction, 
                                                                               GstCaps * caps, 
                                                                               GstCaps * filter)Copy to clipboard

            - Transform sink caps to source caps and vice-versa

                gst_ml_video_super_resolution_transform (GstBaseTransform * base,
                                                         GstBuffer * inbuffer, 
                                                         GstBuffer * outbuffer)Copy to clipboard

            - After inference, postprocessing function
                                        gst\_ml\_video\_superresolution\_module\_execute will be called
                                        based on module.
        - Property

                static void gst_ml_video_super_resolution_set_property (GObject * object, 
                                                                        guint prop_id, 
                                                                        const GValue * value,  
                                                                        GParamSpec * pspec)Copy to clipboard

            - To set plugin properties like module and constant

                static void gst_ml_video_super_resolution_get_property (GObject * object, 
                                                                        guint prop_id, 
                                                                        GValue * value, 
                                                                        GParamSpec * pspec)Copy to clipboard

            - To read plugin properties like module and constant
        - De-init

                static void gst_ml_video_super_resolution_finalize (GObject * object)Copy to clipboard

            - Free all allocated buffers
        - Display text/bounding boxes (based on use case only, not required
                                for super
                                    resolution)

                static gboolean gst_ml_video_<plugin-name>_fill_video_output(GstMLVideoDetection * detection, GArray * predictions, GstBuffer * buffer);Copy to clipboard

            - To overlay result on output frame
        - Update plugin name in
                                    "gst-plugins-mlvsuperresolution/CMakeLists.txt"
            - Reference from existing plugin: [gst-plugin-mlvsegmentation/CMakeLists.txt ·
                                            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-mlvsegmentation/CMakeLists.txt?ref_type=heads)
            - Reuse config.h.in from [gst-plugin-mlvsegmentation/config.h.in ·
                                            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-mlvsegmentation/config.h.in?ref_type=heads)

Last Published: Jan 21, 2026

[Previous Topic
Plugin Directory Structure](https://docs.qualcomm.com/bundle/publicresource/80-70015-15B/topics/plugin-directory-structure.md) [Next Topic
Overview of Module](https://docs.qualcomm.com/bundle/publicresource/80-70015-15B/topics/overview-of-module.md)