Commit 4589c309 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vdpau: video surface to output surface "chroma" conversion

This provides colour space conversion, cropping and scaling of existing
video surfaces (as would come from a hardware decoder).
parent 595575ff
...@@ -38,6 +38,7 @@ struct filter_sys_t ...@@ -38,6 +38,7 @@ struct filter_sys_t
VdpVideoMixer mixer; VdpVideoMixer mixer;
VdpChromaType chroma; VdpChromaType chroma;
VdpYCbCrFormat format; VdpYCbCrFormat format;
VdpVideoSurface (*import)(filter_t *, picture_t *);
}; };
/** Create VDPAU video mixer */ /** Create VDPAU video mixer */
...@@ -183,6 +184,19 @@ static VdpVideoSurface VideoImport(filter_t *filter, picture_t *src) ...@@ -183,6 +184,19 @@ static VdpVideoSurface VideoImport(filter_t *filter, picture_t *src)
return surface; return surface;
} }
static VdpVideoSurface VideoPassthrough(filter_t *filter, picture_t *src)
{
vlc_vdp_video_t *psys = src->context;
if (unlikely(psys == NULL))
{
msg_Err(filter, "corrupt VDPAU video surface");
return VDP_INVALID_HANDLE;
}
/* FIXME: deal with mismatched VDPAU devices */
return psys->surface;
}
static picture_t *MixerRender(filter_t *filter, picture_t *src) static picture_t *MixerRender(filter_t *filter, picture_t *src)
{ {
filter_sys_t *sys = filter->p_sys; filter_sys_t *sys = filter->p_sys;
...@@ -192,7 +206,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src) ...@@ -192,7 +206,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
goto out; goto out;
picture_CopyProperties(dst, src); picture_CopyProperties(dst, src);
VdpVideoSurface surface = VideoImport(filter, src); VdpVideoSurface surface = sys->import(filter, src);
if (surface == VDP_INVALID_HANDLE) if (surface == VDP_INVALID_HANDLE)
goto drop; goto drop;
...@@ -214,6 +228,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src) ...@@ -214,6 +228,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
NULL, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, NULL, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME,
0, NULL, surface, 0, NULL, &src_rect, 0, NULL, surface, 0, NULL, &src_rect,
output, &dst_rect, NULL, 0, NULL); output, &dst_rect, NULL, 0, NULL);
if (sys->import != VideoPassthrough)
vdp_video_surface_destroy(sys->vdp, surface); vdp_video_surface_destroy(sys->vdp, surface);
if (err != VDP_STATUS_OK) if (err != VDP_STATUS_OK)
{ {
...@@ -241,8 +256,22 @@ static int OutputOpen(vlc_object_t *obj) ...@@ -241,8 +256,22 @@ static int OutputOpen(vlc_object_t *obj)
sys->vdp = NULL; sys->vdp = NULL;
sys->mixer = VDP_INVALID_HANDLE; sys->mixer = VDP_INVALID_HANDLE;
if (!vlc_fourcc_to_vdp_ycc(filter->fmt_in.video.i_chroma, if (filter->fmt_in.video.i_chroma == VLC_CODEC_VDPAU_VIDEO_422)
{
sys->chroma = VDP_CHROMA_TYPE_422;
sys->import = VideoPassthrough;
}
else
if (filter->fmt_in.video.i_chroma == VLC_CODEC_VDPAU_VIDEO_420)
{
sys->chroma = VDP_CHROMA_TYPE_420;
sys->import = VideoPassthrough;
}
else
if (vlc_fourcc_to_vdp_ycc(filter->fmt_in.video.i_chroma,
&sys->chroma, &sys->format)) &sys->chroma, &sys->format))
sys->import = VideoImport;
else
{ {
free(sys); free(sys);
return VLC_EGENERIC; return VLC_EGENERIC;
......
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