ffmpeg: Enable compute_edt only when the subtitles are used for a output stream inste...
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 1 Sep 2014 02:13:49 +0000 (04:13 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 1 Sep 2014 17:51:58 +0000 (19:51 +0200)
Fixes/works around Ticket3768

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
ffmpeg.c
ffmpeg.h
ffmpeg_filter.c

index 8bca9e7..220816b 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2297,8 +2297,12 @@ static int init_input_stream(int ist_index, char *error, int error_len)
         ist->dec_ctx->thread_safe_callbacks = 1;
 
         av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
-        if(ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
+        if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
+           (ist->decoding_needed & DECODING_FOR_OST)) {
             av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE);
+            if (ist->decoding_needed & DECODING_FOR_FILTER)
+                av_log(NULL, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
+        }
 
         if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
             av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
@@ -2678,7 +2682,7 @@ static int transcode_init(void)
             }
 
             if (ist)
-                ist->decoding_needed++;
+                ist->decoding_needed |= DECODING_FOR_OST;
             ost->encoding_needed = 1;
 
             set_encoder_id(output_files[ost->file_index], ost);
index 6545286..56eb66a 100644 (file)
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -243,7 +243,10 @@ typedef struct InputStream {
     AVStream *st;
     int discard;             /* true if stream data should be discarded */
     int user_set_discard;
-    int decoding_needed;     /* true if the packets must be decoded in 'raw_fifo' */
+    int decoding_needed;     /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
+#define DECODING_FOR_OST    1
+#define DECODING_FOR_FILTER 2
+
     AVCodecContext *dec_ctx;
     AVCodec *dec;
     AVFrame *decoded_frame;
index 7acff28..93af8ce 100644 (file)
@@ -275,7 +275,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
     av_assert0(ist);
 
     ist->discard         = 0;
-    ist->decoding_needed++;
+    ist->decoding_needed |= DECODING_FOR_FILTER;
     ist->st->discard = AVDISCARD_NONE;
 
     GROW_ARRAY(fg->inputs, fg->nb_inputs);