decoder: use POC to maintain the DPB.

Introduce a POC field in GstVaapiPicture so that to store simpler sequential
numbers. A signed 32-bit integer should be enough for 1 year of continuous
video streaming at 60 Hz.

Use this new POC value to maintain the DPB, instead of 64-bit timestamps.
This also aligns with H.264 that will be migrated to GstVaapiDpb infrastructure.
This commit is contained in:
Gwenole Beauchesne 2012-03-30 17:03:28 +02:00
parent d51bb87482
commit 75538bbc9b
4 changed files with 15 additions and 5 deletions

View file

@ -70,7 +70,7 @@ dpb_get_oldest(GstVaapiDpb *dpb, gboolean output)
GstVaapiPicture * const picture = dpb->pictures[i];
if ((GST_VAAPI_PICTURE_IS_OUTPUT(picture) ^ output) != 0)
continue;
if (picture->pts < dpb->pictures[lowest_pts_index]->pts)
if (picture->poc < dpb->pictures[lowest_pts_index]->poc)
lowest_pts_index = i;
}
return lowest_pts_index;
@ -164,7 +164,7 @@ gst_vaapi_dpb_base_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
while (dpb->num_pictures == dpb->max_pictures) {
for (i = 0; i < dpb->num_pictures; i++) {
if (!GST_VAAPI_PICTURE_IS_OUTPUT(picture) &&
dpb->pictures[i]->pts < picture->pts)
dpb->pictures[i]->poc < picture->poc)
break;
}
if (i == dpb->num_pictures)
@ -261,7 +261,7 @@ gst_vaapi_dpb_mpeg2_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
* - the oldest reference picture is replaced with the new reference picture
*/
if (G_LIKELY(dpb->num_pictures == 2)) {
index = (dpb->pictures[0]->pts > dpb->pictures[1]->pts);
index = (dpb->pictures[0]->poc > dpb->pictures[1]->poc);
ref_picture = dpb->pictures[index];
if (!GST_VAAPI_PICTURE_IS_OUTPUT(ref_picture)) {
if (!dpb_output(dpb, ref_picture))
@ -315,9 +315,9 @@ gst_vaapi_dpb_mpeg2_get_references(
ref_pictures[1] = NULL;
for (i = 0; i < dpb->num_pictures; i++) {
ref_picture = dpb->pictures[i];
index = ref_picture->pts > picture->pts;
index = ref_picture->poc > picture->poc;
picture_ptr = &ref_pictures[index];
if (!*picture_ptr || ((*picture_ptr)->pts > ref_picture->pts) == index)
if (!*picture_ptr || ((*picture_ptr)->poc > ref_picture->poc) == index)
*picture_ptr = ref_picture;
}

View file

@ -94,6 +94,12 @@ pts_get_duration(PTSGenerator *tsg, guint num_frames)
GST_SECOND * tsg->fps_d, tsg->fps_n);
}
static inline guint
pts_get_poc(PTSGenerator *tsg)
{
return tsg->gop_tsn + tsg->ovl_tsn * 1024 + tsg->lst_tsn;
}
static void
pts_set_framerate(PTSGenerator *tsg, guint fps_n, guint fps_d)
{
@ -647,6 +653,7 @@ decode_picture(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
/* Update presentation time */
pts = gst_adapter_prev_timestamp(priv->adapter, NULL);
picture->pts = pts_eval(&priv->tsg, pts, pic_hdr->tsn);
picture->poc = pts_get_poc(&priv->tsg);
return status;
}

View file

@ -106,6 +106,7 @@ gst_vaapi_picture_create(
picture->surface = gst_vaapi_surface_proxy_get_surface(picture->proxy);
picture->type = parent_picture->type;
picture->pts = parent_picture->pts;
picture->poc = parent_picture->poc;
// Copy all picture flags but "output"
GST_VAAPI_PICTURE_FLAG_SET(
@ -180,6 +181,7 @@ gst_vaapi_picture_init(GstVaapiPicture *picture)
picture->iq_matrix = NULL;
picture->bitplane = NULL;
picture->pts = GST_CLOCK_TIME_NONE;
picture->poc = 0;
}
GstVaapiPicture *

View file

@ -148,6 +148,7 @@ struct _GstVaapiPicture {
GstVaapiIqMatrix *iq_matrix;
GstVaapiBitPlane *bitplane;
GstClockTime pts;
gint32 poc;
guint structure;
};