Ticket #11451: 0001a-Respect-the-start-and-end-times-of-menu-highlights-t.patch

File 0001a-Respect-the-start-and-end-times-of-menu-highlights-t.patch, 7.2 KB (added by peper03@…, 7 years ago)

Updated patch to apply cleanly after the 2nd patch from #11371

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

    From 576da56ad211834887b23ff2c917675fbe5b03d1 Mon Sep 17 00:00:00 2001
    From: Richard <peper03@yahoo.com>
    Date: Wed, 13 Mar 2013 18:16:53 +0100
    Subject: [PATCH] Respect the start and end times of menu highlights to avoid
     showing the menu highlight too soon/for too long.
    
    ---
     mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp |   13 ++++++++-----
     mythtv/libs/libmythtv/DVD/dvdringbuffer.h   |    4 ++--
     mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp |   26 ++++++++++++++++++++++++--
     mythtv/libs/libmythtv/avformatdecoder.cpp   |    9 +++++----
     4 files changed, 39 insertions(+), 13 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
    index 2932cd8..a7ef500 100644
    a b void DVDRingBuffer::ActivateButton(void) 
    12401240
    12411241/** \brief get SPU pkt from dvd menu subtitle stream
    12421242 */
    1243 void DVDRingBuffer::GetMenuSPUPkt(uint8_t *buf, int buf_size, int stream_id)
     1243void DVDRingBuffer::GetMenuSPUPkt(uint8_t *buf, int buf_size,
     1244                                  int stream_id, uint32_t startTime)
    12441245{
    12451246    if (buf_size < 4)
    12461247        return;
    void DVDRingBuffer::GetMenuSPUPkt(uint8_t *buf, int buf_size, int stream_id) 
    12661267    {
    12671268        int32_t gotbutton;
    12681269        m_buttonExists = DecodeSubtitles(&m_dvdMenuButton, &gotbutton,
    1269                                         m_menuSpuPkt, m_menuBuflength);
     1270                                        m_menuSpuPkt, m_menuBuflength, startTime);
    12701271    }
    12711272}
    12721273
    QRect DVDRingBuffer::GetButtonCoords(void) 
    13111312 * code obtained from ffmpeg project
    13121313 */
    13131314bool DVDRingBuffer::DecodeSubtitles(AVSubtitle *sub, int *gotSubtitles,
    1314                                     const uint8_t *spu_pkt, int buf_size)
     1315                                    const uint8_t *spu_pkt, int buf_size, uint32_t startTime)
    13151316{
    13161317    #define GETBE16(p) (((p)[0] << 8) | (p)[1])
    13171318
    bool DVDRingBuffer::DecodeSubtitles(AVSubtitle *sub, int *gotSubtitles, 
    13491350            {
    13501351                case 0x00:
    13511352                    force_subtitle_display = true;
     1353                    sub->start_display_time = startTime;
     1354                    sub->end_display_time   = 0xFFFFFFFF;
    13521355                break;
    13531356                case 0x01:
    1354                     sub->start_display_time = (date << 10) / 90;
     1357                    sub->start_display_time = ((date << 10) / 90) + startTime;
    13551358                break;
    13561359                case 0x02:
    1357                     sub->end_display_time = (date << 10) / 90;
     1360                    sub->end_display_time = ((date << 10) / 90) + startTime;
    13581361                break;
    13591362                case 0x03:
    13601363                {
  • mythtv/libs/libmythtv/DVD/dvdringbuffer.h

    diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.h b/mythtv/libs/libmythtv/DVD/dvdringbuffer.h
    index 1c089fe..0e3247f 100644
    a b class MTV_PUBLIC DVDRingBuffer : public RingBuffer 
    7777    bool AudioStreamsChanged(void) const { return m_audioStreamsChanged; }
    7878    bool IsWaiting(void) const           { return m_dvdWaiting;          }
    7979    int  NumPartsInTitle(void)     const { return m_titleParts;          }
    80     void GetMenuSPUPkt(uint8_t *buf, int len, int stream_id);
     80    void GetMenuSPUPkt(uint8_t *buf, int len, int stream_id, uint32_t startTime);
    8181    int64_t GetTimeDiff(void)      const { return m_timeDiff; }
    8282
    8383    // Public menu/button stuff
    class MTV_PUBLIC DVDRingBuffer : public RingBuffer 
    9191    // Subtitles
    9292    uint GetSubtitleLanguage(int key);
    9393    bool DecodeSubtitles(AVSubtitle * sub, int * gotSubtitles,
    94                          const uint8_t * buf, int buf_size);
     94                         const uint8_t * buf, int buf_size, uint32_t startTime);
    9595
    9696    uint GetAudioLanguage(int id);
    9797    int  GetAudioTrackNum(uint key);
  • mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp

    diff --git a/mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp b/mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
    index 3f79e4b..2faf2dd 100644
    a b void MythDVDPlayer::DisplayDVDButton(void) 
    518518    AVSubtitle *dvdSubtitle = player_ctx->buffer->DVD()->GetMenuSubtitle(buttonversion);
    519519    bool numbuttons    = player_ctx->buffer->DVD()->NumMenuButtons();
    520520
     521    bool expired = false;
     522
     523    VideoFrame *currentFrame = videoOutput ? videoOutput->GetLastShownFrame() : NULL;
     524
     525    if (!currentFrame)
     526    {
     527        player_ctx->buffer->DVD()->ReleaseMenuButton();
     528        return;
     529    }
     530
     531    if (dvdSubtitle &&
     532        (dvdSubtitle->end_display_time < currentFrame->timecode))
     533    {
     534        expired = true;
     535    }
     536
    521537    // nothing to do
    522     if (buttonversion == ((uint)m_buttonVersion))
     538    if (!expired && (buttonversion == ((uint)m_buttonVersion)))
    523539    {
    524540        player_ctx->buffer->DVD()->ReleaseMenuButton();
    525541        return;
    526542    }
    527543
    528544    // clear any buttons
    529     if (!numbuttons || !dvdSubtitle || (buttonversion == 0))
     545    if (!numbuttons || !dvdSubtitle || (buttonversion == 0) || expired)
    530546    {
    531547        SetCaptionsEnabled(false, false);
    532548        osdLock.lock();
    void MythDVDPlayer::DisplayDVDButton(void) 
    538554        return;
    539555    }
    540556
     557    if (currentFrame->timecode && (dvdSubtitle->start_display_time > currentFrame->timecode))
     558    {
     559        player_ctx->buffer->DVD()->ReleaseMenuButton();
     560        return;
     561    }
     562
    541563    m_buttonVersion = buttonversion;
    542564    QRect buttonPos = player_ctx->buffer->DVD()->GetButtonCoords();
    543565    osdLock.lock();
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index 7a1716b..cb55ac9 100644
    a b bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) 
    36963696        if (ringBuffer->DVD()->NumMenuButtons() > 0)
    36973697        {
    36983698            ringBuffer->DVD()->GetMenuSPUPkt(pkt->data, pkt->size,
    3699                                              curstream->id);
     3699                                             curstream->id, pts);
    37003700        }
    37013701        else
    37023702        {
    bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) 
    37043704            {
    37053705                QMutexLocker locker(avcodeclock);
    37063706                ringBuffer->DVD()->DecodeSubtitles(&subtitle, &gotSubtitles,
    3707                                                    pkt->data, pkt->size);
     3707                                                   pkt->data, pkt->size, pts);
    37083708            }
    37093709        }
    37103710    }
    bool AvFormatDecoder::ProcessSubtitlePacket(AVStream *curstream, AVPacket *pkt) 
    37133713        QMutexLocker locker(avcodeclock);
    37143714        avcodec_decode_subtitle2(curstream->codec, &subtitle, &gotSubtitles,
    37153715                                 pkt);
     3716
     3717        subtitle.start_display_time += pts;
     3718        subtitle.end_display_time += pts;
    37163719    }
    37173720
    37183721    if (gotSubtitles)
    37193722    {
    37203723        if (isForcedTrack)
    37213724            subtitle.forced = true;
    3722         subtitle.start_display_time += pts;
    3723         subtitle.end_display_time += pts;
    37243725        LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
    37253726            QString("subtl timecode %1 %2 %3 %4")
    37263727                .arg(pkt->pts).arg(pkt->dts)