2013-08-12 21:59:47 +00:00
|
|
|
#ifndef MPV_VAAPI_H
|
|
|
|
#define MPV_VAAPI_H
|
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
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <inttypes.h>
|
2014-08-21 20:04:25 +00:00
|
|
|
#include <pthread.h>
|
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
|
|
|
#include <va/va.h>
|
2013-09-20 13:55:13 +00:00
|
|
|
#include <va/va_x11.h>
|
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
|
|
|
|
|
|
|
/* Compatibility glue with VA-API >= 0.31 */
|
|
|
|
#if defined VA_CHECK_VERSION
|
|
|
|
#if VA_CHECK_VERSION(0,31,0)
|
|
|
|
#define vaPutImage2 vaPutImage
|
|
|
|
#define vaAssociateSubpicture2 vaAssociateSubpicture
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Compatibility glue with VA-API >= 0.34 */
|
|
|
|
#if VA_CHECK_VERSION(0,34,0)
|
|
|
|
#include <va/va_compat.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Compatibility glue with upstream libva */
|
|
|
|
#ifndef VA_SDS_VERSION
|
|
|
|
#define VA_SDS_VERSION 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Compatibility glue with VA-API >= 0.30 */
|
|
|
|
#ifndef VA_INVALID_ID
|
|
|
|
#define VA_INVALID_ID 0xffffffff
|
|
|
|
#endif
|
|
|
|
#ifndef VA_FOURCC
|
|
|
|
#define VA_FOURCC(ch0, ch1, ch2, ch3) \
|
|
|
|
((uint32_t)(uint8_t)(ch0) | \
|
|
|
|
((uint32_t)(uint8_t)(ch1) << 8) | \
|
|
|
|
((uint32_t)(uint8_t)(ch2) << 16) | \
|
|
|
|
((uint32_t)(uint8_t)(ch3) << 24 ))
|
|
|
|
#endif
|
|
|
|
#if defined VA_SRC_BT601 && defined VA_SRC_BT709
|
|
|
|
# define USE_VAAPI_COLORSPACE 1
|
|
|
|
#else
|
|
|
|
# define USE_VAAPI_COLORSPACE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Compatibility glue with VA-API >= 0.31.1 */
|
|
|
|
#ifndef VA_SRC_SMPTE_240
|
|
|
|
#define VA_SRC_SMPTE_240 0x00000040
|
|
|
|
#endif
|
|
|
|
#if defined VA_FILTER_SCALING_MASK
|
|
|
|
# define USE_VAAPI_SCALING 1
|
|
|
|
#else
|
|
|
|
# define USE_VAAPI_SCALING 0
|
|
|
|
#endif
|
|
|
|
|
2013-09-20 13:55:13 +00:00
|
|
|
#ifndef VA_FOURCC_YV12
|
|
|
|
#define VA_FOURCC_YV12 0x32315659
|
|
|
|
#endif
|
|
|
|
#ifndef VA_FOURCC_IYUV
|
|
|
|
#define VA_FOURCC_IYUV 0x56555949
|
|
|
|
#endif
|
|
|
|
#ifndef VA_FOURCC_I420
|
|
|
|
#define VA_FOURCC_I420 VA_FOURCC('I', '4', '2', '0')
|
|
|
|
#endif
|
|
|
|
#ifndef VA_FOURCC_RGBX
|
|
|
|
#define VA_FOURCC_RGBX 0x58424752
|
|
|
|
#endif
|
|
|
|
#ifndef VA_FOURCC_BGRX
|
|
|
|
#define VA_FOURCC_BGRX 0x58524742
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define VA_STR_FOURCC(fcc) \
|
|
|
|
(const char[]){(fcc), (fcc) >> 8u, (fcc) >> 16u, (fcc) >> 24u, 0}
|
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-09-20 13:55:13 +00:00
|
|
|
#include "mp_image.h"
|
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-09-27 14:48:45 +00:00
|
|
|
struct mp_image_pool;
|
2013-12-21 17:11:01 +00:00
|
|
|
struct mp_log;
|
2013-09-27 14:48:45 +00:00
|
|
|
|
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
|
|
|
struct mp_vaapi_ctx {
|
2013-12-21 17:11:01 +00:00
|
|
|
struct mp_log *log;
|
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
|
|
|
VADisplay display;
|
2013-09-20 13:55:13 +00:00
|
|
|
struct va_image_formats *image_formats;
|
2014-08-21 20:04:25 +00:00
|
|
|
pthread_mutex_t lock;
|
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-12-21 17:11:01 +00:00
|
|
|
bool check_va_status(struct mp_log *log, VAStatus status, const char *msg);
|
|
|
|
|
|
|
|
#define CHECK_VA_STATUS(ctx, msg) check_va_status((ctx)->log, status, msg)
|
2013-09-20 13:55:13 +00:00
|
|
|
|
2014-08-21 20:04:25 +00:00
|
|
|
#define va_lock(ctx) pthread_mutex_lock(&(ctx)->lock)
|
|
|
|
#define va_unlock(ctx) pthread_mutex_unlock(&(ctx)->lock)
|
|
|
|
|
2013-09-20 13:55:13 +00:00
|
|
|
int va_get_colorspace_flag(enum mp_csp csp);
|
|
|
|
|
2013-12-21 17:11:01 +00:00
|
|
|
struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *log);
|
2013-09-20 13:55:13 +00:00
|
|
|
void va_destroy(struct mp_vaapi_ctx *ctx);
|
|
|
|
|
|
|
|
enum mp_imgfmt va_fourcc_to_imgfmt(uint32_t fourcc);
|
|
|
|
uint32_t va_fourcc_from_imgfmt(int imgfmt);
|
2015-01-21 21:12:30 +00:00
|
|
|
VAImageFormat * va_image_format_from_imgfmt(struct mp_vaapi_ctx *ctx, int imgfmt);
|
2013-12-21 17:11:01 +00:00
|
|
|
bool va_image_map(struct mp_vaapi_ctx *ctx, VAImage *image, struct mp_image *mpi);
|
|
|
|
bool va_image_unmap(struct mp_vaapi_ctx *ctx, VAImage *image);
|
2013-09-20 13:55:13 +00:00
|
|
|
|
2014-03-17 17:22:25 +00:00
|
|
|
void va_pool_set_allocator(struct mp_image_pool *pool, struct mp_vaapi_ctx *ctx,
|
|
|
|
int rt_format);
|
|
|
|
|
2014-03-17 17:22:35 +00:00
|
|
|
VASurfaceID va_surface_id(struct mp_image *mpi);
|
|
|
|
int va_surface_rt_format(struct mp_image *mpi);
|
|
|
|
struct mp_image *va_surface_download(struct mp_image *src,
|
|
|
|
struct mp_image_pool *pool);
|
2013-09-20 13:55:13 +00:00
|
|
|
|
2014-03-17 17:22:35 +00:00
|
|
|
int va_surface_alloc_imgfmt(struct mp_image *img, int imgfmt);
|
|
|
|
int va_surface_upload(struct mp_image *va_dst, struct mp_image *sw_src);
|
2014-03-17 17:22:25 +00:00
|
|
|
|
2014-05-27 23:37:53 +00:00
|
|
|
bool va_guess_if_emulated(struct mp_vaapi_ctx *ctx);
|
|
|
|
|
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
|
|
|
#endif
|