SetMovieGWorld Can Slow You Down
Dispatch 9
Applications use SetMovieGWorld to associate a
QuickTime movie with a drawing destination called a GWorld. Most
applications only call SetMovieGWorld once, to
indicating where they want the movie to be drawn when the movie is
first created. Some applications, however, display a single movie in
several different windows. These applications often call
SetMovieGWorld more often than necessary, in order to
ensure that the movie is set to the correct destination.
Unfortunately, changing the destination GWorld that a movie is
drawing to is a relatively expensive operation.
When the movie's GWorld is set, internally QuickTime needs to
rebuild its drawing pipeline. This can require reallocating
QuickTime's internal buffers and renegotiating the drawing pipeline
with Image Decompressors. In many cases, particularly if a hardware
based Image Decompressor is involved, this can be a non-trivial
operation. As a result, calling SetMovieGWorld can
result in the overall processing time used by QuickTime increasing
considerably. Note that the work in rebuilding the drawing pipeline
is not actually done in SetMovieGWorld, but during the
next call to MoviesTask. This means that if profiling of
calls to QuickTime will only indicate that MoviesTask is
taking longer than necessary, not that SetMovieGWorld is
the cause of the problem.
One of the common mistakes applications make is to call
SetMovieGWorld between calls to MoviesTask.
In this case, the GWorld being set with SetMovieGWorld
is always the same. It might seem reasonable in this case to expect
QuickTime to ignore the call to SetMovieGWorld as the
GWorld isn't really being changed. However, because of the way
GWorlds are allocated, it is possible that after disposing one GWorld
and allocating another, that the new GWorld will have the same
address but different properties as the disposed GWorld. For this
reason, QuickTime can't ignore this case of the same GWorld being set
in SetMovieGWorld. Therefore, applications concerned
with playback and rendering performance must take care only to call
SetMovieGWorld when necessary.
See Also
Inside Macintosh: QuickTime - Movie Toolbox
Change History
4/16/98 - jph - First published
|