From 020ee62c593778cc7f68d5b7e91457c759a860d4 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 3 Mar 2020 15:21:07 -0500 Subject: [PATCH] d3d11: Use gst_video_decoder_get_frame() Now that the system_frame_number is saved on the pictures we can use gst_video_decoder_get_frame() helper instead of getting the full list and looping over it. --- sys/d3d11/gstd3d11h264dec.c | 25 ++----------------------- sys/d3d11/gstd3d11h265dec.c | 26 ++------------------------ sys/d3d11/gstd3d11vp9dec.c | 25 ++----------------------- 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/sys/d3d11/gstd3d11h264dec.c b/sys/d3d11/gstd3d11h264dec.c index 3f4c9da11b..c572637649 100644 --- a/sys/d3d11/gstd3d11h264dec.c +++ b/sys/d3d11/gstd3d11h264dec.c @@ -709,7 +709,6 @@ gst_d3d11_h264_dec_output_picture (GstH264Decoder * decoder, GstH264Picture * picture) { GstD3D11H264Dec *self = GST_D3D11_H264_DEC (decoder); - GList *pending_frames, *iter; GstVideoCodecFrame *frame = NULL; GstBuffer *output_buffer = NULL; GstFlowReturn ret; @@ -726,28 +725,8 @@ gst_d3d11_h264_dec_output_picture (GstH264Decoder * decoder, return FALSE; } - pending_frames = gst_video_decoder_get_frames (GST_VIDEO_DECODER (self)); - for (iter = pending_frames; iter; iter = g_list_next (iter)) { - GstVideoCodecFrame *tmp; - GstH264Picture *other_pic; - - tmp = (GstVideoCodecFrame *) iter->data; - other_pic = gst_video_codec_frame_get_user_data (tmp); - if (!other_pic) { - /* FIXME: what should we do here? */ - GST_WARNING_OBJECT (self, - "Codec frame %p does not have corresponding picture object", tmp); - continue; - } - - if (other_pic == picture) { - frame = gst_video_codec_frame_ref (tmp); - break; - } - } - - g_list_free_full (pending_frames, - (GDestroyNotify) gst_video_codec_frame_unref); + frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), + picture->system_frame_number); /* if downstream is d3d11 element and forward playback case, * expose our decoder view without copy. In case of reverse playback, however, diff --git a/sys/d3d11/gstd3d11h265dec.c b/sys/d3d11/gstd3d11h265dec.c index ac6b54316f..3adf085a6f 100644 --- a/sys/d3d11/gstd3d11h265dec.c +++ b/sys/d3d11/gstd3d11h265dec.c @@ -751,7 +751,6 @@ gst_d3d11_h265_dec_output_picture (GstH265Decoder * decoder, GstH265Picture * picture) { GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder); - GList *pending_frames, *iter; GstVideoCodecFrame *frame = NULL; GstBuffer *output_buffer = NULL; GstFlowReturn ret; @@ -768,29 +767,8 @@ gst_d3d11_h265_dec_output_picture (GstH265Decoder * decoder, return FALSE; } - pending_frames = gst_video_decoder_get_frames (GST_VIDEO_DECODER (self)); - - for (iter = pending_frames; iter; iter = g_list_next (iter)) { - GstVideoCodecFrame *tmp; - GstH265Picture *other_pic; - - tmp = (GstVideoCodecFrame *) iter->data; - other_pic = gst_video_codec_frame_get_user_data (tmp); - if (!other_pic) { - /* FIXME: what should we do here? */ - GST_WARNING_OBJECT (self, - "Codec frame %p does not have corresponding picture object", tmp); - continue; - } - - if (other_pic == picture) { - frame = gst_video_codec_frame_ref (tmp); - break; - } - } - - g_list_free_full (pending_frames, - (GDestroyNotify) gst_video_codec_frame_unref); + frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), + picture->system_frame_number); /* if downstream is d3d11 element and forward playback case, * expose our decoder view without copy. In case of reverse playback, however, diff --git a/sys/d3d11/gstd3d11vp9dec.c b/sys/d3d11/gstd3d11vp9dec.c index 9acb3cda0a..4b302787fb 100644 --- a/sys/d3d11/gstd3d11vp9dec.c +++ b/sys/d3d11/gstd3d11vp9dec.c @@ -568,7 +568,6 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder, GstVp9Picture * picture) { GstD3D11Vp9Dec *self = GST_D3D11_VP9_DEC (decoder); - GList *pending_frames, *iter; GstVideoCodecFrame *frame = NULL; GstBuffer *output_buffer = NULL; GstFlowReturn ret; @@ -584,28 +583,8 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder, return FALSE; } - pending_frames = gst_video_decoder_get_frames (GST_VIDEO_DECODER (self)); - for (iter = pending_frames; iter; iter = g_list_next (iter)) { - GstVideoCodecFrame *tmp; - GstVp9Picture *other_pic; - - tmp = (GstVideoCodecFrame *) iter->data; - other_pic = gst_video_codec_frame_get_user_data (tmp); - if (!other_pic) { - /* FIXME: what should we do here? */ - GST_WARNING_OBJECT (self, - "Codec frame %p does not have corresponding picture object", tmp); - continue; - } - - if (other_pic == picture) { - frame = gst_video_codec_frame_ref (tmp); - break; - } - } - - g_list_free_full (pending_frames, - (GDestroyNotify) gst_video_codec_frame_unref); + frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), + picture->system_frame_number); if (!picture->frame_hdr.show_frame) { GST_LOG_OBJECT (self, "Decode only picture %p", picture);