Ticket #1043: mythdvd_v8.patch

File mythdvd_v8.patch, 12.2 KB (added by skamithi@…, 18 years ago)

v8 patch. includes v7 patch, cleanup3 patch and bug fixes.

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    227227      livetvchain(NULL), m_tv(NULL),
    228228      // DVD stuff
    229229      indvdstillframe(false), hidedvdbutton(true),
     230      delaydvdbutton(0),
    230231      // Debugging variables
    231232      output_jmeter(NULL)
    232233{
     
    554555
    555556    ClearAfterSeek();
    556557
    557     if (ringBuffer->isDVD())
    558         ringBuffer->Seek(ringBuffer->DVD()->GetCellStartPos(), SEEK_SET);
    559 
    560558    if (textDisplayMode)
    561559    {
    562560        DisableCaptions(textDisplayMode);
     
    829827int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
    830828                                bool allow_libmpeg2)
    831829{
    832     if (ringBuffer && ringBuffer->isDVD())
    833         allow_libmpeg2 = false;
    834 
    835830    if (!skipDsp)
    836831    {
    837832        if (!ringBuffer)
     
    28612856    decoder_thread = pthread_self();
    28622857    pthread_create(&output_video, NULL, kickoffOutputVideoLoop, this);
    28632858
    2864     if (!using_null_videoout)
     2859    if (!using_null_videoout && !ringBuffer->isDVD())
    28652860    {
    28662861        // Request that the video output thread run with realtime priority.
    28672862        // If mythyv/mythfrontend was installed SUID root, this will work.
     
    57225717    int numbuttons = ringBuffer->DVD()->NumMenuButtons();
    57235718    bool osdshown = osd->IsSetDisplaying("subtitles");
    57245719    long long menupktpts = ringBuffer->DVD()->GetMenuPktPts();
     5720    bool instillframe = ringBuffer->DVD()->InStillFrame();
    57255721
    5726     if ((numbuttons == 0) || (osdshown) ||
    5727         ((!osdshown) && (hidedvdbutton) &&
    5728          (buffer->timecode > 0) && (menupktpts != buffer->timecode)))
     5722    if ((numbuttons == 0) ||
     5723        (osdshown) ||
     5724        (instillframe && buffer->timecode > 0) ||
     5725        ((!osdshown) &&
     5726            (!indvdstillframe) &&
     5727            (hidedvdbutton) &&
     5728            (buffer->timecode > 0)  &&
     5729            (menupktpts != buffer->timecode)))
    57295730    {
    57305731        return;
    57315732    }
    57325733
    5733     hidedvdbutton = false;
    5734     AVSubtitleRect *highlightButton;
    57355734    OSDSet *subtitleOSD = NULL;
    5736     highlightButton = ringBuffer->DVD()->GetMenuButton();
     5735    AVSubtitleRect *highlightButton = ringBuffer->DVD()->GetMenuButton();
    57375736
    5738     subtitleLock.lock();
    57395737    if (highlightButton != NULL)
    57405738    {
    57415739        osd->HideSet("subtitles");
    57425740        osd->ClearAll("subtitles");
     5741        if (indvdstillframe)
     5742        {
     5743            delaydvdbutton++;
     5744            if (delaydvdbutton < 5)
     5745                return;
     5746        }
     5747        subtitleLock.lock();
    57435748        int h = highlightButton->h;
    57445749        int w = highlightButton->w;
    57455750        int linesize = highlightButton->linesize;
     
    57705775
    57715776        subtitleOSD->AddType(image);
    57725777        osd->SetVisible(subtitleOSD, 0);
     5778        hidedvdbutton = false;
     5779        subtitleLock.unlock();
    57735780    }
    5774 
    5775     subtitleLock.unlock();
    57765781}
    57775782
    57785783void NuppelVideoPlayer::ActivateDVDButton(void)
  • libs/libmythtv/avformatdecoder.cpp

     
    274274      allow_ac3_passthru(false),    allow_dts_passthru(false),
    275275      disable_passthru(false),
    276276      // DVD
    277       lastdvdtitle(0), dvdmenupktseen(false)
     277      lastdvdtitle(0), lastcellstart(0),
     278      dvdmenupktseen(false), dvdvideopause(false)
    278279{
    279280    bzero(&params, sizeof(AVFormatParameters));
    280281    bzero(prvpkt, 3 * sizeof(char));
     
    493494    // Skip all the desired number of skipFrames
    494495    for (;skipFrames > 0 && !ateof; skipFrames--)
    495496    {
    496         GetFrame(0);
     497        GetFrame(0);
    497498        if (decoded_video_frame)
    498499            GetNVP()->DiscardVideoFrame(decoded_video_frame);
    499500    }
     
    13211322        }
    13221323    }
    13231324
    1324     // Select a new tracks at the next opportunity.
     1325    // Select a new track at the next opportunity
    13251326    ResetTracks();
    13261327
    13271328    // We have to do this here to avoid the NVP getting stuck
     
    16651666#define PICTURE_START 0x00000100
    16661667#define SLICE_MIN     0x00000101
    16671668#define SLICE_MAX     0x000001af
     1669#define SEQ_END_CODE  0x000001b7
    16681670
    16691671void AvFormatDecoder::MpegPreProcessPkt(AVStream *stream, AVPacket *pkt)
    16701672{
     
    16841686        unsigned int last_state = state;
    16851687        state = ((state << 8) | v) & 0xFFFFFF;
    16861688
     1689        if (ringBuffer->isDVD() && pkt->size == 4
     1690                && state == SEQ_END_CODE && !dvdvideopause)
     1691        {
     1692            dvdvideopause = true;
     1693            d->ResetMPEG2();
     1694            return;
     1695        }
     1696       
    16871697        if (last_state != 0x000001)
    16881698            continue;
    16891699        else if (state >= SLICE_MIN && state <= SLICE_MAX)
     
    17131723                                         keyframedist, aspect,
    17141724                                         kScan_Detect);
    17151725
     1726                if (ringBuffer->InDVDMenuOrStillFrame())
     1727                {
     1728                    ScanStreams(true);
     1729                    ringBuffer->Seek(ringBuffer->DVD()->GetCellStartPos(),
     1730                                        SEEK_SET);
     1731                }
     1732
    17161733                current_width  = width;
    17171734                current_height = height;
    17181735                current_aspect = aspect;
     
    21592176
    21602177    bool allowedquit = false;
    21612178    bool storevideoframes = false;
    2162     bool dvdvideopause = false;
    21632179
    21642180    avcodeclock.lock();
    21652181    AutoSelectTracks();
     
    21782194        }
    21792195
    21802196        if (ringBuffer->isDVD())
    2181         { 
     2197        {
    21822198            int dvdtitle  = 0;
    21832199            int dvdpart = 0;
    21842200            ringBuffer->DVD()->GetPartAndTitle(dvdtitle,dvdpart);
    2185             if (dvdtitle != lastdvdtitle)
     2201            uint cellstart = ringBuffer->DVD()->GetCellStart();
     2202            if (GetNVP()->AtNormalSpeed() &&
     2203                    ((lastcellstart != cellstart) ||
     2204                    (lastdvdtitle != dvdtitle)))
    21862205            {
    2187                 posmapStarted = false;
    2188                 m_positionMap.clear();
    2189                 SyncPositionMap();
     2206                if (dvdtitle != lastdvdtitle)
     2207                {
     2208                    posmapStarted = false;
     2209                    m_positionMap.clear();
     2210                    SyncPositionMap();
     2211                    VERBOSE(VB_PLAYBACK, LOC + "DVD Title Changed");
     2212                    ScanStreams(true);
     2213                    lastdvdtitle = dvdtitle;
     2214                }
    21902215                framesPlayed = DVDCurrentFrameNumber();
    21912216                framesRead = framesPlayed;
    2192                 VERBOSE(VB_PLAYBACK,
    2193                     QString(LOC + "DVD Title Changed. Update framesPlayed: %1 ")
    2194                             .arg(framesPlayed));
    2195                 ScanStreams(false);
     2217                VERBOSE(VB_PLAYBACK, QString(LOC + "DVD Cell Changed. Update framesPlayed: %1 ")
     2218                        .arg(framesPlayed));
     2219                lastcellstart = cellstart;
    21962220            }
    2197             lastdvdtitle = dvdtitle;
    2198            
     2221
    21992222            if (storedPackets.count() < 2 && !dvdvideopause)
    22002223                storevideoframes = true;
    22012224            else
     
    22182241            }
    22192242        }
    22202243
    2221         if (ringBuffer->isDVD() && ringBuffer->DVD()->InStillFrame())
    2222         {
    2223             storevideoframes = false;
    2224             dvdvideopause = true;
    2225         }
    2226 
    22272244        if (!storevideoframes && storedPackets.count() > 0)
    22282245        {
    22292246            if (pkt)
     
    22732290        if (pkt->dts != (int64_t)AV_NOPTS_VALUE)
    22742291            pts = (long long)(av_q2d(curstream->time_base) * pkt->dts * 1000);
    22752292
    2276         if (ringBuffer->isDVD() && pkt->size == 4)
     2293        if (ringBuffer->isDVD() &&
     2294                curstream->codec->codec_type == CODEC_TYPE_VIDEO)
    22772295        {
    2278             dvdvideopause = true;
    2279             av_free_packet(pkt);
    2280             continue;
     2296            if (pkt->size == 4)
     2297                MpegPreProcessPkt(curstream,pkt);
     2298            else if (!d->HasMPEG2Dec())
     2299            {
     2300                int current_width = curstream->codec->width;
     2301                int video_width = GetNVP()->GetVideoWidth();
     2302                if (video_width > 0 &&
     2303                    (video_width != current_width))
     2304                {
     2305                    av_free_packet(pkt);
     2306                    av_find_stream_info(ic);
     2307                    ScanStreams(false);
     2308                    allowedquit = true;
     2309                    continue;
     2310                }
     2311            }
    22812312        }
    22822313
    22832314        if (storevideoframes &&
     
    23172348                }
    23182349            }
    23192350
     2351            if (len == 4 && dvdvideopause)
     2352                dvdvideopause = false;
     2353
    23202354            if (framesRead == 0 && !justAfterChange &&
    23212355                !(pkt->flags & PKT_FLAG_KEY))
    23222356            {
     
    25212555                        ret = avcodec_decode_video(context, &mpa_pic,
    25222556                                                   &gotpicture, ptr, len);
    25232557                        // Reparse it to not drop the DVD still frame
    2524                         if (dvdvideopause && storedPackets.count() == 0)
     2558                        if (dvdvideopause)
    25252559                            ret = avcodec_decode_video(context, &mpa_pic,
    25262560                                                        &gotpicture, ptr, len);
    25272561                    }
  • libs/libmythtv/DVDRingBuffer.cpp

     
    811811
    812812uint DVDRingBufferPriv::GetCurrentTime(void)
    813813{
    814     // Macro to convert Binary Coded Decimal to Decimal
    815     // Obtained from VLC Code.
    816     #define BCD2D(__x__) (((__x__ & 0xf0) >> 4) * 10 + (__x__ & 0x0f))
    817 
    818814    dsi_t *dvdnavDsi = dvdnav_get_current_nav_dsi(dvdnav);
    819815    dvd_time_t timeFromCellStart = dvdnavDsi->dsi_gi.c_eltm;
    820     uint8_t hours = BCD2D(timeFromCellStart.hour);
    821     uint8_t minutes = BCD2D(timeFromCellStart.minute);
    822     uint8_t seconds = BCD2D(timeFromCellStart.second);
    823     uint currentTime = GetCellStart() + (hours * 3600) + (minutes * 60) + seconds;
     816    uint currentTime = GetCellStart() +
     817        (uint)(dvdnav_convert_time(&timeFromCellStart) / 90000);
    824818    return currentTime;
    825819}
    826820
  • libs/libmythtv/NuppelVideoPlayer.h

     
    354354    void ActivateDVDButton(void);
    355355    void GoToDVDMenu(QString str);
    356356    void GoToDVDProgram(bool direction);
    357     void HideDVDButton(bool hide) { hidedvdbutton = hide; }
     357    void HideDVDButton(bool hide)
     358    {
     359        hidedvdbutton = hide;
     360        if (hide)
     361            delaydvdbutton = 0;
     362    }
    358363    void SetSubtitleMode(bool setting)
    359364    {
    360365        if (setting)
     
    716721    // DVD
    717722    bool indvdstillframe;
    718723    bool hidedvdbutton;
     724    int  delaydvdbutton;
    719725
    720726    // Debugging variables
    721727    Jitterometer *output_jmeter;
  • libs/libmythtv/tv_play.cpp

     
    26752675            QString action = actions[i];
    26762676            handled = true;
    26772677
    2678             if (prbuffer->isDVD() && prbuffer->DVD()->IsInMenu())
     2678            if (prbuffer->InDVDMenuOrStillFrame())
    26792679            {
    26802680                int nb_buttons = prbuffer->DVD()->NumMenuButtons();
    26812681                if (nb_buttons > 0)
  • libs/libmythtv/decoderbase.cpp

     
    713713            SeekReset(framesPlayed, 0, true, true);
    714714
    715715        // update frames played
    716         long long played = (int)(elapsed * fps);
     716        long long played = DVDCurrentFrameNumber();
    717717
    718718        framesPlayed = played;
    719719        GetNVP()->getVideoOutput()->SetFramesPlayed(played + 1);
  • libs/libmythtv/avformatdecoder.h

     
    232232
    233233    // DVD
    234234    int lastdvdtitle;
     235    uint lastcellstart;
    235236    bool dvdmenupktseen;
     237    bool dvdvideopause;
    236238};
    237239
    238240#endif