va: h265dec: Do not assign the frame->output_buffer until output_picture.

We may need to drop the slices such as RASL pictures with the NoRaslOutputFlag, so
the current picture of h265decoder may be freed. We should not assign the frame->
output_buffer too early until we really output it. Or, the later coming slices will
allocate another picture and trigger the assert of:
  gst_video_decoder_allocate_output_frame_with_params:
  assertion 'frame->output_buffer == NULL' failed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2421>
This commit is contained in:
He Junyan 2021-07-22 22:00:38 +08:00 committed by GStreamer Marge Bot
parent a79a756b79
commit 99636cd101

View file

@ -227,6 +227,10 @@ gst_va_h265_dec_output_picture (GstH265Decoder * decoder,
{
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
GstVaH265Dec *self = GST_VA_H265_DEC (decoder);
GstVaDecodePicture *va_pic;
va_pic = gst_h265_picture_get_user_data (picture);
g_assert (va_pic->gstbuffer);
GST_LOG_OBJECT (self,
"Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
@ -238,6 +242,8 @@ gst_va_h265_dec_output_picture (GstH265Decoder * decoder,
return self->last_ret;
}
gst_buffer_replace (&frame->output_buffer, va_pic->gstbuffer);
if (base->copy_frames)
gst_va_base_dec_copy_output_buffer (base, frame);
@ -842,13 +848,18 @@ gst_va_h265_dec_new_picture (GstH265Decoder * decoder,
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
GstVaH265Dec *self = GST_VA_H265_DEC (decoder);
GstVaDecodePicture *pic;
GstBuffer *output_buffer;
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
self->last_ret = gst_video_decoder_allocate_output_frame (vdec, frame);
if (self->last_ret != GST_FLOW_OK)
output_buffer = gst_video_decoder_allocate_output_buffer (vdec);
if (!output_buffer) {
self->last_ret = GST_FLOW_ERROR;
goto error;
}
self->last_ret = GST_FLOW_OK;
pic = gst_va_decode_picture_new (base->decoder, frame->output_buffer);
pic = gst_va_decode_picture_new (base->decoder, output_buffer);
gst_buffer_unref (output_buffer);
gst_h265_picture_set_user_data (picture, pic,
(GDestroyNotify) gst_va_decode_picture_free);