- if (img->flags & FLAG_RAW)
- return read_raw_frame(img, frame);
-
- if ((img->flags & FLAG_OVERWRITE)
- || (img->chunk && !(frame % img->chunk))) {
- /* Clear the slate. */
- img->currentframe = -1;
- memset(img->framedata[0], 0, img->width * img->height);
- memset(img->mask[0], 0, img->width * img->height);
- } else {
- /* Start over if we are backtracking. */
- if (img->currentframe > frame) {
- memset(img->mask[0], 0, img->width * img->height);
- img->currentframe = -1;
- }