From: Robin Stocker Date: Sat, 8 Dec 2007 18:38:39 +0000 (+0000) Subject: gst/subparse/gstsubparse.c: Some .srt files start with chunk number 0 and not chunk... X-Git-Tag: 1.19.3~511^2~10805 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7bbbf15ad829b27ef81f595bbab3449aaf42667c;p=platform%2Fupstream%2Fgstreamer.git gst/subparse/gstsubparse.c: Some .srt files start with chunk number 0 and not chunk number 1, recognise and accept th... Original commit message from CVS: 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. --- diff --git a/ChangeLog b/ChangeLog index ca7cf75..06260b2 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 7b11a47..ab18bd4 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 9bc5eaf..df1db2b 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;