1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-21 22:30:22 +00:00
mpv/video
Stefano Pigozzi a9cb2dc1b8 video: add vda decode support (with hwaccel) and direct rendering
Decoding H264 using Video Decode Acceleration used the custom 'vda_h264_dec'
decoder in FFmpeg.

The Good: This new implementation has some advantages over the previous one:

 - It works with Libav: vda_h264_dec never got into Libav since they prefer
   client applications to use the hwaccel API.

 - It is way more efficient: in my tests this implementation yields a
   reduction of CPU usage of roughly ~50% compared to using `vda_h264_dec` and
   ~65-75% compared to h264 software decoding. This is mainly because
   `vo_corevideo` was adapted to perform direct rendering of the
   `CVPixelBufferRefs` created by the Video Decode Acceleration API Framework.

The Bad:
  - `vo_corevideo` is required to use VDA decoding acceleration.
  - only works with versions of ffmpeg/libav new enough (needs reference
    refcounting). That is FFmpeg 2.0+ and Libav's git master currently.

The Ugly: VDA was hardcoded to use UYVY (2vuy) for the uploaded video texture.
One one end this makes the code simple since Apple's OpenGL implementation
actually supports this out of the box. It would be nice to support other
output image formats and choose the best format depending on the input, or at
least making it configurable. My tests indicate that CPU usage actually
increases with a 420p IMGFMT output which is not what I would have expected.

NOTE: There is a small memory leak with old versions of FFmpeg and with Libav
since the CVPixelBufferRef is not automatically released when the AVFrame is
deallocated. This can cause leaks inside libavcodec for decoded frames that
are discarded before mpv wraps them inside a refcounted mp_image (this only
happens on seeks).
For frames that enter mpv's refcounting facilities, this is not a problem
since we rewrap the CVPixelBufferRef in our mp_image that properly forwards
CVPixelBufferRetain/CvPixelBufferRelease calls to the underying
CVPixelBufferRef.

So, for FFmpeg use something more recent than `b3d63995` for Libav the patch
was posted to the dev ML in July and in review since, apparently, the proposed
fix is rather hacky.
2013-08-22 12:13:30 +02:00
..
decode video: add vda decode support (with hwaccel) and direct rendering 2013-08-22 12:13:30 +02:00
filter vf_eq: fix behavior when changing parameters 2013-08-20 16:11:07 +02:00
out video: add vda decode support (with hwaccel) and direct rendering 2013-08-22 12:13:30 +02:00
csputils.c video: support setting libswscale chroma position 2013-07-25 23:03:20 +02:00
csputils.h video: support setting libswscale chroma position 2013-07-25 23:03:20 +02:00
fmt-conversion.c video: add vda decode support (with hwaccel) and direct rendering 2013-08-22 12:13:30 +02:00
fmt-conversion.h
image_writer.c core: move contents to mpvcore (2/2) 2013-08-06 22:52:31 +02:00
image_writer.h image_writer: Add PNG filter option (default "mixed") 2013-06-15 15:48:52 +02:00
img_format.c video: add vda decode support (with hwaccel) and direct rendering 2013-08-22 12:13:30 +02:00
img_format.h video: add vda decode support (with hwaccel) and direct rendering 2013-08-22 12:13:30 +02:00
img_fourcc.h
memcpy_pic.h
mp_image_pool.c core: move contents to mpvcore (2/2) 2013-08-06 22:52:31 +02:00
mp_image_pool.h mp_image_pool: make reference counting thread-safe 2013-07-28 19:25:07 +02:00
mp_image.c gl_video: handle non-mod-2 4:2:0 YUV video correctly 2013-08-06 21:46:47 +02:00
mp_image.h core: move contents to mpvcore (2/2) 2013-08-06 22:52:31 +02:00
sws_utils.c img_convert: add function to scale RGBA OSD images 2013-08-12 00:51:31 +02:00
sws_utils.h img_convert: add function to scale RGBA OSD images 2013-08-12 00:51:31 +02:00
vaapi.h vaapi: fix typo 2013-08-14 00:36:33 +02:00
vdpau_functions.inc vo_vdpau: allow setting colorkey 2013-08-17 20:06:20 +02:00
vdpau.c vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API 2013-07-28 19:25:07 +02:00
vdpau.h core: move contents to mpvcore (2/2) 2013-08-06 22:52:31 +02:00
vfcap.h core: simplify OSD capability handling, remove VFCAP_OSD 2013-03-01 11:16:01 +01:00