va: mpeg2dec: Using the current picture's surface when missing reference.

When missing the reference frames, we should not just discard the current
frame. Some streams have group of picture header. It is an optional header
that can be used immediately before a coded I-frame to indicate to the decoder
if the first consecutive B-pictures immediately following the coded I-frame can
be reconstructed properly in the case of a random access.
In that case, the B frames may miss the previous reference and can still be
correctly decoded. We also notice that the second field of the I frame may
be set to P type, and it only ref its first field.
We should not skip all those frames, and even the frame really misses the
reference frame, some manner such as inserting grey picture should be used
to handle these cases.

The driver crashes when it needs to access the reference picture while we set
forward_reference_picture or backward_reference_picture to VA_INVALID_ID. We
now set it to current picture to avoid this. This is just a temp manner.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1929>
This commit is contained in:
He Junyan 2020-12-30 23:29:47 +08:00 committed by Víctor Manuel Jáquez Leal
parent 41d2edc964
commit 4c66a0265c

View file

@ -459,7 +459,9 @@ gst_va_mpeg2_dec_start_picture (GstMpeg2Decoder * decoder,
prev_picture ? gst_mpeg2_picture_get_user_data (prev_picture) : NULL;
if (!prev_pic) {
GST_WARNING_OBJECT (self, "Missing the forward reference picture");
return FALSE;
pic_param.forward_reference_picture =
gst_va_decode_picture_get_surface (gst_mpeg2_picture_get_user_data
(picture));
} else {
pic_param.forward_reference_picture =
gst_va_decode_picture_get_surface (prev_pic);
@ -473,7 +475,9 @@ gst_va_mpeg2_dec_start_picture (GstMpeg2Decoder * decoder,
next_picture ? gst_mpeg2_picture_get_user_data (next_picture) : NULL;
if (!next_pic) {
GST_WARNING_OBJECT (self, "Missing the backward reference picture");
return FALSE;
pic_param.backward_reference_picture =
gst_va_decode_picture_get_surface (gst_mpeg2_picture_get_user_data
(picture));
} else {
pic_param.backward_reference_picture =
gst_va_decode_picture_get_surface (next_pic);