diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2022-11-23 18:14:30 +0100 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2022-12-01 18:54:14 +0000 |
commit | de5b76a922aa466fd86043ce97d782b832e1e48a (patch) | |
tree | 70818a2258517dd5fb4de218a7dc81fd850d409d | |
parent | 765adf5325e894b7e53ea73ec9782dadc2da1fa3 (diff) | |
download | gstreamer-de5b76a922aa466fd86043ce97d782b832e1e48a.tar.gz |
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>
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c | 12 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvabasedec.c | 25 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvabasedec.h | 4 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvah264dec.c | 23 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvah265dec.c | 12 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c | 8 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c | 21 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c | 12 | ||||
-rw-r--r-- | subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c | 10 |
9 files changed, 72 insertions, 55 deletions
diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c index 2c1bb79b92..fafddba468 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index 749c6a42c0..f4c8c1ac49 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -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; +} diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h index 47fa2ddcee..7cb645cb5b 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c index 559c5d5057..756e673477 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c index 45b6c78b7e..51da017879 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c index 2a00cb6643..0ceb04ad87 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c @@ -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); - return gst_video_decoder_finish_frame (vdec, 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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c index 06020e4910..1db97baf13 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c index 0b782317ba..2197000400 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c @@ -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 diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c index 136de0ca66..fce95abdae 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c @@ -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 * |