Ticket #9429: subtitle_menu.patch

File subtitle_menu.patch, 3.1 KB (added by Jonatan Lindblad, 8 years ago)

Only use subtitle tracks reported by dvdnav

  • mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp

    diff --git a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
    index 0fb91b1..58abb8d 100644
    a b void AvFormatDecoderDVD::PostProcessTracks(void) 
    5353
    5454    if (tracks[kTrackTypeSubtitle].size() > 0)
    5555    {
     56        map<int,uint> lang_sub_cnt;
    5657        stable_sort(tracks[kTrackTypeSubtitle].begin(),
    5758                    tracks[kTrackTypeSubtitle].end());
     59
     60        // Get all subtitle tracks from the DVD and filter out any other tracks
     61        // reported by ffmpeg
     62        sinfo_vec_t filteredTracks;
     63        for (unsigned int i = 0; i < 32; ++i)
     64        {
     65            int track = ringBuffer->DVD()->GetSubtitleTrackNum(i);
     66            if (track >= 0 &&
     67                track < (int)tracks[kTrackTypeSubtitle].size())
     68            {
     69                int lang = ringBuffer->DVD()->GetSubtitleLanguage(i);
     70                int lang_indx = lang_sub_cnt[lang]++;
     71                filteredTracks.push_back(tracks[kTrackTypeSubtitle][track]);
     72                filteredTracks.back().language = lang;
     73                filteredTracks.back().language_index = lang_indx;
     74            }
     75        }
     76
     77        tracks[kTrackTypeSubtitle] = filteredTracks;
     78
    5879        sinfo_vec_t::iterator it = tracks[kTrackTypeSubtitle].begin();
    5980        for(; it != tracks[kTrackTypeSubtitle].end(); ++it)
    6081        {
    void AvFormatDecoderDVD::PostProcessTracks(void) 
    6283                QString("DVD Subtitle Track Map Stream id #%1 ")
    6384                    .arg(it->stream_id));
    6485        }
    65         stable_sort(tracks[kTrackTypeSubtitle].begin(),
    66                     tracks[kTrackTypeSubtitle].end());
     86
    6787        int trackNo = ringBuffer->DVD()->GetTrack(kTrackTypeSubtitle);
    6888        uint captionmode = m_parent->GetCaptionMode();
    6989        int trackcount = (int)GetTrackCount(kTrackTypeSubtitle);
  • mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp

    diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
    index 5b066bc..1953bdd 100644
    a b uint DVDRingBuffer::GetSubtitleLanguage(int id) 
    15741574    return ConvertLangCode(lang);
    15751575}
    15761576
     1577/** \brief get the logical subtitle track/stream number from the dvd
     1578 * \param stream_index the stream index, range 0-31
     1579 */
     1580int DVDRingBuffer::GetSubtitleTrackNum(uint stream_index)
     1581{
     1582    return dvdnav_get_spu_logical_stream(m_dvdnav, stream_index);
     1583}
     1584
    15771585/** \brief converts the subtitle/audio lang code to iso639.
    15781586 */
    15791587uint DVDRingBuffer::ConvertLangCode(uint16_t code)
  • mythtv/libs/libmythtv/DVD/dvdringbuffer.h

    diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.h b/mythtv/libs/libmythtv/DVD/dvdringbuffer.h
    index d803627..30818eb 100644
    a b class MTV_PUBLIC DVDRingBuffer : public RingBuffer 
    9191
    9292    // Subtitles
    9393    uint GetSubtitleLanguage(int key);
     94    int GetSubtitleTrackNum(uint stream_index);
    9495    bool DecodeSubtitles(AVSubtitle * sub, int * gotSubtitles,
    9596                         const uint8_t * buf, int buf_size);
    9697