<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi all,<br><br>I have encoder and decoder application in separate projects. I use x264 to encode the incoming frames and use libav to decode them. If the frame has a specific resolution like 1366 x 768, the decode frame contains extra black border at the right side of the frame. I have debugged it and realized that the <span style=" color:#800000;">av_pic.linesize[0] is 50 more than the linesize during the encoding. <br>Here is the code:</span><br><br><span style=" color:#c0c0c0;">              </span><span style=" color:#000000;">lengthDec</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">avcodec_decode_video2</span><span style=" color:#000000;">(</span><span style=" color:#800000;">c1</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">av_pic</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">&</span><span style=" color:#000000;">pic</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">&</span><span style=" color:#800000;">pkt</span><span style=" color:#000000;">);</span><pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span><span style=" color:#000000;">pic</span><span style=" color:#000000;">)<br>       {<br></span>       <span style=" color:#000000;">avpicture_fill</span><span style=" color:#000000;">((</span><span style=" color:#800080;">AVPicture</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*)</span><span style=" color:#c0c0c0;">rgbFrame</span><span style=" color:#000000;"></span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> RGB</span><span style=" color:#000000;">img</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">PIX_FMT_RGB32</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> w</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> h</span><span style=" color:#000000;">);</span><br></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">       </span><span style=" color:#000000;">sws_scale</span><span style=" color:#000000;">(</span><span style=" color:#800000;">ctx</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">av_pic</span><span style=" color:#000000;">-></span><span style=" color:#800000;">data</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">av_pic</span><span style=" color:#000000;">-></span><span style=" color:#800000;">linesize</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> h</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> rgbFrame</span><span style=" color:#000000;">-></span><span style=" color:#800000;">data</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#c0c0c0;">rgbFrame</span><span style=" color:#000000;"></span><span style=" color:#000000;">-></span><span style=" color:#800000;">linesize</span><span style=" color:#000000;">);</span><span style=" color:#000000;"><br>       }<br><br>So, in this code, I decode the packet and convert the decoded data into the rgb. <br>Why does the </span><span style=" color:#c0c0c0;"></span><span style=" color:#000000;">avcodec_decode_video2</span><span style=" color:#800000;"> returns a padded linesize?<br></span><span style=" color:#000000;">Could anyone tell me how I can eliminate the black border?<br><br>Thanks.<br></span></pre><span style=" color:#000000;"></span><br><br>                                          </div></body>
</html>