]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: Combine identical statements
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Wed, 14 Apr 2021 19:56:50 +0000 (21:56 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sun, 18 Apr 2021 02:33:12 +0000 (04:33 +0200)
This would only make a difference in case the first attempt to
initialize the encoder failed and the second succeeded. The only
reason I can think of for this to happen is that the options (in
particular the codec whitelist) are not used for the second try
and that obviously implies that we should not even try a second time
to open the decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavformat/utils.c

index d9971d7fd3bf497263e25b72685d6b6ce931a729..d4ec3d01909e3377a354d99a71e6673e6e9f86aa 100644 (file)
@@ -3747,16 +3747,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
         if (ic->codec_whitelist)
             av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0);
 
-        /* Ensure that subtitle_header is properly set. */
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE
-            && codec && !avctx->codec) {
-            if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
-                av_log(ic, AV_LOG_WARNING,
-                       "Failed to open codec in %s\n",__FUNCTION__);
-        }
-
         // Try to just open decoders, in case this is enough to get parameters.
-        if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) {
+        // Also ensure that subtitle_header is properly set.
+        if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0 ||
+            st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
             if (codec && !avctx->codec)
                 if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
                     av_log(ic, AV_LOG_WARNING,