Author: spyfeng Date: Wed Jun 3 20:09:37 2009 New Revision: 4377 Log: check the target timestamp and returned timestamp before finding the keyframe Modified: seek_api/mpeg.c Modified: seek_api/mpeg.c ============================================================================== --- seek_api/mpeg.c Tue Jun 2 13:58:23 2009 (r4376) +++ seek_api/mpeg.c Wed Jun 3 20:09:37 2009 (r4377) @@ -605,6 +605,7 @@ static int mpegps_read_seek(struct AVFor AVPacket pkt1, *pkt = &pkt1; int64_t pos, pts, ret_ts, av_uninit(pos_min), av_uninit(pos_max), pos_limit = -1; flags = flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0); + if (stream_index < 0){ stream_index= av_find_default_stream_index(s); if(stream_index < 0) @@ -651,6 +652,7 @@ static int mpegps_read_seek(struct AVFor url_fseek(s->pb, pos, SEEK_SET); av_log(s, AV_LOG_DEBUG, "the seek pos = %"PRId64"\n", pos); + if (ts >= ret_ts) { // find the keyframe for (;;) { if (av_read_frame(s, pkt) < 0){ @@ -661,12 +663,12 @@ static int mpegps_read_seek(struct AVFor if(pkt->flags&PKT_FLAG_KEY){ pos = pkt->pos; pts= pkt->pts; - av_log(s, AV_LOG_DEBUG, "keyframe pos = %"PRId64"\n", pos); + av_log(s, AV_LOG_DEBUG, "keyframe pos = %"PRId64" pts = %"PRId64"\n", pos, pts); break; } } - - av_update_cur_dts(s, st, pts); + } + av_update_cur_dts(s, st, ret_ts); return 0; }
participants (1)
-
spyfeng