[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32523] trunk/blender/intern/audaspace/ ffmpeg/AUD_FFMPEGReader.cpp: == Audaspace / FFMPEG ==

Peter Schlaile peter at schlaile.de
Sat Oct 16 17:01:01 CEST 2010


Revision: 32523
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32523
Author:   schlaile
Date:     2010-10-16 17:01:01 +0200 (Sat, 16 Oct 2010)

Log Message:
-----------
== 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.)

Modified Paths:
--------------
    trunk/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp

Modified: trunk/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
===================================================================
--- trunk/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp	2010-10-16 15:00:04 UTC (rev 32522)
+++ trunk/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp	2010-10-16 15:01:01 UTC (rev 32523)
@@ -246,13 +246,23 @@
 {
 	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 @@
 					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)
 						{





More information about the Bf-blender-cvs mailing list