Reg. Need your valuable guidance

Nicolas Dufresne nicolas at ndufresne.ca
Thu Feb 16 17:10:08 UTC 2023


Le jeudi 16 février 2023 à 22:33 +0530, Gaurav Mahajan a écrit :
> Hi Nicolas,
> 
> Instead of configuring like below
> gst_query_add_allocation_pool (query, NULL, <raw-image-size>, 5, 0);
> 
> If I do like this, to make min and Max buffer as 5. (currently max buffers are
> 32)
> gst_query_add_allocation_pool (query, NULL, <raw-image-size>, 5, 5);

I don't remember if the max will be honored or just bumped.

> 
> Does this mean, decoder will have max 5 mmap buffer and will stop decoding and
> wait till any one of the 5 mmap buffer is unrefed?
> Is my understanding correct?
> 
> Also when you say  <raw-image-size> , what do you mean, W*H or W*Padded
> height,
> because when propose_allocation gets called padded_height is not known.

If you have not specific requirement, just use gst_video_info_from_caps() and
use the calculated size. Its just a hint anyway.

> 
> Thanks & Regards
> Gaurav Mahajan 
> 
> 
> On Thu, Feb 16, 2023, 22:05 Nicolas Dufresne <nicolas at ndufresne.ca> wrote:
> > 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:allocat
> > > or> 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:poo
> > > l0:src> 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/200aafd8/attachment-0001.htm>


More information about the gstreamer-devel mailing list