Wednesday, January 11, 2017

How to enable hardware acceleration in VLC running on Fedora 24

I used to use VLC hardware acceleration (http://swapoff.blogspot.com/2014/12/install-libva-intel-driver-to-get-hw.html) because it's a cool thing to have when you play HD videos. Recently I noticed that my CPU is heavily utilized when I played HD videos even though I was under the impression that the hardware acceleration was working. The methods I tried to find out whether the hardware acceleration was working or not gave positive results, but the CPU utilization was telling a different story.

Therefore I tried to understand what was actually happening.

After doing some google searches I landed on a VLC forum thread which describes this was due to the behavior in the FFmpeg library. (https://forum.videolan.org/viewtopic.php?t=134770) According to the information shared in that thread, the library does not support multithreading with hardware acceleration. But VLC set 0 which is auto for the number of threads for FFmpeg.

Therefore changing this value to 1 should work. We can change the value by selecting,  
Tools -> Preferences -> Input/Codecs -> Show Settings All -> Input codecs -> Video codecs -> FFmpeg and set the value of the parameter "Threads" to 1

After setting this value to 1 and restarting the VLC, I tried to play several 720p videos. It actually worked. The CPU utilization was well under 10%.

However when I tried to play a 1080i Blue-Ray video, a nasty thing happened. It triggered a bug in the kernel and crashed the system.

details of the crash from journalctl,

Jan 10 02:31:17 localhost.localdomain kernel: BUG: unable to handle kernel NULL pointer dereference at           (null)
Jan 10 02:31:17 localhost.localdomain kernel: IP: [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: PGD 0
Jan 10 02:31:17 localhost.localdomain kernel: Oops: 0000 [#1] SMP
Jan 10 02:31:17 localhost.localdomain kernel: Modules linked in: uas usb_storage fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun ip6t_REJECT nf_reject_ipv6 xt_con
Jan 10 02:31:17 localhost.localdomain kernel:  intel_rapl_perf snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm joydev i2c_i801 mei_me i2c_smbus snd_timer snd mei shpch
Jan 10 02:31:17 localhost.localdomain kernel: CPU: 3 PID: 2740 Comm: vlc Not tainted 4.8.15-200.fc24.x86_64 #1
Jan 10 02:31:17 localhost.localdomain kernel: Hardware name: ASUS All Series/H97M-E, BIOS 2302 02/09/2015
Jan 10 02:31:17 localhost.localdomain kernel: task: ffff91804f7f1e80 task.stack: ffff91801e340000
Jan 10 02:31:17 localhost.localdomain kernel: RIP: 0010:[<ffffffffc019d58d>]  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: RSP: 0018:ffff91801e3439d8  EFLAGS: 00010246
Jan 10 02:31:17 localhost.localdomain kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: RDX: ffff91801de7aae0 RSI: ffff918088b01000 RDI: 000000038cc4d000
Jan 10 02:31:17 localhost.localdomain kernel: RBP: ffff91801e343a28 R08: 0000000000000000 R09: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: R10: 0000000000000000 R11: ffff918088a20000 R12: ffff918088b01ffc
Jan 10 02:31:17 localhost.localdomain kernel: R13: 0000000000000000 R14: ffff91801de7aae0 R15: 0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: FS:  00007f8b0882a700(0000) GS:ffff91809fb80000(0000) knlGS:0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 10 02:31:17 localhost.localdomain kernel: CR2: 00007fe765248000 CR3: 00000003b4c1a000 CR4: 00000000001406e0
Jan 10 02:31:17 localhost.localdomain kernel: Stack:
Jan 10 02:31:17 localhost.localdomain kernel:  ffff91804f7f1e80 0000000000000200 ffff91808be44000 0000100000000001
Jan 10 02:31:17 localhost.localdomain kernel:  000000038cc4d000 0000000000000000 ffff91801dd0ac00 0000000000000002
Jan 10 02:31:17 localhost.localdomain kernel:  0000000000000001 ffff9180487dba80 ffff91801e343a60 ffffffffc019ee60
Jan 10 02:31:17 localhost.localdomain kernel: Call Trace:
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019ee60>] aliasing_gtt_bind_vma+0x90/0xe0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01a3e8e>] i915_vma_bind+0xce/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa4fb>] i915_gem_object_do_pin+0x86b/0xa60 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa71d>] i915_gem_object_pin+0x2d/0x30 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198acf>] i915_gem_execbuffer_reserve_vma.isra.20+0x9f/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198f3b>] i915_gem_execbuffer_reserve.isra.21+0x38b/0x3b0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019a1d8>] i915_gem_do_execbuffer.isra.24+0x6b8/0x1200 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b944>] i915_gem_execbuffer2+0x104/0x260 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc00cbfa0>] drm_ioctl+0x200/0x4f0 [drm]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b840>] ? i915_gem_execbuffer+0x330/0x330 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0264cc3>] do_vfs_ioctl+0xa3/0x5f0
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0265289>] SyS_ioctl+0x79/0x90
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0803b72>] entry_SYSCALL_64_fastpath+0x1a/0xa4
Jan 10 02:31:17 localhost.localdomain kernel: Code: 5f 5d c3 c7 45 cc 00 00 00 00 31 db 48 c7 45 d0 00 00 00 00 45 31 f6 e9 2a ff ff ff 8b 45 b8 48 8b 4d c0 48 8b 84 c1 c8 0
Jan 10 02:31:17 localhost.localdomain kernel: RIP  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]


Then I have found a bug report (https://bugs.freedesktop.org/show_bug.cgi?id=98760) which was reported for this particular issue. Fortunately it had a workaround mentioned to fix the issue. The workaround is to downgrade the
libvdpau-va-gl installation.

First, find out the available versions of libvdpau-va-gl,
dnf --showduplicates list libvdpau-va-gl

Then remove the existing libvdpau-va-gl installation,
dnf remove libvdpau-va-gl

Then install the previous version of libvdpau-va-gl,
dnf install libvdpau-va-gl-0.3.6-1.fc24.x86_64

Finally I was able to get hardware acceleration in VLC worked for both 720p and 1080i HD videos.

No comments:

Post a Comment