Commit 1c5acb4f authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi*: Do not render non-VLC_CODEC_VAAPI_SURFACE pictures.

Remove displaying of non VLC_CODEC_VAAPI_SURFACE pictures in VAAPI X11 vout output.
parent 6ae684bf
......@@ -425,9 +425,6 @@ static int DisplayPicture( vlc_va_t *p_external, picture_t *p_picture, AVFrame *
if (!p_picture->p_sys)
abort();
if (p_picture->p_sys->b_own_vout)
return VLC_SUCCESS;
/* FindSurface */
p_picture->p_sys->surface = FindSurface( p_external, i_surface_id );
if( !p_picture->p_sys->surface )
......
......@@ -49,7 +49,5 @@ struct picture_sys_t
/* subpicture */
vlc_va_subpicture_t *subpicture;
unsigned int i_sub; /* number of vlc_va_subpicures_t */
bool b_own_vout; /* surface owned by vout? */
};
#endif
......@@ -558,79 +558,6 @@ out_va_free:
return VLC_EGENERIC;
}
static VASurfaceID CopyPictureToVASurface(vout_display_t *vd, picture_t *picture, VAImage *image)
{
vout_display_sys_t *sys = vd->sys;
VASurfaceID surface = VA_INVALID_SURFACE;
VAStatus status;
status = vaCreateSurfaces(sys->conn->p_display,
picture->format.i_visible_width,
picture->format.i_visible_height,
VA_RT_FORMAT_YUV420,
1, &surface);
if (status != VA_STATUS_SUCCESS)
{
msg_Err(vd, "Failed to create display surface");
return VA_INVALID_ID;
}
image->image_id = VA_INVALID_ID;
int err = CopyPictureToVAImage(vd, picture, image, &sys->img_fmt);
if (err != VLC_SUCCESS)
return VA_INVALID_ID;
vout_display_place_t place;
vout_display_PlacePicture (&place, &vd->source, vd->cfg, false);
status = vaPutImage(sys->conn->p_display,
surface,
image->image_id,
picture->format.i_x_offset, picture->format.i_y_offset,
picture->format.i_width, picture->format.i_height,
place.x, place.y,
place.width, place.height);
if (status != VA_STATUS_SUCCESS)
return VA_INVALID_ID;
return surface;
}
static picture_sys_t *RenderImportPicture(vout_display_t *vd, picture_t *picture)
{
vout_display_sys_t *sys = vd->sys;
picture_sys_t *pic_sys = calloc(1, sizeof(picture_sys_t));
if (!pic_sys)
return NULL;
pic_sys->b_own_vout = true;
pic_sys->surface = calloc(1, sizeof(vlc_va_surface_t));
if (!pic_sys->surface)
{
free(pic_sys);
return NULL;
}
VAImage image;
image.buf = VA_INVALID_ID;
image.image_id = VA_INVALID_ID;
pic_sys->surface->i_id = CopyPictureToVASurface(vd, picture, &image);
if (pic_sys->surface->i_id == VA_INVALID_SURFACE)
{
if (image.image_id != VA_INVALID_ID)
vaDestroyImage(sys->conn->p_display, image.image_id);
free(pic_sys->surface);
free(pic_sys);
return NULL;
}
if (image.image_id != VA_INVALID_ID)
vaDestroyImage(sys->conn->p_display, image.image_id);
pic_sys->surface->i_refcount = 1;
return pic_sys;
}
static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture, unsigned int i_region)
{
vout_display_sys_t *sys = vd->sys;
......@@ -733,27 +660,6 @@ static void PictureRelease(picture_t *picture)
picture->p_sys = NULL;
}
static void PictureReleaseVoutOwned(picture_t *picture)
{
assert(picture->format.i_chroma != VLC_CODEC_VAAPI_SURFACE);
if (!picture->p_sys->b_own_vout)
abort();
if (picture->i_refcount > 0)
picture->i_refcount--;
vlc_va_surface_t *surface = picture->p_sys->surface;
#if 0
/* FIXME: pictures discarded by core will leak VASurfaces */
if (surface->i_id != VA_INVALID_SURFACE)
vaDestroySurfaces(sys->conn->p_display, &surface->i_id, 1);
#endif
free(surface);
free(picture->p_sys);
picture->p_sys = NULL;
}
static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
if (!subpicture)
......@@ -771,16 +677,7 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
picture->p_sys->i_sub = 0;
}
if (picture->format.i_chroma != VLC_CODEC_VAAPI_SURFACE)
{
assert(picture->p_sys);
picture->p_sys = RenderImportPicture(vd, picture);
if (!picture->p_sys)
return;
assert(picture->p_sys->surface);
assert(picture->pf_release == NULL);
picture->pf_release = PictureReleaseVoutOwned;
}
assert(picture->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
if (!picture->p_sys->surface)
return;
......@@ -848,7 +745,6 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
if (pic->p_sys->surface == NULL)
{
assert(pic->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
assert(!pic->p_sys->b_own_vout);
msg_Err(vd, "Discarding picture without surface information: %p", pic);
if (pic->p_sys->subpicture)
SubpictureDestroy(vd, pic->p_sys->subpicture, pic->p_sys->i_sub);
......@@ -859,6 +755,7 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
picture_Release(pic);
return;
}
assert(pic->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
unsigned int i_order = (sys->i_display_order > 0) ?
sys->i_display_order++ : pic->p_sys->surface->i_order;
......@@ -884,16 +781,9 @@ cleanup:
if (subpicture)
subpicture_Delete(subpicture);
if (pic->p_sys->b_own_vout)
{
if (pic->p_sys->surface->i_id != VA_INVALID_SURFACE)
vaDestroySurfaces(sys->conn->p_display, &pic->p_sys->surface->i_id, 1);
}
ReleaseSurface(pic->p_sys->surface);
if (!pic->p_sys->b_own_vout)
pic->p_sys->surface = NULL;
pic->p_sys->surface = NULL;
pic->p_sys->subpicture = NULL;
pic->p_sys->i_sub = 0;
......@@ -930,7 +820,6 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
}
pic->format.i_chroma = VLC_CODEC_VAAPI_SURFACE;
sys->b_own_vout = false;
sys->subpicture = NULL;
sys->surface = NULL;
sys->i_sub = 0;
......
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