Reg. Need your valuable guidance
Nicolas Dufresne
nicolas at ndufresne.ca
Thu Feb 16 16:35:47 UTC 2023
Hi,
I add edthe gstreamer-devel mailing is as this is of public interest.
Le jeudi 16 février 2023 à 20:37 +0530, Gaurav Mahajan a écrit :
> Hi Nicolas,
>
> Thank you for your input. It is really helpful and I am able to proceed
> further.
> Now I am facing the following issue.
>
> I have the following pipeline in my case.
> appsrc ! h264parse ! v4l2h264dec ! customvideosink
>
> customvideosink : This will provide the GstBuffer received in show_frame
> callback to application for rendering purposes.
>
> So, from following logs, it can be concluded that v4l2h264dec is allocating 5
> mamp buffers for the capture system.
>
> ---
> v4l2 gstv4l2object.c:3106:gst_v4l2_object_setup_pool:<decoder:src>
> initializing the capture system
> v4l2 gstv4l2object.c:3138:gst_v4l2_object_setup_pool:<decoder:src> accessing
> buffers via mode 4
> v4l2allocator
> gstv4l2allocator.c:706:gst_v4l2_allocator_start:<decoder:pool0:src:allocator>
> allocated 5 mmap buffers out of 5 requested
> ---
>
> So, I am getting GstBuffer for these respective mmap buffers in my
> customvideosink, when I emit these 5 buffers to application
> and application is still processing them,
> I can see that v4l2h264dec is decoding next frames, and as original allocated
> buffers are already in use.
> It is not getting any buffer for reuse and allocating new buffers.
>
> ---
> v4l2bufferpool
> gstv4l2bufferpool.c:2017:gst_v4l2_buffer_pool_process:<decoder:pool0:src> Only
> 0 buffer left in the capture queue.
> v4l2bufferpool
> gstv4l2bufferpool.c:656:gst_v4l2_buffer_pool_resurrect_buffer:<decoder:pool0:s
> rc> A buffer was lost, reallocating it
> ---
>
> But as per my application we have allocated memory based on initial 5 buffers
> and this midway new allocation for new buffer is not possible.
>
> So, I would like to know
> 1. How can I control the decoder if my original allocated buffers are in use
> by application and unavailable for reuse?
Your customsink should implement GstBaseSink::propose_allocation() virtual
method, and minimally announce how many buffers you will be holding on. This is
added to the query as following:
gst_query_add_allocation_pool (query, NULL, <raw-image-size>, 5, 0);
> 2. Is there any way to control input feed to decoder like give 5 input buffers
> to decode and get 5 capture buffers, process them
> and then provide next 5 input buffers?
The decoder manages a DPB which imply some rules regarding how to output frames.
In order to output 5 frames for you to analyze offline, you may need to allocate
up to 21 buffers (16 being the maximum DPB size). But as long as you annonce
your 5 frames requirement, you can do that yes. Usually we add some more to
ensure the HW decoder can run concurrently, but 5 more is starting to be a lot,
and I suspect throughput is your ultimate goal.
> 3. Is there any part of the code in gstreamer v4l2 from where I can post some
> messages to achieve the above.
> If it is possible then I would like to give it a try.
There is no messages (GstMessage) related to buffer allocation. This is handled
through the allocation query between GStreamer elements. Applications are in
general not involved in this process.
>
> I have tried some things with appsrc properties like max-buffers but not
> helpful.
>
> I look forward to hearing from you.
>
> Thanks and Regards,
> Gaurav Mahajan
> M : <phone number removed>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230216/8c4f5f2e/attachment.htm>
More information about the gstreamer-devel
mailing list