Ticket #7397: t7397_mythtv_libav_seek_start_v3.diff

File t7397_mythtv_libav_seek_start_v3.diff, 1.3 KB (added by taylor.ralph@…, 10 years ago)

final update (trunk 23210)

  • libs/libmythtv/avformatdecoder.cpp

     
    640640        return false;
    641641    }
    642642
    643     // If seeking to start of stream force a DTS and start_time of zero as
    644     // libav sometimes returns the end of the stream instead.
    645     if (desiredFrame <= 1)
    646     {
    647         av_update_cur_dts(ic, st, 0);
    648         ic->start_time = 0;
    649     }
    650 
    651643    int normalframes = 0;
    652644
    653645    if (st->cur_dts != (int64_t)AV_NOPTS_VALUE)
     
    660652            int64_t st1 = av_rescale(ic->start_time,
    661653                                    st->time_base.den,
    662654                                    AV_TIME_BASE * (int64_t)st->time_base.num);
    663             adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits);
    664 
     655            // If seeking near the start of stream sometimes the adjusted current dts time
     656            // is less than the start time (possibly due to the AVSEEK_FLAG_BACKWARD flag ?).
     657            // If so, set adjusted current dts to zero.
     658            if (adj_cur_dts < st1)
     659                adj_cur_dts = 0;
     660            else
     661                adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits);
    665662        }
    666663
    667664        long long newts = av_rescale(adj_cur_dts,