Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#8621 closed Developer Task (Won't Fix)

Add VDA support

Reported by: markk Owned by: JYA
Priority: minor Milestone: unknown
Component: MythTV - Video Playback Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no


This is a tracking ticket for adding VDA hardware accelerated H.264 decoding for Mac OS X

Change History (12)

comment:1 Changed 10 years ago by markk

Owner: changed from Janne Grunau to markk
Status: newaccepted

comment:2 Changed 10 years ago by markk

Milestone: unknown0.24

comment:3 Changed 10 years ago by markk

(In [25571]) Add support for the VideoDecodeAcceleration? framework on OS X.

This enables video acceleration on certain hardware when running OS X 10.6.3 and above (see

There are 2 outstanding issues:-

  • there is no interlaced and repeat picture detection (and hence no deinterlacing). This will require some additional parsing or perhaps a tie in into the existing H264 parser.
  • some H264 broadcast streams are broken. So far the only problem seems to be BBC HD.

Implementation wise, the VDA library is loaded dynamically in order to simplify package management (the framework is only available on newer versions of OS X) and the additional privatedecoder_vda_defs file replicates the required elements of the framework headers as the headers are currently private.

There is a clear performance improvement, though nothing approaching the gains seen with, for example, VDPAU on the same hardware - no doubt due to the additional overhead of transferring the frames back into main memory (and back to GPU memory again).

The interaction with the Quartz video renderer is untested.

Refs #8621.

comment:4 Changed 10 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

comment:5 Changed 10 years ago by anonymous

comment:6 Changed 10 years ago by markk

Milestone: 0.240.25

Pushing back completion to 0.25 as there are unresolved issues and hence VDA decoding will need to be flagged as experimental for 0.24.

Current issues are:-

  • certain broadcast streams will fail a short period into decoding, usually somewhere between 16 and 30 frames. Possibly reference frame related. Offenders include BBC HD and hdpvr output.
  • interlaced detection is not working
  • av sync issues on some streams (probably need to get tralph on the case to fix some timestamp ordering)

comment:7 Changed 10 years ago by markk

(In [26593]) Improved av sync with the VDA decoder. We now use the pts exclusively and force AvFormatDecoder? to use reordered pts timestamps. Thanks to tralph for the suggestions. Refs #8621

comment:8 Changed 10 years ago by stuartm

Milestone: 0.25

Milestone 0.25 deleted

comment:9 Changed 9 years ago by markk

Type: enhancementDeveloper Task

comment:10 Changed 8 years ago by markk

Owner: markk deleted
Status: acceptedassigned

comment:11 Changed 8 years ago by danielk

Resolution: Won't Fix
Status: assignedclosed

Without someone to work on this..

comment:12 Changed 8 years ago by JYA

Milestone: 0.25unknown
Owner: set to JYA

VDA decoding doesn't work with interlaced content. This results in various crashes, hang or kernel panic.

In 2c08a7d1788b4a8183a70c288be0cec46a3f36d0, I disabled VDA playback for interlaced content. While this is obviously a big downside as playing content such as BBC HD will just fail on all but the most powerful mac (mac mini 2010, macbook air 2011, entry-level MBP 13" all fail to play the BBC HD sample when using software decode).

How VDA will behave is dependent on the graphic adapter being used. Mark Kendall reported that it worked on his mac with a nvidia adapter (I don't know which nvidia that is). On my iMac with an ATI 6970M, I would only get the top half properly decoded, the bottom half stays green. On a 2011 macbook air with an intel HD3000, the whole picture decoded is green. On my mac mini 2010 with a nvidia 320M, it either hangs or cause a kernel panic

While obviously it would be nice to play interlaced content with VDA, if it's to get it to work only occasionally and get corrupted decoding, a crash or worse a kernel panic most of the time: there's no other choice.

The following bug report was submitted to Apple:

The VDA framework doesn't state anything in regards to interlaced videos. Experimentations prove that VDA doesn't handle it properly. However, creating the decoder doesn't fail.

When trying to decode h264 interlaced video, using the VDA framework will result in either a crash, a hang or a kernel panic.

The kernel panic can be consistently reproduced on a mac mini 2010 with a nvidia 320M graphic adapter.

The side-effects will vary depending on which video card you are using. ATI and Intel are more resistant to crashes. On nvidia, it's where the worst issues can be seen.

Examples of videos causing issues: Intel: only get green crap ATI: top half is good, bottom half is green nVidia 320M: hang for a while. Leave the machine in unstable state, you can't reboot it, put it to sleep. Hard reset is the only salvation.

Video sample that will cause consistently a kernel panic on nvidia 320M

Kernel panic backtrace on mac mini 2010 with 320M:

Interval Since Last Panic Report:  -21 sec
Panics Since Last Report:          1
Anonymous UUID:                    11D8A7A9-943C-4F2E-8804-1B81C62084DF

Sat Mar 17 23:01:01 2012
panic(cpu 1 caller 0xffffff80002c266d): Kernel trap at 0xffffff7f817e288d, type 14=page fault, registers:
CR0: 0x0000000080010033, CR2: 0x0000000000000000, CR3: 0x000000000c38a000, CR4: 0x0000000000000660
RAX: 0x0000000000000000, RBX: 0xffffff807325ba40, RCX: 0xffffff806dcef07c, RDX: 0x000000004b4b4b4b
RSP: 0xffffff807325b8c0, RBP: 0xffffff807325b8e0, RSI: 0xffffff807325ba40, RDI: 0xffffff80654bd000
R8:  0x000000000003ffe0, R9:  0x0000000000000001, R10: 0xffffff7f817970be, R11: 0xffffff80111f15e8
R12: 0xffffff800cabcd88, R13: 0xffffff80654bd000, R14: 0xffffff80654bd000, R15: 0x0000000000000000
RFL: 0x0000000000010246, RIP: 0xffffff7f817e288d, CS:  0x0000000000000008, SS:  0x0000000000000010
CR2: 0x0000000000000000, Error code: 0x0000000000000002, Faulting CPU: 0x1

Backtrace (CPU 1), Frame : Return Address
0xffffff807325b580 : 0xffffff8000220702 
0xffffff807325b600 : 0xffffff80002c266d 
0xffffff807325b7a0 : 0xffffff80002d7a1d 
0xffffff807325b7c0 : 0xffffff7f817e288d 
0xffffff807325b8e0 : 0xffffff7f8179a0b0 
0xffffff807325baa0 : 0xffffff7f817e2f68 
0xffffff807325bb60 : 0xffffff7f81797119 
0xffffff807325bbc0 : 0xffffff800065239e 
0xffffff807325bbe0 : 0xffffff8000652c7a 
0xffffff807325bc40 : 0xffffff800065341b 
0xffffff807325bd80 : 0xffffff80002a3b78 
0xffffff807325be80 : 0xffffff8000223006 
0xffffff807325beb0 : 0xffffff8000214829 
0xffffff807325bf10 : 0xffffff800021bb58 
0xffffff807325bf70 : 0xffffff80002aeb80 
0xffffff807325bfb0 : 0xffffff80002d8383 
      Kernel Extensions in backtrace:[61FD1644-DA39-3645-9380-7F490FB000DB]@0xffffff7f8178c000->0xffffff7f8184bfff

BSD process name corresponding to current thread: MythFrontend

Mac OS version:

Kernel version:
Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64
Kernel UUID: 7B6546C7-70E8-3ED8-A6C3-C927E4D3D0D6
System model name: Macmini4,1 (Mac-F2208EC8)

System uptime in nanoseconds: 113132298799
last loaded kext at 7277751980:	1.9.4d0 (addr 0xffffff7f81d8f000, size 28672)
last unloaded kext at 104747606707:	1.11 (addr 0xffffff7f81d1e000, size 24576)
loaded kexts:	1.9.4d0	3.0	1.59	2.0.4d2	100.12.42	2.1.7f9	122	3.5.9	1.0.26	2.1.7f9	7.1.8	1.5.3	1.0.0d1	7.0.0	1.2.2	4.7.5d4	312	1.0.0d1	1.0.0d1	33	3.0.3	2.0.1	4.8.9	4.5.0	1.5.0	1.1.4	3.0.8b2	513.20.19	2.2.0	4.5.8	4.4.5	1.4	1.6	1.4	1.7	1.4	1.5	167.3.0	3.2.30	1.1	167.3.0	1.0	1.0.0d11	2.1.7f9	2.1.7f9	2.1.7f9	7.1.8	7.1.8	2.2.4	80.0	4.0.3f12	10.0.5	1.0.0d22	1.8.6fc6	1.3	1.0.10d0	3.0.16	3.0.16	2.3.2	2.3.2	3.1.1d8	4.7.5d4	1.0.10d0	4.0.3f12	4.0.3f12	4.0.3f12	152.3	152.3	170.4	170.4	4.4.5	4.5.3	4.5.8	3.0.3	1.6	1.7	1.7	403	2.0.1	3.0.3	4.4.5	4.5.8	2.2.9	1.0.0d5	412.2	2.0	2.0.7	4.5.8	1.5.0	1.7.1	1.1	177.3	1.0.0d1	7	331.3	1.7	28.18	1.4	2.6.8	1.4
Model: Macmini4,1, BootROM MM41.0042.B00, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.65f2
Graphics: NVIDIA GeForce 320M, NVIDIA GeForce 320M, PCI, 256 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334648302D4346382020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334648302D4346382020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x93), Broadcom BCM43xx 1.0 (
Bluetooth: Version 4.0.3f12, 2 service, 18 devices, 1 incoming serial ports
Network Service: Ethernet, Ethernet, en0
Serial ATA Device: INTEL SSDSA2M040G2GC, 40.02 GB
Serial ATA Device: HL-DT-STDVDRW  GA32N
USB Device: Keyboard Hub, apple_vendor_id, 0x1006, 0x24400000 / 2
USB Device: Apple Keyboard, apple_vendor_id, 0x0220, 0x24420000 / 3
USB Device: Apple Optical USB Mouse, apple_vendor_id, 0x0304, 0x06400000 / 4
USB Device: BRCM2070 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x06600000 / 3
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8218, 0x06630000 / 7
USB Device: IR Receiver, apple_vendor_id, 0x8242, 0x06500000 / 2
Version 1, edited 8 years ago by JYA (previous) (next) (diff)
Note: See TracTickets for help on using tickets.