closedcaption: move cdp framerate table to common file
authorMatthew Waters <matthew@centricular.com>
Thu, 12 May 2022 03:19:58 +0000 (13:19 +1000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 10 Nov 2022 00:52:14 +0000 (00:52 +0000)
shared by both cccombiner and ccconverter

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3211>

subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c [new file with mode: 0644]
subprojects/gst-plugins-bad/ext/closedcaption/ccutils.h [new file with mode: 0644]
subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c
subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.h
subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c
subprojects/gst-plugins-bad/ext/closedcaption/meson.build

diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c b/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c
new file mode 100644 (file)
index 0000000..3c96754
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * GStreamer
+ * Copyright (C) 2022 Matthew Waters <matthew@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "ccutils.h"
+
+static const struct cdp_fps_entry cdp_fps_table[] = {
+  {0x1f, 24000, 1001, 25, 22, 3 /* FIXME: alternating max cea608 count! */ },
+  {0x2f, 24, 1, 25, 22, 2},
+  {0x3f, 25, 1, 24, 22, 2},
+  {0x4f, 30000, 1001, 20, 18, 2},
+  {0x5f, 30, 1, 20, 18, 2},
+  {0x6f, 50, 1, 12, 11, 1},
+  {0x7f, 60000, 1001, 10, 9, 1},
+  {0x8f, 60, 1, 10, 9, 1},
+};
+const struct cdp_fps_entry null_fps_entry = { 0, 0, 0, 0 };
+
+const struct cdp_fps_entry *
+cdp_fps_entry_from_fps (guint fps_n, guint fps_d)
+{
+  int i;
+  for (i = 0; i < G_N_ELEMENTS (cdp_fps_table); i++) {
+    if (cdp_fps_table[i].fps_n == fps_n && cdp_fps_table[i].fps_d == fps_d)
+      return &cdp_fps_table[i];
+  }
+  return &null_fps_entry;
+}
+
+const struct cdp_fps_entry *
+cdp_fps_entry_from_id (guint8 id)
+{
+  int i;
+  for (i = 0; i < G_N_ELEMENTS (cdp_fps_table); i++) {
+    if (cdp_fps_table[i].fps_idx == id)
+      return &cdp_fps_table[i];
+  }
+  return &null_fps_entry;
+}
diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.h b/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.h
new file mode 100644 (file)
index 0000000..d7586c8
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * GStreamer
+ * Copyright (C) 2022 Matthew Waters <matthew@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>
+
+#ifndef __CCUTILS_H__
+#define __CCUTILS_H__
+
+G_BEGIN_DECLS
+
+struct cdp_fps_entry
+{
+  guint8 fps_idx;               /* value stored in cdp */
+  guint fps_n, fps_d;
+  guint max_cc_count;
+  guint max_ccp_count;
+  guint max_cea608_count;
+};
+
+G_GNUC_INTERNAL
+const struct cdp_fps_entry * cdp_fps_entry_from_fps (guint fps_n, guint fps_d);
+G_GNUC_INTERNAL
+const struct cdp_fps_entry * cdp_fps_entry_from_id  (guint8 id);
+
+extern const struct cdp_fps_entry null_fps_entry;
+
+G_END_DECLS
+
+#endif
index 15a41c1..0f75170 100644 (file)
@@ -28,6 +28,7 @@
 #include <gst/video/video.h>
 #include <string.h>
 
+#include "ccutils.h"
 #include "gstcccombiner.h"
 
 GST_DEBUG_CATEGORY_STATIC (gst_cc_combiner_debug);
@@ -192,30 +193,6 @@ done:
 #define MAX_CDP_PACKET_LEN 256
 #define MAX_CEA608_LEN 32
 
-static const struct cdp_fps_entry cdp_fps_table[] = {
-  {0x1f, 24000, 1001, 25, 22, 3 /* FIXME: alternating max cea608 count! */ },
-  {0x2f, 24, 1, 25, 22, 2},
-  {0x3f, 25, 1, 24, 22, 2},
-  {0x4f, 30000, 1001, 20, 18, 2},
-  {0x5f, 30, 1, 20, 18, 2},
-  {0x6f, 50, 1, 12, 11, 1},
-  {0x7f, 60000, 1001, 10, 9, 1},
-  {0x8f, 60, 1, 10, 9, 1},
-};
-static const struct cdp_fps_entry null_fps_entry = { 0, 0, 0, 0 };
-
-static const struct cdp_fps_entry *
-cdp_fps_entry_from_fps (guint fps_n, guint fps_d)
-{
-  int i;
-  for (i = 0; i < G_N_ELEMENTS (cdp_fps_table); i++) {
-    if (cdp_fps_table[i].fps_n == fps_n && cdp_fps_table[i].fps_d == fps_d)
-      return &cdp_fps_table[i];
-  }
-  return &null_fps_entry;
-}
-
-
 static GstBuffer *
 make_cdp (GstCCCombiner * self, const guint8 * cc_data, guint cc_data_len,
     const struct cdp_fps_entry *fps_entry, const GstVideoTimeCode * tc)
index 6336ab1..2b17e41 100644 (file)
@@ -40,15 +40,6 @@ G_BEGIN_DECLS
 typedef struct _GstCCCombiner GstCCCombiner;
 typedef struct _GstCCCombinerClass GstCCCombinerClass;
 
-struct cdp_fps_entry
-{
-  guint8 fps_idx;
-  guint fps_n, fps_d;
-  guint max_cc_count;
-  guint max_ccp_count;
-  guint max_cea608_count;
-};
-
 struct _GstCCCombiner
 {
   GstAggregator parent;
index 1774364..10d1204 100644 (file)
@@ -28,6 +28,7 @@
 #include <gst/video/video.h>
 #include <string.h>
 
+#include "ccutils.h"
 #include "gstccconverter.h"
 
 GST_DEBUG_CATEGORY_STATIC (gst_cc_converter_debug);
@@ -471,49 +472,6 @@ invalid_caps:
   }
 }
 
-struct cdp_fps_entry
-{
-  guint8 fps_idx;
-  guint fps_n, fps_d;
-  guint max_cc_count;
-  guint max_ccp_count;
-  guint max_cea608_count;
-};
-
-static const struct cdp_fps_entry cdp_fps_table[] = {
-  {0x1f, 24000, 1001, 25, 22, 3 /* FIXME: alternating max cea608 count! */ },
-  {0x2f, 24, 1, 25, 22, 2},
-  {0x3f, 25, 1, 24, 22, 2},
-  {0x4f, 30000, 1001, 20, 18, 2},
-  {0x5f, 30, 1, 20, 18, 2},
-  {0x6f, 50, 1, 12, 11, 1},
-  {0x7f, 60000, 1001, 10, 9, 1},
-  {0x8f, 60, 1, 10, 9, 1},
-};
-static const struct cdp_fps_entry null_fps_entry = { 0, 0, 0, 0 };
-
-static const struct cdp_fps_entry *
-cdp_fps_entry_from_id (guint8 id)
-{
-  int i;
-  for (i = 0; i < G_N_ELEMENTS (cdp_fps_table); i++) {
-    if (cdp_fps_table[i].fps_idx == id)
-      return &cdp_fps_table[i];
-  }
-  return &null_fps_entry;
-}
-
-static const struct cdp_fps_entry *
-cdp_fps_entry_from_fps (guint fps_n, guint fps_d)
-{
-  int i;
-  for (i = 0; i < G_N_ELEMENTS (cdp_fps_table); i++) {
-    if (cdp_fps_table[i].fps_n == fps_n && cdp_fps_table[i].fps_d == fps_d)
-      return &cdp_fps_table[i];
-  }
-  return &null_fps_entry;
-}
-
 static void
 get_framerate_output_scale (GstCCConverter * self,
     const struct cdp_fps_entry *in_fps_entry, gint * scale_n, gint * scale_d)
index 568d51f..ab83582 100644 (file)
@@ -12,7 +12,7 @@ zvbi_sources = [
 if closedcaption_dep.found()
   gstclosedcaption = library('gstclosedcaption',
     'gstcccombiner.c', 'gstccextractor.c', 'gstccconverter.c', 'gstclosedcaption.c',
-    'gstline21dec.c', 'gstcea708decoder.c', 'gstceaccoverlay.c', 'gstline21enc.c',
+    'gstline21dec.c', 'gstcea708decoder.c', 'gstceaccoverlay.c', 'gstline21enc.c', 'ccutils.c',
     zvbi_sources,
     c_args : gst_plugins_bad_args,
     link_args : noseh_link_args,