gst/subparse/gstsubparse.c: Some .srt files start with chunk number 0 and not chunk...
authorRobin Stocker <robin.stocker@gmx.ch>
Sat, 8 Dec 2007 18:38:39 +0000 (18:38 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Sat, 8 Dec 2007 18:38:39 +0000 (18:38 +0000)
Original commit message from CVS:
Patch by: Robin Stocker <robin dot stocker at gmx dot ch>
* gst/subparse/gstsubparse.c: (gst_sub_parse_data_format_autodetect):
Some .srt files start with chunk number 0 and not chunk number 1,
recognise and accept those as well (fixes #502497).
* tests/check/elements/subparse.c: (srt_input), (srt_input0),
(test_src):
Add unit test for the above.

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

index ca7cf75..06260b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-12-08  Tim-Philipp Müller  <tim at centricular dot net>
+
+       Patch by: Robin Stocker <robin dot stocker at gmx dot ch>
+
+       * gst/subparse/gstsubparse.c: (gst_sub_parse_data_format_autodetect):
+         Some .srt files start with chunk number 0 and not chunk number 1,
+         recognise and accept those as well (fixes #502497).
+
+       * tests/check/elements/subparse.c: (srt_input), (srt_input0),
+         (test_src):
+         Add unit test for the above.
+
 2007-12-06  Wim Taymans  <wim.taymans@gmail.com>
 
        * gst/playback/gstplay-enum.c:
index 7b11a47..ab18bd4 100644 (file)
@@ -895,7 +895,7 @@ 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, "^[1-9]([0-9]){0,3}(\x0d)?\x0a"
+        (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}",
                 REG_EXTENDED | REG_NEWLINE | REG_NOSUB)) != 0) {
index 9bc5eaf..df1db2b 100644 (file)
@@ -106,6 +106,17 @@ static SubParseInputChunk srt_input[] = {
       600 * GST_SECOND, 660 * GST_SECOND, "This is in blue but &lt;5"}
 };
 
+/* starts with chunk number 0 (not exactly according to spec) */
+static SubParseInputChunk srt_input0[] = {
+  {
+        "0\n00:00:01,000 --> 00:00:02,000\nOne\n\n",
+      1 * GST_SECOND, 2 * GST_SECOND, "One"}, {
+        "1\n00:00:02,000 --> 00:00:03,000\nTwo\n\n",
+      2 * GST_SECOND, 3 * GST_SECOND, "Two"}, {
+        "2\n00:00:03,000 --> 00:00:04,000\nThree\n\n",
+      3 * GST_SECOND, 4 * GST_SECOND, "Three"}
+};
+
 static void
 setup_subparse (void)
 {
@@ -205,6 +216,9 @@ GST_START_TEST (test_srt)
 
   /* try with empty input, immediate EOS */
   test_srt_do_test (srt_input, 5, G_N_ELEMENTS (srt_input) - 5);
+
+  /* try with chunk number 0 (which is not exactly according to spec) */
+  test_srt_do_test (srt_input0, 0, G_N_ELEMENTS (srt_input0));
 }
 
 GST_END_TEST;