Skip to content

Commit

Permalink
Removed __loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 30, 2025
1 parent cb383ca commit 590cc64
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def _get_default_max_threads() -> int:
class AvifImageFile(ImageFile.ImageFile):
format = "AVIF"
format_description = "AVIF image"
__loaded = -1
__frame = 0
__frame = -1

def _open(self) -> None:
if not SUPPORTED:
Expand Down Expand Up @@ -105,28 +104,28 @@ def _open(self) -> None:
exif = exif_data.tobytes()
if exif:
self.info["exif"] = exif
self.seek(0)

def seek(self, frame: int) -> None:
if not self._seek_check(frame):
return

self.__frame = frame
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, self.mode)]

def load(self) -> Image.core.PixelAccess | None:
if self.__loaded != self.__frame:
if self.tile:
# We need to load the image data for this frame
data, timescale, tsp_in_ts, dur_in_ts = self._decoder.get_frame(
self.__frame
)
self.info["timestamp"] = round(1000 * (tsp_in_ts / timescale))
self.info["duration"] = round(1000 * (dur_in_ts / timescale))
self.__loaded = self.__frame

# Set tile
if self.fp and self._exclusive_fp:
self.fp.close()
self.fp = BytesIO(data)
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, self.mode)]

return super().load()

Expand Down

0 comments on commit 590cc64

Please sign in to comment.