mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
decoder: h264: fix integration of second field into the DPB.
If the new picture to be added to the DPB is not a first field, then it shall be the second field of the previous picture that was added before. This removes the need for dpb_find_picture() now that we track the immediately preceding decoded picture, in decode order.
This commit is contained in:
parent
d4ccae8398
commit
06147100f2
1 changed files with 7 additions and 27 deletions
|
@ -759,23 +759,6 @@ dpb_evict(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture, guint i)
|
||||||
dpb_remove_index(decoder, i);
|
dpb_remove_index(decoder, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finds the frame store holding the supplied picture */
|
|
||||||
static gint
|
|
||||||
dpb_find_picture(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture)
|
|
||||||
{
|
|
||||||
GstVaapiDecoderH264Private * const priv = &decoder->priv;
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->dpb_count; i++) {
|
|
||||||
GstVaapiFrameStore * const fs = priv->dpb[i];
|
|
||||||
for (j = 0; j < fs->num_buffers; j++) {
|
|
||||||
if (fs->buffers[j] == picture)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finds the picture with the nearest previous POC and same structure */
|
/* Finds the picture with the nearest previous POC and same structure */
|
||||||
static gint
|
static gint
|
||||||
dpb_find_nearest_prev_poc(GstVaapiDecoderH264 *decoder,
|
dpb_find_nearest_prev_poc(GstVaapiDecoderH264 *decoder,
|
||||||
|
@ -1049,18 +1032,15 @@ dpb_add(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture)
|
||||||
// Check if picture is the second field and the first field is still in DPB
|
// Check if picture is the second field and the first field is still in DPB
|
||||||
if (GST_VAAPI_PICTURE_IS_INTERLACED(picture) &&
|
if (GST_VAAPI_PICTURE_IS_INTERLACED(picture) &&
|
||||||
!GST_VAAPI_PICTURE_IS_FIRST_FIELD(picture)) {
|
!GST_VAAPI_PICTURE_IS_FIRST_FIELD(picture)) {
|
||||||
const gint found_index = dpb_find_picture(decoder,
|
|
||||||
GST_VAAPI_PICTURE_H264(picture->base.parent_picture));
|
|
||||||
if (found_index >= 0)
|
|
||||||
return gst_vaapi_frame_store_add(priv->dpb[found_index], picture);
|
|
||||||
|
|
||||||
// ... also check the previous picture that was immediately output
|
|
||||||
fs = priv->prev_frames[picture->base.voc];
|
fs = priv->prev_frames[picture->base.voc];
|
||||||
if (fs && &fs->buffers[0]->base == picture->base.parent_picture) {
|
if (!fs || &fs->buffers[0]->base != picture->base.parent_picture)
|
||||||
|
return FALSE;
|
||||||
if (!gst_vaapi_frame_store_add(fs, picture))
|
if (!gst_vaapi_frame_store_add(fs, picture))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (fs->output_called)
|
||||||
return dpb_output(decoder, fs);
|
return dpb_output(decoder, fs);
|
||||||
}
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to output the previous frame again if it was not submitted yet
|
// Try to output the previous frame again if it was not submitted yet
|
||||||
|
|
Loading…
Reference in a new issue