Merge branch 'CR_744_Port_gstreamer_from_JH7100_Windsome.Zeng' into 'jh7110-mm-devel'
Cr 744 port gstreamer from jh7100 windsome.zeng See merge request sdk/buildroot!6
This commit is contained in:
@@ -2572,7 +2572,6 @@ menu "Text editors and viewers"
|
||||
source "package/vim/Config.in"
|
||||
endmenu
|
||||
|
||||
|
||||
menu "starfive packages"
|
||||
source "package/starfive/Config.in"
|
||||
endmenu
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
--- a/sys/fbdev/gstfbdevsink.c 2021-07-06 16:02:46.304928800 +0800
|
||||
+++ b/sys/fbdev/gstfbdevsink.c 2021-07-06 16:02:11.593693100 +0800
|
||||
@@ -73,7 +73,7 @@
|
||||
static GstStateChangeReturn gst_fbdevsink_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
-#define VIDEO_CAPS "{ RGB, BGR, BGRx, xBGR, RGB, RGBx, xRGB, RGB15, RGB16 }"
|
||||
+#define VIDEO_CAPS "{ RGB, BGR, BGRx, xBGR, RGB, RGBx, xRGB, RGB15, RGB16, I420, NV12, NV21 }"
|
||||
|
||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
@@ -133,7 +133,10 @@
|
||||
/* FIXME: locking */
|
||||
if (!fbdevsink->framebuffer)
|
||||
goto done;
|
||||
-
|
||||
+ if (fbdevsink->varinfo.grayscale == 1) {
|
||||
+ format = GST_VIDEO_FORMAT_NV12;
|
||||
+ goto common;
|
||||
+ }
|
||||
bpp = fbdevsink->varinfo.bits_per_pixel;
|
||||
|
||||
rmask = ((1 << fbdevsink->varinfo.red.length) - 1)
|
||||
@@ -182,6 +185,8 @@
|
||||
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
goto unknown_format;
|
||||
|
||||
+common:
|
||||
+
|
||||
caps = gst_caps_make_writable (caps);
|
||||
gst_caps_set_simple (caps, "format", G_TYPE_STRING,
|
||||
gst_video_format_to_string (format), NULL);
|
||||
@@ -272,12 +277,33 @@
|
||||
if (!gst_buffer_map (buf, &map, GST_MAP_READ))
|
||||
return GST_FLOW_ERROR;
|
||||
|
||||
- for (i = 0; i < fbdevsink->lines; i++) {
|
||||
- memcpy (fbdevsink->framebuffer
|
||||
- + (i + fbdevsink->cy) * fbdevsink->fixinfo.line_length
|
||||
- + fbdevsink->cx * fbdevsink->bytespp,
|
||||
- map.data + i * fbdevsink->width * fbdevsink->bytespp,
|
||||
- fbdevsink->linelen);
|
||||
+ if (fbdevsink->varinfo.grayscale == 1) {
|
||||
+ int screen_offset = fbdevsink->varinfo.xres * fbdevsink->varinfo.yres;
|
||||
+ int buffer_offset = fbdevsink->height * fbdevsink->width;
|
||||
+
|
||||
+ for (i = 0; i < fbdevsink->lines; i++) {
|
||||
+ memcpy (fbdevsink->framebuffer
|
||||
+ + (i + fbdevsink->cy) * fbdevsink->varinfo.xres
|
||||
+ + fbdevsink->cx * 1,
|
||||
+ map.data + i * fbdevsink->width * 1,
|
||||
+ fbdevsink->width);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < fbdevsink->lines/2; i++) {
|
||||
+ memcpy (fbdevsink->framebuffer + screen_offset
|
||||
+ + (i + fbdevsink->cy/2) * fbdevsink->varinfo.xres
|
||||
+ + fbdevsink->cx * 1,
|
||||
+ map.data + buffer_offset + i * fbdevsink->width * 1,
|
||||
+ fbdevsink->width);
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (i = 0; i < fbdevsink->lines; i++) {
|
||||
+ memcpy (fbdevsink->framebuffer
|
||||
+ + (i + fbdevsink->cy) * fbdevsink->fixinfo.line_length
|
||||
+ + fbdevsink->cx * fbdevsink->bytespp,
|
||||
+ map.data + i * fbdevsink->width * fbdevsink->bytespp,
|
||||
+ fbdevsink->linelen);
|
||||
+ }
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, &map);
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/sys/kms/gstkmssink.c 2020-10-26 19:14:46.656235000 +0800
|
||||
+++ b/sys/kms/gstkmssink.c 2021-12-16 15:35:15.590755066 +0800
|
||||
@@ -450,6 +450,18 @@
|
||||
goto bo_failed;
|
||||
fb_id = kmsmem->fb_id;
|
||||
|
||||
+ GST_INFO_OBJECT (self, "size = %lu, width = %d, height = %d.", vinfo->size, vinfo->width, vinfo->height);
|
||||
+ if (vinfo->size == vinfo->width * vinfo->height * 3 / 2) {
|
||||
+ GstMapInfo mapInfo;
|
||||
+ if (gst_memory_map((GstMemory *)kmsmem, &mapInfo, GST_MAP_WRITE)) {
|
||||
+ guint8 *start = mapInfo.data + vinfo->width * vinfo->height;
|
||||
+ guint32 size = vinfo->width * vinfo->height / 2;
|
||||
+ GST_INFO_OBJECT (self, "Set buffer to blank.");
|
||||
+ memset(start, 128, size);
|
||||
+ gst_memory_unmap((GstMemory *)kmsmem, &mapInfo);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
conn = drmModeGetConnector (self->fd, self->conn_id);
|
||||
if (!conn)
|
||||
goto connector_failed;
|
||||
@@ -0,0 +1,106 @@
|
||||
diff -Naur a/tools/gst-play.c b/tools/gst-play.c
|
||||
--- a/tools/gst-play.c 2020-10-26 19:10:32.459882500 +0800
|
||||
+++ b/tools/gst-play.c 2022-04-07 14:13:15.126395339 +0800
|
||||
@@ -19,7 +19,6 @@
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
-
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -40,6 +39,9 @@
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#include "gst-play-kb.h"
|
||||
+#ifdef G_OS_UNIX
|
||||
+#include <glib-unix.h>
|
||||
+#endif
|
||||
|
||||
#define VOLUME_STEPS 20
|
||||
|
||||
@@ -104,6 +106,31 @@
|
||||
gdouble rate;
|
||||
} GstPlay;
|
||||
|
||||
+#if defined(G_OS_UNIX)
|
||||
+static guint signal_watch_intr_id;
|
||||
+#endif
|
||||
+
|
||||
+#if defined(G_OS_UNIX)
|
||||
+/* As the interrupt handler is dispatched from GMainContext as a GSourceFunc
|
||||
+ * handler, we can react to this by posting a message. */
|
||||
+static gboolean
|
||||
+intr_handler (gpointer user_data)
|
||||
+{
|
||||
+ GstPlay *play = (GstPlay *) user_data;
|
||||
+ gst_print ("handling interrupt.\n");
|
||||
+
|
||||
+ /* post an application specific message */
|
||||
+ gst_element_post_message (GST_ELEMENT (play->playbin),
|
||||
+ gst_message_new_application (GST_OBJECT (play->playbin),
|
||||
+ gst_structure_new ("GstLaunchInterrupt",
|
||||
+ "message", G_TYPE_STRING, "Pipeline interrupted", NULL)));
|
||||
+
|
||||
+ /* remove signal handler */
|
||||
+ signal_watch_intr_id = 0;
|
||||
+ return G_SOURCE_REMOVE;
|
||||
+}
|
||||
+#endif /* G_OS_UNIX */
|
||||
+
|
||||
static gboolean quiet = FALSE;
|
||||
static gboolean instant_rate_changes = FALSE;
|
||||
|
||||
@@ -594,6 +621,24 @@
|
||||
}
|
||||
break;
|
||||
}
|
||||
+ case GST_MESSAGE_APPLICATION:{
|
||||
+ const GstStructure *s;
|
||||
+
|
||||
+ s = gst_message_get_structure (msg);
|
||||
+
|
||||
+ if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
|
||||
+ /* this application message is posted when we caught an interrupt and
|
||||
+ * we need to stop the pipeline. */
|
||||
+
|
||||
+ gst_print (_("Interrupt: GST_MESSAGE_APPLICATION ...\n"));
|
||||
+ if (play->desired_state == GST_STATE_PLAYING){
|
||||
+ gst_print (_("Interrupt: Stopping pipeline ...\n"));
|
||||
+ g_main_loop_quit (play->loop);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
default:
|
||||
if (gst_is_missing_plugin_message (msg)) {
|
||||
gchar *desc;
|
||||
@@ -1622,6 +1667,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#ifdef G_OS_UNIX
|
||||
+ gst_print("g_source_remove signal_watch_intr_id \n");
|
||||
+ signal_watch_intr_id =
|
||||
+ g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, play);
|
||||
+#endif
|
||||
+
|
||||
/* play */
|
||||
do_play (play);
|
||||
|
||||
@@ -1632,6 +1683,14 @@
|
||||
g_free (video_sink);
|
||||
|
||||
gst_print ("\n");
|
||||
+
|
||||
+#ifdef G_OS_UNIX
|
||||
+ if (signal_watch_intr_id > 0){
|
||||
+ gst_print("g_source_remove signal_watch_intr_id \n");
|
||||
+ g_source_remove (signal_watch_intr_id);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
gst_deinit ();
|
||||
return 0;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
From 25af3820863d70905268710761784fd84298f80f Mon Sep 17 00:00:00 2001
|
||||
From: "andy.hu" <andy.hu@starfive.com>
|
||||
Date: Mon, 25 Oct 2021 11:13:54 +0800
|
||||
Subject: [PATCH] Enable install operation when build examples
|
||||
|
||||
---
|
||||
examples/meson.build | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/examples/meson.build b/examples/meson.build
|
||||
index 2bacd48..757ac49 100644
|
||||
--- a/examples/meson.build
|
||||
+++ b/examples/meson.build
|
||||
@@ -26,7 +26,7 @@ foreach example : examples
|
||||
c_args : rtspserver_args,
|
||||
include_directories : rtspserver_incs,
|
||||
dependencies : [glib_dep, gst_dep, gstapp_dep, gstnet_dep, gst_rtsp_server_dep],
|
||||
- install: false)
|
||||
+ install: true)
|
||||
endforeach
|
||||
|
||||
cgroup_dep = dependency('libcgroup', version : '>= 0.26', required : false)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@@ -21,13 +21,13 @@ GST1_RTSP_SERVER_DEPENDENCIES = \
|
||||
GST1_RTSP_SERVER_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
|
||||
|
||||
GST1_RTSP_SERVER_CONF_OPTS = \
|
||||
-Dexamples=disabled \
|
||||
-Dtests=disabled \
|
||||
-Dexamples=enabled \
|
||||
-Dtests=enabled \
|
||||
-Ddoc=disabled
|
||||
|
||||
GST1_RTSP_SERVER_CONF_OPTS += \
|
||||
-Dexamples=disabled \
|
||||
-Dtests=disabled \
|
||||
-Dexamples=enabled \
|
||||
-Dtests=enabled \
|
||||
-Dgobject-cast-checks=disabled \
|
||||
-Dglib-asserts=disabled \
|
||||
-Dglib-checks=disabled
|
||||
|
||||
@@ -7,6 +7,7 @@ source "package/starfive/sf-omx-il/Config.in"
|
||||
source "package/starfive/sf-omx-il-test/Config.in"
|
||||
source "package/starfive/v4l2_test/Config.in"
|
||||
source "package/starfive/libcamera-apps/Config.in"
|
||||
source "package/starfive/sf-gst-omx/Config.in"
|
||||
source "package/starfive/ispsdk/Config.in"
|
||||
source "package/starfive/mailbox-test/Config.in"
|
||||
source "package/starfive/e24-test/Config.in"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
diff --git a/config/meson.build b/config/meson.build
|
||||
index 1068c6d..7f8abe9 100755
|
||||
--- a/config/meson.build
|
||||
+++ b/config/meson.build
|
||||
@@ -6,6 +6,8 @@ elif omx_target == 'zynqultrascaleplus'
|
||||
sub = 'zynqultrascaleplus'
|
||||
elif omx_target == 'tizonia'
|
||||
sub = 'tizonia'
|
||||
+ elif omx_target == 'stf'
|
||||
+ sub = 'stf'
|
||||
else
|
||||
# No config file defined for the 'generic' target
|
||||
sub = ''
|
||||
diff --git a/config/stf/gstomx.conf b/config/stf/gstomx.conf
|
||||
new file mode 100644
|
||||
index 0000000..b4cdebb
|
||||
--- /dev/null
|
||||
+++ b/config/stf/gstomx.conf
|
||||
@@ -0,0 +1,17 @@
|
||||
+[omxh265dec]
|
||||
+type-name=GstOMXH265Dec
|
||||
+core-name=/usr/lib/libsf-omx-il.so
|
||||
+component-name=sf.dec.decoder.h265
|
||||
+in-port-index=0
|
||||
+out-port-index=1
|
||||
+rank=0
|
||||
+hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
+
|
||||
+[omxh264dec]
|
||||
+type-name=GstOMXH264Dec
|
||||
+core-name=/usr/lib/libsf-omx-il.so
|
||||
+component-name=sf.dec.decoder.h264
|
||||
+in-port-index=0
|
||||
+out-port-index=1
|
||||
+rank=1
|
||||
+hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
diff --git a/config/stf/meson.build b/config/stf/meson.build
|
||||
new file mode 100644
|
||||
index 0000000..dc99c08
|
||||
--- /dev/null
|
||||
+++ b/config/stf/meson.build
|
||||
@@ -0,0 +1 @@
|
||||
+install_data (['gstomx.conf'], install_dir : omx_conf_dir)
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 32c7fa7..aeda56a 100755
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -216,6 +216,8 @@ elif omx_target == 'tizonia'
|
||||
tizil_includedir = tizil_dep.get_pkgconfig_variable('includedir')
|
||||
gst_omx_args += ['-I' + tizil_includedir + '/tizonia']
|
||||
omx_inc = []
|
||||
+elif omx_target == 'stf'
|
||||
+ warning('stf selected')
|
||||
else
|
||||
error ('Unsupported omx target specified. Use the -Dtarget option')
|
||||
endif
|
||||
diff --git a/meson_options.txt b/meson_options.txt
|
||||
index e18beb2..4fc6139 100755
|
||||
--- a/meson_options.txt
|
||||
+++ b/meson_options.txt
|
||||
@@ -1,7 +1,7 @@
|
||||
option('header_path', type : 'string', value : '',
|
||||
description : 'An extra include directory to find the OpenMax headers')
|
||||
option('target', type : 'combo',
|
||||
- choices : ['none', 'generic', 'rpi', 'bellagio', 'tizonia', 'zynqultrascaleplus'], value : 'none',
|
||||
+ choices : ['none', 'generic', 'rpi', 'bellagio', 'tizonia', 'zynqultrascaleplus', 'stf'], value : 'none',
|
||||
description : 'The OMX platform to target')
|
||||
option('struct_packing', type : 'combo',
|
||||
choices : ['0', '1', '2', '4', '8'], value : '0',
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
From 810800c303965e5cb0cf135210667c003f050ee0 Mon Sep 17 00:00:00 2001
|
||||
From: "andy.hu" <andy.hu@starfive.com>
|
||||
Date: Tue, 10 Aug 2021 19:18:00 +0800
|
||||
Subject: [PATCH] Fix(gst-omx): Enable the gst-omx VPU decoding and encoding
|
||||
support h264 High L5.2
|
||||
|
||||
---
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index aeda56a..48121ab 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -217,6 +217,7 @@ elif omx_target == 'tizonia'
|
||||
gst_omx_args += ['-I' + tizil_includedir + '/tizonia']
|
||||
omx_inc = []
|
||||
elif omx_target == 'stf'
|
||||
+ cdata.set('USE_OMX_TARGET_STARFIVE', 1)
|
||||
warning('stf selected')
|
||||
else
|
||||
error ('Unsupported omx target specified. Use the -Dtarget option')
|
||||
diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c
|
||||
index 51d84a8..875f974 100644
|
||||
--- a/omx/gstomxh264enc.c
|
||||
+++ b/omx/gstomxh264enc.c
|
||||
@@ -824,6 +824,11 @@ gst_omx_h264_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port,
|
||||
case OMX_VIDEO_AVCLevel51:
|
||||
level = "5.1";
|
||||
break;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case OMX_VIDEO_AVCLevel52:
|
||||
+ level = "5.2";
|
||||
+ break;
|
||||
+#else
|
||||
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
||||
case OMX_ALG_VIDEO_AVCLevel52:
|
||||
level = "5.2";
|
||||
@@ -837,6 +842,7 @@ gst_omx_h264_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port,
|
||||
case OMX_ALG_VIDEO_AVCLevel62:
|
||||
level = "6.2";
|
||||
break;
|
||||
+#endif
|
||||
#endif
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
diff --git a/omx/gstomxh264utils.c b/omx/gstomxh264utils.c
|
||||
index ba29211..a6e95e3 100644
|
||||
--- a/omx/gstomxh264utils.c
|
||||
+++ b/omx/gstomxh264utils.c
|
||||
@@ -115,6 +115,10 @@ gst_omx_h264_utils_get_level_from_str (const gchar * level)
|
||||
return OMX_VIDEO_AVCLevel5;
|
||||
} else if (g_str_equal (level, "5.1")) {
|
||||
return OMX_VIDEO_AVCLevel51;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ } else if (g_str_equal (level, "5.2")) {
|
||||
+ return OMX_VIDEO_AVCLevel52;
|
||||
+#else
|
||||
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
||||
} else if (g_str_equal (level, "5.2")) {
|
||||
return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel52;
|
||||
@@ -124,6 +128,7 @@ gst_omx_h264_utils_get_level_from_str (const gchar * level)
|
||||
return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel61;
|
||||
} else if (g_str_equal (level, "6.2")) {
|
||||
return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel62;
|
||||
+#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
--- a/omx/gstomxvideodec.c 2020-10-26 19:17:03.000000000 +0800
|
||||
+++ b/omx/gstomxvideodec.c 2021-08-16 16:23:08.082113380 +0800
|
||||
@@ -2185,6 +2185,7 @@
|
||||
gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
|
||||
{
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE param;
|
||||
+ OMX_PARAM_PORTDEFINITIONTYPE port_def;
|
||||
OMX_ERRORTYPE err;
|
||||
GstCaps *comp_supported_caps;
|
||||
GList *negotiation_map = NULL, *l;
|
||||
@@ -2192,6 +2193,7 @@
|
||||
GstVideoFormat format;
|
||||
GstStructure *s;
|
||||
const gchar *format_str;
|
||||
+ gint width, height;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Trying to negotiate a video format with downstream");
|
||||
|
||||
@@ -2281,6 +2283,31 @@
|
||||
gst_omx_error_to_string (err), err);
|
||||
}
|
||||
|
||||
+ if (gst_structure_get_int(s, "width", &width) && gst_structure_get_int(s, "height", &height))
|
||||
+ {
|
||||
+ GST_OMX_INIT_STRUCT (&port_def);
|
||||
+ port_def.nPortIndex = self->dec_out_port->index;
|
||||
+ err = gst_omx_component_get_parameter (self->dec,
|
||||
+ OMX_IndexParamPortDefinition, &port_def);
|
||||
+ if (err != OMX_ErrorNone) {
|
||||
+ GST_ERROR_OBJECT (self, "Failed to get video port definition: %s (0x%08x)",
|
||||
+ gst_omx_error_to_string (err), err);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ port_def.format.video.nFrameHeight = height;
|
||||
+ port_def.format.video.nFrameWidth = width;
|
||||
+
|
||||
+ err =
|
||||
+ gst_omx_component_set_parameter (self->dec,
|
||||
+ OMX_IndexParamPortDefinition, &port_def);
|
||||
+ if (err != OMX_ErrorNone) {
|
||||
+ GST_ERROR_OBJECT (self, "Failed to set video port definition: %s (0x%08x)",
|
||||
+ gst_omx_error_to_string (err), err);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
gst_caps_unref (intersection);
|
||||
return (err == OMX_ErrorNone);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/config/stf/gstomx.conf 2021-08-18 14:51:51.384176799 +0800
|
||||
+++ b/config/stf/gstomx.conf 2021-08-18 14:50:58.972186447 +0800
|
||||
@@ -15,3 +15,21 @@
|
||||
out-port-index=1
|
||||
rank=1
|
||||
hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
+
|
||||
+[omxh265enc]
|
||||
+type-name=GstOMXH265Enc
|
||||
+core-name=/usr/lib/libsf-omx-il.so
|
||||
+component-name=sf.enc.encoder.h265
|
||||
+in-port-index=0
|
||||
+out-port-index=1
|
||||
+rank=1
|
||||
+hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual;video-framerate-integer
|
||||
+
|
||||
+[omxh264enc]
|
||||
+type-name=GstOMXH264Enc
|
||||
+core-name=/usr/lib/libsf-omx-il.so
|
||||
+component-name=sf.enc.encoder.h264
|
||||
+in-port-index=0
|
||||
+out-port-index=1
|
||||
+rank=1
|
||||
+hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual;video-framerate-integer
|
||||
@@ -0,0 +1,19 @@
|
||||
diff -Naur a/config/stf/gstomx.conf b/config/stf/gstomx.conf
|
||||
--- a/config/stf/gstomx.conf 2021-08-23 16:04:48.928905742 +0800
|
||||
+++ b/config/stf/gstomx.conf 2021-08-23 16:03:38.590578856 +0800
|
||||
@@ -4,7 +4,7 @@
|
||||
component-name=sf.dec.decoder.h265
|
||||
in-port-index=0
|
||||
out-port-index=1
|
||||
-rank=0
|
||||
+rank=257
|
||||
hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
|
||||
[omxh264dec]
|
||||
@@ -13,5 +13,5 @@
|
||||
component-name=sf.dec.decoder.h264
|
||||
in-port-index=0
|
||||
out-port-index=1
|
||||
-rank=1
|
||||
+rank=257
|
||||
hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/omx/gstomxvideodec.c
|
||||
+++ b/omx/gstomxvideodec.c
|
||||
@@ -718,6 +718,15 @@
|
||||
goto out;
|
||||
}
|
||||
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ if ( !gst_is_dmabuf_memory (mem)) {
|
||||
+ GST_INFO_OBJECT (self,
|
||||
+ " %d-th buffer doesn't contain dmabuf, go to out. port->port_def.nBufferSize: %lu",
|
||||
+ i, port->port_def.nBufferSize);
|
||||
+ goto out;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
*frame = g_slice_new0 (GstVideoFrame);
|
||||
|
||||
is_mapped = gst_video_frame_map (*frame, v_info, buffer, flags);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/config/stf/gstomx.conf
|
||||
+++ b/config/stf/gstomx.conf
|
||||
@@ -33,3 +33,12 @@
|
||||
out-port-index=1
|
||||
rank=1
|
||||
hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual;video-framerate-integer
|
||||
+
|
||||
+[omxmjpegdec]
|
||||
+type-name=GstOMXMJPEGDec
|
||||
+core-name=/usr/lib/libsf-omx-il.so
|
||||
+component-name=sf.dec.decoder.mjpeg
|
||||
+in-port-index=0
|
||||
+out-port-index=1
|
||||
+rank=1
|
||||
+hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
--- a/config/stf/gstomx.conf
|
||||
+++ b/config/stf/gstomx.conf
|
||||
@@ -42,3 +42,4 @@
|
||||
out-port-index=1
|
||||
rank=1
|
||||
hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual
|
||||
+src-template-caps=video/x-raw, format = (string) { NV16_10LE32, NV12_10LE32, NV16, YUY2, YVYU, UYVY, NV12, NV21, I420, RGB16, BGR16, ABGR, ARGB, GRAY8, Y42B, Y444 }, width = (int) [ 1, max ], height = (int) [ 1, max ], framerate = (fraction) [ 0, max ]
|
||||
--- a/omx/gstomxbufferpool.c
|
||||
+++ b/omx/gstomxbufferpool.c
|
||||
@@ -370,9 +370,29 @@
|
||||
case GST_VIDEO_FORMAT_NV12_10LE32:
|
||||
case GST_VIDEO_FORMAT_NV16:
|
||||
case GST_VIDEO_FORMAT_NV16_10LE32:
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case GST_VIDEO_FORMAT_NV21:
|
||||
+#endif
|
||||
stride[1] = nstride;
|
||||
offset[1] = offset[0] + stride[0] * nslice;
|
||||
break;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case GST_VIDEO_FORMAT_Y42B:
|
||||
+ stride[0] = GST_ROUND_UP_4 (nstride);
|
||||
+ stride[1] = GST_ROUND_UP_8 (nstride) / 2;
|
||||
+ stride[2] = stride[1];
|
||||
+
|
||||
+ offset[1] = stride[0] * nslice;
|
||||
+ offset[2] = offset[1] + stride[1] * nslice;
|
||||
+ break;
|
||||
+
|
||||
+ case GST_VIDEO_FORMAT_Y444:
|
||||
+ stride[1] = nstride;
|
||||
+ stride[2] = nstride;
|
||||
+ offset[1] = offset[0] + stride[0] * nslice;
|
||||
+ offset[2] = offset[1] + stride[1] * nslice;
|
||||
+ break;
|
||||
+#endif
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
--- a/omx/gstomxvideo.c
|
||||
+++ b/omx/gstomxvideo.c
|
||||
@@ -93,6 +93,17 @@
|
||||
format = GST_VIDEO_FORMAT_NV16_10LE32;
|
||||
break;
|
||||
#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case OMX_COLOR_FormatYUV422Planar:
|
||||
+ format = GST_VIDEO_FORMAT_Y42B;
|
||||
+ break;
|
||||
+ case OMX_COLOR_FormatYUV444Interleaved:
|
||||
+ format = GST_VIDEO_FORMAT_Y444;
|
||||
+ break;
|
||||
+ case OMX_COLOR_FormatYVU420SemiPlanar:
|
||||
+ format = GST_VIDEO_FORMAT_NV21;
|
||||
+ break;
|
||||
#endif
|
||||
default:
|
||||
format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
--- a/omx/gstomxvideodec.c
|
||||
+++ b/omx/gstomxvideodec.c
|
||||
@@ -592,6 +592,9 @@
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
case GST_VIDEO_FORMAT_YVYU:
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case GST_VIDEO_FORMAT_Y42B:
|
||||
+#endif
|
||||
dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 2;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_GRAY8:
|
||||
@@ -609,6 +612,9 @@
|
||||
dst_height[2] = GST_VIDEO_INFO_FIELD_HEIGHT (vinfo) / 2;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case GST_VIDEO_FORMAT_NV21:
|
||||
+#endif
|
||||
dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
|
||||
src_stride[1] = nstride;
|
||||
src_size[1] = src_stride[1] * nslice / 2;
|
||||
@@ -638,6 +644,18 @@
|
||||
src_size[1] = src_stride[1] * nslice;
|
||||
dst_height[1] = GST_VIDEO_INFO_FIELD_HEIGHT (vinfo);
|
||||
break;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ case GST_VIDEO_FORMAT_Y444:
|
||||
+ dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo);
|
||||
+ dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
|
||||
+ dst_width[2] = GST_VIDEO_INFO_WIDTH (vinfo);
|
||||
+ src_size[1] = src_size[0];
|
||||
+ src_size[2] = src_size[0];
|
||||
+ src_stride[1] = nstride;
|
||||
+ dst_height[1] = dst_height[0];
|
||||
+ dst_height[2] = dst_height[0];
|
||||
+ break;
|
||||
+#endif
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -0,0 +1,247 @@
|
||||
diff -Naur a/omx/gstomx.h b/omx/gstomx.h
|
||||
--- a/omx/gstomx.h 2020-10-26 19:17:03.488452200 +0800
|
||||
+++ b/omx/gstomx.h 2022-04-24 18:50:01.353690234 +0800
|
||||
@@ -332,6 +332,7 @@
|
||||
*/
|
||||
gint settings_cookie;
|
||||
gint configured_settings_cookie;
|
||||
+ GstBuffer * c_buf;
|
||||
};
|
||||
|
||||
struct _GstOMXComponent {
|
||||
diff -Naur a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
|
||||
--- a/omx/gstomxvideoenc.c 2020-10-26 19:17:03.492452100 +0800
|
||||
+++ b/omx/gstomxvideoenc.c 2022-04-24 18:53:42.211595096 +0800
|
||||
@@ -2102,6 +2102,143 @@
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+static GstBuffer *
|
||||
+gst_omx_try_importing_buffer (GstOMXVideoEnc * self, GstBufferPool * pool,
|
||||
+ GstOMXPort * port, GstVideoInfo * v_info, guint i, GstVideoFrame ** frame)
|
||||
+{
|
||||
+ GstBufferPoolAcquireParams params = { 0, };
|
||||
+ GstBuffer *buffer = NULL;
|
||||
+ GstMemory *mem;
|
||||
+ GstMapFlags flags = GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF;
|
||||
+ gboolean is_mapped = FALSE;
|
||||
+
|
||||
+ *frame = NULL;
|
||||
+
|
||||
+ if (gst_buffer_pool_acquire_buffer (pool, &buffer, ¶ms) != GST_FLOW_OK) {
|
||||
+ GST_INFO_OBJECT (self, "Failed to acquire %d-th buffer", i);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (gst_buffer_n_memory (buffer) != 1) {
|
||||
+ GST_INFO_OBJECT (self, "%d-th buffer has more than one memory (%d)", i,
|
||||
+ gst_buffer_n_memory (buffer));
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ mem = gst_buffer_peek_memory (buffer, 0);
|
||||
+ if (!mem) {
|
||||
+ GST_INFO_OBJECT (self, "Failed to acquire memory of %d-th buffer", i);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if ( !gst_is_dmabuf_memory (mem)) {
|
||||
+ GST_INFO_OBJECT (self,
|
||||
+ " %d-th buffer doesn't contain dmabuf, go to out. port->port_def.nBufferSize: %lu",
|
||||
+ i, port->port_def.nBufferSize);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ *frame = g_slice_new0 (GstVideoFrame);
|
||||
+
|
||||
+ is_mapped = gst_video_frame_map (*frame, v_info, buffer, flags);
|
||||
+ GST_INFO_OBJECT (self, " *frame = %p, mem: %p", *frame, mem);
|
||||
+
|
||||
+ if (!is_mapped) {
|
||||
+ GST_INFO_OBJECT (self, "Failed to map %d-th buffer", i);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (GST_VIDEO_FRAME_SIZE (*frame) < port->port_def.nBufferSize) {
|
||||
+ GST_INFO_OBJECT (self,
|
||||
+ "Frame size of %d-th buffer (%" G_GSIZE_FORMAT
|
||||
+ ") is too small for port buffer size (%d)", i,
|
||||
+ GST_VIDEO_FRAME_SIZE (*frame), (guint32) port->port_def.nBufferSize);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ return buffer;
|
||||
+
|
||||
+out:
|
||||
+ if (*frame) {
|
||||
+ if (is_mapped)
|
||||
+ gst_video_frame_unmap (*frame);
|
||||
+ g_slice_free (GstVideoFrame, *frame);
|
||||
+ *frame = NULL;
|
||||
+ }
|
||||
+ gst_buffer_unref (buffer);
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+static gboolean
|
||||
+gst_omx_video_enc_use_buffers (GstOMXVideoEnc * self)
|
||||
+{
|
||||
+ GstOMXPort * port = self->enc_in_port;
|
||||
+ GstBufferPool *pool = port->c_buf->pool;
|
||||
+ GstVideoCodecState *input_state = self->input_state;
|
||||
+ GstVideoInfo v_info = input_state->info;
|
||||
+ guint n = port->port_def.nBufferCountActual;
|
||||
+ GList *images = NULL;
|
||||
+ GList *buffers = NULL;
|
||||
+ GList *frames = NULL;
|
||||
+ OMX_ERRORTYPE err = OMX_ErrorNone;
|
||||
+ gboolean is_mapped = FALSE ;
|
||||
+ GST_DEBUG(" nBufferCountActual=%d, nBufferCountMin= %lu", n, port->port_def.nBufferCountMin);
|
||||
+
|
||||
+ if ( pool != NULL ) {
|
||||
+ guint i;
|
||||
+ for (i = 0; i < n; i++) {
|
||||
+ GstBuffer * buf = NULL;
|
||||
+ GstVideoFrame *frame = NULL;
|
||||
+ buf = gst_omx_try_importing_buffer (self, pool, port, &v_info, i, &frame);
|
||||
+ if (!buf) {
|
||||
+ GST_DEBUG_OBJECT (self, "Failed to import %d-th buffer", i);
|
||||
+ g_list_free (images);
|
||||
+ g_list_free_full (frames, (GDestroyNotify) gst_video_frame_unmap);
|
||||
+ g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
|
||||
+ break;
|
||||
+ } else {
|
||||
+ buffers = g_list_append (buffers, buf);
|
||||
+ frames = g_list_append (frames, frame);
|
||||
+ images = g_list_append (images, GST_VIDEO_FRAME_PLANE_DATA (frame, 0));
|
||||
+ GST_DEBUG_OBJECT (self, " pBuffer: %p", GST_VIDEO_FRAME_PLANE_DATA (frame, 0));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (images) {
|
||||
+ is_mapped = TRUE;
|
||||
+
|
||||
+ err = gst_omx_port_use_buffers (port, images);
|
||||
+ g_list_free (images);
|
||||
+ g_list_free_full (frames, (GDestroyNotify) gst_video_frame_unmap);
|
||||
+
|
||||
+ if (err == OMX_ErrorNone) {
|
||||
+ GST_DEBUG_OBJECT (self, "Using %d buffers", n);
|
||||
+ } else {
|
||||
+ GST_INFO_OBJECT (self,
|
||||
+ "Failed to OMX_UseBuffer on port: %s (0x%08x)",
|
||||
+ gst_omx_error_to_string (err), err);
|
||||
+ g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ( !is_mapped ) {
|
||||
+ GST_WARNING_OBJECT (self, " failed to call UseBuffer, trying to use allocation");
|
||||
+ self->input_dmabuf = FALSE;
|
||||
+ self->input_allocation = GST_OMX_BUFFER_ALLOCATION_ALLOCATE_BUFFER;
|
||||
+ if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone){
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static gboolean
|
||||
gst_omx_video_enc_allocate_in_buffers (GstOMXVideoEnc * self)
|
||||
{
|
||||
@@ -2115,6 +2252,9 @@
|
||||
return FALSE;
|
||||
break;
|
||||
case GST_OMX_BUFFER_ALLOCATION_USE_BUFFER:
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ return gst_omx_video_enc_use_buffers(self);
|
||||
+#endif
|
||||
default:
|
||||
/* Not supported */
|
||||
g_return_val_if_reached (FALSE);
|
||||
@@ -2179,8 +2319,18 @@
|
||||
gst_omx_video_enc_pick_input_allocation_mode (GstOMXVideoEnc * self,
|
||||
GstBuffer * inbuf)
|
||||
{
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ if (!gst_omx_is_dynamic_allocation_supported ()){
|
||||
+ if (gst_is_dmabuf_memory (gst_buffer_peek_memory (inbuf, 0))){
|
||||
+ GST_DEBUG_OBJECT (self, "select GST_OMX_BUFFER_ALLOCATION_USE_BUFFER");
|
||||
+ return GST_OMX_BUFFER_ALLOCATION_USE_BUFFER;
|
||||
+ }
|
||||
+ return GST_OMX_BUFFER_ALLOCATION_ALLOCATE_BUFFER;
|
||||
+ }
|
||||
+#else
|
||||
if (!gst_omx_is_dynamic_allocation_supported ())
|
||||
return GST_OMX_BUFFER_ALLOCATION_ALLOCATE_BUFFER;
|
||||
+#endif
|
||||
|
||||
if (can_use_dynamic_buffer_mode (self, inbuf)) {
|
||||
GST_DEBUG_OBJECT (self,
|
||||
@@ -2272,6 +2422,15 @@
|
||||
input);
|
||||
self->input_dmabuf = FALSE;
|
||||
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ if (self->input_allocation ==
|
||||
+ GST_OMX_BUFFER_ALLOCATION_USE_BUFFER) {
|
||||
+ self->input_dmabuf = TRUE;
|
||||
+ self->enc_in_port->c_buf = input;
|
||||
+ GST_DEBUG_OBJECT (self, "input_dmabuf is true");
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
||||
if (gst_is_dmabuf_memory (gst_buffer_peek_memory (input, 0))) {
|
||||
if (self->input_allocation ==
|
||||
@@ -2786,7 +2945,11 @@
|
||||
}
|
||||
|
||||
if (self->enc_in_port->allocation ==
|
||||
- GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC) {
|
||||
+ GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ || self->enc_in_port->allocation == GST_OMX_BUFFER_ALLOCATION_USE_BUFFER
|
||||
+#endif
|
||||
+ ) {
|
||||
if (gst_buffer_n_memory (inbuf) > 1) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL),
|
||||
("input buffer now has more than one memory, can't use dynamic allocation any more"));
|
||||
@@ -2812,12 +2975,29 @@
|
||||
gst_buffer_get_size (inbuf));
|
||||
} else {
|
||||
/* dmabuf input */
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ if (self->enc_in_port->allocation == GST_OMX_BUFFER_ALLOCATION_USE_BUFFER) {
|
||||
+ GstMemory *mem = gst_buffer_peek_memory (inbuf, 0);
|
||||
+ GST_LOG_OBJECT (self, " mem: %p, inbuf: %p, outbuf: %p", mem, inbuf, outbuf);
|
||||
+ if (!gst_omx_buffer_map_memory (outbuf, mem)) {
|
||||
+ GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL),("failed to import"));
|
||||
+ GST_ERROR_OBJECT (self, "failed to import dmabuf %p, inbuf: %p",mem, inbuf);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (!gst_omx_buffer_import_fd (outbuf, inbuf)) {
|
||||
+ GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL),
|
||||
+ ("failed to import dmabuf"));
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+#else
|
||||
if (!gst_omx_buffer_import_fd (outbuf, inbuf)) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL),
|
||||
("failed to import dmabuf"));
|
||||
return FALSE;
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
GST_LOG_OBJECT (self, "Import dmabuf of %" G_GSIZE_FORMAT " bytes",
|
||||
gst_buffer_get_size (inbuf));
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
--- a/omx/gstomxmjpegdec.h
|
||||
+++ b/omx/gstomxmjpegdec.h
|
||||
@@ -45,6 +45,16 @@
|
||||
struct _GstOMXMJPEGDec
|
||||
{
|
||||
GstOMXVideoDec parent;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ //If container shows fps as public api, it won't work
|
||||
+ //as GstBuffer containing pts/dts/duration and it will calculate fps in upstream.
|
||||
+ //i.e.
|
||||
+ //not works:
|
||||
+ // gst-launch-1.0 -v filesrc location=xxx.mp4 ! qtdemux name=demux demux.video_0 ! jpegparse ! omxmjpegdec framerate=xxx ! kmssink driver-name=starfive force-modesetting=1
|
||||
+ //works:
|
||||
+ // gst-launch-1.0 -v filesrc location=xxx.mjpeg ! jpegparse ! omxmjpegdec framerate=xxx ! kmssink driver-name=starfive force-modesetting=1
|
||||
+ gint framerate;
|
||||
+#endif
|
||||
};
|
||||
|
||||
struct _GstOMXMJPEGDecClass
|
||||
|
||||
--- a/omx/gstomxmjpegdec.c
|
||||
+++ b/omx/gstomxmjpegdec.c
|
||||
@@ -28,16 +28,28 @@
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_omx_mjpeg_dec_debug_category);
|
||||
#define GST_CAT_DEFAULT gst_omx_mjpeg_dec_debug_category
|
||||
-
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+#define DEFAULT_FRAMERATE 0
|
||||
+#endif
|
||||
/* prototypes */
|
||||
static gboolean gst_omx_mjpeg_dec_is_format_change (GstOMXVideoDec * dec,
|
||||
GstOMXPort * port, GstVideoCodecState * state);
|
||||
static gboolean gst_omx_mjpeg_dec_set_format (GstOMXVideoDec * dec,
|
||||
GstOMXPort * port, GstVideoCodecState * state);
|
||||
-
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+static void gst_omx_mjpeg_dec_set_property (GObject * object, guint prop_id,
|
||||
+ const GValue * value, GParamSpec * pspec);
|
||||
+static void gst_omx_mjpeg_dec_get_property (GObject * object, guint prop_id,
|
||||
+ GValue * value, GParamSpec * pspec);
|
||||
+#endif
|
||||
enum
|
||||
{
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ PROP_0,
|
||||
+ PROP_FRAMERATE
|
||||
+#else
|
||||
PROP_0
|
||||
+#endif
|
||||
};
|
||||
|
||||
/* class initialization */
|
||||
@@ -54,11 +66,16 @@
|
||||
{
|
||||
GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
-
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ GObjectClass *gobject_class = G_OBJECT_CLASS (videodec_class);
|
||||
+#endif
|
||||
videodec_class->is_format_change =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_is_format_change);
|
||||
videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_set_format);
|
||||
-
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_set_property);
|
||||
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_get_property);
|
||||
+#endif
|
||||
videodec_class->cdata.default_sink_template_caps = "image/jpeg, "
|
||||
"width=(int) [1,MAX], " "height=(int) [1,MAX]";
|
||||
|
||||
@@ -67,7 +84,16 @@
|
||||
"Codec/Decoder/Video/Hardware",
|
||||
"Decode MJPEG video streams",
|
||||
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
||||
-
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ g_object_class_install_property (gobject_class, PROP_FRAMERATE,
|
||||
+ g_param_spec_int ("framerate",
|
||||
+ "Framerate",
|
||||
+ "Frames per second in raw stream.\n \
|
||||
+ Only workable for the container not exposing fps.\n\
|
||||
+ '0' means disabled.",
|
||||
+ 0, G_MAXINT,
|
||||
+ DEFAULT_FRAMERATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
+#endif
|
||||
gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mjpeg");
|
||||
}
|
||||
|
||||
@@ -89,10 +115,53 @@
|
||||
{
|
||||
gboolean ret;
|
||||
OMX_PARAM_PORTDEFINITIONTYPE port_def;
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ GstVideoInfo *info = &state->info;
|
||||
+ GstOMXMJPEGDec * mjpeg_dec = GST_OMX_MJPEG_DEC (dec);
|
||||
|
||||
+ if (mjpeg_dec->framerate != DEFAULT_FRAMERATE) {
|
||||
+ GST_DEBUG_OBJECT (dec, " change fps from %d/%d to %d/1" GST_PTR_FORMAT, info->fps_n, info->fps_d, mjpeg_dec->framerate);
|
||||
+ info->fps_n = mjpeg_dec->framerate;
|
||||
+ info->fps_d = 1;
|
||||
+ if (state->caps) {
|
||||
+ gst_caps_set_simple (state->caps, "framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
gst_omx_port_get_port_definition (port, &port_def);
|
||||
port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMJPEG;
|
||||
ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone;
|
||||
|
||||
return ret;
|
||||
}
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+static void
|
||||
+gst_omx_mjpeg_dec_set_property (GObject * object, guint prop_id,
|
||||
+ const GValue * value, GParamSpec * pspec)
|
||||
+{
|
||||
+ GstOMXMJPEGDec * mjpeg_dec = GST_OMX_MJPEG_DEC (object);
|
||||
+ switch (prop_id) {
|
||||
+ case PROP_FRAMERATE:
|
||||
+ mjpeg_dec->framerate = g_value_get_int (value);
|
||||
+ break;
|
||||
+ default:
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gst_omx_mjpeg_dec_get_property (GObject * object, guint prop_id, GValue * value,
|
||||
+ GParamSpec * pspec)
|
||||
+{
|
||||
+ GstOMXMJPEGDec * mjpeg_dec = GST_OMX_MJPEG_DEC (object);
|
||||
+ switch (prop_id) {
|
||||
+ case PROP_FRAMERATE:
|
||||
+ g_value_set_int (value, mjpeg_dec->framerate);
|
||||
+ break;
|
||||
+ default:
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/omx/gstomxh264utils.c
|
||||
+++ b/omx/gstomxh264utils.c
|
||||
@@ -54,6 +54,19 @@
|
||||
#endif
|
||||
};
|
||||
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+static const H264ProfileMapping h264_ext_profiles[] = {
|
||||
+ {"progressive-high",
|
||||
+ (OMX_VIDEO_AVCPROFILETYPE) OMX_VIDEO_AVCProfileHigh},
|
||||
+ {"constrained-high",
|
||||
+ (OMX_VIDEO_AVCPROFILETYPE) OMX_VIDEO_AVCProfileHigh},
|
||||
+ {"high-10-intra",
|
||||
+ (OMX_VIDEO_AVCPROFILETYPE) OMX_VIDEO_AVCProfileHigh10},
|
||||
+ {"high-4:2:2-intra",
|
||||
+ (OMX_VIDEO_AVCPROFILETYPE) OMX_VIDEO_AVCProfileHigh422},
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
OMX_VIDEO_AVCPROFILETYPE
|
||||
gst_omx_h264_utils_get_profile_from_str (const gchar * profile)
|
||||
{
|
||||
@@ -63,6 +76,15 @@
|
||||
if (g_str_equal (profile, h264_profiles[i].profile))
|
||||
return h264_profiles[i].e;
|
||||
}
|
||||
+
|
||||
+#ifdef USE_OMX_TARGET_STARFIVE
|
||||
+ for (i = 0; i < G_N_ELEMENTS (h264_ext_profiles); i++) {
|
||||
+ if (g_str_equal (profile, h264_ext_profiles[i].profile)) {
|
||||
+ GST_INFO("extra profile: %s ==> avc profie type: %d", profile, h264_ext_profiles[i].e);
|
||||
+ return h264_ext_profiles[i].e;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
return OMX_VIDEO_AVCProfileMax;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
Combine SPS/PPS header to IDR frame.
|
||||
|
||||
Signed-off-by: Windsome Zeng <windsome.zeng@starfivetech.com>
|
||||
|
||||
diff -purN a/meson.build b/meson.build
|
||||
--- a/meson.build 2022-05-13 11:31:02.725614796 +0800
|
||||
+++ b/meson.build 2022-05-13 11:32:26.213975419 +0800
|
||||
@@ -218,6 +218,7 @@ elif omx_target == 'tizonia'
|
||||
omx_inc = []
|
||||
elif omx_target == 'stf'
|
||||
cdata.set('USE_OMX_TARGET_STARFIVE', 1)
|
||||
+ gst_omx_args += ['-DCOMBINE_SPS_PPS_HEADERS']
|
||||
warning('stf selected')
|
||||
else
|
||||
error ('Unsupported omx target specified. Use the -Dtarget option')
|
||||
diff -purN a/omx/gstomx.c b/omx/gstomx.c
|
||||
--- a/omx/gstomx.c 2022-05-13 11:31:02.725614796 +0800
|
||||
+++ b/omx/gstomx.c 2022-05-13 11:33:15.461950978 +0800
|
||||
@@ -70,6 +70,11 @@ static GHashTable *core_handles;
|
||||
G_LOCK_DEFINE_STATIC (buffer_flags_str);
|
||||
static GHashTable *buffer_flags_str;
|
||||
|
||||
+#ifdef COMBINE_SPS_PPS_HEADERS
|
||||
+static OMX_U8 *sps_pps_header = NULL;
|
||||
+static OMX_U32 sps_pps_header_size = 0;
|
||||
+#endif
|
||||
+
|
||||
GstOMXCore *
|
||||
gst_omx_core_acquire (const gchar * filename)
|
||||
{
|
||||
@@ -903,6 +908,36 @@ FillBufferDone (OMX_HANDLETYPE hComponen
|
||||
|
||||
g_assert (buf->omx_buf == pBuffer);
|
||||
|
||||
+#ifdef COMBINE_SPS_PPS_HEADERS
|
||||
+ if (pBuffer->nFlags == 0x80) {
|
||||
+ g_assert (sps_pps_header == NULL);
|
||||
+ if (sps_pps_header)
|
||||
+ g_free (sps_pps_header);
|
||||
+
|
||||
+ sps_pps_header = g_new (OMX_U8, pBuffer->nFilledLen);
|
||||
+ if (sps_pps_header) {
|
||||
+ sps_pps_header_size = pBuffer->nFilledLen;
|
||||
+ memcpy(sps_pps_header, pBuffer->pBuffer + pBuffer->nOffset, pBuffer->nFilledLen);
|
||||
+ }
|
||||
+ return OMX_ErrorNone;
|
||||
+ }
|
||||
+
|
||||
+ if (sps_pps_header) {
|
||||
+ g_assert (sps_pps_header_size + pBuffer->nFilledLen <= pBuffer->nAllocLen);
|
||||
+ if (sps_pps_header_size + pBuffer->nFilledLen <= pBuffer->nAllocLen) {
|
||||
+ OMX_U8 *buf;
|
||||
+ buf = pBuffer->pBuffer + pBuffer->nOffset;
|
||||
+ memmove (buf + sps_pps_header_size, buf, pBuffer->nFilledLen);
|
||||
+ memcpy (buf, sps_pps_header, sps_pps_header_size);
|
||||
+ pBuffer->nFilledLen += sps_pps_header_size;
|
||||
+
|
||||
+ g_free (sps_pps_header);
|
||||
+ sps_pps_header = NULL;
|
||||
+ sps_pps_header_size = 0;
|
||||
+ }
|
||||
+ }
|
||||
+#endif /* COMBINE_SPS_PPS_HEADERS */
|
||||
+
|
||||
if (buf->port->tunneled) {
|
||||
GST_ERROR ("FillBufferDone on tunneled port");
|
||||
return OMX_ErrorBadParameter;
|
||||
@@ -0,0 +1,11 @@
|
||||
config BR2_PACKAGE_SF_GST_OMX
|
||||
bool "sf-gst-omx"
|
||||
depends on BR2_PACKAGE_SF_OMX_IL
|
||||
select BR2_PACKAGE_GST1_PLUGINS_BASE
|
||||
help
|
||||
GStreamer plug-in to use OpenMAX API.
|
||||
|
||||
https://cgit.freedesktop.org/gstreamer/gst-omx
|
||||
|
||||
comment "gst-omx requires a OpenMAX implementation"
|
||||
depends on !BR2_PACKAGE_SF_OMX_IL
|
||||
@@ -0,0 +1,3 @@
|
||||
# From https://gstreamer.freedesktop.org/src/gst-omx/gst-omx-1.18.5.tar.xz.sha256sum
|
||||
sha256 2cd457c1e8deb1a9b39608048fb36a44f6c9a864a6b6115b1453a32e7be93b42 gst-omx-1.18.5.tar.xz
|
||||
sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 COPYING
|
||||
@@ -0,0 +1,36 @@
|
||||
################################################################################
|
||||
#
|
||||
# sf-gst-omx
|
||||
#
|
||||
################################################################################
|
||||
|
||||
SF_GST_OMX_VERSION = 1.18.5
|
||||
SF_GST_OMX_SOURCE = gst-omx-$(GST_OMX_VERSION).tar.xz
|
||||
SF_GST_OMX_SITE = https://gstreamer.freedesktop.org/src/gst-omx
|
||||
|
||||
SF_GST_OMX_LICENSE = LGPL-2.1
|
||||
SF_GST_OMX_LICENSE_FILES = COPYING
|
||||
|
||||
SF_GST_OMX_CONF_OPTS = \
|
||||
-Dexamples=disabled \
|
||||
-Dtests=disabled \
|
||||
-Dtools=disabled \
|
||||
-Ddoc=disabled
|
||||
|
||||
|
||||
SF_GST_OMX_VARIANT = stf
|
||||
SF_GST_OMX_CONF_OPTS += -Dheader_path=$(STAGING_DIR)/usr/include/omx-il
|
||||
|
||||
SF_GST_OMX_CONF_OPTS += -Dtarget=$(SF_GST_OMX_VARIANT)
|
||||
|
||||
SF_GST_OMX_DEPENDENCIES = gstreamer1 gst1-plugins-base sf-omx-il
|
||||
|
||||
# adjust library paths to where buildroot installs them
|
||||
define SF_GST_OMX_FIXUP_CONFIG_PATHS
|
||||
find $(@D)/config -name gstomx.conf | \
|
||||
xargs $(SED) 's|/usr/local|/usr|g' -e 's|/opt/vc|/usr|g'
|
||||
endef
|
||||
|
||||
SF_GST_OMX_POST_PATCH_HOOKS += SF_GST_OMX_FIXUP_CONFIG_PATHS
|
||||
|
||||
$(eval $(meson-package))
|
||||
Reference in New Issue
Block a user