From bed6719df772ffb8a8f30d97382da601d6782bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 29 Aug 2007 12:16:46 +0000 Subject: [PATCH] gst/subparse/gstssaparse.c: Convert SSA newline codes into actual newline characters (#470766). Original commit message from CVS: * gst/subparse/gstssaparse.c: Convert SSA newline codes into actual newline characters (#470766). --- ChangeLog | 5 +++++ gst/subparse/gstssaparse.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ChangeLog b/ChangeLog index d1087dfdb2..d68b3b46e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-08-29 Tim-Philipp Müller + + * gst/subparse/gstssaparse.c: + Convert SSA newline codes into actual newline characters (#470766). + 2007-08-28 Tim-Philipp Müller * docs/libs/gst-plugins-base-libs-sections.txt: diff --git a/gst/subparse/gstssaparse.c b/gst/subparse/gstssaparse.c index 94e83ab48a..d876f1bdb3 100644 --- a/gst/subparse/gstssaparse.c +++ b/gst/subparse/gstssaparse.c @@ -204,6 +204,21 @@ gst_ssa_parse_remove_override_codes (GstSsaParse * parse, gchar * txt) removed_any = TRUE; } + /* these may occur outside of curly brackets. We don't handle the different + * wrapping modes yet, so just remove these markers from the text for now */ + while ((t = strstr (txt, "\\n"))) { + t[0] = ' '; + t[1] = '\n'; + } + while ((t = strstr (txt, "\\N"))) { + t[0] = ' '; + t[1] = '\n'; + } + while ((t = strstr (txt, "\\h"))) { + t[0] = ' '; + t[1] = ' '; + } + return removed_any; } @@ -273,6 +288,9 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf) GstClockTime ts; gchar *txt; + if (G_UNLIKELY (!parse->framed)) + goto not_framed; + /* make double-sure it's 0-terminated and all */ txt = g_strndup ((gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); @@ -295,6 +313,14 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf) g_free (txt); return ret; + +/* ERRORS */ +not_framed: + { + GST_ELEMENT_ERROR (parse, STREAM, FORMAT, (NULL), + ("Only SSA subtitles embedded in containers are supported")); + return GST_FLOW_NOT_NEGOTIATED; + } } static GstStateChangeReturn