OSDN Git Service

lavc: deprecate decoded ass subtitles with timings
authorClément Bœsch <u@pkh.me>
Sun, 21 Feb 2016 11:58:36 +0000 (12:58 +0100)
committerClément Bœsch <u@pkh.me>
Fri, 26 Feb 2016 20:53:34 +0000 (21:53 +0100)
libavcodec/assenc.c
libavcodec/avcodec.h
libavcodec/movtextenc.c
libavcodec/options_table.h
libavcodec/srtenc.c
libavcodec/utils.c
libavcodec/version.h
libavcodec/webvttenc.c

index 4e9825c..dc4f0ff 100644 (file)
@@ -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);
 
index 695ca05..5dc4b73 100644 (file)
@@ -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.
index fcd6613..791132a 100644 (file)
@@ -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);
index 1a02862..d29996f 100644 (file)
@@ -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 },
index 88fc241..9c8aefc 100644 (file)
@@ -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))
index 49a3e88..0da82ad 100644 (file)
@@ -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) {
index decc4a4..10a10a7 100644 (file)
 #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 */
index f85b340..c84bbf4 100644 (file)
@@ -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))