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
f148954b
Commit
f148954b
authored
Oct 23, 2013
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ass: factor out ff_ass_bprint_dialog
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
65fb59ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
12 deletions
+46
-12
ass.c
libavcodec/ass.c
+23
-12
ass.h
libavcodec/ass.h
+23
-0
No files found.
libavcodec/ass.c
View file @
f148954b
...
...
@@ -77,14 +77,11 @@ static void insert_ts(AVBPrint *buf, int ts)
}
}
int
ff_ass_
add_rect
(
AVSubtitle
*
sub
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
)
int
ff_ass_
bprint_dialog
(
AVBPrint
*
buf
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
)
{
AVBPrint
buf
;
int
ret
,
dlen
;
AVSubtitleRect
**
rects
;
int
dlen
;
av_bprint_init
(
&
buf
,
0
,
AV_BPRINT_SIZE_UNLIMITED
);
if
(
!
raw
||
raw
==
2
)
{
long
int
layer
=
0
;
...
...
@@ -101,19 +98,33 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
return
AVERROR_INVALIDDATA
;
dialog
++
;
}
av_bprintf
(
&
buf
,
"Dialogue: %ld,"
,
layer
);
insert_ts
(
&
buf
,
ts_start
);
insert_ts
(
&
buf
,
duration
==
-
1
?
-
1
:
ts_start
+
duration
);
av_bprintf
(
buf
,
"Dialogue: %ld,"
,
layer
);
insert_ts
(
buf
,
ts_start
);
insert_ts
(
buf
,
duration
==
-
1
?
-
1
:
ts_start
+
duration
);
if
(
raw
!=
2
)
av_bprintf
(
&
buf
,
"Default,"
);
av_bprintf
(
buf
,
"Default,"
);
}
dlen
=
strcspn
(
dialog
,
"
\n
"
);
dlen
+=
dialog
[
dlen
]
==
'\n'
;
av_bprintf
(
&
buf
,
"%.*s"
,
dlen
,
dialog
);
av_bprintf
(
buf
,
"%.*s"
,
dlen
,
dialog
);
if
(
raw
==
2
)
av_bprintf
(
&
buf
,
"
\r\n
"
);
av_bprintf
(
buf
,
"
\r\n
"
);
return
dlen
;
}
int
ff_ass_add_rect
(
AVSubtitle
*
sub
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
)
{
AVBPrint
buf
;
int
ret
,
dlen
;
AVSubtitleRect
**
rects
;
av_bprint_init
(
&
buf
,
0
,
AV_BPRINT_SIZE_UNLIMITED
);
if
((
dlen
=
ff_ass_bprint_dialog
(
&
buf
,
dialog
,
ts_start
,
duration
,
raw
))
<
0
)
return
dlen
;
if
(
!
av_bprint_is_complete
(
&
buf
))
return
AVERROR
(
ENOMEM
);
...
...
libavcodec/ass.h
View file @
f148954b
...
...
@@ -23,6 +23,7 @@
#define AVCODEC_ASS_H
#include "avcodec.h"
#include "libavutil/bprint.h"
/**
* @name Default values for ASS style
...
...
@@ -90,4 +91,26 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx);
int
ff_ass_add_rect
(
AVSubtitle
*
sub
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
);
/**
* Add an ASS dialog line to an AVBPrint buffer.
*
* @param buf pointer to an initialized AVBPrint buffer
* @param dialog ASS dialog to add to sub
* @param ts_start start timestamp for this dialog (in 1/100 second unit)
* @param duration duration for this dialog (in 1/100 second unit), can be -1
* to last until the end of the presentation
* @param raw when set to 2, it indicates that dialog contains an ASS
* dialog line as muxed in Matroska
* when set to 1, it indicates that dialog contains a whole SSA
* dialog line which should be copied as is.
* when set to 0, it indicates that dialog contains only the Text
* part of the ASS dialog line, the rest of the line
* will be generated.
* @return number of characters read from dialog. It can be less than the whole
* length of dialog, if dialog contains several lines of text.
* A negative value indicates an error.
*/
int
ff_ass_bprint_dialog
(
AVBPrint
*
buf
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
);
#endif
/* AVCODEC_ASS_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