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>
{
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);
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;
}
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
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;
+}
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
{
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
{
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);
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
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
{
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
{
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)",
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
{
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 *