diff options
author | Marton Balint <cus@passwd.hu> | 2013-10-23 11:20:04 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2013-11-10 18:57:51 +0100 |
commit | f148954b0ac11123e47eedf24abb99366dc9a3ad (patch) | |
tree | 740af248ceb3197370d3438ebd98b39f3d0090da /libavcodec/ass.c | |
parent | 65fb59abd27af8e71f3a76e30f4536a878918fb1 (diff) | |
download | ffmpeg-f148954b0ac11123e47eedf24abb99366dc9a3ad.tar.gz |
ass: factor out ff_ass_bprint_dialog
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavcodec/ass.c')
-rw-r--r-- | libavcodec/ass.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 6fe18f512e..21d2b8b380 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -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); |