<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></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">https://docs.kernel.org/userspace-api/media/v4l/dev-encoder.html#initialization</a>)<o:p></o:p></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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<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.<o:p></o:p></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">https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4409</a><br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
1. sizeimage that we get from video driver<br>
<br>
<o:p></o:p></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="Picture_x0020_2" src="cid:image001.png@01DBDAC4.66AEF9B0"></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="Picture_x0020_4" src="cid:image002.png@01DBDAC4.66AEF9B0"><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="Picture_x0020_6" src="cid:image003.png@01DBDAC4.66AEF9B0"><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="Picture_x0020_8" src="cid:image004.png@01DBDAC4.66AEF9B0"><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>
<o:p></o:p></span></p>
</div>
</body>
</html>