--- libavcodec/assenc.c | 2 ++ libavcodec/avcodec.h | 2 ++ libavcodec/movtextenc.c | 7 ++++++- libavcodec/options_table.h | 6 ++++++ libavcodec/srtenc.c | 7 ++++++- libavcodec/utils.c | 4 ++++ libavcodec/version.h | 3 +++ libavcodec/webvttenc.c | 7 ++++++- 8 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index 4e9825c..dc4f0ff 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 5ff52f3..e23ada4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3281,7 +3281,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 fcd6613..791132a 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 1a02862..d29996f 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 88fc241..9c8aefc 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 48764d4..885d025 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2413,6 +2413,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) { @@ -2482,6 +2483,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, @@ -2533,9 +2535,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 52b8f2a..f51c719 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -212,5 +212,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 f85b340..c84bbf4 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)) -- 2.7.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel