2009-02-14 17:57:47 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2013-08-06 20:41:30 +00:00
|
|
|
#include "mpvcore/mp_msg.h"
|
2009-02-14 17:57:47 +00:00
|
|
|
#include "libavutil/avutil.h"
|
2011-06-25 22:04:53 +00:00
|
|
|
#include <libavutil/pixdesc.h>
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/img_format.h"
|
2009-02-14 17:57:47 +00:00
|
|
|
#include "fmt-conversion.h"
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
int fmt;
|
2013-11-29 16:39:57 +00:00
|
|
|
enum AVPixelFormat pix_fmt;
|
2009-02-14 17:57:47 +00:00
|
|
|
} conversion_map[] = {
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_ARGB, AV_PIX_FMT_ARGB},
|
|
|
|
{IMGFMT_BGRA, AV_PIX_FMT_BGRA},
|
|
|
|
{IMGFMT_BGR24, AV_PIX_FMT_BGR24},
|
|
|
|
{IMGFMT_BGR16_BE, AV_PIX_FMT_RGB565BE},
|
|
|
|
{IMGFMT_BGR16_LE, AV_PIX_FMT_RGB565LE},
|
|
|
|
{IMGFMT_BGR15_BE, AV_PIX_FMT_RGB555BE},
|
|
|
|
{IMGFMT_BGR15_LE, AV_PIX_FMT_RGB555LE},
|
|
|
|
{IMGFMT_BGR12_BE, AV_PIX_FMT_RGB444BE},
|
|
|
|
{IMGFMT_BGR12_LE, AV_PIX_FMT_RGB444LE},
|
|
|
|
{IMGFMT_BGR8, AV_PIX_FMT_RGB8},
|
|
|
|
{IMGFMT_BGR4, AV_PIX_FMT_RGB4},
|
|
|
|
{IMGFMT_MONO, AV_PIX_FMT_MONOBLACK},
|
|
|
|
{IMGFMT_MONO_W, AV_PIX_FMT_MONOWHITE},
|
|
|
|
{IMGFMT_RGB4_BYTE, AV_PIX_FMT_BGR4_BYTE},
|
|
|
|
{IMGFMT_BGR4_BYTE, AV_PIX_FMT_RGB4_BYTE},
|
|
|
|
{IMGFMT_RGB48_LE, AV_PIX_FMT_RGB48LE},
|
|
|
|
{IMGFMT_RGB48_BE, AV_PIX_FMT_RGB48BE},
|
|
|
|
{IMGFMT_ABGR, AV_PIX_FMT_ABGR},
|
|
|
|
{IMGFMT_RGBA, AV_PIX_FMT_RGBA},
|
|
|
|
{IMGFMT_RGB24, AV_PIX_FMT_RGB24},
|
|
|
|
{IMGFMT_RGB16_BE, AV_PIX_FMT_BGR565BE},
|
|
|
|
{IMGFMT_RGB16_LE, AV_PIX_FMT_BGR565LE},
|
|
|
|
{IMGFMT_RGB15_BE, AV_PIX_FMT_BGR555BE},
|
|
|
|
{IMGFMT_RGB15_LE, AV_PIX_FMT_BGR555LE},
|
|
|
|
{IMGFMT_RGB12_BE, AV_PIX_FMT_BGR444BE},
|
|
|
|
{IMGFMT_RGB12_LE, AV_PIX_FMT_BGR444LE},
|
|
|
|
{IMGFMT_RGB8, AV_PIX_FMT_BGR8},
|
|
|
|
{IMGFMT_RGB4, AV_PIX_FMT_BGR4},
|
|
|
|
{IMGFMT_PAL8, AV_PIX_FMT_PAL8},
|
|
|
|
{IMGFMT_GBRP, AV_PIX_FMT_GBRP},
|
|
|
|
{IMGFMT_GBRP9_BE, AV_PIX_FMT_GBRP9BE},
|
|
|
|
{IMGFMT_GBRP9_LE, AV_PIX_FMT_GBRP9LE},
|
|
|
|
{IMGFMT_GBRP10_BE, AV_PIX_FMT_GBRP10BE},
|
|
|
|
{IMGFMT_GBRP10_LE, AV_PIX_FMT_GBRP10LE},
|
|
|
|
{IMGFMT_GBRP16_BE, AV_PIX_FMT_GBRP16BE},
|
|
|
|
{IMGFMT_GBRP16_LE, AV_PIX_FMT_GBRP16LE},
|
|
|
|
{IMGFMT_YUYV, AV_PIX_FMT_YUYV422},
|
|
|
|
{IMGFMT_UYVY, AV_PIX_FMT_UYVY422},
|
|
|
|
{IMGFMT_NV12, AV_PIX_FMT_NV12},
|
|
|
|
{IMGFMT_NV21, AV_PIX_FMT_NV21},
|
|
|
|
{IMGFMT_Y8, AV_PIX_FMT_GRAY8},
|
2012-12-26 23:58:45 +00:00
|
|
|
// Support really ancient ffmpeg versions (before e91946ed23dfbb)
|
2013-11-29 16:39:57 +00:00
|
|
|
// Newer versions use AV_PIX_FMT_GRAY8A
|
|
|
|
{IMGFMT_YA8, AV_PIX_FMT_Y400A},
|
|
|
|
{IMGFMT_Y16_LE, AV_PIX_FMT_GRAY16LE},
|
|
|
|
{IMGFMT_Y16_BE, AV_PIX_FMT_GRAY16BE},
|
|
|
|
{IMGFMT_410P, AV_PIX_FMT_YUV410P},
|
|
|
|
{IMGFMT_420P, AV_PIX_FMT_YUV420P},
|
|
|
|
{IMGFMT_411P, AV_PIX_FMT_YUV411P},
|
|
|
|
{IMGFMT_422P, AV_PIX_FMT_YUV422P},
|
|
|
|
{IMGFMT_444P, AV_PIX_FMT_YUV444P},
|
|
|
|
{IMGFMT_440P, AV_PIX_FMT_YUV440P},
|
|
|
|
|
|
|
|
{IMGFMT_420P16_LE, AV_PIX_FMT_YUV420P16LE},
|
|
|
|
{IMGFMT_420P16_BE, AV_PIX_FMT_YUV420P16BE},
|
|
|
|
{IMGFMT_420P9_LE, AV_PIX_FMT_YUV420P9LE},
|
|
|
|
{IMGFMT_420P9_BE, AV_PIX_FMT_YUV420P9BE},
|
|
|
|
{IMGFMT_420P10_LE, AV_PIX_FMT_YUV420P10LE},
|
|
|
|
{IMGFMT_420P10_BE, AV_PIX_FMT_YUV420P10BE},
|
|
|
|
{IMGFMT_422P10_LE, AV_PIX_FMT_YUV422P10LE},
|
|
|
|
{IMGFMT_422P10_BE, AV_PIX_FMT_YUV422P10BE},
|
|
|
|
{IMGFMT_444P9_BE , AV_PIX_FMT_YUV444P9BE},
|
|
|
|
{IMGFMT_444P9_LE , AV_PIX_FMT_YUV444P9LE},
|
|
|
|
{IMGFMT_444P10_BE, AV_PIX_FMT_YUV444P10BE},
|
|
|
|
{IMGFMT_444P10_LE, AV_PIX_FMT_YUV444P10LE},
|
|
|
|
{IMGFMT_422P16_LE, AV_PIX_FMT_YUV422P16LE},
|
|
|
|
{IMGFMT_422P16_BE, AV_PIX_FMT_YUV422P16BE},
|
|
|
|
{IMGFMT_422P9_LE, AV_PIX_FMT_YUV422P9LE},
|
|
|
|
{IMGFMT_422P9_BE, AV_PIX_FMT_YUV422P9BE},
|
|
|
|
{IMGFMT_444P16_LE, AV_PIX_FMT_YUV444P16LE},
|
|
|
|
{IMGFMT_444P16_BE, AV_PIX_FMT_YUV444P16BE},
|
2009-02-19 12:19:55 +00:00
|
|
|
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
// YUVJ are YUV formats that use the full Y range. Decoder color range
|
|
|
|
// information is used instead. Deprecated in ffmpeg.
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_420P, AV_PIX_FMT_YUVJ420P},
|
|
|
|
{IMGFMT_422P, AV_PIX_FMT_YUVJ422P},
|
|
|
|
{IMGFMT_444P, AV_PIX_FMT_YUVJ444P},
|
|
|
|
{IMGFMT_440P, AV_PIX_FMT_YUVJ440P},
|
2009-02-19 12:19:55 +00:00
|
|
|
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_420AP, AV_PIX_FMT_YUVA420P},
|
2012-12-26 23:58:45 +00:00
|
|
|
|
2013-05-01 15:00:52 +00:00
|
|
|
#if LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52, 10, 0)
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_422AP, AV_PIX_FMT_YUVA422P},
|
|
|
|
{IMGFMT_444AP, AV_PIX_FMT_YUVA444P},
|
2012-12-26 23:58:45 +00:00
|
|
|
|
|
|
|
{IMGFMT_420AP9_BE, AV_PIX_FMT_YUVA420P9BE},
|
|
|
|
{IMGFMT_420AP9_LE, AV_PIX_FMT_YUVA420P9LE},
|
|
|
|
{IMGFMT_420AP10_BE, AV_PIX_FMT_YUVA420P10BE},
|
|
|
|
{IMGFMT_420AP10_LE, AV_PIX_FMT_YUVA420P10LE},
|
|
|
|
{IMGFMT_420AP16_BE, AV_PIX_FMT_YUVA420P16BE},
|
|
|
|
{IMGFMT_420AP16_LE, AV_PIX_FMT_YUVA420P16LE},
|
|
|
|
|
|
|
|
{IMGFMT_422AP9_BE, AV_PIX_FMT_YUVA422P9BE},
|
|
|
|
{IMGFMT_422AP9_LE, AV_PIX_FMT_YUVA422P9LE},
|
|
|
|
{IMGFMT_422AP10_BE, AV_PIX_FMT_YUVA422P10BE},
|
|
|
|
{IMGFMT_422AP10_LE, AV_PIX_FMT_YUVA422P10LE},
|
|
|
|
{IMGFMT_422AP16_BE, AV_PIX_FMT_YUVA422P16BE},
|
|
|
|
{IMGFMT_422AP16_LE, AV_PIX_FMT_YUVA422P16LE},
|
|
|
|
|
|
|
|
{IMGFMT_444AP9_BE, AV_PIX_FMT_YUVA444P9BE},
|
|
|
|
{IMGFMT_444AP9_LE, AV_PIX_FMT_YUVA444P9LE},
|
|
|
|
{IMGFMT_444AP10_BE, AV_PIX_FMT_YUVA444P10BE},
|
|
|
|
{IMGFMT_444AP10_LE, AV_PIX_FMT_YUVA444P10LE},
|
|
|
|
{IMGFMT_444AP16_BE, AV_PIX_FMT_YUVA444P16BE},
|
|
|
|
{IMGFMT_444AP16_LE, AV_PIX_FMT_YUVA444P16LE},
|
|
|
|
#endif
|
|
|
|
|
2013-05-01 14:16:03 +00:00
|
|
|
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52, 25, 0)
|
|
|
|
// Libav added this already at 52.10.0
|
|
|
|
{IMGFMT_XYZ12_LE, AV_PIX_FMT_XYZ12LE},
|
|
|
|
{IMGFMT_XYZ12_BE, AV_PIX_FMT_XYZ12BE},
|
|
|
|
#endif
|
|
|
|
|
2012-10-30 18:32:30 +00:00
|
|
|
// ffmpeg only
|
2013-11-29 16:39:57 +00:00
|
|
|
#if LIBAVUTIL_VERSION_MICRO >= 100
|
|
|
|
{IMGFMT_420P12_LE, AV_PIX_FMT_YUV420P12LE},
|
|
|
|
{IMGFMT_420P12_BE, AV_PIX_FMT_YUV420P12BE},
|
|
|
|
{IMGFMT_420P14_LE, AV_PIX_FMT_YUV420P14LE},
|
|
|
|
{IMGFMT_420P14_BE, AV_PIX_FMT_YUV420P14BE},
|
|
|
|
{IMGFMT_422P12_LE, AV_PIX_FMT_YUV422P12LE},
|
|
|
|
{IMGFMT_422P12_BE, AV_PIX_FMT_YUV422P12BE},
|
|
|
|
{IMGFMT_422P14_LE, AV_PIX_FMT_YUV422P14LE},
|
|
|
|
{IMGFMT_422P14_BE, AV_PIX_FMT_YUV422P14BE},
|
|
|
|
{IMGFMT_444P12_BE, AV_PIX_FMT_YUV444P12BE},
|
|
|
|
{IMGFMT_444P12_LE, AV_PIX_FMT_YUV444P12LE},
|
|
|
|
{IMGFMT_444P14_BE, AV_PIX_FMT_YUV444P14BE},
|
|
|
|
{IMGFMT_444P14_LE, AV_PIX_FMT_YUV444P14LE},
|
|
|
|
|
|
|
|
{IMGFMT_GBRP12_BE, AV_PIX_FMT_GBRP12BE},
|
|
|
|
{IMGFMT_GBRP12_LE, AV_PIX_FMT_GBRP12LE},
|
|
|
|
{IMGFMT_GBRP14_BE, AV_PIX_FMT_GBRP14BE},
|
|
|
|
{IMGFMT_GBRP14_LE, AV_PIX_FMT_GBRP14LE},
|
|
|
|
|
|
|
|
{IMGFMT_RGBA64_BE, AV_PIX_FMT_RGBA64BE},
|
|
|
|
{IMGFMT_RGBA64_LE, AV_PIX_FMT_RGBA64LE},
|
|
|
|
{IMGFMT_BGRA64_BE, AV_PIX_FMT_BGRA64BE},
|
|
|
|
{IMGFMT_BGRA64_LE, AV_PIX_FMT_BGRA64LE},
|
|
|
|
|
|
|
|
{IMGFMT_BGR0, AV_PIX_FMT_BGR0},
|
|
|
|
{IMGFMT_0RGB, AV_PIX_FMT_0RGB},
|
|
|
|
{IMGFMT_RGB0, AV_PIX_FMT_RGB0},
|
|
|
|
{IMGFMT_0BGR, AV_PIX_FMT_0BGR},
|
|
|
|
{IMGFMT_BGR0, AV_PIX_FMT_BGR0},
|
2013-11-05 20:59:26 +00:00
|
|
|
#else
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_BGR0, AV_PIX_FMT_BGRA},
|
|
|
|
{IMGFMT_0RGB, AV_PIX_FMT_ARGB},
|
|
|
|
{IMGFMT_RGB0, AV_PIX_FMT_RGBA},
|
|
|
|
{IMGFMT_0BGR, AV_PIX_FMT_ABGR},
|
|
|
|
{IMGFMT_BGR0, AV_PIX_FMT_BGRA},
|
2012-10-30 18:32:30 +00:00
|
|
|
#endif
|
2012-10-20 23:10:32 +00:00
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_AVCODEC_NEW_VDPAU_API
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-27 23:49:45 +00:00
|
|
|
{IMGFMT_VDPAU, AV_PIX_FMT_VDPAU},
|
|
|
|
#else
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_VDPAU_MPEG1, AV_PIX_FMT_VDPAU_MPEG1},
|
|
|
|
{IMGFMT_VDPAU_MPEG2, AV_PIX_FMT_VDPAU_MPEG2},
|
|
|
|
{IMGFMT_VDPAU_H264, AV_PIX_FMT_VDPAU_H264},
|
|
|
|
{IMGFMT_VDPAU_WMV3, AV_PIX_FMT_VDPAU_WMV3},
|
|
|
|
{IMGFMT_VDPAU_VC1, AV_PIX_FMT_VDPAU_VC1},
|
|
|
|
{IMGFMT_VDPAU_MPEG4, AV_PIX_FMT_VDPAU_MPEG4},
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-27 23:49:45 +00:00
|
|
|
// map to an arbitrary but existing vdpau format
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_VDPAU, AV_PIX_FMT_VDPAU_H264},
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-27 23:49:45 +00:00
|
|
|
#endif
|
video: add vaapi decode and output support
This is based on the MPlayer VA API patches. To be exact it's based on
a very stripped down version of commit f1ad459a263f8537f6c from
git://gitorious.org/vaapi/mplayer.git.
This doesn't contain useless things like benchmarking hacks and the
demo code for GLX interop. Also, unlike in the original patch, decoding
and video output are split into separate source files (the separation
between decoding and display also makes pixel format hacks unnecessary).
On the other hand, some features not present in the original patch were
added, like screenshot support.
VA API is rather bad for actual video output. Dealing with older libva
versions or the completely broken vdpau backend doesn't help. OSD is
low quality and should be rather slow. In some cases, only either OSD
or subtitles can be shown at the same time (because OSD is drawn first,
OSD is prefered).
Also, libva can't decide whether it accepts straight or premultiplied
alpha for OSD sub-pictures: the vdpau backend seems to assume
premultiplied, while a native vaapi driver uses straight. So I picked
straight alpha. It doesn't matter much, because the blending code for
straight alpha I added to img_convert.c is probably buggy, and ASS
subtitles might be blended incorrectly.
Really good video output with VA API would probably use OpenGL and the
GL interop features, but at this point you might just use vo_opengl.
(Patches for making HW decoding with vo_opengl have a chance of being
accepted.)
Despite these issues, decoding seems to work ok. I still got tearing
on the Intel system I tested (Intel(R) Core(TM) i3-2350M). It was also
tested with the vdpau vaapi wrapper on a nvidia system; however this
was rather broken. (Fortunately, there is no reason to use mpv's VAAPI
support over native VDPAU.)
2013-08-09 12:01:30 +00:00
|
|
|
|
2013-11-29 16:39:57 +00:00
|
|
|
{IMGFMT_VDA, AV_PIX_FMT_VDA_VLD},
|
|
|
|
{IMGFMT_VAAPI, AV_PIX_FMT_VAAPI_VLD},
|
video: add vaapi decode and output support
This is based on the MPlayer VA API patches. To be exact it's based on
a very stripped down version of commit f1ad459a263f8537f6c from
git://gitorious.org/vaapi/mplayer.git.
This doesn't contain useless things like benchmarking hacks and the
demo code for GLX interop. Also, unlike in the original patch, decoding
and video output are split into separate source files (the separation
between decoding and display also makes pixel format hacks unnecessary).
On the other hand, some features not present in the original patch were
added, like screenshot support.
VA API is rather bad for actual video output. Dealing with older libva
versions or the completely broken vdpau backend doesn't help. OSD is
low quality and should be rather slow. In some cases, only either OSD
or subtitles can be shown at the same time (because OSD is drawn first,
OSD is prefered).
Also, libva can't decide whether it accepts straight or premultiplied
alpha for OSD sub-pictures: the vdpau backend seems to assume
premultiplied, while a native vaapi driver uses straight. So I picked
straight alpha. It doesn't matter much, because the blending code for
straight alpha I added to img_convert.c is probably buggy, and ASS
subtitles might be blended incorrectly.
Really good video output with VA API would probably use OpenGL and the
GL interop features, but at this point you might just use vo_opengl.
(Patches for making HW decoding with vo_opengl have a chance of being
accepted.)
Despite these issues, decoding seems to work ok. I still got tearing
on the Intel system I tested (Intel(R) Core(TM) i3-2350M). It was also
tested with the vdpau vaapi wrapper on a nvidia system; however this
was rather broken. (Fortunately, there is no reason to use mpv's VAAPI
support over native VDPAU.)
2013-08-09 12:01:30 +00:00
|
|
|
|
2013-11-29 16:39:57 +00:00
|
|
|
{0, AV_PIX_FMT_NONE}
|
2009-02-14 17:57:47 +00:00
|
|
|
};
|
|
|
|
|
2013-11-29 16:39:57 +00:00
|
|
|
enum AVPixelFormat imgfmt2pixfmt(int fmt)
|
2009-02-14 17:57:47 +00:00
|
|
|
{
|
2013-01-17 15:10:26 +00:00
|
|
|
if (fmt == IMGFMT_NONE)
|
2013-11-29 16:39:57 +00:00
|
|
|
return AV_PIX_FMT_NONE;
|
2013-01-17 15:10:26 +00:00
|
|
|
|
2009-02-14 17:57:47 +00:00
|
|
|
int i;
|
2013-11-29 16:39:57 +00:00
|
|
|
enum AVPixelFormat pix_fmt;
|
2009-02-14 17:57:47 +00:00
|
|
|
for (i = 0; conversion_map[i].fmt; i++)
|
|
|
|
if (conversion_map[i].fmt == fmt)
|
|
|
|
break;
|
|
|
|
pix_fmt = conversion_map[i].pix_fmt;
|
2013-11-29 16:39:57 +00:00
|
|
|
if (pix_fmt == AV_PIX_FMT_NONE)
|
2012-12-14 20:33:54 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_V, "Unsupported format %s\n", vo_format_name(fmt));
|
2009-02-14 17:57:47 +00:00
|
|
|
return pix_fmt;
|
|
|
|
}
|
|
|
|
|
2013-11-29 16:39:57 +00:00
|
|
|
int pixfmt2imgfmt(enum AVPixelFormat pix_fmt)
|
2009-02-14 17:57:47 +00:00
|
|
|
{
|
2013-11-29 16:39:57 +00:00
|
|
|
if (pix_fmt == AV_PIX_FMT_NONE)
|
2013-01-17 15:10:26 +00:00
|
|
|
return IMGFMT_NONE;
|
|
|
|
|
2009-02-14 17:57:47 +00:00
|
|
|
int i;
|
2013-11-29 16:39:57 +00:00
|
|
|
for (i = 0; conversion_map[i].pix_fmt != AV_PIX_FMT_NONE; i++)
|
2009-02-14 17:57:47 +00:00
|
|
|
if (conversion_map[i].pix_fmt == pix_fmt)
|
|
|
|
break;
|
2011-06-25 22:04:53 +00:00
|
|
|
int fmt = conversion_map[i].fmt;
|
|
|
|
if (!fmt) {
|
|
|
|
const char *fmtname = av_get_pix_fmt_name(pix_fmt);
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %s (%d)\n",
|
|
|
|
fmtname ? fmtname : "INVALID", pix_fmt);
|
|
|
|
}
|
2009-02-14 17:57:47 +00:00
|
|
|
return fmt;
|
|
|
|
}
|