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.
This commit is contained in:
Nicolas Dufresne 2020-03-03 15:21:07 -05:00 committed by Nicolas Dufresne
parent 56c3b40c30
commit 020ee62c59
3 changed files with 6 additions and 70 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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);