driver/audiodec/ffmpegdec.cpp: fix jump forward/backward

This commit is contained in:
[CST] Focus
2013-12-11 12:40:21 +04:00
parent ecf0fb03a6
commit fcc6cc6ff2

View File

@@ -59,10 +59,12 @@ static OpenThreads::Mutex mutex;
static int cover_count = 0; static int cover_count = 0;
#if 0
static void log_callback(void *, int, const char *format, va_list ap) static void log_callback(void *, int, const char *format, va_list ap)
{ {
vfprintf(stderr, format, ap); vfprintf(stderr, format, ap);
} }
#endif
CFfmpegDec::CFfmpegDec(void) CFfmpegDec::CFfmpegDec(void)
{ {
@@ -261,14 +263,15 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, const CFile::FileType ft, int /
int64_t pts = 0, start_pts = 0, next_skip_pts = 0; int64_t pts = 0, start_pts = 0, next_skip_pts = 0;
uint64_t skip = 0; uint64_t skip = 0;
int seek_flags = 0; int seek_flags = 0;
if (!is_stream && secondsToSkip && *secondsToSkip)
skip = avc->streams[best_stream]->time_base.num * *secondsToSkip / avc->streams[best_stream]->time_base.den;
do do
{ {
if (!is_stream && (skip || *state==FF || *state==REV) && avc->streams[best_stream]->time_base.num) { int actSecsToSkip = *secondsToSkip;
if (!is_stream && (actSecsToSkip || *state==FF || *state==REV) && avc->streams[best_stream]->time_base.num) {
if (!next_skip_pts || pts >= next_skip_pts) { if (!next_skip_pts || pts >= next_skip_pts) {
skip = avc->streams[best_stream]->time_base.den / avc->streams[best_stream]->time_base.num; skip = avc->streams[best_stream]->time_base.den / avc->streams[best_stream]->time_base.num;
if (actSecsToSkip)
skip *= actSecsToSkip;
if (*state == REV) { if (*state == REV) {
next_skip_pts = pts - skip; next_skip_pts = pts - skip;
pts = next_skip_pts - skip/4; pts = next_skip_pts - skip/4;
@@ -284,6 +287,11 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, const CFile::FileType ft, int /
} }
av_seek_frame(avc, best_stream, pts, seek_flags); av_seek_frame(avc, best_stream, pts, seek_flags);
skip = 0; skip = 0;
// if a custom value was set we only jump once
if (actSecsToSkip != 0) {
*state=PLAY;
*secondsToSkip = 0;
}
} }
} }