summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/assenc.c2
-rw-r--r--libavcodec/avcodec.h2
-rw-r--r--libavcodec/movtextenc.c7
-rw-r--r--libavcodec/options_table.h6
-rw-r--r--libavcodec/srtenc.c7
-rw-r--r--libavcodec/utils.c4
-rw-r--r--libavcodec/version.h3
-rw-r--r--libavcodec/webvttenc.c7
8 files changed, 35 insertions, 3 deletions
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index 4e9825cb66..dc4f0ffa97 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -60,6 +60,7 @@ static int ass_encode_frame(AVCodecContext *avctx,
return -1;
}
+#if FF_API_ASS_TIMING
if (!strncmp(ass, "Dialogue: ", 10)) {
if (i > 0) {
av_log(avctx, AV_LOG_ERROR, "ASS encoder supports only one "
@@ -86,6 +87,7 @@ static int ass_encode_frame(AVCodecContext *avctx,
ass_line[strcspn(ass_line, "\r\n")] = 0;
ass = ass_line;
}
+#endif
len = av_strlcpy(buf+total_len, ass, bufsize-total_len);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 695ca053e1..5dc4b73e72 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3291,7 +3291,9 @@ typedef struct AVCodecContext {
int sub_text_format;
#define FF_SUB_TEXT_FMT_ASS 0
+#if FF_API_ASS_TIMING
#define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1
+#endif
/**
* Skip processing alpha if supported by codec.
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index fcd66138dc..791132ae1a 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -324,7 +324,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
{
MovTextContext *s = avctx->priv_data;
ASSDialog *dialog;
- int i, num, length;
+ int i, length;
size_t j;
s->text_pos = 0;
@@ -339,19 +339,24 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
return AVERROR(ENOSYS);
}
+#if FF_API_ASS_TIMING
if (!strncmp(ass, "Dialogue: ", 10)) {
+ int num;
dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
// TODO reindent
for (; dialog && num--; dialog++) {
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
}
} else {
+#endif
dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
if (!dialog)
return AVERROR(ENOMEM);
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
ff_ass_free_dialog(&dialog);
+#if FF_API_ASS_TIMING
}
+#endif
for (j = 0; j < box_count; j++) {
box_types[j].encode(s, box_types[j].type);
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 1a028621fd..d29996f896 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -520,9 +520,15 @@ static const AVOption avcodec_options[] = {
{"do_nothing", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_DO_NOTHING}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
{"pre_decoder", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_PRE_DECODER}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
+#if FF_API_ASS_TIMING
{"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, 0, 1, S|D, "sub_text_format"},
+#else
+{"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS}, 0, 1, S|D, "sub_text_format"},
+#endif
{"ass", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS}, INT_MIN, INT_MAX, S|D, "sub_text_format"},
+#if FF_API_ASS_TIMING
{"ass_with_timings", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, INT_MIN, INT_MAX, S|D, "sub_text_format"},
+#endif
{"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|D },
#if FF_API_SIDEDATA_ONLY_PKT
{"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A|V|E },
diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
index 88fc2411e5..9c8aefc66c 100644
--- a/libavcodec/srtenc.c
+++ b/libavcodec/srtenc.c
@@ -232,7 +232,7 @@ static int encode_frame(AVCodecContext *avctx,
{
SRTContext *s = avctx->priv_data;
ASSDialog *dialog;
- int i, num;
+ int i;
av_bprint_clear(&s->buffer);
@@ -244,7 +244,9 @@ static int encode_frame(AVCodecContext *avctx,
return AVERROR(ENOSYS);
}
+#if FF_API_ASS_TIMING
if (!strncmp(ass, "Dialogue: ", 10)) {
+ int num;
dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
// TODO reindent
for (; dialog && num--; dialog++) {
@@ -253,6 +255,7 @@ static int encode_frame(AVCodecContext *avctx,
ff_ass_split_override_codes(cb, s, dialog->text);
}
} else {
+#endif
dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
if (!dialog)
return AVERROR(ENOMEM);
@@ -260,7 +263,9 @@ static int encode_frame(AVCodecContext *avctx,
srt_style_apply(s, dialog->style);
ff_ass_split_override_codes(cb, s, dialog->text);
ff_ass_free_dialog(&dialog);
+#if FF_API_ASS_TIMING
}
+#endif
}
if (!av_bprint_is_complete(&s->buffer))
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 49a3e88710..0da82adaf9 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2426,6 +2426,7 @@ static int utf8_check(const uint8_t *str)
return 1;
}
+#if FF_API_ASS_TIMING
static void insert_ts(AVBPrint *buf, int ts)
{
if (ts == -1) {
@@ -2495,6 +2496,7 @@ static int convert_sub_to_old_ass_form(AVSubtitle *sub, const AVPacket *pkt, AVR
av_bprint_finalize(&buf, NULL);
return 0;
}
+#endif
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
@@ -2546,9 +2548,11 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
av_assert1((ret >= 0) >= !!*got_sub_ptr &&
!!*got_sub_ptr >= !!sub->num_rects);
+#if FF_API_ASS_TIMING
if (avctx->sub_text_format == FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS
&& *got_sub_ptr && sub->num_rects)
ret = convert_sub_to_old_ass_form(sub, avpkt, avctx->time_base);
+#endif
if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
avctx->pkt_timebase.num) {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index decc4a4c46..10a10a7e56 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -211,5 +211,8 @@
#ifndef FF_API_PRIVATE_OPT
#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_ASS_TIMING
+#define FF_API_ASS_TIMING (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */
diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index f85b34092a..c84bbf4b4e 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -159,7 +159,7 @@ static int webvtt_encode_frame(AVCodecContext *avctx,
{
WebVTTContext *s = avctx->priv_data;
ASSDialog *dialog;
- int i, num;
+ int i;
av_bprint_clear(&s->buffer);
@@ -171,7 +171,9 @@ static int webvtt_encode_frame(AVCodecContext *avctx,
return AVERROR(ENOSYS);
}
+#if FF_API_ASS_TIMING
if (!strncmp(ass, "Dialogue: ", 10)) {
+ int num;
dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
// TODO reindent
for (; dialog && num--; dialog++) {
@@ -179,13 +181,16 @@ static int webvtt_encode_frame(AVCodecContext *avctx,
ff_ass_split_override_codes(&webvtt_callbacks, s, dialog->text);
}
} else {
+#endif
dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
if (!dialog)
return AVERROR(ENOMEM);
webvtt_style_apply(s, dialog->style);
ff_ass_split_override_codes(&webvtt_callbacks, s, dialog->text);
ff_ass_free_dialog(&dialog);
+#if FF_API_ASS_TIMING
}
+#endif
}
if (!av_bprint_is_complete(&s->buffer))