Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
378a830e
Commit
378a830e
authored
Sep 08, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/subtitles: support standalone CR (MacOS).
Recent .srt files with CR only were found in the wild.
parent
90fc00a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
subtitles.c
libavformat/subtitles.c
+3
-2
subtitles.h
libavformat/subtitles.h
+11
-2
No files found.
libavformat/subtitles.c
View file @
378a830e
...
@@ -228,7 +228,7 @@ static inline int is_eol(char c)
...
@@ -228,7 +228,7 @@ static inline int is_eol(char c)
void
ff_subtitles_read_chunk
(
AVIOContext
*
pb
,
AVBPrint
*
buf
)
void
ff_subtitles_read_chunk
(
AVIOContext
*
pb
,
AVBPrint
*
buf
)
{
{
char
eol_buf
[
5
];
char
eol_buf
[
5
]
,
last_was_cr
=
0
;
int
n
=
0
,
i
=
0
,
nb_eol
=
0
;
int
n
=
0
,
i
=
0
,
nb_eol
=
0
;
av_bprint_clear
(
buf
);
av_bprint_clear
(
buf
);
...
@@ -245,12 +245,13 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf)
...
@@ -245,12 +245,13 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf)
/* line break buffering: we don't want to add the trailing \r\n */
/* line break buffering: we don't want to add the trailing \r\n */
if
(
is_eol
(
c
))
{
if
(
is_eol
(
c
))
{
nb_eol
+=
c
==
'\n'
;
nb_eol
+=
c
==
'\n'
||
last_was_cr
;
if
(
nb_eol
==
2
)
if
(
nb_eol
==
2
)
break
;
break
;
eol_buf
[
i
++
]
=
c
;
eol_buf
[
i
++
]
=
c
;
if
(
i
==
sizeof
(
eol_buf
)
-
1
)
if
(
i
==
sizeof
(
eol_buf
)
-
1
)
break
;
break
;
last_was_cr
=
c
==
'\r'
;
continue
;
continue
;
}
}
...
...
libavformat/subtitles.h
View file @
378a830e
...
@@ -99,11 +99,20 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
...
@@ -99,11 +99,20 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
/**
/**
* Get the number of characters to increment to jump to the next line, or to
* Get the number of characters to increment to jump to the next line, or to
* the end of the string.
* the end of the string.
* The function handles the following line breaks schemes: LF (any sane
* system), CRLF (MS), or standalone CR (old MacOS).
*/
*/
static
av_always_inline
int
ff_subtitles_next_line
(
const
char
*
ptr
)
static
av_always_inline
int
ff_subtitles_next_line
(
const
char
*
ptr
)
{
{
int
n
=
strcspn
(
ptr
,
"
\n
"
);
int
n
=
strcspn
(
ptr
,
"
\r\n
"
);
return
n
+
!!*
ptr
;
ptr
+=
n
;
if
(
*
ptr
==
'\r'
)
{
ptr
++
;
n
++
;
}
if
(
*
ptr
==
'\n'
)
n
++
;
return
n
;
}
}
#endif
/* AVFORMAT_SUBTITLES_H */
#endif
/* AVFORMAT_SUBTITLES_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment