Make the detection of the used subtitle a bit less strict for srt subtitles. Fixes...
authorSebastian Dröge <slomo@circular-chaos.org>
Fri, 10 Oct 2008 15:32:10 +0000 (15:32 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Fri, 10 Oct 2008 15:32:10 +0000 (15:32 +0000)
Original commit message from CVS:
Based on a patch by: xavierb at gmail dot com
* gst/subparse/gstsubparse.c:
(gst_sub_parse_data_format_autodetect):
* tests/check/elements/subparse.c: (GST_START_TEST):
Make the detection of the used subtitle a bit less strict
for srt subtitles. Fixes bug #555607.

ChangeLog
gst/subparse/gstsubparse.c
tests/check/elements/subparse.c

index b8d1d0f..9439e35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-10-10  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
 
+       Based on a patch by: xavierb at gmail dot com
+
+       * gst/subparse/gstsubparse.c:
+       (gst_sub_parse_data_format_autodetect):
+       * tests/check/elements/subparse.c: (GST_START_TEST):
+       Make the detection of the used subtitle a bit less strict
+       for srt subtitles. Fixes bug #555607.
+
+2008-10-10  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
+
        * ext/vorbis/vorbisenc.c:
        (gst_vorbis_enc_buffer_check_discontinuous):
        Fix discontinuity detection which was broken by last commit.
index 6dc25bc..dc2a345 100644 (file)
@@ -913,9 +913,9 @@ gst_sub_parse_data_format_autodetect (gchar * match_str)
     need_init_regexps = FALSE;
     if ((err = regcomp (&mdvd_rx, "^\\{[0-9]+\\}\\{[0-9]+\\}",
                 REG_EXTENDED | REG_NEWLINE | REG_NOSUB) != 0) ||
-        (err = regcomp (&subrip_rx, "^[0-9]([0-9]){0,3}(\x0d)?\x0a"
-                "[0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9]{3}"
-                " --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9]{3}",
+        (err = regcomp (&subrip_rx, "^([ 0-9]){0,3}[0-9](\x0d)?\x0a"
+                "[ 0-9][0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]"
+                " --> ([ 0-9])?[0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]",
                 REG_EXTENDED | REG_NEWLINE | REG_NOSUB)) != 0) {
       regerror (err, &subrip_rx, errstr, 127);
       GST_WARNING ("Compilation of subrip regex failed: %s", errstr);
index 8cb02f4..05e3619 100644 (file)
@@ -116,6 +116,22 @@ static SubParseInputChunk srt_input0[] = {
       3 * GST_SECOND, 4 * GST_SECOND, "Three"}
 };
 
+/* has spaces instead of doubled zeroes (not exactly according to spec) */
+static SubParseInputChunk srt_input1[] = {
+  {
+        "1\n 0: 0:26, 26 --> 0: 0:28, 17\nI cant see.\n\n",
+        26 * GST_SECOND + 26 * GST_MSECOND,
+      28 * GST_SECOND + 17 * GST_MSECOND, "I cant see."},
+  {
+        "2\n 0: 0:30, 30 --> 0: 0:33, 22\nI really cant see.\n\n",
+        30 * GST_SECOND + 30 * GST_MSECOND,
+      33 * GST_SECOND + 22 * GST_MSECOND, "I really cant see."},
+  {
+        "3\n 0: 0:40, 40 --> 0: 0:44, 44\nI still cant see anything.\n\n",
+        40 * GST_SECOND + 40 * GST_MSECOND,
+      44 * GST_SECOND + 44 * GST_MSECOND, "I still cant see anything."}
+};
+
 static void
 setup_subparse (void)
 {
@@ -218,6 +234,9 @@ GST_START_TEST (test_srt)
 
   /* try with chunk number 0 (which is not exactly according to spec) */
   test_srt_do_test (srt_input0, 0, G_N_ELEMENTS (srt_input0));
+
+  /* try with spaces instead of doubled zeroes (which is not exactly according to spec) */
+  test_srt_do_test (srt_input1, 0, G_N_ELEMENTS (srt_input1));
 }
 
 GST_END_TEST;