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
d948893d
Commit
d948893d
authored
Jun 17, 2012
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/subtitles: add some SMIL helpers.
This is needed for SAMI and RealText demuxers.
parent
e301f2f8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
subtitles.c
libavformat/subtitles.c
+44
-0
subtitles.h
libavformat/subtitles.h
+16
-0
No files found.
libavformat/subtitles.c
View file @
d948893d
...
...
@@ -20,6 +20,7 @@
#include "avformat.h"
#include "subtitles.h"
#include "libavutil/avstring.h"
AVPacket
*
ff_subtitles_queue_insert
(
FFDemuxSubtitlesQueue
*
q
,
const
uint8_t
*
event
,
int
len
,
int
merge
)
...
...
@@ -99,3 +100,46 @@ void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
av_freep
(
&
q
->
subs
);
q
->
nb_subs
=
q
->
allocated_size
=
q
->
current_sub_idx
=
0
;
}
int
ff_smil_extract_next_chunk
(
AVIOContext
*
pb
,
AVBPrint
*
buf
,
char
*
c
)
{
int
i
=
0
;
char
end_chr
;
if
(
!*
c
)
// cached char?
*
c
=
avio_r8
(
pb
);
if
(
!*
c
)
return
0
;
end_chr
=
*
c
==
'<'
?
'>'
:
'<'
;
do
{
av_bprint_chars
(
buf
,
*
c
,
1
);
*
c
=
avio_r8
(
pb
);
i
++
;
}
while
(
*
c
!=
end_chr
&&
*
c
);
if
(
end_chr
==
'>'
)
{
av_bprint_chars
(
buf
,
'>'
,
1
);
*
c
=
0
;
}
return
i
;
}
const
char
*
ff_smil_get_attr_ptr
(
const
char
*
s
,
const
char
*
attr
)
{
int
in_quotes
=
0
;
const
int
len
=
strlen
(
attr
);
while
(
*
s
)
{
while
(
*
s
)
{
if
(
!
in_quotes
&&
isspace
(
*
s
))
break
;
in_quotes
^=
*
s
==
'"'
;
// XXX: support escaping?
s
++
;
}
while
(
isspace
(
*
s
))
s
++
;
if
(
!
av_strncasecmp
(
s
,
attr
,
len
)
&&
s
[
len
]
==
'='
)
return
s
+
len
+
1
+
(
s
[
len
+
1
]
==
'"'
);
}
return
NULL
;
}
libavformat/subtitles.h
View file @
d948893d
...
...
@@ -23,6 +23,7 @@
#include <stdint.h>
#include "avformat.h"
#include "libavutil/bprint.h"
typedef
struct
{
AVPacket
*
subs
;
///< array of subtitles packets
...
...
@@ -58,4 +59,19 @@ int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt);
*/
void
ff_subtitles_queue_clean
(
FFDemuxSubtitlesQueue
*
q
);
/**
* SMIL helper to load next chunk ("<...>" or untagged content) in buf.
*
* @param c cached character, to avoid a backward seek
*/
int
ff_smil_extract_next_chunk
(
AVIOContext
*
pb
,
AVBPrint
*
buf
,
char
*
c
);
/**
* SMIL helper to point on the value of an attribute in the given tag.
*
* @param s SMIL tag ("<...>")
* @param attr the attribute to look for
*/
const
char
*
ff_smil_get_attr_ptr
(
const
char
*
s
,
const
char
*
attr
);
#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