<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2019 at 12:59 PM Carl Eugen Hoyos <<a href="mailto:ceffmpeg@gmail.com">ceffmpeg@gmail.com</a>> wrote: </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Di., 2. Juli 2019 um 10:58 Uhr schrieb Asaf Kave <<a href="mailto:kaveasaf@gmail.com" target="_blank">kaveasaf@gmail.com</a>>:<br>
<br>
> I track the first call to 'avcodec_send_packet', and i find that the majority of<br>
> the memory consumption is made by call to<br>
> 'IDirectXVideoAccelerationService_CreateSurface' with initial_pool_size == 20.<br>
<br>
16 is the maximum number of surfaces needed for h264 streams, my guess<br>
is that the remaining four surfaces come from the number of decoding threads.<br></blockquote><div><br></div><div>You are correct, the 16 is from the "dxva2.c" file at 'ff_dxva2_common_frame_params' function, it's surfaces based on number of possible refs.</div><div>The 4 (really 3 + 1) rest of the surfaces come from decode.c at 'ff_decode_get_hw_frames_ctx' function.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> Is  there any way to configure this number ?<br>
<br>
Edit the source code.<br></blockquote><div><br></div><div>I found the function 'avcodec_get_hw_frames_parameters'  located at  avcodec, that helping me to set the number of the initial_pool_size to whatever i want, instead changing the hard coded source files.</div><div>I am calling that from the get_format callback, and it's work for me very well.</div><div><br></div><div>Now, i want to take this further, and try dynamically find the best value for the initial_pool_size, for example starting with size of 3 and if 'avcodec_send_packet' is failed with AVERROR(ENOMEM) i will try to increase it by 1 each time till i will get the limit that needed.</div><div>I succeeded to do it for H.264 codec as follow :</div><div><br></div><div>ret = avcodec_send_packet(m_avContext, m_avPkt);<br>              if (ret == AVERROR(ENOMEM))     {<br>    m_avContext->pix_fmt = AV_PIX_FMT_NONE;<br><br>    if(m_avContext->hw_frames_ctx != NULL) {<br>          av_buffer_unref(&m_avContext->hw_frames_ctx);<br>          m_avContext->hw_frames_ctx = NULL;<br>    }<br>          }</div><div><br></div><div>this work, because at "h264_slice.c" function 'h264_init_ps' there is check if pix_fmt not initialized, line 1056, then get_format is calling again.</div><div><br></div><div>For the HEVC, i didn't succeeded to find equivalent to ignite a new call to the get_format.</div><div>I will be happy to get advise here.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Please find out what top-posting means and avoid it here, Carl Eugen<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote></div></div>