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
1043cb8e
Commit
1043cb8e
authored
Apr 09, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/ass: use bprint API in ff_ass_add_rect().
parent
b4eb06d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
ass.c
libavcodec/ass.c
+26
-19
No files found.
libavcodec/ass.c
View file @
1043cb8e
...
...
@@ -23,6 +23,7 @@
#include "ass.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
int
ff_ass_subtitle_header
(
AVCodecContext
*
avctx
,
...
...
@@ -62,36 +63,42 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx)
ASS_DEFAULT_ALIGNMENT
);
}
static
int
ts_to_string
(
char
*
str
,
int
strlen
,
int
ts
)
static
void
insert_ts
(
AVBPrint
*
buf
,
int
ts
)
{
int
h
,
m
,
s
;
h
=
ts
/
360000
;
ts
-=
360000
*
h
;
m
=
ts
/
6000
;
ts
-=
6000
*
m
;
s
=
ts
/
100
;
ts
-=
100
*
s
;
return
snprintf
(
str
,
strlen
,
"%d:%02d:%02d.%02d"
,
h
,
m
,
s
,
ts
);
if
(
ts
==
-
1
)
{
av_bprintf
(
buf
,
"9:59:59.99,"
);
}
else
{
int
h
,
m
,
s
;
h
=
ts
/
360000
;
ts
-=
360000
*
h
;
m
=
ts
/
6000
;
ts
-=
6000
*
m
;
s
=
ts
/
100
;
ts
-=
100
*
s
;
av_bprintf
(
buf
,
"%d:%02d:%02d.%02d,"
,
h
,
m
,
s
,
ts
);
}
}
int
ff_ass_add_rect
(
AVSubtitle
*
sub
,
const
char
*
dialog
,
int
ts_start
,
int
duration
,
int
raw
)
{
int
len
=
0
,
dlen
;
char
s_start
[
16
],
s_end
[
16
],
header
[
48
]
=
{
0
}
;
AVBPrint
buf
;
int
ret
,
dlen
;
AVSubtitleRect
**
rects
;
av_bprint_init
(
&
buf
,
0
,
AV_BPRINT_SIZE_UNLIMITED
);
if
(
!
raw
)
{
ts_to_string
(
s_start
,
sizeof
(
s_start
),
ts_start
);
if
(
duration
==
-
1
)
snprintf
(
s_end
,
sizeof
(
s_end
),
"9:59:59.99"
);
else
ts_to_string
(
s_end
,
sizeof
(
s_end
),
ts_start
+
duration
);
len
=
snprintf
(
header
,
sizeof
(
header
),
"Dialogue: 0,%s,%s,Default,"
,
s_start
,
s_end
);
av_assert0
(
len
<
sizeof
(
header
));
av_bprintf
(
&
buf
,
"Dialogue: 0,"
);
insert_ts
(
&
buf
,
ts_start
);
insert_ts
(
&
buf
,
duration
==
-
1
?
-
1
:
ts_start
+
duration
);
av_bprintf
(
&
buf
,
"Default,"
);
}
dlen
=
strcspn
(
dialog
,
"
\n
"
);
dlen
+=
dialog
[
dlen
]
==
'\n'
;
av_bprintf
(
&
buf
,
"%.*s"
,
dlen
,
dialog
);
if
(
!
av_bprint_is_complete
(
&
buf
))
return
AVERROR
(
ENOMEM
);
rects
=
av_realloc
(
sub
->
rects
,
(
sub
->
num_rects
+
1
)
*
sizeof
(
*
sub
->
rects
));
if
(
!
rects
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -99,9 +106,9 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
sub
->
end_display_time
=
FFMAX
(
sub
->
end_display_time
,
10
*
duration
);
rects
[
sub
->
num_rects
]
=
av_mallocz
(
sizeof
(
*
rects
[
0
]));
rects
[
sub
->
num_rects
]
->
type
=
SUBTITLE_ASS
;
re
cts
[
sub
->
num_rects
]
->
ass
=
av_malloc
(
len
+
dlen
+
1
);
strcpy
(
rects
[
sub
->
num_rects
]
->
ass
,
header
);
av_strlcpy
(
rects
[
sub
->
num_rects
]
->
ass
+
len
,
dialog
,
dlen
+
1
)
;
re
t
=
av_bprint_finalize
(
&
buf
,
&
rects
[
sub
->
num_rects
]
->
ass
);
if
(
ret
<
0
)
return
ret
;
sub
->
num_rects
++
;
return
dlen
;
}
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