Commit 707d7b50 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi_x11.c: Cleanup

- Renamed PictureReleaseLocked to ReleaseSurfaceLocked
- Cleanup code paths
parent afc54207
...@@ -720,9 +720,9 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict ...@@ -720,9 +720,9 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
if (subpicture->b_ephemer) if (subpicture->b_ephemer)
return; return;
if (!picture->p_sys && if (picture->format.i_chroma != VLC_CODEC_VAAPI_SURFACE)
(picture->format.i_chroma != VLC_CODEC_VAAPI_SURFACE))
{ {
assert(picture->p_sys);
picture->p_sys = RenderImportPicture(vd, picture); picture->p_sys = RenderImportPicture(vd, picture);
if (!picture->p_sys) if (!picture->p_sys)
return; return;
...@@ -755,15 +755,10 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict ...@@ -755,15 +755,10 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
vlc_mutex_unlock(&picture->p_sys->surface->lock); vlc_mutex_unlock(&picture->p_sys->surface->lock);
} }
static void PictureReleaseLocked(picture_t *pic) static void ReleaseSurfaceLocked(vlc_va_surface_t *surface)
{ {
assert(pic); surface->i_refcount--;
assert(surface->i_refcount >= 0);
if (pic->p_sys && pic->p_sys->surface)
{
pic->p_sys->surface->i_refcount--;
assert(pic->p_sys->surface->i_refcount >= 0);
}
} }
static void DisplayVASurface(vout_display_t *vd, VASurfaceID surface, picture_t *picture) static void DisplayVASurface(vout_display_t *vd, VASurfaceID surface, picture_t *picture)
...@@ -822,35 +817,29 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub ...@@ -822,35 +817,29 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
pic->p_sys->surface->i_refcount, pic); pic->p_sys->surface->i_refcount, pic);
if (pic->p_sys->surface->i_refcount > 1) if (pic->p_sys->surface->i_refcount > 1)
pic->p_sys->surface->i_refcount = 1; pic->p_sys->surface->i_refcount = 1;
if (subpicture)
{ goto cleanup;
SubpictureDestroy(vd, pic->p_sys->surface);
subpicture_Delete(subpicture);
}
PictureReleaseLocked(pic);
vlc_mutex_unlock(&pic->p_sys->surface->lock);
pic->p_sys->surface = NULL;
picture_Release(pic);
return;
} }
DisplayVASurface(vd, pic->p_sys->surface->i_id, pic); DisplayVASurface(vd, pic->p_sys->surface->i_id, pic);
cleanup:
if (subpicture) if (subpicture)
{ {
SubpictureDestroy(vd, pic->p_sys->surface); SubpictureDestroy(vd, pic->p_sys->surface);
subpicture_Delete(subpicture); subpicture_Delete(subpicture);
} }
PictureReleaseLocked(pic);
vlc_mutex_unlock(&pic->p_sys->surface->lock);
if (pic->p_sys->b_own_vout) if (pic->p_sys->b_own_vout)
{ {
if (pic->p_sys->surface->i_id != VA_INVALID_SURFACE) if (pic->p_sys->surface->i_id != VA_INVALID_SURFACE)
vaDestroySurfaces(sys->conn->p_display, &pic->p_sys->surface->i_id, 1); vaDestroySurfaces(sys->conn->p_display, &pic->p_sys->surface->i_id, 1);
} }
else pic->p_sys->surface = NULL; ReleaseSurfaceLocked(pic->p_sys->surface);
vlc_mutex_unlock(&pic->p_sys->surface->lock);
if (!pic->p_sys->b_own_vout)
pic->p_sys->surface = NULL;
picture_Release(pic); picture_Release(pic);
} }
......
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