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