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

vdpau: retain only VDPAU video context, not whole picture_t

The video output core does not deal with filters retaining pictures.
Also, this leaves more pictures for the decoder in the decoder pool.
parent 192bf986
...@@ -43,7 +43,14 @@ struct filter_sys_t ...@@ -43,7 +43,14 @@ struct filter_sys_t
VdpChromaType chroma; VdpChromaType chroma;
VdpYCbCrFormat format; VdpYCbCrFormat format;
picture_t *(*import)(filter_t *, picture_t *); picture_t *(*import)(filter_t *, picture_t *);
picture_t *history[MAX_PAST + 1 + MAX_FUTURE];
struct
{
vlc_vdp_video_field_t *field;
mtime_t date;
bool force;
} history[MAX_PAST + 1 + MAX_FUTURE];
struct struct
{ {
float brightness; float brightness;
...@@ -264,10 +271,10 @@ static void Flush(filter_t *filter) ...@@ -264,10 +271,10 @@ static void Flush(filter_t *filter)
filter_sys_t *sys = filter->p_sys; filter_sys_t *sys = filter->p_sys;
for (unsigned i = 0; i < MAX_PAST + MAX_FUTURE; i++) for (unsigned i = 0; i < MAX_PAST + MAX_FUTURE; i++)
if (sys->history[i] != NULL) if (sys->history[i].field != NULL)
{ {
picture_Release(sys->history[i]); sys->history[i].field->destroy(sys->history[i].field);
sys->history[i] = NULL; sys->history[i].field = NULL;
} }
} }
...@@ -466,15 +473,17 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src) ...@@ -466,15 +473,17 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
src = sys->import(filter, src); src = sys->import(filter, src);
/* Update history and take "present" picture */ /* Update history and take "present" picture field */
sys->history[MAX_PAST + MAX_FUTURE] = src; sys->history[MAX_PAST + MAX_FUTURE].field = vlc_vdp_video_detach(src);
src = sys->history[MAX_PAST]; sys->history[MAX_PAST + MAX_FUTURE].date = src->date;
sys->history[MAX_PAST + MAX_FUTURE].force = src->b_force;
picture_Release(src);
if (src == NULL) vlc_vdp_video_field_t *f = sys->history[MAX_PAST].field;
if (f == NULL)
goto skip; goto skip;
picture_CopyProperties(dst, src); dst->date = sys->history[MAX_PAST].date;
dst->b_force = sys->history[MAX_PAST].force;
vlc_vdp_video_field_t *f = src->context;
/* Enable/Disable features */ /* Enable/Disable features */
const VdpVideoMixerFeature features[] = { const VdpVideoMixerFeature features[] = {
...@@ -520,7 +529,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src) ...@@ -520,7 +529,7 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
/* Render video into output */ /* Render video into output */
VdpVideoMixerPictureStructure structure = f->structure; VdpVideoMixerPictureStructure structure = f->structure;
VdpVideoSurface past[MAX_PAST]; VdpVideoSurface past[MAX_PAST];
VdpVideoSurface surface = picture_GetVideoSurface(src); VdpVideoSurface surface = f->frame->surface;
VdpVideoSurface future[MAX_FUTURE]; VdpVideoSurface future[MAX_FUTURE];
VdpRect src_rect = { VdpRect src_rect = {
filter->fmt_in.video.i_x_offset, filter->fmt_in.video.i_y_offset, filter->fmt_in.video.i_x_offset, filter->fmt_in.video.i_y_offset,
...@@ -536,19 +545,13 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src) ...@@ -536,19 +545,13 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
for (unsigned i = 0; i < MAX_PAST; i++) for (unsigned i = 0; i < MAX_PAST; i++)
{ {
picture_t *pic = sys->history[(MAX_PAST - 1) - i]; f = sys->history[(MAX_PAST - 1) - i].field;
if (pic != NULL) past[i] = (f != NULL) ? f->frame->surface : VDP_INVALID_HANDLE;
past[i] = picture_GetVideoSurface(pic);
else
past[i] = VDP_INVALID_HANDLE;
} }
for (unsigned i = 0; i < MAX_FUTURE; i++) for (unsigned i = 0; i < MAX_FUTURE; i++)
{ {
picture_t *pic = sys->history[(MAX_PAST + 1) + i]; f = sys->history[(MAX_PAST + 1) + i].field;
if (pic != NULL) future[i] = (f != NULL) ? f->frame->surface : VDP_INVALID_HANDLE;
future[i] = picture_GetVideoSurface(pic);
else
future[i] = VDP_INVALID_HANDLE;
} }
err = vdp_video_mixer_render(sys->vdp, sys->mixer, VDP_INVALID_HANDLE, err = vdp_video_mixer_render(sys->vdp, sys->mixer, VDP_INVALID_HANDLE,
...@@ -564,10 +567,10 @@ skip: ...@@ -564,10 +567,10 @@ skip:
dst = NULL; dst = NULL;
} }
/* Forget old history */ f = sys->history[0].field;
if (sys->history[0] != NULL) if (f != NULL)
picture_Release(sys->history[0]); f->destroy(f); /* Release oldest field */
memmove(sys->history, sys->history + 1, memmove(sys->history, sys->history + 1, /* Advance history */
sizeof (sys->history[0]) * (MAX_PAST + MAX_FUTURE)); sizeof (sys->history[0]) * (MAX_PAST + MAX_FUTURE));
return dst; return dst;
...@@ -617,7 +620,7 @@ static int OutputOpen(vlc_object_t *obj) ...@@ -617,7 +620,7 @@ static int OutputOpen(vlc_object_t *obj)
* video pipeline. Thus capabilities should be checked earlier. */ * video pipeline. Thus capabilities should be checked earlier. */
for (unsigned i = 0; i < MAX_PAST + MAX_FUTURE; i++) for (unsigned i = 0; i < MAX_PAST + MAX_FUTURE; i++)
sys->history[i] = NULL; sys->history[i].field = NULL;
sys->procamp.brightness = 0.f; sys->procamp.brightness = 0.f;
sys->procamp.contrast = 1.f; sys->procamp.contrast = 1.f;
...@@ -635,7 +638,7 @@ static void OutputClose(vlc_object_t *obj) ...@@ -635,7 +638,7 @@ static void OutputClose(vlc_object_t *obj)
filter_t *filter = (filter_t *)obj; filter_t *filter = (filter_t *)obj;
filter_sys_t *sys = filter->p_sys; filter_sys_t *sys = filter->p_sys;
/*Flush(filter); -- core frees pictures for us! */ Flush(filter);
if (sys->mixer != VDP_INVALID_HANDLE) if (sys->mixer != VDP_INVALID_HANDLE)
vdp_video_mixer_destroy(sys->vdp, sys->mixer); vdp_video_mixer_destroy(sys->vdp, sys->mixer);
......
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