diff options
author | Seungha Yang <seungha@centricular.com> | 2021-09-18 00:09:24 +0900 |
---|---|---|
committer | Nicolas Dufresne <nicolas@ndufresne.ca> | 2021-09-20 13:03:44 +0000 |
commit | e009e801788be672d97c12f5a416eddfd7f18c51 (patch) | |
tree | 728bdb15cc86113c5cb509cb810990d5e9856452 /sys | |
parent | aaeb76f09c5e3c83439fbfebfd15f36767b34f0d (diff) | |
download | gstreamer-plugins-bad-e009e801788be672d97c12f5a416eddfd7f18c51.tar.gz |
codecs: vp9decoder: Use GstFlowReturn everywhere
The same modification as that of VP8 decoder
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2528>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/d3d11/gstd3d11vp9dec.cpp | 48 | ||||
-rw-r--r-- | sys/nvcodec/gstnvvp9dec.c | 31 | ||||
-rw-r--r-- | sys/va/gstvavp9dec.c | 47 |
3 files changed, 70 insertions, 56 deletions
diff --git a/sys/d3d11/gstd3d11vp9dec.cpp b/sys/d3d11/gstd3d11vp9dec.cpp index b2e3faf9d..2e5482644 100644 --- a/sys/d3d11/gstd3d11vp9dec.cpp +++ b/sys/d3d11/gstd3d11vp9dec.cpp @@ -141,17 +141,17 @@ static gboolean gst_d3d11_vp9_dec_sink_event (GstVideoDecoder * decoder, GstEvent * event); /* GstVp9Decoder */ -static gboolean gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder, +static GstFlowReturn gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder, const GstVp9FrameHeader * frame_hdr); -static gboolean gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); static GstVp9Picture *gst_d3d11_vp9_dec_duplicate_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); -static gboolean gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder, GstVp9Picture * picture); -static gboolean gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb); -static gboolean gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture); static GstFlowReturn gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); @@ -347,7 +347,7 @@ gst_d3d11_vp9_dec_sink_event (GstVideoDecoder * decoder, GstEvent * event) return GST_VIDEO_DECODER_CLASS (parent_class)->sink_event (decoder, event); } -static gboolean +static GstFlowReturn gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder, const GstVp9FrameHeader * frame_hdr) { @@ -365,7 +365,7 @@ gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder, if (out_format == GST_VIDEO_FORMAT_UNKNOWN) { GST_ERROR_OBJECT (self, "Could not support profile %d", frame_hdr->profile); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } gst_video_info_set_format (&info, @@ -375,22 +375,22 @@ gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder, decoder->input_state, &info, (gint) frame_hdr->width, (gint) frame_hdr->height, NUM_OUTPUT_VIEW)) { GST_ERROR_OBJECT (self, "Failed to create decoder"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } /* Will be updated per decode_picture */ inner->last_frame_width = inner->last_frame_height = 0; inner->last_show_frame = FALSE; - return TRUE; + return GST_FLOW_OK; } -static gboolean +static GstFlowReturn gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture) { @@ -402,7 +402,7 @@ gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder, GST_VIDEO_DECODER (decoder)); if (!view_buffer) { GST_DEBUG_OBJECT (self, "No available output view buffer"); - return FALSE; + return GST_FLOW_FLUSHING; } GST_LOG_OBJECT (self, "New output view buffer %" GST_PTR_FORMAT, view_buffer); @@ -412,7 +412,7 @@ gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder, GST_LOG_OBJECT (self, "New VP9 picture %p", picture); - return TRUE; + return GST_FLOW_OK; } static GstVp9Picture * @@ -446,7 +446,7 @@ gst_d3d11_vp9_dec_duplicate_picture (GstVp9Decoder * decoder, return new_picture; } -static gboolean +static GstFlowReturn gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) { @@ -455,7 +455,7 @@ gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder, inner->bitstream_buffer.resize (0); - return TRUE; + return GST_FLOW_OK; } static ID3D11VideoDecoderOutputView * @@ -658,7 +658,7 @@ gst_d3d11_vp9_dec_copy_segmentation_params (GstD3D11Vp9Dec * self, } } -static gboolean +static GstFlowReturn gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb) { @@ -673,7 +673,7 @@ gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder, &view_id); if (!view) { GST_ERROR_OBJECT (self, "current picture does not have output view handle"); - return FALSE; + return GST_FLOW_ERROR; } memset (pic_params, 0, sizeof (DXVA_PicParams_VP9)); @@ -702,10 +702,10 @@ gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder, inner->last_frame_height = pic_params->height; inner->last_show_frame = TRUE; - return TRUE; + return GST_FLOW_OK; } -static gboolean +static GstFlowReturn gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) { GstD3D11Vp9Dec *self = GST_D3D11_VP9_DEC (decoder); @@ -718,14 +718,14 @@ gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) if (inner->bitstream_buffer.empty ()) { GST_ERROR_OBJECT (self, "No bitstream buffer to submit"); - return FALSE; + return GST_FLOW_ERROR; } view = gst_d3d11_vp9_dec_get_output_view_from_picture (self, picture, &view_id); if (!view) { GST_ERROR_OBJECT (self, "current picture does not have output view handle"); - return FALSE; + return GST_FLOW_ERROR; } memset (&input_args, 0, sizeof (GstD3D11DecodeInputStreamArgs)); @@ -751,8 +751,10 @@ gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) input_args.bitstream = &inner->bitstream_buffer[0]; input_args.bitstream_size = inner->bitstream_buffer.size (); - return gst_d3d11_decoder_decode_frame (inner->d3d11_decoder, - view, &input_args); + if (!gst_d3d11_decoder_decode_frame (inner->d3d11_decoder, view, &input_args)) + return GST_FLOW_ERROR; + + return GST_FLOW_OK; } static GstFlowReturn diff --git a/sys/nvcodec/gstnvvp9dec.c b/sys/nvcodec/gstnvvp9dec.c index 9b85730eb..e64b6e4c2 100644 --- a/sys/nvcodec/gstnvvp9dec.c +++ b/sys/nvcodec/gstnvvp9dec.c @@ -73,13 +73,13 @@ static gboolean gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder, GstQuery * query); /* GstVp9Decoder */ -static gboolean gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, +static GstFlowReturn gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, const GstVp9FrameHeader * frame_hdr); -static gboolean gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); static GstVp9Picture *gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); -static gboolean gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder, +static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb); static GstFlowReturn gst_nv_vp9_dec_output_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture); @@ -230,7 +230,7 @@ gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder, GstQuery * query) return GST_VIDEO_DECODER_CLASS (parent_class)->src_query (decoder, query); } -static gboolean +static GstFlowReturn gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, const GstVp9FrameHeader * frame_hdr) { @@ -254,7 +254,7 @@ gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, if (out_format == GST_VIDEO_FORMAT_UNKNOWN) { GST_ERROR_OBJECT (self, "Could not support profile %d", self->profile); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } gst_video_info_set_format (&info, out_format, self->width, self->height); @@ -262,22 +262,22 @@ gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, cudaVideoCodec_VP9, &info, self->width, self->height, NUM_OUTPUT_VIEW)) { GST_ERROR_OBJECT (self, "Failed to configure decoder"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } memset (&self->params, 0, sizeof (CUVIDPICPARAMS)); self->params.CodecSpecific.vp9.colorSpace = frame_hdr->color_space; - return TRUE; + return GST_FLOW_OK; } -static gboolean +static GstFlowReturn gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture) { @@ -287,7 +287,7 @@ gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder, nv_frame = gst_nv_decoder_new_frame (self->decoder); if (!nv_frame) { GST_ERROR_OBJECT (self, "No available decoder frame"); - return FALSE; + return GST_FLOW_ERROR; } GST_LOG_OBJECT (self, @@ -296,7 +296,7 @@ gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder, gst_vp9_picture_set_user_data (picture, nv_frame, (GDestroyNotify) gst_nv_decoder_frame_unref); - return TRUE; + return GST_FLOW_OK; } static GstNvDecoderFrame * @@ -338,7 +338,7 @@ gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder * decoder, return new_picture; } -static gboolean +static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb) { @@ -387,7 +387,7 @@ gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder, frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture); if (!frame) { GST_ERROR_OBJECT (self, "Decoder frame is unavailable"); - return FALSE; + return GST_FLOW_ERROR; } params->nBitstreamDataLen = picture->size; @@ -479,7 +479,10 @@ gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder, memcpy (vp9_params->segmentFeatureData, sp->feature_data, sizeof (sp->feature_data)); - return gst_nv_decoder_decode_picture (self->decoder, &self->params); + if (!gst_nv_decoder_decode_picture (self->decoder, &self->params)) + return GST_FLOW_ERROR; + + return GST_FLOW_OK; } static GstFlowReturn diff --git a/sys/va/gstvavp9dec.c b/sys/va/gstvavp9dec.c index 0a0913bd0..ee583df09 100644 --- a/sys/va/gstvavp9dec.c +++ b/sys/va/gstvavp9dec.c @@ -143,7 +143,7 @@ _get_profile (GstVaVp9Dec * self, GstVP9Profile profile) return VAProfileNone; } -static gboolean +static GstFlowReturn gst_va_vp9_new_sequence (GstVp9Decoder * decoder, const GstVp9FrameHeader * frame_hdr) { @@ -155,18 +155,18 @@ gst_va_vp9_new_sequence (GstVp9Decoder * decoder, profile = _get_profile (self, frame_hdr->profile); if (profile == VAProfileNone) - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; if (!gst_va_decoder_has_profile (base->decoder, profile)) { GST_ERROR_OBJECT (self, "Profile %s is not supported", gst_va_profile_name (profile)); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } rt_format = _get_rtformat (self, frame_hdr->profile, frame_hdr->bit_depth, frame_hdr->subsampling_x, frame_hdr->subsampling_y); if (rt_format == 0) - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; if (!gst_va_decoder_config_is_equal (base->decoder, profile, rt_format, frame_hdr->width, frame_hdr->height)) { @@ -183,14 +183,14 @@ gst_va_vp9_new_sequence (GstVp9Decoder * decoder, self->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; } } - return TRUE; + return GST_FLOW_OK; } -static gboolean +static GstFlowReturn _check_resolution_change (GstVaVp9Dec * self, GstVp9Picture * picture) { GstVaBaseDec *base = GST_VA_BASE_DEC (self); @@ -204,7 +204,7 @@ _check_resolution_change (GstVaVp9Dec * self, GstVp9Picture * picture) if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Resolution changed, but failed to" " negotiate with downstream"); - return FALSE; + return GST_FLOW_NOT_NEGOTIATED; /* @TODO: if negotiation fails, decoder should resize output * frame. For that we would need an auxiliar allocator, and @@ -212,10 +212,10 @@ _check_resolution_change (GstVaVp9Dec * self, GstVp9Picture * picture) } } - return TRUE; + return GST_FLOW_OK; } -static gboolean +static GstFlowReturn gst_va_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture) { @@ -225,8 +225,9 @@ gst_va_vp9_dec_new_picture (GstVp9Decoder * decoder, GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder); GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); - if (!_check_resolution_change (self, picture)) - return FALSE; + ret = _check_resolution_change (self, picture); + if (ret != GST_FLOW_OK) + return ret; ret = gst_video_decoder_allocate_output_frame (vdec, frame); if (ret != GST_FLOW_OK) @@ -240,13 +241,13 @@ gst_va_vp9_dec_new_picture (GstVp9Decoder * decoder, GST_LOG_OBJECT (self, "New va decode picture %p - %#x", pic, gst_va_decode_picture_get_surface (pic)); - return TRUE; + return GST_FLOW_OK; error: { GST_WARNING_OBJECT (self, "Failed to allocated output buffer, return %s", gst_flow_get_name (ret)); - return FALSE; + return ret; } } @@ -472,14 +473,17 @@ _fill_slice (GstVp9Decoder * decoder, GstVp9Picture * picture) sizeof (slice_param), (gpointer) picture->data, picture->size); } -static gboolean +static GstFlowReturn gst_va_vp9_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb) { - return _fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture); + if (_fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture)) + return GST_FLOW_OK; + + return GST_FLOW_ERROR; } -static gboolean +static GstFlowReturn gst_va_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) { GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); @@ -489,7 +493,10 @@ gst_va_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) va_pic = gst_vp9_picture_get_user_data (picture); - return gst_va_decoder_decode (base->decoder, va_pic); + if (!gst_va_decoder_decode (base->decoder, va_pic)) + return GST_FLOW_ERROR; + + return GST_FLOW_OK; } static GstFlowReturn @@ -516,8 +523,10 @@ gst_va_vp9_dec_duplicate_picture (GstVp9Decoder * decoder, GstVaDecodePicture *va_pic, *va_dup; GstVp9Picture *new_picture; - if (!_check_resolution_change (GST_VA_VP9_DEC (decoder), picture)) + if (_check_resolution_change (GST_VA_VP9_DEC (decoder), picture) != + GST_FLOW_OK) { return NULL; + } va_pic = gst_vp9_picture_get_user_data (picture); va_dup = gst_va_decode_picture_dup (va_pic); |