From 39d1ab82e5a3ac30e5495c6b6773823c2ff56594 Mon Sep 17 00:00:00 2001 From: xylosper Date: Fri, 20 Sep 2013 22:55:13 +0900 Subject: vaapi: add vf_vavpp and use it for deinterlacing Merged from pull request #246 by xylosper. Minor cosmetic changes, some adjustments (compatibility with older libva versions), and manpage additions by wm4. Signed-off-by: wm4 --- video/vaapi.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 14 deletions(-) (limited to 'video/vaapi.h') diff --git a/video/vaapi.h b/video/vaapi.h index af6d7e70c4..fa87658391 100644 --- a/video/vaapi.h +++ b/video/vaapi.h @@ -3,8 +3,8 @@ #include #include - #include +#include /* Compatibility glue with VA-API >= 0.31 */ #if defined VA_CHECK_VERSION @@ -51,23 +51,72 @@ # define USE_VAAPI_SCALING 0 #endif -#include "mpvcore/mp_msg.h" +#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} -static inline bool check_va_status(VAStatus status, const char *msg) -{ - if (status != VA_STATUS_SUCCESS) { - mp_msg(MSGT_VO, MSGL_ERR, "[vaapi] %s: %s\n", msg, vaErrorStr(status)); - return false; - } - return true; -} +#include "mp_image.h" struct mp_vaapi_ctx { VADisplay display; - struct mp_image *(*get_surface)(struct mp_vaapi_ctx *ctx, int va_format, - int mp_format, int w, int h); - void (*flush)(struct mp_vaapi_ctx *ctx); - void *priv; // for VO + struct va_image_formats *image_formats; }; +struct va_surface_pool; +struct va_image_formats; + +struct va_surface { + VASurfaceID id; // VA_INVALID_ID if unallocated + int w, h, rt_format; // parameters of allocated image (0/0/-1 unallocated) + + struct va_surface_priv *p; +}; + +bool check_va_status(VAStatus status, const char *msg); + +int va_get_colorspace_flag(enum mp_csp csp); + +struct mp_vaapi_ctx *va_initialize(VADisplay *display); +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); +VAImageFormat * va_image_format_from_imgfmt(const struct va_image_formats *formats, int imgfmt); +bool va_image_map(VADisplay display, VAImage *image, struct mp_image *mpi); +bool va_image_unmap(VADisplay display, VAImage *image); + +struct va_surface_pool * va_surface_pool_alloc(VADisplay display, int rt_format); +void va_surface_pool_release(struct va_surface_pool *pool); +void va_surface_pool_releasep(struct va_surface_pool **pool); +void va_surface_pool_clear(struct va_surface_pool *pool); +bool va_surface_pool_reserve(struct va_surface_pool *pool, int count, int w, int h); +int va_surface_pool_rt_format(const struct va_surface_pool *pool); +struct va_surface * va_surface_pool_get(struct va_surface_pool *pool, int w, int h); +struct va_surface * va_surface_pool_get_by_imgfmt(struct va_surface_pool *pool, const struct va_image_formats *formats, int imgfmt, int w, int h); +struct mp_image * va_surface_pool_get_wrapped(struct va_surface_pool *pool, const struct va_image_formats *formats, int imgfmt, int w, int h); + +void va_surface_release(struct va_surface *surface); +void va_surface_releasep(struct va_surface **surface); +struct va_surface * va_surface_in_mp_image(struct mp_image *mpi); +struct mp_image * va_surface_wrap(struct va_surface *surface); // takes ownership +VASurfaceID va_surface_id(const struct va_surface *surface); +VASurfaceID va_surface_id_in_mp_image(const struct mp_image *mpi); +bool va_surface_upload(struct va_surface *surface, const struct mp_image *mpi); +struct mp_image * va_surface_download(const struct va_surface *surface, const struct va_image_formats *formats); + #endif -- cgit v1.2.3