Fix crash with subtitles for which we have no codec.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index c3d32bc752306abd1beb81f6042a80a9bc9acc9c..6e9d671a2fa87792e2ea5b58d6b2d9b2e136822c 100644 (file)
@@ -634,9 +634,14 @@ FFmpegDecoder::process_video_frame ()
 void
 FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
 {
+       auto context = subtitle_codec_context();
+       if (!context) {
+               return;
+       }
+
        int got_subtitle;
        AVSubtitle sub;
-       if (avcodec_decode_subtitle2 (subtitle_codec_context(), &sub, &got_subtitle, packet) < 0 || !got_subtitle) {
+       if (avcodec_decode_subtitle2(context, &sub, &got_subtitle, packet) < 0 || !got_subtitle) {
                return;
        }