Use $HOME rather than hard-coded user name.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index dcad184fa81ea17ea3ddc5e4a0cdf7b9052984db..019e4f95c6080061579178da6b9cdd2ab87d5188 100644 (file)
@@ -89,7 +89,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
                _pts_offset = {};
        }
 
-       if (c->audio) {
+       if (c->has_mapped_audio()) {
                audio = make_shared<AudioDecoder>(this, c->audio, fast);
        }
 
@@ -240,7 +240,7 @@ FFmpegDecoder::pass ()
                decode_and_process_video_packet (packet);
        } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index(_format_context, si) && !only_text()->ignore()) {
                decode_and_process_subtitle_packet (packet);
-       } else {
+       } else if (audio) {
                decode_and_process_audio_packet (packet);
        }
 
@@ -668,11 +668,11 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
        */
        ContentTime from;
        from = sub_period.from + _pts_offset;
+       _have_current_subtitle = true;
        if (sub_period.to) {
                _current_subtitle_to = *sub_period.to + _pts_offset;
        } else {
                _current_subtitle_to = optional<ContentTime>();
-               _have_current_subtitle = true;
        }
 
        ContentBitmapText bitmap_text(from);
@@ -720,7 +720,7 @@ FFmpegDecoder::process_bitmap_subtitle (AVSubtitleRect const * rect)
        /* sub_p looks up into a BGRA palette which is at rect->pict.data[1];
           (i.e. first byte B, second G, third R, fourth A)
        */
-       auto const palette = rect->pict.data[1];
+       auto const* palette = rect->pict.data[1];
 #else
        /* Start of the first line in the subtitle */
        auto sub_p = rect->data[0];
@@ -828,11 +828,14 @@ FFmpegDecoder::process_ass_subtitle (string ass, ContentTime from)
        }
 
        sub::RawSubtitle base;
+       auto video_size = _ffmpeg_content->video->size();
+       DCPOMATIC_ASSERT(video_size);
+
        auto raw = sub::SSAReader::parse_line (
                base,
                text,
-               _ffmpeg_content->video->size().width,
-               _ffmpeg_content->video->size().height,
+               video_size->width,
+               video_size->height,
                sub::Colour(1, 1, 1)
                );