<div dir="ltr">I've changed the size and number of the slices from the source and it shows perfectly the video.<div>What is the relation between the slices and the DXVA2 ?</div><div><br></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-08-26 10:58 GMT+02:00 Hector Alonso <span dir="ltr"><<a href="mailto:hector.alonso.aparicio@gmail.com" target="_blank">hector.alonso.aparicio@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div>I've modified my initialization code: supressed flags, and enabled thread_safe_callbacks, but the result is the same, lots of "Missing reference picture, default is __" error messages and avcodec_decode_video2 returns -1094995529 "Invalid data found when processing input" half the time. </div>

<div>The video is showing very very poorly with tons of compression artifacts.</div><div>I've read the extradata comment in ffmpeg code and it seems that is not really used with H264 codec. I've run my ffmpeg-not-HWaccel decoder and the extradata is not used at all indeed.</div>

<div><br></div><div>This is the new initialization:</div><div><br></div><div><div>#ifdef DXVA2_DECODER_ENABLED</div><div><br></div><div><span style="white-space:pre-wrap">   </span>// Create and populate Input Stream structure:</div>

<div><span style="white-space:pre-wrap">  </span>InputStream* ist = new InputStream();</div><div class=""><div><span style="white-space:pre-wrap">      </span>ist->hwaccel_id = HWACCEL_AUTO;</div><div><span style="white-space:pre-wrap">       </span>ist->hwaccel_device = "dxva2";</div>

<div><span style="white-space:pre-wrap">  </span>ist->dec = _pCodec;</div><div><span style="white-space:pre-wrap">   </span>ist->dec_ctx = _pCodecCtx;</div><div><br></div></div><div><span style="white-space:pre-wrap">       </span>// Set Known width and height</div>
<div class="">
<div><span style="white-space:pre-wrap">  </span>_pCodecCtx->coded_width  = 1280;<span style="white-space:pre-wrap">    </span></div><div><span style="white-space:pre-wrap"> </span>_pCodecCtx->coded_height = 720;</div>

<div><span style="white-space:pre-wrap">  </span><br></div></div><div><span style="white-space:pre-wrap">   </span>// Set Input Stream structure as ancillary data into codec</div><div><span style="white-space:pre-wrap">       </span>_pCodecCtx->opaque = ist;</div>

<div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>// Initialize DXV2 context</div><div><span style="white-space:pre-wrap">       </span>dxva2_init(_pCodecCtx);</div>
<div><br></div><div><span style="white-space:pre-wrap"> </span>// Set DXVA2 callbacks to codec context</div><div class=""><div><span style="white-space:pre-wrap">    </span>_pCodecCtx->get_buffer2 = ist->hwaccel_get_buffer;</div>

<div><span style="white-space:pre-wrap">  </span>_pCodecCtx->get_format = get_format;</div></div><div><span style="white-space:pre-wrap">      </span>_pCodecCtx->thread_safe_callbacks = 1;</div><div><br></div><div>#endif</div>
</div>
<div><br></div><div>Remember: dxva2_init is a call to the analogue method from ffmpeg_dxva.c file modified by me into a .h and a .cpp attached in a previous mail (I don't know if that's a common practice in this mail list or you do it in another way).</div>

<div><br></div><div>Regarding the next step (using the DX surface directly as an OpenGL texture), it can be done using: WGLEW_NV_DX_interop, wglDXOpenDeviceNV, wglDXSetResourceShareHandleNV, wglDXRegisterObjectNV, make current, lock, etc.</div>

<div><br></div><div>Look at WiDiSample code -> RenderOpenGL.cpp bind texture (Intel Media SDK video decoder example), and this page:</div><div><a href="http://halogenica.net/sharing-resources-between-directx-and-opengl/" target="_blank">http://halogenica.net/sharing-resources-between-directx-and-opengl/</a></div>

<div><br></div><div>...but for now I'm more worried about getting the DXVA2 to work properly with FFMPEG.</div><div><br></div><div>What am I missing?</div><div><br></div><div><br></div></div><div class="gmail_extra">
<br>
<br><div class="gmail_quote">2014-08-25 17:53 GMT+02:00 wm4 <span dir="ltr"><<a href="mailto:nfxjfg@googlemail.com" target="_blank">nfxjfg@googlemail.com</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On Mon, 25 Aug 2014 15:23:20 +0200<br>
Hector Alonso <<a href="mailto:hector.alonso.aparicio@gmail.com" target="_blank">hector.alonso.aparicio@gmail.com</a>> wrote:<br>
<br>
</div><div><div>> Hi,<br>
> I've rebuilt ffmpeg using these instructions<br>
> <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC" target="_blank">https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC</a> from the Visual Studio<br>
> Console, installing MinGW directly from the link with the flags --enable-dxva2<br>
> and --enable-hwaccel=h264_dxva2 and is almost working but I get a lot<br>
> of errors:<br>
> -1094995529 "Invalid data found when processing input"<br>
> from avcodec_decode_video2 a lot of artifacts and a very poor and<br>
> inconsistent image quality.<br>
> This is my dxva initialization code:<br>
><br>
> _pCodecCtx->flags|= CODEC_CAP_DR1;<br>
> _pCodecCtx->flags|= CODEC_CAP_HWACCEL;<br>
><br>
> InputStream *ist = new InputStream ();<br>
> ist->hwaccel_id = HWACCEL_AUTO;<br>
> ist->hwaccel_device = "dxva2";<br>
> ist->dec = _pCodec;<br>
> ist->dec_ctx = _pCodecCtx;<br>
> _pCodecCtx->coded_width  = 1280;<br>
> _pCodecCtx->coded_height = 720;<br>
> _pCodecCtx->opaque = ist;<br>
> dxva2_init(_pCodecCtx);<br>
> _pCodecCtx->opaque  = ist;<br>
> _pCodecCtx->get_buffer2 = ist->hwaccel_get_buffer;<br>
> _pCodecCtx->get_format = get_format;<br>
> _pCodecCtx->thread_safe_callbacks = 0;<br>
><br>
> before  calling<br>
><br>
>  if (avcodec_open2(_pCodecCtx , _pCodec, 0) < 0)  ...<br>
><br>
> Where get_format is:<br>
><br>
> static enum AVPixelFormat get_format(AVCodecContext *s, const enum<br>
> AVPixelFormat *pix_fmts)<br>
> {<br>
> InputStream* ist = (InputStream*)s->opaque;<br>
> ist->active_hwaccel_id = HWACCEL_DXVA2;<br>
> ist->hwaccel_pix_fmt   = AV_PIX_FMT_DXVA2_VLD;<br>
> return ist->hwaccel_pix_fmt;<br>
> }<br>
><br>
> Find attached my modified ffmpeg_dxva2.cpp and ffmpeg_dxva2.h files from<br>
> the original ffmpeg_dxva2.c and the InputStream declaration from ffmpeg.h<br>
><br>
> For getting the decoded frame I call: dxva2_retrieve_data_call, and then I<br>
> convert it to YUV420p (I make the final conversion via pixel shader with<br>
> OpenGL texture).<br>
><br>
> Also, with my old CPU decoder I had 3-6% CPU usage and 5-10% GPU usage (as<br>
> I said, I'm converting and painting with OpenGL) and now with the "GPU<br>
> Accelerated" one I have 5-13% CPU and 6-12% GPU.<br>
<br>
</div></div>PS: nevcairiel mentioned:<br>
<a href="http://developer.download.nvidia.com/opengl/specs/WGL_NV_DX_interop.txt" target="_blank">http://developer.download.nvidia.com/opengl/specs/WGL_NV_DX_interop.txt</a><br>
<br>
Unfortunately, it's marked as experimental, and other drivers probably<br>
don't provide it.<br>
<br>
> Any thoughts?<br>
><br>
> Thank you!<br>
<div><div>><br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>