mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
va: Add and use gst_va_base_dec_process_output().
This function will copy the frame, if it's needed, and will apply buffer flags. The function is used by all the decoders. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3480>
This commit is contained in:
parent
765adf5325
commit
de5b76a922
9 changed files with 72 additions and 55 deletions
|
@ -946,6 +946,8 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
{
|
||||
GstVaAV1Dec *self = GST_VA_AV1_DEC (decoder);
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
gboolean ret;
|
||||
|
||||
g_assert (picture->frame_hdr.show_frame ||
|
||||
picture->frame_hdr.show_existing_frame);
|
||||
|
@ -956,7 +958,7 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
|
||||
if (self->last_ret != GST_FLOW_OK) {
|
||||
gst_av1_picture_unref (picture);
|
||||
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
|
||||
gst_video_decoder_drop_frame (vdec, frame);
|
||||
return self->last_ret;
|
||||
}
|
||||
|
||||
|
@ -968,12 +970,12 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
frame->output_buffer = gst_buffer_ref (pic->gstbuffer);
|
||||
}
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, 0);
|
||||
gst_av1_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -1027,3 +1027,28 @@ fail:
|
|||
GST_ERROR_OBJECT (base, "Failed copy output buffer.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_va_base_dec_process_output (GstVaBaseDec * base, GstVideoCodecFrame * frame,
|
||||
GstVideoBufferFlags buffer_flags)
|
||||
{
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (base);
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
if (buffer_flags != 0) {
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
gboolean interlaced =
|
||||
(buffer_flags & GST_VIDEO_BUFFER_FLAG_INTERLACED) != 0;
|
||||
gboolean tff = (buffer_flags & GST_VIDEO_BUFFER_FLAG_TFF) != 0;
|
||||
|
||||
GST_TRACE_OBJECT (base,
|
||||
"apply buffer flags 0x%x (interlaced %d, top-field-first %d)",
|
||||
buffer_flags, interlaced, tff);
|
||||
#endif
|
||||
GST_BUFFER_FLAG_SET (frame->output_buffer, buffer_flags);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -132,5 +132,7 @@ void gst_va_base_dec_get_preferred_format_and_caps_features (Gs
|
|||
GstCapsFeatures ** capsfeatures);
|
||||
gboolean gst_va_base_dec_copy_output_buffer (GstVaBaseDec * base,
|
||||
GstVideoCodecFrame * codec_frame);
|
||||
|
||||
gboolean gst_va_base_dec_process_output (GstVaBaseDec * base,
|
||||
GstVideoCodecFrame * frame,
|
||||
GstVideoBufferFlags buffer_flags);
|
||||
G_END_DECLS
|
||||
|
|
|
@ -121,33 +121,24 @@ gst_va_h264_dec_output_picture (GstH264Decoder * decoder,
|
|||
{
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaH264Dec *self = GST_VA_H264_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
gboolean ret;
|
||||
|
||||
GST_LOG_OBJECT (self,
|
||||
"Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
|
||||
|
||||
if (self->last_ret != GST_FLOW_OK) {
|
||||
gst_h264_picture_unref (picture);
|
||||
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
|
||||
gst_video_decoder_drop_frame (vdec, frame);
|
||||
return self->last_ret;
|
||||
}
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
if (picture->buffer_flags != 0) {
|
||||
gboolean interlaced =
|
||||
(picture->buffer_flags & GST_VIDEO_BUFFER_FLAG_INTERLACED) != 0;
|
||||
gboolean tff = (picture->buffer_flags & GST_VIDEO_BUFFER_FLAG_TFF) != 0;
|
||||
|
||||
GST_TRACE_OBJECT (self,
|
||||
"apply buffer flags 0x%x (interlaced %d, top-field-first %d)",
|
||||
picture->buffer_flags, interlaced, tff);
|
||||
GST_BUFFER_FLAG_SET (frame->output_buffer, picture->buffer_flags);
|
||||
}
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
|
||||
gst_h264_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -232,7 +232,9 @@ gst_va_h265_dec_output_picture (GstH265Decoder * decoder,
|
|||
{
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaH265Dec *self = GST_VA_H265_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstVaDecodePicture *va_pic;
|
||||
gboolean ret;
|
||||
|
||||
va_pic = gst_h265_picture_get_user_data (picture);
|
||||
g_assert (va_pic->gstbuffer);
|
||||
|
@ -243,18 +245,18 @@ gst_va_h265_dec_output_picture (GstH265Decoder * decoder,
|
|||
if (self->last_ret != GST_FLOW_OK) {
|
||||
gst_h265_picture_unref (picture);
|
||||
_replace_previous_slice (self, NULL, 0);
|
||||
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
|
||||
gst_video_decoder_drop_frame (vdec, frame);
|
||||
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);
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
|
||||
gst_h265_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -327,12 +327,12 @@ static GstFlowReturn
|
|||
gst_va_jpeg_dec_output_picture (GstJpegDecoder * decoder,
|
||||
GstVideoCodecFrame * frame)
|
||||
{
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
if (gst_va_base_dec_process_output (base, frame, 0))
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
/* @XXX: Checks for drivers that can do color convertion to nv12
|
||||
|
|
|
@ -568,27 +568,18 @@ gst_va_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder,
|
|||
{
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
gboolean ret;
|
||||
|
||||
GST_LOG_OBJECT (self,
|
||||
"Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
if (picture->buffer_flags != 0) {
|
||||
gboolean interlaced =
|
||||
(picture->buffer_flags & GST_VIDEO_BUFFER_FLAG_INTERLACED) != 0;
|
||||
gboolean tff = (picture->buffer_flags & GST_VIDEO_BUFFER_FLAG_TFF) != 0;
|
||||
|
||||
GST_TRACE_OBJECT (self,
|
||||
"apply buffer flags 0x%x (interlaced %d, top-field-first %d)",
|
||||
picture->buffer_flags, interlaced, tff);
|
||||
GST_BUFFER_FLAG_SET (frame->output_buffer, picture->buffer_flags);
|
||||
}
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
|
||||
gst_mpeg2_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -445,6 +445,8 @@ gst_va_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
{
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaVp8Dec *self = GST_VA_VP8_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
gboolean ret;
|
||||
|
||||
GST_LOG_OBJECT (self,
|
||||
"Outputting picture %p (system_frame_number %d)",
|
||||
|
@ -452,16 +454,16 @@ gst_va_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
|
||||
if (self->last_ret != GST_FLOW_OK) {
|
||||
gst_vp8_picture_unref (picture);
|
||||
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
|
||||
gst_video_decoder_drop_frame (vdec, frame);
|
||||
return self->last_ret;
|
||||
}
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, 0);
|
||||
gst_vp8_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -506,15 +506,17 @@ gst_va_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
|||
{
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaVp9Dec *self = GST_VA_VP9_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
gboolean ret;
|
||||
|
||||
GST_LOG_OBJECT (self, "Outputting picture %p", picture);
|
||||
|
||||
if (base->copy_frames)
|
||||
gst_va_base_dec_copy_output_buffer (base, frame);
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, 0);
|
||||
gst_vp9_picture_unref (picture);
|
||||
|
||||
return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
|
||||
if (ret)
|
||||
return gst_video_decoder_finish_frame (vdec, frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static GstVp9Picture *
|
||||
|
|
Loading…
Reference in a new issue