Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#2649 closed enhancement (fixed)

Opengl video renderer

Reported by: mark_kendall@… Owned by: danielk
Priority: minor Milestone: unknown
Component: mythtv Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Video renderer using opengl for the mythtv-vid branch. Highlighs/lowlights include:-

  • Works with XGL
    • tested with XGL 7.0.0, Beryl 0.1.1 on Ubuntu 6.0.6 (Dapper).
    • but large(ish) performance penalty under xgl.
    • some window issues
  • Hardware yuv to rgb conversion
    • based on xine/glitz fragment program
    • uses rectangular textures when available
    • added colour adjustment as well (enable xv colour controls to use) - brightness, contrast, colour only (no hue).
  • Vertical sync
    • takes care of itself if opengl sync to vblank is enabled (nvidia-settings) and GPU can keep up
    • 'normal' opengl vsync will fail silently
    • better sync (less tearing) at 1080i when using buggy nvidia drivers (i.e. don't need to disable sync to vblank for xv)
  • PiP
    • hardware scaling of pip
    • pip sizing should be accurate for XrandR/aspect ratios etc
    • but pip is currently rendered over osd
  • XRandR
    • appears to be working pretty well (but see ticket:2648)
  • Performance
    • worse than xvideo but seems to be on par with mplayer/xine using opengl
    • FX5200 seems to cope with main video and pip at SD resolutions
  • EPG
    • preview EPG not currently supported
  • To do
    • if RGB OSD surfaces become available, hardware rendering of OSD
    • scaling of video resize for interactive tv - easy; but dependant on OSD above.
    • support for non YV12 picture formats (e.g. YUV422p, RGB24 - should be easy enough)
    • preview EPG if using opengl painter in mythui?
    • use QGLWidget for portability?
    • bobdeint - I've tried more approaches than I can remember. Doubling the refresh rate is easy enough but impacts so badly on texture sampling that you lose the fields. You end up with nothing more than a form of linear blend.

You'll need to tweak your display profiles and use --override-setting UseOpenglVideo?=1 (probably a short term hack) to get it working.

Regards

Mark

Attachments (12)

opengl.diff (4.2 KB) - added by anonymous 13 years ago.
videoout_opengl.cpp (28.9 KB) - added by anonymous 13 years ago.
videoout_opengl.h (3.1 KB) - added by anonymous 13 years ago.
openglv2.diff (7.7 KB) - added by anonymous 13 years ago.
util-opengl.cpp (16.0 KB) - added by anonymous 13 years ago.
util-opengl.h (3.2 KB) - added by anonymous 13 years ago.
videoout_opengl.2.cpp (64.5 KB) - added by anonymous 13 years ago.
videoout_opengl.2.h (6.8 KB) - added by anonymous 13 years ago.
video_opengl_v2.diff.gz (20.4 KB) - added by skamithi 13 years ago.
unified diff of the v2 patches. makes its a little easier to apply to mythtv-vid branch.
opengl_osd_fixes.diff (2.3 KB) - added by mark_kendall@… 13 years ago.
Opengl OSD improvements
opengl_deinterlacing_fixes.diff (2.5 KB) - added by mark_kendall@… 13 years ago.
Opengl deinterlacing fixes
opengl_3textures.diff (13.5 KB) - added by mark_kendall@… 13 years ago.
Use 3 textures for frame upload/colour conversion

Download all attachments as: .zip

Change History (27)

Changed 13 years ago by anonymous

Attachment: opengl.diff added

Changed 13 years ago by anonymous

Attachment: videoout_opengl.cpp added

Changed 13 years ago by anonymous

Attachment: videoout_opengl.h added

comment:1 Changed 13 years ago by danielk

Owner: changed from Isaac Richards to danielk

comment:2 Changed 13 years ago by mark_kendall@…

Version 2 of the OpenGL renderer(substantially re-written).

  • Major changes
    • Implements a simple, multipass filtering structure utilising multiple framebuffer objects and/or multiple fragment programs.
    • Includes opengl versions of each of the existing deinterlacers (onefield, kernel, linearblend, bob) (N.B. these will deinterlace normal softblend osd)
    • Adds 3 new progressive scan versions of onefield, linearblend and kerneldeint
    • Mix and match software and opengl deinterlacers for main/fallback deinterlacers.
    • Adds an opengl rendered OSD. This uses the existing YUV osd frame and alpha mask but does utilise the full screen size and resolution.
    • Software yuv2rgb fallback if fragment programs are not available on the graphics hardware.
    • Added a seperate opengl class to handle the window/context and all opengl resources (textures, fragment programs, framebuffers and 'non-standard' function calls)
    • Resizing of interactive tv is now handled in hardware if using the opengl osd.
  • Issues
    • Xrandr support is at least partially broken.
    • Some deinterlacers assume topfield first field ordering.
    • Small off-by-one rendering innacuracies of interactive tv(MHEG) when using opengl osd.
  • Performance/quality
    • NVidia 62XX series seems to be about the minimum needed for standard definition progressive scan (using progressive kerneldeint - which is by far the most GPU hungry) (FX5200 cannot cope with more then basic opengl deinterlacing)
    • NVidia 7600GS copes well with SD main video, pip and opengl osd rendered at 720P
    • Quality of the progressive scan deinterlacers is pretty good. They cope very well with low to moderate movement but less well with fast motion. (Also seem to handle frame rate discrepancies better than bobdeint - eg PAL at 60Hz)
    • If the GPU cannot handle the demands, CPU utilisation seems to go through the roof...
  • To Do
    • Additional filters (lanczos and/or kaiser, denoise) - needs some upstream intergration (also need some help with lanczos)
    • More advanced deinterlacers (I've started to look at edge detection)
    • Framerate conversions e.g. PAL to NTSC rates
    • Performance improvements (minimise opengl state changes, does pip need deinterlacing)
    • Offscreen rendering for use by preview pip (ie hardware color conversion and scaling) and maybe transcode?

Changed 13 years ago by anonymous

Attachment: openglv2.diff added

Changed 13 years ago by anonymous

Attachment: util-opengl.cpp added

Changed 13 years ago by anonymous

Attachment: util-opengl.h added

Changed 13 years ago by anonymous

Attachment: videoout_opengl.2.cpp added

Changed 13 years ago by anonymous

Attachment: videoout_opengl.2.h added

Changed 13 years ago by skamithi

Attachment: video_opengl_v2.diff.gz added

unified diff of the v2 patches. makes its a little easier to apply to mythtv-vid branch.

comment:3 Changed 13 years ago by danielk

(In [12693]) Refs #2287. Refs #2649. Adds Mark Kendall's OpenGL video rendering to mythtv-vid tree.

I've made this default to being included in ./configure. You just need to select opengl as a video renderer for one of your display profiles to use this. Here it looks pretty rotten with SD material, but looks quite good with HD material.

comment:4 Changed 13 years ago by danielk

(In [12697]) Refs #2649. Some cleanup of the OpenGL code in mythtv-vid.

comment:5 Changed 13 years ago by danielk

(In [12700]) Refs #2649. Merges the OpenGL init code in XvMCTextures and OpenGLContext.

comment:6 Changed 13 years ago by danielk

(In [12708]) Refs #2649. Fixes #3036. More OpenGL cleanup in mythtv-vid branch.

This also appears to have fixed the stability issue with using OpenGL OSD with OpenGL Video, the problem was that two OpenGL OSD renderers were being initialized, the pbuffer one used for XvMC OpenGL Video and the framebuffer one used for non-XvMC OpenGL Video.

comment:7 Changed 13 years ago by danielk

(In [12727]) Refs #2649. More cleanup of the OpenGL code in mythtv-vid.

comment:8 Changed 13 years ago by danielk

(In [12729]) Refs #2649. Fixes #3037. Adds frame doubling opengl linear blend to video display profile filters.

comment:9 Changed 13 years ago by danielk

(In [12730]) Refs #2649. More OpenGL cleanup, this allows you to create profiles you haven't compiled for, but then adds additional checking so that these profiles won't be used at runtime.

comment:10 Changed 13 years ago by danielk

(In [12732]) Refs #2287. Refs #2649. Uses utils-opengl functions for OpenGL VSync.

comment:11 Changed 13 years ago by mark_kendall@…

Opengl OSD performance improvements.

  1. Rather than converting the YUV OSD frame each time it is displayed, we render into a framebuffer and only update when necessary. This is a major performance improvement, esp. if used in conjunction with the new option to enable/disable the OSD fade.
  1. Make sure the viewport is set for the osd filter (it otherwise defaults to 1920x1080).

Changed 13 years ago by mark_kendall@…

Attachment: opengl_osd_fixes.diff added

Opengl OSD improvements

comment:12 Changed 13 years ago by mark_kendall@…

Opengl Deinterlacing fixes.

  1. Make sure the resize 'filter' is applied last, otherwise the field information is distorted for the hardware deinterlacers.
  1. Tidy up OpenglVideo?.
  1. Ensure opengl deinterlacing is preserved following an input change.

Changed 13 years ago by mark_kendall@…

Opengl deinterlacing fixes

comment:13 Changed 13 years ago by mark_kendall@…

Use 3 textures for YUV texture upload

By using 3 textures rather than one for frame upload, we avoid having to calculate the frame offsets and avoid 'random' memory reads during yuv to rgb conversion. There appears to be no upload penalty for 3 textures rather than one.

On my test system (FX5200), this yields a 15-30% performance improvement, depending on display size.

Changed 13 years ago by mark_kendall@…

Attachment: opengl_3textures.diff added

Use 3 textures for frame upload/colour conversion

comment:14 Changed 13 years ago by danielk

Resolution: fixed
Status: newclosed

(In [13287]) Refs #2287. Fixes #3044. Fixes #2649. OpenGL video renderer improvements and fixes.

This improves the speed of the YUV->RGB conversion by accessing the texels with greater coherency. This fixes removes a doubled call to the resize filter. This avoids a segfault by leaking some memory (temporary fix).

comment:15 Changed 13 years ago by danielk

(In [13548]) Refs #2287. Refs #2649. Fixes a bug in XvMC-OpenGL introduced by [12708].

We changed to using glTexSubImage2D() to fill the OSD texture, but we're losing the alpha so it covers up the video. This changes back to using glTexImage2D().

Note: See TracTickets for help on using tickets.