Changes to the movie buffer
The movie buffer has been farily substantially changed. Previous
versions of HFB relied on a rather complex "sort of" circular buffering
scheme. In order to limit the amount of copying of data, HFB would
reserve some space at the beginning and end of the normal buffer for frames
to overhang the buffer. This has been eliminated in 2 ways:
When in "regular" i/o mode, a small 8K "pre-hang" area is reserved at the head of the buffer. If a chunk is referenced that overhangs the end of the buffer is requested (via HFB_GetStreamingData) the part of the data that is at the beginning of the requested frame (the data at the end of the buffer) is copied to that 8 K pre-buffer area. If that "pre-hang" amount is greater than 8 K, the entire chunk is copied (fore and aft) to an extra (dynamically resizable) buffer pointed to by the buffer structure.
When using memory mapped file i/o, the buffer is always linear, there is no wrapping around of data, rather, the view of the file that is mapped is shifted to make certain that the data access falls entirely within the buffer.
Note that this also greatly simplifies the buffer offset issues, by removing many special cases.
Changes to indexing
Old-style hfb indexing was relatively simple. The entire index was read when the file was opened and stored for the duration of playback. This as been replaced by a more complex, but far more compact indexing scheme where the index is parsed in smaller chunks, remaining ahead of playback enough to provide meaningful information about the datarate characteristics of the file without overwhelming physical memory.
Each stream maintains a window into the index, and the new index handles are actually a 1 to 1 mapping of the chunks. Consequently the 100th frame of the file is referenced via index entry 100 for that stream. This greatly simplifies navigation.
One optimization is that a linked list is maintained that keeps information for navigating through the index one large chunk at a time. This functions as a sort of "cache" of sub index information so that is not always necessary to reparse the whole index during ff/rew and navigation.
Changes to random access of frames
Since HFB no longer maintains a comprehensive index in memory at all times, a number of structures have been added to provide meaningful random access throughout the file. Each stream maintains an index of keyframes collected at 1 second intervals. This way it is always possible to locate quickly to a keyframe within 1 second of the desired destination.
Changes to file i/o
Support for memory mapped file i/o has been added. In this mode, there is no need for any deidicated movie buffer, instead, the the buffer directly references a memory mapping of the file. This has the added beneficial side effect that many connections can share the buffered file data without re-reading the data and copying to their own dedicated buffer. The buffer space only exists as virtual memory, rather than as physical memory dedicated to the individual connection.