Commit 6c3d6973 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi*: move VASubpictures back to vlc_va_surface_t.

parent e8d4cca9
......@@ -430,7 +430,7 @@ static int DisplayPicture( vlc_va_t *p_external, picture_t *p_picture, AVFrame *
if( !p_picture->p_sys->surface )
abort();
assert(p_picture->p_sys->subpicture == NULL);
assert(p_picture->p_sys->surface->subpicture == NULL);
return VLC_SUCCESS;
}
......@@ -463,6 +463,13 @@ static int Get( vlc_va_t *p_external, AVFrame *p_ff )
p_surface->i_refcount++;
p_surface->i_order = p_va->i_surface_order++;
if (p_surface->subpicture)
SubpictureDestroy( p_va->conn, &p_surface->i_id,
p_surface->subpicture, p_surface->i_sub );
p_surface->subpicture = NULL;
p_surface->i_sub = 0;
/* */
for( int i = 0; i < 4; i++ )
{
......
......@@ -30,7 +30,6 @@ struct vlc_va_conn_t
typedef struct
{
VASubpictureID i_id; /* VASubpictureIDs */
VASurfaceID i_surface;
VAImage image;
} vlc_va_subpicture_t;
......@@ -39,16 +38,16 @@ typedef struct
VASurfaceID i_id;
int i_refcount;
unsigned int i_order;
/* subpicture */
vlc_va_subpicture_t *subpicture;
unsigned int i_sub; /* number of vlc_va_subpicures_t */
} vlc_va_surface_t;
struct picture_sys_t
{
/* surface */
vlc_va_surface_t *surface;
/* subpicture */
vlc_va_subpicture_t *subpicture;
unsigned int i_sub; /* number of vlc_va_subpicures_t */
};
void SubpictureDestroy( vlc_va_conn_t *p_connection, VASurfaceID *i_surface_id,
......
......@@ -356,7 +356,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
}
}
static VASubpictureID SubpictureCreate(vout_display_t *vd, const subpicture_t *subpicture,
static VASubpictureID SubpictureCreate(vout_display_t *vd, VASurfaceID *i_surface_id, const subpicture_t *subpicture,
const subpicture_region_t *region, vlc_va_subpicture_t *vasubpicture, const int flags)
{
vout_display_sys_t *sys = vd->sys;
......@@ -417,7 +417,7 @@ static VASubpictureID SubpictureCreate(vout_display_t *vd, const subpicture_t *s
/* Associate subpicture with surface */
status = vaAssociateSubpicture(sys->conn->p_display, subpic,
&vasubpicture->i_surface, 1, /* array of surfaces */
i_surface_id, 1, /* array of surfaces */
/* src rectangle */
src_left, src_top, src_right, src_bottom,
/* dest rectangle */
......@@ -510,11 +510,13 @@ out_va_free:
return VLC_EGENERIC;
}
static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture, unsigned int i_region)
static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture,
subpicture_t *subpicture, const unsigned int i_region)
{
vout_display_sys_t *sys = vd->sys;
vlc_va_surface_t *surface = picture->p_sys->surface;
assert(picture->p_sys->subpicture == NULL);
assert(surface->subpicture == NULL);
vlc_va_subpicture_t *vasubpic = (vlc_va_subpicture_t*) calloc(i_region, sizeof(vlc_va_subpicture_t));
if (!vasubpic)
......@@ -545,10 +547,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
vasubpic[i_sub].image.format.blue_mask = region->p_picture->format.i_bmask;
vasubpic[i_sub].image.format.green_mask = region->p_picture->format.i_gmask;
vasubpic[i_sub].i_surface = picture->p_sys->surface->i_id;
/* Create Subpicture */
vasubpic[i_sub].i_id = SubpictureCreate(vd, subpicture, region,
vasubpic[i_sub].i_id = SubpictureCreate(vd, &surface->i_id, subpicture, region,
&vasubpic[i_sub], sys->sflags);
if (vasubpic[i_sub].i_id == VA_INVALID_ID)
{
......@@ -561,8 +561,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
}
/* remember what was created, so it can be released in DisplayPicture() */
picture->p_sys->subpicture = vasubpic;
picture->p_sys->i_sub = i_sub;
surface->subpicture = vasubpic;
surface->i_sub = i_sub;
return VLC_SUCCESS;
}
......@@ -574,39 +574,44 @@ static void PictureRelease(picture_t *picture)
if (picture->p_sys)
{
vlc_va_conn_t *conn = vlc_va_get_conn();
vlc_va_subpicture_t *subpicture = picture->p_sys->subpicture;
vlc_va_surface_t *surface = picture->p_sys->surface;
vlc_va_subpicture_t *subpicture = surface->subpicture;
VAStatus status;
const int i_sub = picture->p_sys->i_sub;
for (int i = 0; i < i_sub; i++)
if (surface)
{
if ((subpicture[i].i_surface != VA_INVALID_SURFACE) &&
(subpicture[i].i_id != VA_INVALID_ID))
VAStatus status;
const int i_sub = surface->i_sub;
for (int i = 0; i < i_sub; i++)
{
status = vaDeassociateSubpicture(conn->p_display,
subpicture[i].i_id, &subpicture[i].i_surface, 1);
assert(status == VA_STATUS_SUCCESS);
if ((surface->i_id != VA_INVALID_SURFACE) &&
(subpicture[i].i_id != VA_INVALID_ID))
{
status = vaDeassociateSubpicture(conn->p_display,
subpicture[i].i_id, &surface->i_id, 1);
assert(status == VA_STATUS_SUCCESS);
}
if (subpicture[i].i_id != VA_INVALID_ID)
{
status = vaDestroySubpicture(conn->p_display, subpicture[i].i_id);
assert(status == VA_STATUS_SUCCESS);
}
if (subpicture[i].image.image_id != VA_INVALID_ID)
{
status = vaDestroyImage(conn->p_display,
subpicture[i].image.image_id);
assert(status == VA_STATUS_SUCCESS);
}
}
if (subpicture[i].i_id != VA_INVALID_ID)
{
status = vaDestroySubpicture(conn->p_display, subpicture[i].i_id);
assert(status == VA_STATUS_SUCCESS);
}
/* */
free(surface->subpicture);
surface->subpicture = NULL;
surface->i_sub = 0;
if (subpicture[i].image.image_id != VA_INVALID_ID)
{
status = vaDestroyImage(conn->p_display,
subpicture[i].image.image_id);
assert(status == VA_STATUS_SUCCESS);
}
picture->p_sys->surface = NULL;
}
free(picture->p_sys->subpicture);
/* */
picture->p_sys->i_sub = 0;
picture->p_sys->surface = NULL;
picture->p_sys->subpicture = NULL;
}
free(picture->p_sys);
picture->p_sys = NULL;
......@@ -623,13 +628,15 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
/* Cleanup for reclaimed surface */
if (picture->p_sys &&
picture->p_sys->subpicture &&
picture->p_sys->surface &&
picture->p_sys->surface->subpicture &&
(picture->format.i_chroma == VLC_CODEC_VAAPI_SURFACE))
{
SubpictureDestroy(sys->conn, &picture->p_sys->subpicture->i_surface,
picture->p_sys->subpicture, picture->p_sys->i_sub);
picture->p_sys->subpicture = NULL;
picture->p_sys->i_sub = 0;
vlc_va_surface_t *surface = picture->p_sys->surface;
SubpictureDestroy(sys->conn, &surface->i_id,
surface->subpicture, surface->i_sub);
surface->subpicture = NULL;
surface->i_sub = 0;
}
assert(picture->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
......@@ -701,48 +708,42 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
{
assert(pic->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
msg_Err(vd, "Discarding picture without surface information: %p", pic);
if (pic->p_sys->subpicture)
SubpictureDestroy(sys->conn, &pic->p_sys->subpicture->i_surface,
pic->p_sys->subpicture, pic->p_sys->i_sub);
if (subpicture)
subpicture_Delete(subpicture);
pic->p_sys->subpicture = NULL;
pic->p_sys->i_sub = 0;
picture_Release(pic);
return;
}
assert(pic->format.i_chroma == VLC_CODEC_VAAPI_SURFACE);
vlc_va_surface_t *surface = pic->p_sys->surface;
unsigned int i_order = (sys->i_display_order > 0) ?
sys->i_display_order++ : pic->p_sys->surface->i_order;
if ((i_order != pic->p_sys->surface->i_order) &&
sys->i_display_order++ : surface->i_order;
if ((i_order != surface->i_order) &&
(pic->format.i_chroma == VLC_CODEC_VAAPI_SURFACE))
{
/* Reset picture */
msg_Err(vd, "Reclaimed picture - id=%d, order=%d, refcount=%d (%p)",
pic->p_sys->surface->i_id, pic->p_sys->surface->i_order,
pic->p_sys->surface->i_refcount, pic);
if (pic->p_sys->surface->i_refcount > 1)
pic->p_sys->surface->i_refcount = 1;
surface->i_id, surface->i_order, surface->i_refcount, pic);
if (surface->i_refcount > 1)
surface->i_refcount = 1;
goto cleanup;
}
DisplayVASurface(vd, pic->p_sys->surface->i_id, pic);
DisplayVASurface(vd, surface->i_id, pic);
cleanup:
if (pic->p_sys->subpicture)
SubpictureDestroy(sys->conn, &pic->p_sys->subpicture->i_surface,
pic->p_sys->subpicture, pic->p_sys->i_sub);
if (surface->subpicture)
SubpictureDestroy(sys->conn, &surface->i_id,
surface->subpicture, surface->i_sub);
surface->subpicture = NULL;
if (subpicture)
subpicture_Delete(subpicture);
ReleaseSurface(pic->p_sys->surface);
ReleaseSurface(surface);
pic->p_sys->surface = NULL;
pic->p_sys->subpicture = NULL;
pic->p_sys->i_sub = 0;
picture_Release(pic);
}
......@@ -777,9 +778,7 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
}
pic->format.i_chroma = VLC_CODEC_VAAPI_SURFACE;
sys->subpicture = NULL;
sys->surface = NULL;
sys->i_sub = 0;
pic_array[count] = pic;
pic_array[count]->b_progressive = true;
......
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