diff --git a/ChangeLog b/ChangeLog index ca7cf753bb..06260b2394 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-12-08 Tim-Philipp Müller + + Patch by: Robin Stocker + + * 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 * gst/playback/gstplay-enum.c: diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 7b11a47a0f..ab18bd4d38 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -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) { diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c index 9bc5eafe7c..df1db2b75e 100644 --- a/tests/check/elements/subparse.c +++ b/tests/check/elements/subparse.c @@ -106,6 +106,17 @@ static SubParseInputChunk srt_input[] = { 600 * GST_SECOND, 660 * GST_SECOND, "This is in blue but <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;