Ticket #7397: mythtv_libav_seek_start_fix2.diff

File mythtv_libav_seek_start_fix2.diff, 1.3 KB (added by tralph11@…, 10 years ago)

set adj_cur_dts to zero if dts is earlier than start_time

  • libs/libmythtv/avformatdecoder.cpp

     
    621621        return false;
    622622    }
    623623
    624     // If seeking to start of stream force a DTS and start_time of zero as
    625     // libav sometimes returns the end of the stream instead.
    626     if (desiredFrame <= 1)
    627     {
    628         av_update_cur_dts(ic, st, 0);
    629         ic->start_time = 0;
    630     }
    631 
    632624    int normalframes = 0;
    633625
    634626    if (st->cur_dts != (int64_t)AV_NOPTS_VALUE)
     
    641633            int64_t st1 = av_rescale(ic->start_time,
    642634                                    st->time_base.den,
    643635                                    AV_TIME_BASE * (int64_t)st->time_base.num);
    644             adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits);
     636            // If seeking near the start of stream sometimes the adjusted current dts time
     637            // is less than the start time (possibly due to the AVSEEK_FLAG_BACKWARD flag ?).
     638            // If so, set adjusted current dts to zero.
     639            if (adj_cur_dts < st1)
     640            {
     641                adj_cur_dts = 0;
     642            }
     643            else
     644            {
     645                adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits);
     646            }
    645647
    646648        }
    647649