<div dir="ltr">Hi,<div><br></div><div>I'm investigating the possibility to use VA-API for H264 decoding on Android, using Android-x86. At the moment, I'm using Android-4.4-r5 (from android-x86), which is based on ffmpeg-2.1. I realize this is not the current ffmpeg version, nervertheless I understand that 2.1 should support VA-API decoding.</div><div><br></div><div>I've recompiled libavcodec with support for libva (1.7.1) and I've added the intel driver (i965). Running vainfo on the device yields the following, so I assume everything is ok on that front:</div><div><br></div><div><div>vainfo: VA-API version: 0.39 (libva 1.1.0)</div><div>vainfo: Driver version: Intel i965 driver for Intel(R) Bay Trail - 1.0.16.pre1 ()</div><div>vainfo: Supported profile and entrypoints</div><div>      VAProfileMPEG2Simple            :<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>VAEntrypointVLD</div><div>      VAProfileMPEG2Simple            :<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>VAEntrypointEncSlice</div><div>      VAProfileMPEG2Main              :<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>VAEntrypointVLD</div><div>      VAProfileMPEG2Main              :<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>VAEntrypointEncSlice</div><div>      VAProfileH264ConstrainedBaseline:<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>VAEntrypointVLD</div><div>      VAProfileH264ConstrainedBaseline:<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>VAEntrypointEncSlice</div><div>      VAProfileH264Main               :<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>VAEntrypointVLD</div><div>      VAProfileH264Main               :<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>VAEntrypointEncSlice</div><div>      VAProfileH264High               :<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>VAEntrypointVLD</div><div>      VAProfileH264High               :<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>VAEntrypointEncSlice</div><div>      VAProfileH264StereoHigh         :<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>VAEntrypointVLD</div><div>      VAProfileVC1Simple              :<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>VAEntrypointVLD</div><div>      VAProfileVC1Main                :<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>VAEntrypointVLD</div><div>      VAProfileVC1Advanced            :<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>VAEntrypointVLD</div><div>      VAProfileNone                   :<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>VAEntrypointVideoProc</div><div>      VAProfileJPEGBaseline           :<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>VAEntrypointVLD</div></div><div><br></div><div>My problem is that it seems ffmpeg's h264 decoder never uses VA-API. I've added log statements at various places to trace the code execution:</div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/h264.c#L3270">https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/h264.c#L3270</a><br></div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/h264.c#L3200">https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/h264.c#L3200</a><br></div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/utils.c#L3204">https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/utils.c#L3204</a><br></div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/utils.c#L3218">https://github.com/FFmpeg/FFmpeg/blob/release/2.1/libavcodec/utils.c#L3218</a><br></div><div><br></div><div>The log I see is below. It appears ff_find_hwaccel returns NULL, as it tries to match the pix_fmt. The given pix_fmt is AV_PIX_FMT_YUV420P, and it should be AV_PIX_FMT_VAAPI_VLD for the hwaccel object to be detected. And I can't figure out how the pix_fmt could be set to AV_PIX_FMT_VAAPI_VLD.</div><div><br></div><div>Any pointer or suggestion?</div><div><br></div><div><div>I/FFMPEG  ( 2708): register hwaccel: h264_vaapi</div><div>I/FFMPEG  ( 2708): register hwaccel: mpeg2_vaapi</div><div>I/FFMPEG  ( 2708): register hwaccel: mpeg4_vaapi</div><div>D/FFMPEG  ( 2708): android source begin open</div><div>D/FFMPEG  ( 2708): android open, url: android-source:0x416b9df0</div><div>D/FFMPEG  ( 2708): ffmpeg open android data source success, source ptr: 0x416b9df0</div><div>D/FFMPEG  ( 2708): android source open success</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=0, pix_fmt=-1, fmt=53, force_callback=0</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=1, pix_fmt=-1, fmt=0, force_callback=0</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=0, pix_fmt=-1, fmt=53, force_callback=1</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=1, pix_fmt=-1, fmt=0, force_callback=1</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: codec=0000001c, pix_fmt=0</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=h264_vaapi</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=mpeg2_vaapi</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=mpeg4_vaapi</div><div>I/FFMPEG  ( 2708): [h264 @ 0x42dfdd00] hwaccel: (null)</div><div>I/FFMPEG  ( 2708): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'android-source:0x416b9df0':</div><div>I/FFMPEG  ( 2708):   Metadata:</div><div>I/FFMPEG  ( 2708):     major_brand     : mp42</div><div>I/FFMPEG  ( 2708):     minor_version   : 0</div><div>I/FFMPEG  ( 2708):     compatible_brands: isomavc1mp42</div><div>I/FFMPEG  ( 2708):     creation_time   : 2010-06-07 20:19:05</div><div>I/FFMPEG  ( 2708):   Duration: 00:04:06.71, start: 0.000000, bitrate: 3606 kb/s</div><div>I/FFMPEG  ( 2708):     Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)</div><div>I/FFMPEG  ( 2708):     Metadata:</div><div>I/FFMPEG  ( 2708):       creation_time   : 2010-06-07 20:19:05</div><div>I/FFMPEG  ( 2708):       handler_name    : (C) 2007 Google Inc. v08.13.2007.</div><div>I/FFMPEG  ( 2708):     Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3478 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc (default)</div><div>I/FFMPEG  ( 2708):     Metadata:</div><div>I/FFMPEG  ( 2708):       creation_time   : 2010-06-07 20:19:05</div><div>I/FFMPEG  ( 2708):       handler_name    : (C) 2007 Google Inc. v08.13.2007.</div><div>D/FFMPEG  ( 2708): android source close</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=0, pix_fmt=-1, fmt=53, force_callback=0</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=1, pix_fmt=-1, fmt=0, force_callback=0</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=0, pix_fmt=-1, fmt=53, force_callback=1</div><div>I/FFMPEG  ( 2708): get_pixel_format: i=1, pix_fmt=-1, fmt=0, force_callback=1</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: codec=0000001c, pix_fmt=0</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=h264_vaapi</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=mpeg2_vaapi</div><div>I/FFMPEG  ( 2708): ff_find_hwaccel: hwaccel=mpeg4_vaapi</div><div>I/FFMPEG  ( 2708): [h264 @ 0x42dfe320] hwaccel: (null)</div></div><div><br></div><div>Thanks,</div><div>Michael.</div><div><br></div></div>