Revision 3ba1438d ffplay.c

View differences:

ffplay.c
92 92
    int paused;
93 93
    int last_paused;
94 94
    int seek_req;
95
    int seek_flags;
95 96
    int64_t seek_pos;
96 97
    AVFormatContext *ic;
97 98
    int dtg_active_format;
......
589 590
}
590 591

  
591 592
/* seek in the stream */
592
static void stream_seek(VideoState *is, int64_t pos)
593
static void stream_seek(VideoState *is, int64_t pos, int rel)
593 594
{
594 595
    is->seek_pos = pos;
595 596
    is->seek_req = 1;
597
    is->seek_flags = rel < 0 ? AVSEEK_FLAG_BACKWARD : 0;
596 598
}
597 599

  
598 600
/* pause or resume the video */
......
1335 1337
        /* add the stream start time */
1336 1338
        if (ic->start_time != AV_NOPTS_VALUE)
1337 1339
            timestamp += ic->start_time;
1338
        ret = av_seek_frame(ic, -1, timestamp);
1340
        ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
1339 1341
        if (ret < 0) {
1340 1342
            fprintf(stderr, "%s: could not seek to position %0.3f\n", 
1341 1343
                    is->filename, (double)timestamp / AV_TIME_BASE);
......
1412 1414
#endif
1413 1415
        if (is->seek_req) {
1414 1416
            /* XXX: must lock decoder threads */
1415
            ret = av_seek_frame(is->ic, -1, is->seek_pos);
1417
            ret = av_seek_frame(is->ic, -1, is->seek_pos, is->seek_flags);
1416 1418
            if (ret < 0) {
1417 1419
                fprintf(stderr, "%s: error while seeking\n", is->ic->filename);
1418 1420
            }else{
......
1682 1684
                if (cur_stream) {
1683 1685
                    pos = get_master_clock(cur_stream);
1684 1686
                    pos += incr;
1685
                    stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE));
1687
                    stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), incr);
1686 1688
                }
1687 1689
                break;
1688 1690
            default:
......
1704 1706
		ss = (ns%60);
1705 1707
		fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d)       \n", frac*100,
1706 1708
			hh, mm, ss, thh, tmm, tss);
1707
		stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration));
1709
		stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration), 0);
1708 1710
	    }
1709 1711
	    break;
1710 1712
        case SDL_VIDEORESIZE:

Also available in: Unified diff