<div dir="auto"><div>Hi Pratik,<br><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Le mer. 11 juin 2025, 02 h 32, Pratik Pachange <<a href="mailto:ppachang@qti.qualcomm.com">ppachang@qti.qualcomm.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="m_4526923880893153397WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">In gstv4l2videoenc, gst_v4l2_video_enc_set_format(), S_FMT is called on CAPTURE port first and then later, on the OUTPUT port.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Initially, on capture port, the width and height values set using S_FMT call are ignored by the driver and it returns default values. (<a href="https://docs.kernel.org/userspace-api/media/v4l/dev-encoder.html#initialization" target="_blank" rel="noreferrer">https://docs.kernel.org/userspace-api/media/v4l/dev-encoder.html#initialization</a>)</span></p></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It's a very bad spec decision clearly, since it imply doing back and forth, doing useless ioctl. I'll have to check if we can change that, it's possible it miss-match with actual code.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div class="m_4526923880893153397WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Later, when S_FMT is called on output port, video driver internally reconfigures the capture port with the desired width and height and updates the sizeimage of the capture buffers</span></p></div></div></blockquote></div></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div class="m_4526923880893153397WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">But this updated sizeimage value is not updated in the Gstvideoinfo of v4l2object of capture side and the bufferpool created during decide_allocation remains with the older value.</span></p></div></div></blockquote></div></div><div dir="auto">This is not specced apparently. I pretty much dislike a flow that requires going backward.</div><div dir="auto"><br></div><div dir="auto">Originally, it's application task to guess the compressed buffer size. I'm pretty sure GStreamer simply assumed this size (2M or more, would have to check) will be used.</div><div dir="auto"><br></div><div dir="auto">In GStreamer itself, due to lack of spec, all I can do is increased/ improved the requested size image.</div><div dir="auto"><br></div><div dir="auto">Nicolas</div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div class="m_4526923880893153397WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">This is causing assertions when the encoded output is of bigger size than the gst buffers of v4l2bufferpool.<br>
<br>
<a href="https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4409" target="_blank" rel="noreferrer">https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4409</a><br>
<br>
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
1. sizeimage that we get from video driver<br>
<br>
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><img border="0" width="1707" height="433" style="width:17.7812in;height:4.5104in" id="m_4526923880893153397Picture_x0020_2" src="cid:ii_1975efec7af4cff311"></span><span style="font-size:11.0pt"><br>
<br>
<br>
2. The buffers allocated on capture queue are of bigger size.<br>
<br>
<img border="0" width="1674" height="396" style="width:17.4375in;height:4.125in" id="m_4526923880893153397Picture_x0020_4" src="cid:ii_1975efec7af5b16b22"><br>
<br>
<br>
3. Gst v4l2bufferpool is unaware of the change in size.<br>
<br>
<img border="0" width="2435" height="85" style="width:25.3645in;height:.8854in" id="m_4526923880893153397Picture_x0020_6" src="cid:ii_1975efec7af692e333"><br>
<br>
<br>
4. If the encoded output size is greater than the size of gstbuffer in v4l2bufferpool, there are assertion while trying to copy the buffers.<br>
<br>
<img border="0" width="1247" height="26" style="width:12.9895in;height:.2708in" id="m_4526923880893153397Picture_x0020_8" src="cid:ii_1975efec7af7745b44"><br>
<br>
<br>
<br>
<br>
<br>
How can we address this issue, because decide_allocation is completed before s_fmt is called on output queue.<br>
<br>
<br>
<br>
<br>
Thanks<br>
Pratik<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<u></u><u></u></span></p>
</div>
</div>

</blockquote></div></div></div>