Ticket #7521: avseek_fixes_rev1.diff

File avseek_fixes_rev1.diff, 2.7 KB (added by tralph11@…, 10 years ago)

avseek improvements

  • libs/libmythtv/decoderbase.h

     
    6262                         int testbufsize = kDecoderProbeBufferSize) = 0;
    6363
    6464    void setExactSeeks(bool exact) { exactseeks = exact; }
     65    bool getExactSeeks(void) { return exactseeks; }
    6566    void setLiveTVMode(bool live) { livetv = live; }
    6667
    6768    // Must be done while player is paused.
  • libs/libmythtv/avformatdecoder.cpp

     
    570570    if (recordingHasPositionMap || livetv)
    571571        return DecoderBase::DoRewind(desiredFrame, discardFrames);
    572572
     573    dorewind = true;
     574
    573575    // avformat-based seeking
    574576    return DoFastForward(desiredFrame, discardFrames);
    575577}
     
    587589    bool oldrawstate = getrawframes;
    588590    getrawframes = false;
    589591
     592    bool needflush = true;
     593
    590594    AVStream *st = NULL;
    591595    for (uint i = 0; i < ic->nb_streams; i++)
    592596    {
     
    614618    long double diff = (max(desiredFrame - frameseekadjust, 0LL)) * AV_TIME_BASE / fps;
    615619    ts += (long long)diff;
    616620
    617     if (av_seek_frame(ic, -1, ts, AVSEEK_FLAG_BACKWARD) < 0)
     621    bool exactseeks = DecoderBase::getExactSeeks();
     622
     623    int flags = 0;
     624
     625    if (dorewind || exactseeks)
     626        flags |= AVSEEK_FLAG_BACKWARD;
     627
     628    if (av_seek_frame(ic, -1, ts, flags) < 0)
    618629    {
    619630        VERBOSE(VB_IMPORTANT, LOC_ERR
    620631                <<"av_seek_frame(ic, -1, "<<ts<<", 0) -- error");
     
    653664        framesPlayed = lastKey;
    654665        framesRead = lastKey;
    655666
    656         normalframes = desiredFrame - framesPlayed;
     667        normalframes = (exactseeks) ? desiredFrame - framesPlayed : 0;
    657668        normalframes = max(normalframes, 0);
    658669        no_dts_hack = false;
    659670    }
     
    666677        normalframes = 0;
    667678    }
    668679
    669     SeekReset(lastKey, normalframes, discardFrames, discardFrames);
     680    SeekReset(lastKey, normalframes, needflush, discardFrames);
    670681
    671682    if (discardFrames)
    672683    {
     
    674685        GetNVP()->getVideoOutput()->SetFramesPlayed(framesPlayed + 1);
    675686    }
    676687
     688    dorewind = false;
     689
    677690    getrawframes = oldrawstate;
    678691
    679692    return true;
  • libs/libmythtv/avformatdecoder.h

     
    220220
    221221    bool no_dts_hack;
    222222
     223    bool dorewind;
     224
    223225    bool gopset;
    224226    /// A flag to indicate that we've seen a GOP frame.  Used in junction with seq_count.
    225227    bool seen_gop;