mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
- added a quick header check for WebP before loading the entire file for real identification.
This allows quick rejection of virtually everything that's not a WebP without loading the entire file first.
This commit is contained in:
parent
1748477086
commit
42283f56ab
1 changed files with 7 additions and 1 deletions
|
@ -56,6 +56,12 @@ FImageSource *WebPImage_TryCreate(FileReader &file, int lumpnum)
|
||||||
{
|
{
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
int xoff = 0, yoff = 0;
|
int xoff = 0, yoff = 0;
|
||||||
|
file.Seek(0, FileReader::SeekSet);
|
||||||
|
|
||||||
|
uint8_t header[12];
|
||||||
|
if (file.Read(header, 12) != 12) return nullptr;
|
||||||
|
if (memcmp(header, "RIFF", 4) || memcmp(header + 8, "WEBP", 4)) return nullptr;
|
||||||
|
|
||||||
file.Seek(0, FileReader::SeekSet);
|
file.Seek(0, FileReader::SeekSet);
|
||||||
auto bytes = file.Read();
|
auto bytes = file.Read();
|
||||||
|
|
||||||
|
@ -76,7 +82,7 @@ FImageSource *WebPImage_TryCreate(FileReader &file, int lumpnum)
|
||||||
}
|
}
|
||||||
return new FWebPTexture(lumpnum, width, height, xoff, yoff);
|
return new FWebPTexture(lumpnum, width, height, xoff, yoff);
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FWebPTexture::FWebPTexture(int lumpnum, int w, int h, int xoff, int yoff)
|
FWebPTexture::FWebPTexture(int lumpnum, int w, int h, int xoff, int yoff)
|
||||||
|
|
Loading…
Reference in a new issue