<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head><body dir="ltr"><div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Hello everyone, I hope that someone can point me into the right direction with this
issue.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">I have a decoding loop that can optionally use HW acceleration.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">The code has been tested on different machines with both Intel and NVIDIA graphic cards and works without issues
in most cases.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">I'm seeing a memory leak though during a test on a laptop with the following specs:</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<ul data-editing-info="{"orderedStyleType":1,"unorderedStyleType":2}" style="text-align: left; margin-top: 0px; margin-bottom: 0px; background-color: rgb(255, 255, 255);">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); list-style-type: "- ";">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Intel i7<br>
</span></li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); list-style-type: "- ";">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b>NVIDIA quadro p520</b><br>
</span></li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); list-style-type: "- ";">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">File being played is a H.264 1920x1080</span></li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); list-style-type: "- ";">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">HW device is
<b>AV_HWDEVICE_TYPE_D3D11VA</b></span></li></ul>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><br>
</b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">The leak will eat up all the available memory very quickly and crash the machine.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">When running on this machine
<b><i>avcodec_receive_frame(d->avctx, cur_frame)</i></b><i> </i>will always return -11 (AVERROR(EAGAIN)) while
<b><i>avcodec_send_packet </i></b>executes without any issue and it is continuously called even if
</span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><b><i>avcodec_receive_frame</i></b><i> </i></span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">is
not dequeuing any frame from <b><i>AVCodecContext* </i></b></span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><b><i>d->avctx.</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><b><i><br>
</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i>av_hwdevice_ctx_create
</i></b>is executed without any problem and creating the context correctly.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><b><i>cur_frame</i></b></span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> is
not allocated and de-allocated at each step of the decoding loop as in <a href="https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c" id="OWA4bce5b22-c9c9-d782-1a4e-41e55e00752d" class="x_fui-Link x____1rxvrpe x_f2hkw1w x_f3rmtva x_f1ewtqcl x_fyind8e x_f1k6fduh x_f1w7gpdv x_fk6fouc x_fjoy568 x_figsok6 x_f1hu3pq6 x_f11qmguv x_f19f4twv x_f1tyq0we x_f1g0x7ka x_fhxju0i x_f1qch9an x_f1cnd47f x_fqv5qza x_f1vmzxwi x_f1o700av x_f13mvf36 x_f1cmlufx x_f9n3di6 x_f1ids18y x_f1tx3yz7 x_f1deo86v x_f1eh06m1 x_f1iescvh x_fhgqx19 x_f1olyrje x_f1p93eir x_f1nev41a x_f1h8hb77 x_f1lqvz6u x_f10aw75t x_fsle3fq x_f17ae5zn x_OWAAutoLink" title="https://github.com/ffmpeg/ffmpeg/blob/master/doc/examples/hw_decode.c" data-auth="NotApplicable" data-loopstyle="linkonly" data-linkindex="0" style="margin: 0px;">
hw_decode.c</a> example but is allocated only once inside a init() function:</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i>d->valid_frame = av_frame_alloc();<br>
d->sw_valid_frame = av_frame_alloc();</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">and destroyed once in a destroy() function:</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i>av_frame_free(&d->valid_frame);</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i>av_frame_free(&d->sw_valid_frame);</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i> av_packet_unref(&d->pkt);</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i> avcodec_free_context(&d->avctx);</i></b></span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><i><br>
</i></b></span></div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">The leak seems is not due to any missing de-allocation.</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Any help is much appreciated. Thank you!</span></div>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px;">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Andrea</span></div>
<br><br>
--<br>
<span style="font-family:Arial, Helvetica, sans-serif; font-weight:bold; Font-size:14.0px; color:#2a5e8e">
Andrea Campisi<br>
Research & Development<br>
<br><br>
Avolites Limited
<br> <br>
</span>
<span style="font-family:Arial, Helvetica, sans-serif;Font-size:14.0px; color:#2a5e8e">
184 Park Avenue, Park Royal, London, NW10 7XL<br>
T: +44 (0) 208 965 8522<br>
F: +44 (0) 208 965 0290<br>
DD:<br>
<a href="http://www.avolites.com" target="_blank">www.avolites.com</a><br><br>
<table>
<tbody>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="http://www.facebook.com/avolites"><IMG border="0" src="https://eu-api.mimecast.com/s/store/zTlmCywmFZ3-1lH5h0482DXHY1vRyJZYXSoAxAPGbYdzHEIWfSPmwiKDUa_msmDtA4TgUEkMuhSRxtJsqZeH3Yrr2l_NZI7DizqSpGd8RXpqLjH2xlrYWyqcWVEa4kFzyttakN5UOdiAVdTGPaoDSeeyb3hBF3l0lBrJ5BKw8jyeYO9Y9ogEnC9Bl_5vxo0t" ></A></td></tr></table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="https://plus.google.com/+avolites/"><IMG border="0" src="https://eu-api.mimecast.com/s/store/Hqdr9-8l34VTlqjuO_FHJ53gh7jhFFXDCf2-zrczlj2atGnibDGjsZ9fkjoFXwIzmAwTv18YDK_9-Q5wClC6_87wJfaJ_CdnbL0QIWpsalWZov--jWYMTTfo32t7A1c10Am0yH07QQvyjf6g84s_VSsSeaKDUkYIGR9qWUAy2QDN3dErWIHIzb-LuznMeQ16" ></A></td></tr></table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="https://www.instagram.com/avolitesltd/"><IMG border="0" src="https://eu-api.mimecast.com/s/store/zTlmCywmFZ3-1lH5h0482DiGozcbFf4wGE7LaplG92YendqTNRRtJQR980ltZzLCJw_9FCnSzkX-FAuqXhUKwtB3glbM-hKwsV3B3S59h8X10QDrx8DIcLh_XYFid_AA0Ex6AaIMbGhB9BEYafE7SN0TJgid5M1vSuuQOm0EcIhEXQ5kpPzA0tR_ADWdR-Yn" ></A></td></tr></table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="https://www.linkedin.com/company/avolites-ltd"><IMG border="0" src="https://eu-api.mimecast.com/s/store/lfdlbh-CuaEmFwqhh57kbpEEDK0Rhh3KOMiocoF0rc0PTUFa5SPibXj-6s1NID8N3BmjQ2YvBrXiGrF2E_dEHm4WoEEBCqqYcnsLcT0nD9qA7pYtdQgL9zciZmqs1BTiVGoKrfwj9m1KcpN4h_WysD0YxmeFC4c9ScKTR65BUU6xP53S0bRQ9zfLyMXQ4nBX" ></A></td></tr></table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="https://www.twitter.com/avolitesltd"><IMG border="0" src="https://eu-api.mimecast.com/s/store/ahxMomHoEitvHUEdAAfxyaeJltYF2eNIMT442WCsBWEGAjsQhbCL5LAkJ9Q4WdCJOv3m4_b3EhorduqhrN9418p8iuHmSxE38EAPPrqFvnIb_ydniaKZM1kFlWbZRZHDVSaSaMzuWpVOyBK2A5PMhs9K64bg0pskg8wVnrefZrA48ouxRlMBh5e6Qf6PzM_J" ></A></td></tr></table>
</td>
</tr></tbody></table></span>
<br>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="https://www.d9.avolites.com"><IMG border="0" src="https://eu-api.mimecast.com/s/store/zTlmCywmFZ3-1lH5h0482JJYHWaGUW2lDZgdZnSf-bXj8nwpAwT28b9rpVltfCEjmsXxDaxz2ru7zl6av8KIRTftGWB2Kn5sjlkOCDuHsexVAQ-rDuwdxNgMjGj3RReDI4sdLIhaBaV6wjhS01bbZcThY6y9RCj4MxczAabxYIH7EB1R5w1FAgzZLBt0knid" ></A></td></tr></table>
<br>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><IMG border="0" src="https://eu-api.mimecast.com/s/store/yhtQlti3cdvkQRSR-cosqd4w1D5t37lWBiZgw08gMwnbb-JjoRtUGs3A2ctEfTdi0AN1VHky5ibYN6QchPonteDMkuP4dD4-o6ciCi37AENeS47ibelFDKrUars6FyxHunJ1sfEgGdJlWa2058Wskf9NObvuhH9ZzhriB7yA60y9GE6Wot6fLGE48zn-0KZS" ></td></tr></table>
<br>
<span style="font-family:Calibri, Helvetica, sans-serif; font-weight:bold; Font-size:12.0px; color:#7a7a7a;">
This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed.<br>
If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone.<br>
Please contact the sender if you believe you have received this email in error. <br><br>
</span>
</body></html>