[Scummvm-git-logs] scummvm master -> 3f0c1f81d5d1981dbf249b5af980bd0f5ea10532

bluegr noreply at scummvm.org
Sun Sep 18 20:07:43 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3f0c1f81d5 COMMON: Add function to flatten edit lists to work around Obsidian audio popping problem.


Commit: 3f0c1f81d5d1981dbf249b5af980bd0f5ea10532
    https://github.com/scummvm/scummvm/commit/3f0c1f81d5d1981dbf249b5af980bd0f5ea10532
Author: elasota (ejlasota at gmail.com)
Date: 2022-09-18T23:07:39+03:00

Commit Message:
COMMON: Add function to flatten edit lists to work around Obsidian audio popping problem.

Obsidian's vidbot videos have audio tracks of consecutive audio chunks that are 22080 samples of 44100Hz audio, and a series of edit lists that are 0.5 seconds in duration (which would be 22050 samples), but have media times spaced 22080 samples apart, meaning every half-second, the audio skips 30 samples ahead.  This seems in line with how the QTTF specification says it should work, so it's not clear why other players don't have this problem.

Changed paths:
    common/quicktime.cpp
    common/quicktime.h


diff --git a/common/quicktime.cpp b/common/quicktime.cpp
index c49f53ac3f1..55f1ddd7ca5 100644
--- a/common/quicktime.cpp
+++ b/common/quicktime.cpp
@@ -807,6 +807,34 @@ void QuickTimeParser::close() {
 	_fd = nullptr;
 }
 
+void QuickTimeParser::flattenEditLists() {
+	// This flattens the movie edit list, collapsing everything into a single edit.
+	// This is necessary to work around sound popping in Obsidian on certain movies:
+	//
+	// For some reason, numerous movies have audio tracks with edit lists consisting
+	// off numerous 0.5-second duration chunks, which is 22050 audio examples at the
+	// 44100Hz media rate, but the edit media times are spaced out 22080 apart.
+	//
+	// The QuickTime File Format reference seems to suggest that this means the audio
+	// would skip ahead 30 samples every half-second, which is what the playback code
+	// currently does, and that causes audible popping in some movies (such as the
+	// cube maze greeter vidbot when she says "Take take take, that's all you ever do!"
+	// after repeatedly visiting her.)
+	//
+	// Other players seem to just play the audio track chunks consecutively without the
+	// 30-sample skips, which produces the correct results, not sure why.
+
+	for (Track *track : _tracks) {
+		if (track->editList.size()) {
+			EditListEntry &lastEntry = track->editList.back();
+			EditListEntry &firstEntry = track->editList.front();
+			firstEntry.trackDuration = (lastEntry.timeOffset + lastEntry.trackDuration);
+
+			track->editList.resize(1);
+		}
+	}
+}
+
 QuickTimeParser::SampleDesc::SampleDesc(Track *parentTrack, uint32 codecTag) {
 	_parentTrack = parentTrack;
 	_codecTag = codecTag;
diff --git a/common/quicktime.h b/common/quicktime.h
index f943af79aad..d16a75b18fb 100644
--- a/common/quicktime.h
+++ b/common/quicktime.h
@@ -77,6 +77,12 @@ public:
 	 */
 	void close();
 
+	/**
+	 * Flattens edit lists to a single edit containing the first edit contiguously through the last edit.
+	 * Used to work around bad edit offsets.
+	 */
+	void flattenEditLists();
+
 	/**
 	 * Set the beginning offset of the video so we can modify the offsets in the stco
 	 * atom of videos inside the Mohawk/mTropolis archives




More information about the Scummvm-git-logs mailing list