Make the detection of the used subtitle a bit less strict for srt subtitles. Fixes bug #555607.

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.
This commit is contained in:
Sebastian Dröge 2008-10-10 15:32:10 +00:00
parent 0d43cf2474
commit b735321f58
3 changed files with 32 additions and 3 deletions

View file

@ -1,3 +1,13 @@
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:

View 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);

View 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;