Skip to content

Commit

Permalink
Fix: Address review
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DawidWesierski4 committed Jan 2, 2025
1 parent f98c2f6 commit 5348c3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 18 additions & 6 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -540,30 +544,35 @@ 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);

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;
}

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;
}

Expand All @@ -580,7 +589,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;
Expand All @@ -604,7 +613,10 @@ static GstFlowReturn gst_mtl_st20p_rx_create(GstBaseSrc* basesrc, guint64 offset
}

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) {
Expand Down
18 changes: 3 additions & 15 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5348c3f

Please sign in to comment.