<div dir="ltr">Hi Guys, <div><br></div><div style>I met a crash when doing image conversion (just pixel format conversion, no resizing).</div><div style><br></div><div style>sws_context is got using sws_getContext (I also tried sws_getCachedContext)</div>
<div style><br></div><div style>code fragment is here:</div><div style><br></div><div style><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">pFrameConverted = avcodec_alloc_frame();</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">int numBytes = avpicture_get_size(LPixelFormatToFFMPEG(vfSource.pf), vfSource.iWidth, vfSource.iHeight);</span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px">
<span style="font-size:10pt">buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));</span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">avpicture_fill((AVPicture *)pFrameConverted, buffer, LPixelFormatToFFMPEG(vfSource.pf), vfSource.iWidth, vfSource.iHeight);</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt"><br></span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">// pCurrentFrame is the AVFrame object returned by av_decode_video2</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">sws_scale(pSwsContext, pCurrentFrame->data, pCurrentFrame->linesize, 0, vfSource.iHeight, pFrameConverted->data, pFrameConverted->linesize) ;</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt"><br></span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">sws_scale crashes randomly (crashes in different frames).</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt"><br></span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">Can anyone provide any idea on this?</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt"><br></span></p><p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt">Thanks</span></p>
<p style="margin:0px;padding:0px;color:rgb(0,0,0);line-height:16px"><span style="font-size:10pt"><br></span></p></div></div>