Pre_process() function in nvivafilter questions

I use nvivafilter to access the NVMM buffers. There are something in the pre_process() function that I don’t understand.
My image format is NV12. How do NV12 is store in the buffer? How do a make a pixel black?
Is there any documentations that you recommend? (I’m a newbie to this stuff)
Thank you.

Please refer to the README:

2. Image processing APIs
    a. Pre-/Post- processing
        i. input parameters:
            void ** sBaseAddr       : mapped pointers array point to different
                                      plane of image.

            unsigned int * smemsize : actually allocated memory size array for
                                      each image plane, no less than plane
                                      width * height.

            unsigned int * swidth   : width array for each image plane

            unsigned int * sheight  : height array for each image plane

            unsigned int * spitch   : actual line width array in memory for
                                      each image plane, no less than plane

            ColorFormat * sformat   : color format array, i.e.,
                                      * NV12 image will have:
                                      sformat[0] = COLOR_FORMAT_Y8
                                      sformat[1] = COLOR_FORMAT_U8_V8
                                      * RGBA image will have:
                                      sformat[0] = COLOR_FORMAT_RGBA

            unsigned int nsurfcount : number of planes of current image type

            void ** userPtr         : point to customer allocated buffer in
                                      processing function

        ii. output parameters:

Is there any tool to convert a .png file to RGBA format array?

You would need to decode png through software decoder and then convert to RGBA. May try gstreamer pipeline like:
Problem with opening png sequence by gstreamer and nvvidconv - #2 by DaneLLL

Is possible to pass arguments from gstreamer pipeline to pre_process() function?
I put my pre_process() function below. I noticed that if the pipeline was left running for about 15 minutes, the jetson became very slow. Can you recommend what I should do to speed up the code? Thanks

static void
pre_process (void **sBaseAddr,
                unsigned int *smemsize,
                unsigned int *swidth,
                unsigned int *sheight,
                unsigned int *spitch,
                ColorFormat  *sformat,
                unsigned int nsurfcount,
                void ** usrptr)
  if (sformat[0] == COLOR_FORMAT_RGBA) {
    cairo_surface_t *surface, *mask_surface;
    cairo_t *cairo_context;

    surface = cairo_image_surface_create_for_data
            ((unsigned char *)sBaseAddr[0], CAIRO_FORMAT_ARGB32, swidth[0],
             sheight[0], spitch[0]);
    cairo_context = cairo_create (surface);

    mask_surface = cairo_image_surface_create_from_png("Square_Mask_v2p00.png");
    cairo_set_source_surface(cairo_context, mask_surface, 0.0, 0.0);

    cairo_destroy (cairo_context);
    cairo_surface_destroy (surface);

Please run $ sudo nvpmodel -m 0 and $ sudo jetson_clocks to run CPU cores at maximum clock. This shall bring optimal perofrmance.

And please run $ sudo jetson_clocks to check system status. Probably the system has hit thermal condition and gets slow.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.