Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Schlaile <peter@schlaile.de>2010-10-16 19:01:01 +0400
committerPeter Schlaile <peter@schlaile.de>2010-10-16 19:01:01 +0400
commit7122b534fa6879c7f321705213a71ffdc091dcfd (patch)
tree7648a99daa9b4870e3a050267b9b847265891d63
parent53ced0be29c2672226d16d63118a02a4c8eee342 (diff)
== Audaspace / FFMPEG ==
Audaspace audio seek code wasn't taking start_time into account. (Most common symptom: HDV MPEG2TS files always start audio playback at the beginning regardless of seek position.)
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
index 623e99d5edc..09fdb31e938 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
@@ -246,13 +246,23 @@ void AUD_FFMPEGReader::seek(int position)
{
if(position >= 0)
{
+ uint64_t st_time = m_formatCtx->streams[m_stream]->start_time;
+ double time_base =
+ av_q2d(m_formatCtx->streams[m_stream]->time_base);
+ uint64_t seek_pos = position / time_base / m_specs.rate;
+
+ if (seek_pos < 0) {
+ seek_pos = 0;
+ }
+
+ if (st_time != AV_NOPTS_VALUE) {
+ seek_pos += st_time;
+ }
+
+
// a value < 0 tells us that seeking failed
- if(av_seek_frame(m_formatCtx,
- -1,
- (uint64_t)(((uint64_t)position *
- (uint64_t)AV_TIME_BASE) /
- (uint64_t)m_specs.rate),
- AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
+ if(av_seek_frame(m_formatCtx, m_stream, seek_pos,
+ AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
{
avcodec_flush_buffers(m_codecCtx);
m_position = position;
@@ -273,9 +283,8 @@ void AUD_FFMPEGReader::seek(int position)
if(packet.pts != AV_NOPTS_VALUE)
{
// calculate real position, and read to frame!
- m_position = packet.pts *
- av_q2d(m_formatCtx->streams[m_stream]->time_base) *
- m_specs.rate;
+ m_position = (packet.pts -
+ ((st_time != AV_NOPTS_VALUE) ? st_time : 0)) * time_base * m_specs.rate;
if(m_position < position)
{