Commit dea831a9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI-X11: cleanup

parent f5b05c6b
......@@ -762,6 +762,7 @@ static int SubpictureRegionsLink(vout_display_t *vd, const picture_t *picture)
assert(cache->i_id > 0);
const int count = vlc_array_count(&cache->subpictures);
msg_Info(vd, "Subpicture cache count %d", vlc_array_count(&sys->cache));
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "link surface %d cache %d size %d",
surface->i_id, cache->i_id, count);
......@@ -818,7 +819,7 @@ static int SubpictureRegionsLink(vout_display_t *vd, const picture_t *picture)
cleanup:
/* Cleanup linked subpictures */
msg_Warn(vd, "unlink surface %d cache %d", surface->i_id, cache->i_id);
msg_Err(vd, "unlink surface %d cache %d", surface->i_id, cache->i_id);
for (int i = 0; i < i_sub; i++)
{
vasubpicture_cache_t *sub = vlc_array_item_at_index(&cache->subpictures, i);
......@@ -852,6 +853,8 @@ static void SubpictureRegionsUnlink(vout_display_t *vd, picture_t *picture)
vlc_mutex_lock(&sys->cache_lock);
assert(surface->i_cache > 0);
subpicture_cache_t *cache = cache_find(&sys->cache, surface->i_cache);
if (cache == NULL)
goto error;
......@@ -1040,7 +1043,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
cache->i_stop = subpicture->i_stop;
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "creating surface %d cache %d", surface->i_id, cache->i_id);
msg_Dbg(vd, "new subpicture %p prev %p cache %d surface %d",
subpicture, sys->render.prev_subpicture, cache->i_id, surface->i_id);
#endif
int i_sub = 0;
......@@ -1113,7 +1117,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
cleanup:
surface->i_cache = VA_INVALID_ID;
msg_Err(vd, "failed creating surface %d cache %d", surface->i_id, cache->i_id);
msg_Err(vd, "failed creating subpicture cache %d for surface %d",
cache->i_id, surface->i_id);
SubpictureCacheClean(vd, sys->conn, cache);
cache_destroy(cache);
cache = NULL;
......@@ -1128,35 +1133,26 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
assert(picture);
assert(subpicture);
picture_sys_t *surface = picture->p_sys;
vlc_mutex_lock(&sys->cache_lock);
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "reuse subpicture %p prev %p cache %d",
msg_Dbg(vd, "reuse subpicture %p prev %p cache %d surface %d",
subpicture, sys->render.prev_subpicture,
sys->render.i_cache);
sys->render.i_cache, surface->i_id);
#endif
subpicture_cache_t *cache = (subpicture_cache_t *) cache_find(&sys->cache, sys->render.i_cache);
if (cache == NULL)
{
msg_Dbg(vd, "did not find cached subpictures, resetting");
sys->render.i_cache = 0;
goto cleanup;
}
assert(cache->i_id > 0);
if ((cache->i_start != subpicture->i_start) &&
(cache->i_stop != subpicture->i_stop))
{
msg_Dbg(vd, "different cached subpictures, resetting");
goto cleanup;
}
/* Check if all subpictures region pictures match */
const int count = vlc_array_count(&cache->subpictures);
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "reuse surface %d cache %d size %d",
surface->i_id, cache->i_id, count);
#endif
int i_sub = 0;
subpicture_region_t *region;
for (region = subpicture->p_region; region != NULL; region = region->p_next)
......@@ -1196,6 +1192,8 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
cleanup:
/* Cannot reuse this cached subpicture */
msg_Err(vd, "cannot reuse cached subpicture %d for surface %d -- resetting",
cache->i_id, surface->i_id);
sys->render.i_cache = 0;
sys->render.prev_subpicture = NULL;
vlc_mutex_unlock(&sys->cache_lock);
......@@ -1223,10 +1221,8 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
{
/* Skip non-RGBA regions for now */
if (region->fmt.i_chroma == VLC_CODEC_RGBA)
{
i_region++;
}
}
if (i_region == 0)
return;
......@@ -1243,14 +1239,8 @@ again:
}
else
{
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "new subpicture %p prev %p", subpicture, sys->render.prev_subpicture);
#endif
if (RenderDirectSubpicture(vd, picture, subpicture) != VLC_SUCCESS)
{
msg_Err(vd, "failed rendering subtitles");
return;
}
sys->render.prev_subpicture = subpicture;
sys->render.i_start = subpicture->i_start;
sys->render.i_stop = subpicture->i_stop;
......
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