diff --git a/mythtv/libs/libmythtv/captions/subtitlereader.cpp b/mythtv/libs/libmythtv/captions/subtitlereader.cpp index c8519845815..03fb45aac6c 100644 --- a/mythtv/libs/libmythtv/captions/subtitlereader.cpp +++ b/mythtv/libs/libmythtv/captions/subtitlereader.cpp @@ -57,11 +57,19 @@ void SubtitleReader::SeekFrame(int64_t ts, int flags) bool SubtitleReader::AddAVSubtitle(AVSubtitle &subtitle, bool fix_position, + bool is_selected_forced_track, bool allow_forced, - bool isExternal) + bool isExternal) { bool enableforced = false; bool forced = false; + + if (m_avSubtitlesEnabled && is_selected_forced_track) + { + FreeAVSubtitle(subtitle); + return enableforced; + } + for (unsigned i = 0; i < subtitle.num_rects; i++) { forced = forced || static_cast(subtitle.rects[i]->flags & AV_SUBTITLE_FLAG_FORCED); diff --git a/mythtv/libs/libmythtv/captions/subtitlereader.h b/mythtv/libs/libmythtv/captions/subtitlereader.h index 5102e94c626..fca814456b2 100644 --- a/mythtv/libs/libmythtv/captions/subtitlereader.h +++ b/mythtv/libs/libmythtv/captions/subtitlereader.h @@ -56,7 +56,8 @@ class SubtitleReader : public QObject AVSubtitles* GetAVSubtitles(void) { return &m_avSubtitles; } bool AddAVSubtitle(AVSubtitle& subtitle, bool fix_position, - bool allow_forced, bool isExternal); + bool is_selected_forced_track, bool allow_forced, + bool isExternal); void ClearAVSubtitles(void); static void FreeAVSubtitle(AVSubtitle &sub); diff --git a/mythtv/libs/libmythtv/captions/textsubtitleparser.cpp b/mythtv/libs/libmythtv/captions/textsubtitleparser.cpp index edeb3822342..95800d8f0a1 100644 --- a/mythtv/libs/libmythtv/captions/textsubtitleparser.cpp +++ b/mythtv/libs/libmythtv/captions/textsubtitleparser.cpp @@ -255,7 +255,7 @@ int TextSubtitleParser::ReadNextSubtitle(void) sub.start_display_time = av_q2d(m_stream->time_base) * m_pkt->dts * 1000; sub.end_display_time = av_q2d(m_stream->time_base) * (m_pkt->dts + m_pkt->duration) * 1000; - m_parent->AddAVSubtitle(sub, m_decCtx->codec_id == AV_CODEC_ID_XSUB, false, true); + m_parent->AddAVSubtitle(sub, m_decCtx->codec_id == AV_CODEC_ID_XSUB, false, false, true); return ret; } diff --git a/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp b/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp index edd00c1cec1..9b8042b1da7 100644 --- a/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp +++ b/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp @@ -3917,6 +3917,7 @@ bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) m_trackLock.lock(); int subIdx = m_selectedTrack[kTrackTypeSubtitle].m_av_stream_index; int forcedSubIdx = m_selectedForcedSubtitleTrack.m_av_stream_index; + bool isSelectedForcedTrack = false; bool isForcedTrack = m_selectedTrack[kTrackTypeSubtitle].m_forced; m_trackLock.unlock(); @@ -3954,7 +3955,10 @@ bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) subtitle.end_display_time += pts; if (pkt->stream_index == forcedSubIdx) + { + isSelectedForcedTrack = true; isForcedTrack = true; + } } if (gotSubtitles) @@ -3974,6 +3978,7 @@ bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) bool forcedon = m_parent->GetSubReader(pkt->stream_index)->AddAVSubtitle( subtitle, curstream->codecpar->codec_id == AV_CODEC_ID_XSUB, + isSelectedForcedTrack, m_parent->GetAllowForcedSubtitles(), false); m_parent->EnableForcedSubtitles(forcedon || isForcedTrack); }