From 05ec1c5f7dbcfa71d06cb9d4cc0bbca64c61167a Mon Sep 17 00:00:00 2001 From: dawidwesierski4 Date: Tue, 31 Dec 2024 13:27:47 +0100 Subject: [PATCH] Fix: Address review Syntax changes, fixing a bug where where 422 format was treated as 420. Syntax changes. Fix bug with shift in buffer. Fix bug with last 3 frames being stopped. --- ecosystem/gstreamer_plugin/gst_mtl_common.c | 2 +- ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c | 24 ++++++++++++++----- ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c | 18 +++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ecosystem/gstreamer_plugin/gst_mtl_common.c b/ecosystem/gstreamer_plugin/gst_mtl_common.c index 6d02f604..5a910d43 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_common.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_common.c @@ -12,7 +12,7 @@ gboolean gst_mtl_common_parse_input_finfo(const GstVideoFormatInfo* finfo, enum st_frame_fmt* fmt) { if (finfo->format == GST_VIDEO_FORMAT_v210) { *fmt = ST_FRAME_FMT_V210; - } else if (finfo->format == GST_VIDEO_FORMAT_I420_10LE) { + } else if (finfo->format == GST_VIDEO_FORMAT_I422_10LE) { *fmt = ST_FRAME_FMT_YUV422PLANAR10LE; } else { return FALSE; diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c b/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c index 8ad331f7..9d2be93c 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c @@ -83,10 +83,10 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st20p_rx_debug); #define GST_PACKAGE_ORIGIN "https://github.com/OpenVisualCloud/Media-Transport-Library" #endif #ifndef PACKAGE -#define PACKAGE "gst-mtl-rx-st20" +#define PACKAGE "gst-mtl-st20p-rx" #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.19.0.1" +#define PACKAGE_VERSION "1.0" #endif enum { @@ -529,6 +529,10 @@ static gboolean gst_mtl_st20p_rx_negotiate(GstBaseSrc* basesrc) { GstCaps* caps; info = gst_video_info_new(); + if (!info) { + GST_ERROR("Failed to allocate video info"); + return FALSE; + } /* * Convert boolean interlaced value to integer, @@ -540,15 +544,16 @@ static gboolean gst_mtl_st20p_rx_negotiate(GstBaseSrc* basesrc) { case ST_FRAME_FMT_V210: info->finfo = gst_video_format_get_info(GST_VIDEO_FORMAT_v210); break; - case ST20_FMT_YUV_420_10BIT: + case ST20_FMT_YUV_422_10BIT: info->finfo = gst_video_format_get_info(GST_VIDEO_FORMAT_I422_10LE); break; default: GST_ERROR("Unsupported pixel format"); + gst_video_info_free(info); return FALSE; } - caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "v210", "width", + caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, gst_video_format_to_string(info->finfo->format), "width", G_TYPE_INT, info->width, "height", G_TYPE_INT, info->height, "framerate", GST_TYPE_FRACTION, info->fps_n, 1, "interlace-mode", G_TYPE_BOOLEAN, src->interlaced, NULL); @@ -556,6 +561,8 @@ static gboolean gst_mtl_st20p_rx_negotiate(GstBaseSrc* basesrc) { if (!caps) caps = gst_pad_get_pad_template_caps(GST_BASE_SRC_PAD(basesrc)); if (gst_caps_is_empty(caps)) { + GST_ERROR("Failed to set caps: caps are empty"); + gst_video_info_free(info); gst_caps_unref(caps); return FALSE; } @@ -563,7 +570,8 @@ static gboolean gst_mtl_st20p_rx_negotiate(GstBaseSrc* basesrc) { ret = gst_pad_set_caps(GST_BASE_SRC_PAD(basesrc), caps); gst_caps_unref(caps); if (!ret) { - GST_ERROR("Failed to set caps"); + GST_ERROR("Failed to set caps error %d", ret); + gst_video_info_free(info); return FALSE; } @@ -580,7 +588,7 @@ static GstFlowReturn gst_mtl_st20p_rx_create(GstBaseSrc* basesrc, guint64 offset gint ret; gsize fill_size; - buf = gst_buffer_new_allocate(NULL, src->frame_size + 1, NULL); + buf = gst_buffer_new_allocate(NULL, src->frame_size, NULL); if (!buf) { GST_ERROR("Failed to allocate buffer"); return GST_FLOW_ERROR; @@ -603,8 +611,12 @@ static GstFlowReturn gst_mtl_st20p_rx_create(GstBaseSrc* basesrc, guint64 offset return GST_FLOW_EOS; } + gst_buffer_map(buf, &dest_info, GST_MAP_WRITE); + fill_size = gst_buffer_fill(buf, 0, frame->addr[0], src->frame_size); + GST_BUFFER_PTS (buf) = frame->timestamp; + gst_buffer_unmap(buf, &dest_info); if (fill_size != src->frame_size) { diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c b/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c index fbed8672..558a1bc6 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c @@ -82,11 +82,11 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st20p_tx_debug); #ifndef GST_PACKAGE_ORIGIN #define GST_PACKAGE_ORIGIN "https://github.com/OpenVisualCloud/Media-Transport-Library" #endif -#ifndef PACKAGE -#define PACKAGE "gst-mtl-st20-tx" +#ifndef PACKAGEf +#define PACKAGE "gst-mtl-st20p-tx" #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.1" +#define PACKAGE_VERSION "1.0" #endif enum { @@ -134,7 +134,6 @@ static GstFlowReturn gst_mtl_st20p_tx_chain(GstPad* pad, GstObject* parent, GstBuffer* buf); static gboolean gst_mtl_st20p_tx_start(GstBaseSink* bsink); -static gboolean gst_mtl_st20p_tx_stop(GstBaseSink* bsink); static void gst_mtl_st20p_tx_class_init(Gst_Mtl_St20p_TxClass* klass) { GObjectClass* gobject_class; @@ -526,7 +525,6 @@ static gboolean gst_mtl_st20p_tx_sink_event(GstPad* pad, GstObject* parent, ret = gst_pad_event_default(pad, parent, event); break; case GST_EVENT_EOS: - gst_mtl_st20p_tx_stop(GST_BASE_SINK(sink)); ret = gst_pad_event_default(pad, parent, event); gst_element_post_message(GST_ELEMENT(sink), gst_message_new_eos(GST_OBJECT(sink))); break; @@ -603,16 +601,6 @@ static void gst_mtl_st20p_tx_finalize(GObject* object) { } } -static gboolean gst_mtl_st20p_tx_stop(GstBaseSink* bsink) { - Gst_Mtl_St20p_Tx* sink = GST_MTL_ST20P_TX(bsink); - - if (sink->mtl_lib_handle) { - mtl_stop(sink->mtl_lib_handle); - } - - return true; -} - static gboolean plugin_init(GstPlugin* mtl_st20p_tx) { return gst_element_register(mtl_st20p_tx, "mtl_st20p_tx", GST_RANK_SECONDARY, GST_TYPE_MTL_ST20P_TX);