summaryrefslogtreecommitdiff
path: root/gst/dvbsubenc/gstdvbsubenc.h
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2020-04-07 21:47:22 +1000
committerJan Schmidt <jan@centricular.com>2020-06-17 12:50:13 +1000
commit1cf3cae5e1e35c2e8eb8a919db77f2970e743676 (patch)
treefc0411d02fc3ad55378912f49b85fb6406db99f0 /gst/dvbsubenc/gstdvbsubenc.h
parentf899728dd45bbf154123bca3c1c8c9e2b6af5c24 (diff)
downloadgstreamer-plugins-bad-1cf3cae5e1e35c2e8eb8a919db77f2970e743676.tar.gz
dvbsubenc: Add DVB Subtitle encoder
Add an element that converts AYUV video frames to a DVB subpicture stream. It's fairly simple for now. Later it would be good to support input via a stream that contains only GstVideoOverlayComposition meta. The element searches each input video frame for the largest sub-region containing non-transparent pixels and encodes that as a single DVB subpicture region. It can also do palette reduction of the input frames using code taken from libimagequant. There are various FIXME for potential improvements for now, but it works. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1227>
Diffstat (limited to 'gst/dvbsubenc/gstdvbsubenc.h')
-rw-r--r--gst/dvbsubenc/gstdvbsubenc.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gst/dvbsubenc/gstdvbsubenc.h b/gst/dvbsubenc/gstdvbsubenc.h
new file mode 100644
index 000000000..76d8f5fd6
--- /dev/null
+++ b/gst/dvbsubenc/gstdvbsubenc.h
@@ -0,0 +1,70 @@
+/* GStreamer
+ * Copyright (C) <2020> Jan Schmidt <jan@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+
+#define GST_TYPE_DVB_SUB_ENC (gst_dvb_sub_enc_get_type())
+#define GST_DVB_SUB_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVB_SUB_ENC,GstDvbSubEnc))
+#define GST_DVB_SUB_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVB_SUB_ENC,GstDvbSubEncClass))
+#define GST_IS_DVB_SUB_ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVB_SUB_ENC))
+#define GST_IS_DVB_SUB_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVB_SUB_ENC))
+
+GST_DEBUG_CATEGORY_EXTERN (gst_dvb_sub_enc_debug);
+#define GST_CAT_DEFAULT (gst_dvb_sub_enc_debug)
+
+typedef struct _GstDvbSubEnc GstDvbSubEnc;
+typedef struct _GstDvbSubEncClass GstDvbSubEncClass;
+typedef struct SubpictureRect SubpictureRect;
+
+struct SubpictureRect {
+ /* Paletted 8-bit picture */
+ GstVideoFrame *frame;
+ /* Actual number of colours used from the palette */
+ guint32 nb_colours;
+
+ guint x, y;
+};
+
+struct _GstDvbSubEnc
+{
+ GstElement element;
+
+ GstVideoInfo in_info;
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ int object_version;
+
+ int max_colours;
+ GstClockTimeDiff ts_offset;
+
+ GstClockTime current_end_time;
+};
+
+struct _GstDvbSubEncClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_dvb_sub_enc_get_type (void);
+
+gboolean gst_dvbsubenc_ayuv_to_ayuv8p (GstVideoFrame * src, GstVideoFrame * dest, int max_colours, guint32 *out_num_colours);
+
+GstBuffer *gst_dvbenc_encode (int object_version, int page_id, SubpictureRect *s, guint num_subpictures);