Commit fc1226e3 authored by Thomas Guillem's avatar Thomas Guillem

hw: vaapi: choose va formats/chromas from vlc chromas

parent f67d9330
......@@ -334,9 +334,10 @@ static int CreateDRM(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt
.i_visible_width = ctx->coded_width,
.i_visible_height = ctx->coded_height
};
VASurfaceID *surfaces;
sys->pool = vlc_vaapi_PoolNew(o, sys->va_inst, sys->hw_ctx.display, count,
&surfaces, &vfmt, VA_RT_FORMAT_YUV420, 0);
&surfaces, &vfmt, false);
if (!sys->pool)
goto error;
......
......@@ -304,8 +304,7 @@ vlc_vaapi_OpenChroma(vlc_object_t *obj)
filter_sys->dest_pics =
vlc_vaapi_PoolNew(obj, filter_sys->va_inst, filter_sys->dpy,
DEST_PICS_POOL_SZ, &filter_sys->va_surface_ids,
&filter->fmt_out.video, VA_RT_FORMAT_YUV420,
VA_FOURCC_NV12);
&filter->fmt_out.video, true);
if (!filter_sys->dest_pics)
{
vlc_vaapi_FilterReleaseInstance(filter, filter_sys->va_inst);
......
......@@ -383,14 +383,14 @@ Open(filter_t * filter,
vlc_vaapi_PoolNew(VLC_OBJECT(filter), filter_sys->va.inst,
filter_sys->va.dpy, DEST_PICS_POOL_SZ,
&filter_sys->va.surface_ids, &filter->fmt_out.video,
VA_RT_FORMAT_YUV420, VA_FOURCC_NV12);
true);
if (!filter_sys->dest_pics)
goto error;
filter_sys->va.conf =
vlc_vaapi_CreateConfigChecked(VLC_OBJECT(filter), filter_sys->va.dpy,
VAProfileNone, VAEntrypointVideoProc,
VA_FOURCC_NV12);
filter->fmt_out.video.i_chroma);
if (filter_sys->va.conf == VA_INVALID_ID)
goto error;
......
......@@ -55,6 +55,20 @@
} \
} while (0)
static void
vlc_chroma_to_vaapi(int i_vlc_chroma, unsigned *va_rt_format, int *va_fourcc)
{
switch (i_vlc_chroma)
{
case VLC_CODEC_VAAPI_420:
*va_rt_format = VA_RT_FORMAT_YUV420;
*va_fourcc = VA_FOURCC_NV12;
break;
default:
vlc_assert_unreachable();
}
}
/**************************
* VA instance management *
**************************/
......@@ -369,8 +383,15 @@ error:
VAConfigID
vlc_vaapi_CreateConfigChecked(vlc_object_t *o, VADisplay dpy,
VAProfile i_profile, VAEntrypoint entrypoint,
int va_force_fourcc)
int i_force_vlc_chroma)
{
int va_force_fourcc = 0;
if (i_force_vlc_chroma != 0)
{
unsigned unused;
vlc_chroma_to_vaapi(i_force_vlc_chroma, &unused, &va_force_fourcc);
}
if (!IsVaProfileSupported(dpy, i_profile))
{
msg_Err(o, "profile(%d) is not supported", i_profile);
......@@ -514,9 +535,12 @@ pic_sys_ctx_destroy_cb(struct picture_context_t *opaque)
picture_pool_t *
vlc_vaapi_PoolNew(vlc_object_t *o, struct vlc_vaapi_instance *va_inst,
VADisplay dpy, unsigned count, VASurfaceID **render_targets,
const video_format_t *restrict fmt,
unsigned va_rt_format, int va_force_fourcc)
const video_format_t *restrict fmt, bool b_force_fourcc)
{
unsigned va_rt_format;
int va_fourcc;
vlc_chroma_to_vaapi(fmt->i_chroma, &va_rt_format, &va_fourcc);
struct pic_sys_vaapi_instance *instance =
malloc(sizeof(*instance) + count * sizeof(VASurfaceID));
if (!instance)
......@@ -531,10 +555,10 @@ vlc_vaapi_PoolNew(vlc_object_t *o, struct vlc_vaapi_instance *va_inst,
.type = VASurfaceAttribPixelFormat,
.flags = VA_SURFACE_ATTRIB_SETTABLE,
.value.type = VAGenericValueTypeInteger,
.value.value.i = va_force_fourcc,
.value.value.i = b_force_fourcc ? va_fourcc : 0,
}
};
if (va_force_fourcc != 0)
if (b_force_fourcc)
{
attribs = fourcc_attribs;
num_attribs = 1;
......
......@@ -173,15 +173,14 @@ vlc_vaapi_EndPicture(vlc_object_t *o, VADisplay dpy, VAContextID ctx);
VAConfigID
vlc_vaapi_CreateConfigChecked(vlc_object_t *o, VADisplay dpy,
VAProfile i_profile, VAEntrypoint entrypoint,
int va_force_fourcc);
int i_force_vlc_chroma);
/* Create a pool backed by VASurfaceID. render_targets will destroyed once
* the pool and every pictures are released. */
picture_pool_t *
vlc_vaapi_PoolNew(vlc_object_t *o, struct vlc_vaapi_instance *vainst,
VADisplay dpy, unsigned count, VASurfaceID **render_targets,
const video_format_t *restrict fmt,
unsigned va_rt_format, int va_force_fourcc);
const video_format_t *restrict fmt, bool b_force_fourcc);
/* Get render targets from a pic_sys allocated by the vaapi pool (see
* vlc_vaapi_PoolNew()) */
......
......@@ -231,7 +231,7 @@ tc_vaegl_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count)
picture_pool_t *pool =
vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), priv->vainst, priv->vadpy,
requested_count, &priv->va_surface_ids, &tc->fmt,
VA_RT_FORMAT_YUV420, VA_FOURCC_NV12);
true);
if (!pool)
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment