Modify
Warning Please read the Ticket HowTo before creating or commenting on a ticket. Failure to do so may cause your ticket to be rejected or result in a slower response.

Opened 4 years ago

Closed 3 years ago

#8593 closed task (Fixed)

Add VA API support

Reported by: markk Owned by: markk
Priority: minor Milestone: 0.25
Component: MythTV - Video Playback Version: Master Head
Severity: medium Keywords: vaapi
Cc: beirdo Ticket locked: yes

Description

This is a tracking ticket for adding VA API decoding and rendering.

Attachments (7)

vaapi_v1.diff (40.4 KB) - added by markk 4 years ago.
Initial VA API patch
vaapi_v3.diff (54.1 KB) - added by markk 4 years ago.
vaapi_v5.diff (50.4 KB) - added by markk 4 years ago.
vaapi_v6.diff (39.9 KB) - added by markk 4 years ago.
vaapi_v7.diff (48.9 KB) - added by markk 4 years ago.
vaapi_v118_aka_sticking_needles_in_your_eyes.diff (51.7 KB) - added by markk 4 years ago.
vaapi-working.diff (37.9 KB) - added by markk 3 years ago.
Working version of VAAPI support

Download all attachments as: .zip

Change History (32)

comment:1 Changed 4 years ago by markk

  • Owner changed from janne to markk
  • Status changed from new to assigned

Changed 4 years ago by markk

Initial VA API patch

comment:2 Changed 4 years ago by markk

I noticed several discussions on VA API support so I thought I'd better post what I have to date.

Version 1 has been tested with the Splitted Desktop VDPAU backend using an NVIDIA GeForce? 210. Decoding works and video does appear on screen.

Issues/Outstanding? features

  • the configure changes are wrong/incomplete
  • video presentation is a complete hack as I have been unable to get the GLX driver support working to copy the decoded surfaces to a GL texture. Hence there is no OSD etc
  • Live tv does not work - though I think the problem may actually be related to the OSD port merge.
  • handling of unsupported profiles may well be buggy and in combination with video renderer fallback behaviour may well be a sizeable problem.
  • the approach of sub-classing VideoOutputOpenGL may not work - though the alternatives are potentially messier.

comment:3 Changed 4 years ago by beirdo

  • Cc beirdo added

I was hoping to start with this soon, so this is timely. I can start testing for GMA500 if it's ready for that.

Changed 4 years ago by markk

comment:4 Changed 4 years ago by markk

Version 3 of the patch (I didn't post v2) should be largely functional. There is still no post processing (i.e. deinterlacing or colour control) but it is now fully integrated with the base OpenGL video renderer class and should fallback seemlessly to software decoding if needed. The approach to deinterlacing (settings and cpu/gpu fallbacks) will need some thought.

Still a little rough around the edges and configure needs fixing.

N.B. this uses the functionality available in libva-glx and not libva-x11. I've not checked the exact status but I don't think the glx extension is available yet in the upstream libva - hence you will need to use the splitted desktop versions.

It is also worth noting that non-power of two extensions are not supported in libva-glx and hence there is some unnecessary scaling (by the driver) and a little hack in the render pipeline to get the correct image on screen.

comment:5 Changed 4 years ago by markk

(In [25203]) Generalise the VideoBuffers::CreateBuffer? method so that it can be re-

Refs #8593.

comment:6 Changed 4 years ago by markk

(In [25204]) Add some initial VA API codec/enumeration support. Refs #8593.

Changed 4 years ago by markk

comment:7 Changed 4 years ago by markk

  • Status changed from assigned to accepted

Version 5 of the patch reflects commits already made to trunk and testing using the Splitted Desktop XvBA backend for ATI cards.

  • the VDPAU backend still works without much issue but I have removed the scaling hack for the time being as the XvBA driver gets this right (and you can just use VDPAU directly!)
  • improved configure changes with a partial attempt at ensuring the correct library version.
  • restricts support to VLD level acceleration. While the ATI XvBA backend reports some IDCT level acceleration for MPEG2, it fails. The XvBA notes suggest FFMPEG only supports VLD.
  • move the VA display into a ref counted class. The driver clearly recycles connections internally and closing a display that is being used for testing functionality will break other, existing connections (e.g. during live tv).

Success with the XvBA backend is erratic at best. The only consistent results I've had are with H.264 HD channels on live tv. Videos and recordings (of the same channels) will rarely work due to an assertion in the XvBA driver. Playback will often fail after a few channel changes and playback is often 'jumpy'.

I'm reasonably confident some of the problem is thread related, as a different test patch created the VAAPI buffers from the decoder thread and this had more success (but was pretty hacky). But even then certain files would abort consistently. It is also likely that my ATI card isn't working well as the same setup does not work well with other players with VAAPI support (broken playback, crashes etc).

If you are testing the VDPAU/XvBA backends, you'll need the latest Splitted Desktop libraries and drivers but Intel cards may work with the upstream 0.31.1 library (freedesktop.org) that has had GLX support added.

N.B. If you get a consistent crash on video exit, comment out the line with 'delete m_x_disp' in vaapicontext.cpp

comment:8 Changed 4 years ago by anonymous

I forgot to mention that there may well be some issues that are fixed in upstream FFMPEG. There are quite a few changes since the last sync.

comment:9 Changed 4 years ago by markk

(In [25256]) Add some missing codec handling in MythCodecID. Refs #8593.

comment:10 Changed 4 years ago by beirdo

I plan on trying this when I get home (Jul 19), testing on the GMA500.

comment:11 Changed 4 years ago by seppl@…

Tested this with a AMD/ATI HD4290 onboard GPU.
Running on latest release of Mythbuntu (10.4)
Splitted Desktop XvBA backend for ATI cards is installed on the latest Version

I've took the latest trunc and compiled with
./configure --disable-vdpau --enable-vaapi

Effect: On live TV (H264) ZDF HD i've got vertical bars on start and after 5 minutes i've got blocks.
Nearly same issues for Playback of SD.

But maybee i've set some options wrong.

Is there a recommendation for setup?
Which Version of the sourcecode is recommended?

Many thanks for starting development of a VAAPI support.
If there is something i can test or do for you please keep me informed.

THANKS
/Seppl

Changed 4 years ago by markk

comment:12 Changed 4 years ago by anonymous

Added version 6. No real changes - just an update to reflect the recent commits in trunk.

Tested with libva-0.31.1-1+sds4 from splitted desktop and the splitted deskptop vdpau backend version 0.6.10.

comment:14 Changed 4 years ago by stuartm

  • Ticket locked set

Changed 4 years ago by markk

comment:15 Changed 4 years ago by markk

Added version 7 which should apply cleanly to r25868. No functional changes yet.

comment:15 Changed 4 years ago by markk

(In [26098]) Refactor VideoOutputOpenGL to allow efficient subclassing and extend
OpenGLVideo to enable direct update of the output video textures via
hardware decoders.

This will be used by VAAPI in the short term (if I ever get it working
properly) and probably VDPAU and VDA for 0.25. There are other potential
issues such as deinterlacing of RGBA frames (generally a bad idea) but
I'll deal with those as they arise.

Refs #8593. Refs #8621

Changed 4 years ago by markk

comment:16 Changed 4 years ago by markk

  • Milestone changed from 0.24 to 0.25

comment:17 Changed 4 years ago by stuartm

  • Milestone 0.25 deleted

Milestone 0.25 deleted

comment:18 Changed 3 years ago by Github

libmythtv: Fix videooutbase.h includes for vaapi compilation.

Refs #8593

Branch: master
Changeset: 857fc430c6182f4983f5cf1425146eda7a1fe45b

Changed 3 years ago by markk

Working version of VAAPI support

comment:19 Changed 3 years ago by markk

The latest vaapi-working.diff works with master. Tested on an Intel Core i3 530 (clarkdale) and the latest ubuntu xorg-edgers ppa.

The magic sauce for success is the change in videoout_opengl.cpp that forces the video to use the same OpenGL context as the UI. This is fine until the decoder tries to signal a stream change (not all that common) - at which point bad things happen.

So some painful changes/fixes are needed to how stream changes are handled before vaapi will work. Those changes are needed for windows opengl anyway and are on my todo list.

N.B. deinterlacing does not work with the libva i965 driver I tested with and it is deliberately disabled for performance reasons.

comment:20 Changed 3 years ago by Github

VideoOutputOpenGL: Use a shared OpenGL context for OpenGL video and UI.

This should fix:-

  • blank OpenGL video playback on OS X.
  • framebuffer 'confusion' where the driver gets stuck displaying a UI

context backbuffer during video playback and vica-versa. Seen on intel
clarkdale and AMD with the proprietary driver.

This also clears the way for VAAPI integration and the removal of
context locking and switching code that is reducing performance and
breaking OpenGL rendering on windows.

In the medium term, integrated video and UI rendering is now
straightforward.

Refs #9268
Refs #8593

Branch: master
Changeset: 6846e140499e77432954d2d8ef56cabcbc6063e7

comment:21 Changed 3 years ago by Github

Add VAAPI support.

This seems to be pretty stable here although only tested using the xorg
edgers ubuntu PPA on an Intel i3 530.

  • you must be using OpenGL to draw the main UI (otherwise initialisation

will fail).

  • rendering is subclassed from the standard OpenGL video renderer, so

OSD, subtitles etc all work as expected.

  • there is no deinterlacing support.
  • picture adjustments will follow.
  • there are some still frame issues with DVD playback.

I haven't yet found a file that VAAPI won't accelerate for H.264 and
MPEG2, including flawless playback of killa_sampla.

Refs #8593

Branch: master
Changeset: c4bc3e9eb9a8a082d243b9d091018e58072eb3b6

comment:22 Changed 3 years ago by markk

Picture controls added in 8b0883e9b7

comment:23 Changed 3 years ago by Github

VAAPI: Don't test for support if we don't want it.

Refs #8593

Branch: master
Changeset: 651b83b0fea6b7c75f5ea7b52836f2c316787675

comment:24 Changed 3 years ago by Github

VAAPI: Implement proper pause frame handling.

Refs #8593

Branch: master
Changeset: e468ec9b447a1c2f0872c84e99e8b5fa1ee3c78b

comment:25 Changed 3 years ago by markk

  • Resolution set to Fixed
  • Status changed from accepted to closed

Closing this as I'm not sure what else I can do with it at the moment:)

For reference, the outstanding issues and potential problems:

  • deinterlacing is disabled as it does not appear to work with Intel at the moment.
  • Intel have not implemented picture controls.
  • there may be issues if setting up a decoder fails (we setup the base OpenGL class and then VAAPI, so if VAAPI fails there is no fallback). I haven't seen a failure yet though.

It would also be nice to hear feedback on Sandybridge performance and VC1 support (should be available with Sandybridge).

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'new'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.