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

vdpau: simplify surface copy when deinterlacing

parent 59ab278d
......@@ -45,9 +45,9 @@ static picture_t *Deinterlace(filter_t *filter, picture_t *src)
vlc_vdp_video_field_t *f1 = src->context;
if (unlikely(f1 == NULL))
return src;
if (f1->structure != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
return src; /* cannot deinterlace twice */
#ifdef VOUT_CORE_GETS_A_CLUE
picture_t *dst = filter_NewPicture(filter);
#else
......@@ -55,12 +55,16 @@ static picture_t *Deinterlace(filter_t *filter, picture_t *src)
#endif
if (dst == NULL)
return src; /* cannot deinterlace without copying fields */
if (vlc_vdp_video_copy(dst, src) != VDP_STATUS_OK) // shallow copy
vlc_vdp_video_field_t *f2 = vlc_vdp_video_copy(f1); // shallow copy
if (unlikely(f2 == NULL))
{
picture_Release(dst);
return src;
}
picture_CopyProperties(dst, src);
dst->context = f2;
if (last_pts != VLC_TS_INVALID)
dst->date = (3 * src->date - last_pts) / 2;
......@@ -75,7 +79,6 @@ static picture_t *Deinterlace(filter_t *filter, picture_t *src)
assert(src->p_next == NULL);
src->p_next = dst;
vlc_vdp_video_field_t *f2 = dst->context;
if (src->b_progressive || src->b_top_field_first)
{
f1->structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
......
......@@ -94,21 +94,12 @@ VdpStatus vlc_vdp_video_attach(vdp_t *vdp, VdpVideoSurface surface,
return VDP_STATUS_OK;
}
VdpStatus vlc_vdp_video_copy(picture_t *restrict dst, picture_t *restrict src)
vlc_vdp_video_field_t *vlc_vdp_video_copy(vlc_vdp_video_field_t *fold)
{
vlc_vdp_video_field_t *fold = src->context;
vlc_vdp_video_frame_t *frame = fold->frame;
vlc_vdp_video_field_t *fnew = malloc(sizeof (*fnew));
if (unlikely(fnew == NULL))
return VDP_STATUS_RESOURCES;
assert(src->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_420
|| src->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_422);
assert(dst->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_420
|| dst->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_422);
assert(!picture_IsReferenced(dst));
assert(dst->context == NULL);
dst->context = fnew;
return NULL;
fnew->destroy = SurfaceDestroy;
fnew->frame = frame;
......@@ -117,7 +108,7 @@ VdpStatus vlc_vdp_video_copy(picture_t *restrict dst, picture_t *restrict src)
fnew->sharpen = fold->sharpen;
atomic_fetch_add(&frame->refs, 1);
return VDP_STATUS_OK;
return fnew;
}
vlc_vdp_video_field_t *vlc_vdp_video_detach(picture_t *pic)
......
......@@ -271,9 +271,10 @@ typedef struct vlc_vdp_video_field
VdpStatus vlc_vdp_video_attach(vdp_t *, VdpVideoSurface, picture_t *);
/**
* Copies the VDPAU video surface from a VLC picture into another VLC picture.
* Performs a shallow copy of a VDPAU video surface context
* (the underlying VDPAU video surface is shared).
*/
VdpStatus vlc_vdp_video_copy(picture_t *dst, picture_t *src);
vlc_vdp_video_field_t *vlc_vdp_video_copy(vlc_vdp_video_field_t *);
/**
* Detaches a VDPAU video surface as context from a VLC picture.
......
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