Fixes an error when playing a QuickTime video that has a mediaTime set
on its first edit. This was caused by mediaTime changes in:
ef184a6cef98a1756c0669a03fa9b6fa2386b6e7
Those changes buffered frames during initialization so that the keyframe
and other frames don't play instead of the intended start frame that
mediaTime specifies. My mistake was that decoding isn't allowed during
VideoDecoder::loadStream(); VideoDecoder::setDitheringPalette() requires
that no frames have been decoded yet, and at least Director and Mohawk
call that.
Now the initial mediaTime buffering is delayed until the first decode.
Fixes bug #13479 where certain Myst videos error.
Fixes the opening movie in the Director game Chop Suey.
The amount of lines to skip is in `len`. This wasn't taken into account
when decoding the endcurrentline opcode.
Thanks to Kostya for resolving the issue.
A PACo 'frame' has both the audio and video part of the frame. Where decodeNextFrame only handles video, readNextPacket enables the option to read a PACo frame and decode and queue both audio and video.
Move the VideoTrack to FixedRateVideoTrack. It handles frame duration
internally and removes the need to use nextFrameStartTime accounting.
Add getPalette function.
The code decodes PACo video frames.
Other features, such as audio and palette changes are detected
but not handled.
Format documentation: https://wiki.multimedia.cx/index.php?title=PACo
Thanks to Kostya for reverse engineering the format and the original C
code.
Color depths greater than 32 have grayscale bit 0x20 set, but the
decoder incorrectly treats 32 as grayscale and and clears the bit,
leaving the color depth as zero and causing codecs to fail.
Confirmed correct behavior in the ffmpeg code that the decoder was
based off. The decoder was introduced with the Mohawk engine in
2009,so presumably no Mohawk movies had color depth 32.
Fixes videos in the Director game Virtual Cocktail Bar
QuickTimeDecoder has a bug which causes the mediaTime offset to be
ignored when a track begins with an empty edit and is followed by an
edit with a non-zero mediaTime. This causes the KQ6 Mac opening movie
to start several tracks at unintended frames (they're never supposed to
be displayed) and the intended frames at the end of the edit to never
be displayed. (Bug #11085)
QuickTimeDecoder has a workaround for a video in a Spanish version of
Riven, but this workaround breaks valid QuickTime videos such as the
KQ6 Macintosh opening movie. (Bug #11085)
Until the original Riven video bug can be debugged to improve the
workaround, it is now disabled unless an engine enables it.
Workaround added in: b8abe400850a23d12fe5cdc24d7106820d0f13fd
Mostly done using the following Ruby script:
(Dir.glob('**/*.cpp') + Dir.glob('**/*.h')).each do |file|
s = File.read(file, encoding: 'iso8859-1')
t = s.gsub(/(([\w_.\[\]]+)\s*=\s*new\s+\S+?\[[^\]]+?\](?!\())([^\{\}]*?)\n\s+memset\(\s*\2\s*,\s*0\s*,[^;]*;/m, '\1()\3')
if t != s
File.open(file, 'w') { |io| io.write(t) }
end
end