Beta 2. No longer using STB_Image.

This commit is contained in:
Scott Duensing 2023-11-27 20:46:37 -06:00
parent 6d29632daf
commit c614cb55df
21 changed files with 298 additions and 203 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
cmake-build-debug/ cmake-build-debug/
*.log *.log
*.user *.user
temp/

View file

@ -388,6 +388,8 @@ set(LIB_LIST
${BUILD_DIR}/lib/libarchive.a ${BUILD_DIR}/lib/libarchive.a
${BUILD_DIR}/lib/libcrypto.a ${BUILD_DIR}/lib/libcrypto.a
${BUILD_DIR}/lib/libssl.a ${BUILD_DIR}/lib/libssl.a
${BUILD_DIR}/lib/libjpeg.a
${BUILD_DIR}/lib/libpng.a
) )
target_link_libraries(${CMAKE_PROJECT_NAME} target_link_libraries(${CMAKE_PROJECT_NAME}
-Wl,--start-group -Wl,--start-group

View file

@ -31,8 +31,9 @@ For all Singe 2 and later games, it will automatically appear in the menu.
To upgrade, back up any changes you may have made to files inside the Singe To upgrade, back up any changes you may have made to files inside the Singe
subdirectory that was generated during installation. (You really shouldn't subdirectory that was generated during installation. (You really shouldn't
be changing things in there!) Delete the Singe subdirectory and run the new be changing things in there!) Delete the Singe subdirectory, Menu.bat (or
Singe binary with no command line arguments to generate the new files. .sh) and run the new Singe binary with no command line arguments to generate
the new files.
COMMAND LINE COMMAND LINE

View file

@ -26,7 +26,9 @@
SINGE_FRAMEWORK_VERSION = 2.10 SINGE_FRAMEWORK_VERSION = 2.10
DIR = singeGetScriptPath():match("(.*[/\\])") or "./" if singeGetScriptPath ~= nil then
DIR = singeGetScriptPath():match("(.*[/\\])") or "./"
end
function utilDeepCopy(orig) function utilDeepCopy(orig)

View file

@ -48,59 +48,7 @@ function buildAll() {
mkdir -p ${G_GENERATED} mkdir -p ${G_GENERATED}
if [[ 0 == 1 ]]; then if [[ 1 == 1 ]]; then
pushd thirdparty/SDL2
clearAndEnterBuild
cmake ${COMMON} \
-DSDL_SHARED=off \
-DSDL_STATIC=on \
..
make install
popd
pushd thirdparty/SDL2_image
clearAndEnterBuild
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2IMAGE_DEPS_SHARED=off \
-DSDL2IMAGE_SAMPLES=off \
-DSDL2IMAGE_TESTS=off \
-DSDL2IMAGE_VENDORED=on \
-DSDL2IMAGE_AVIF=off \
-DSDL2IMAGE_JXL=off \
-DSDL2IMAGE_TIF=off \
-DSDL2IMAGE_WEBP=on \
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
..
make install
popd
pushd thirdparty/SDL2_mixer
clearAndEnterBuild
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2MIXER_CMD=off \
-DSDL2MIXER_DEPS_SHARED=off \
-DSDL2MIXER_VENDORED=on \
-DSDL2MIXER_SAMPLES=off \
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
-DWAVPACK_ENABLE_ASM=no \
..
make install
popd
pushd thirdparty/SDL2_ttf
clearAndEnterBuild
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2TTF_VENDORED=on \
-DSDL2TTF_HARFBUZZ=off \
-DSDL2TTF_SAMPLES=off \
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
..
make install
popd
pushd thirdparty/bzip2 pushd thirdparty/bzip2
clearAndEnterBuild clearAndEnterBuild
cmake ${COMMON} \ cmake ${COMMON} \
@ -138,6 +86,79 @@ if [[ 0 == 1 ]]; then
make install make install
popd popd
pushd thirdparty/SDL2
clearAndEnterBuild
cmake ${COMMON} \
-DSDL_SHARED=off \
-DSDL_STATIC=on \
..
make install
popd
fi
pushd thirdparty/SDL2_image
clearAndEnterBuild
CFLAGS="-Iexternal/libpng -I${G_TARGET}/include" \
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2IMAGE_DEPS_SHARED=off \
-DSDL2IMAGE_SAMPLES=off \
-DSDL2IMAGE_TESTS=off \
-DSDL2IMAGE_VENDORED=on \
-DSDL2IMAGE_BACKEND_STB=off \
-DSDL2IMAGE_AVIF=off \
-DSDL2IMAGE_JXL=off \
-DSDL2IMAGE_TIF=off \
-DSDL2IMAGE_WEBP=on \
-DSDL_LIBRARY="${G_TARGET}/lib/libSDL2.a" \
-DSDL_INCLUDE_DIR="${G_TARGET}/include" \
-DWEBP_BUILD_ANIM_UTILS=off \
-DWEBP_BUILD_CWEBP=off \
-DWEBP_BUILD_DWEBP=off \
-DWEBP_BUILD_GIF2WEBP=off \
-DWEBP_BUILD_IMG2WEBP=off \
-DWEBP_BUILD_VWEBP=off \
-DWEBP_BUILD_WEBPINFO=off \
-DWEBP_BUILD_WEBPMUX=off \
-DWEBP_BUILD_EXTRAS=off \
..
# 'make install' failes on zlib, which we don't want anyway.
make
cp -f ../include/SDL_image.h "${G_TARGET}/include/SDL2/."
cp -f libSDL2_image.a "${G_TARGET}/lib/."
cp -f external/jpeg/libjpeg.a "${G_TARGET}/lib/."
cp -f external/libpng/libpng.a "${G_TARGET}/lib/."
cp -f external/libwebp/libwebp.a "${G_TARGET}/lib/."
cp -f external/libwebp/libwebpdemux.a "${G_TARGET}/lib/."
popd
if [[ 1 == 1 ]]; then
pushd thirdparty/SDL2_mixer
clearAndEnterBuild
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2MIXER_CMD=off \
-DSDL2MIXER_DEPS_SHARED=off \
-DSDL2MIXER_VENDORED=on \
-DSDL2MIXER_SAMPLES=off \
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
-DWAVPACK_ENABLE_ASM=no \
..
make install
popd
pushd thirdparty/SDL2_ttf
clearAndEnterBuild
cmake ${COMMON} \
-DBUILD_SHARED_LIBS=off \
-DSDL2TTF_VENDORED=on \
-DSDL2TTF_HARFBUZZ=off \
-DSDL2TTF_SAMPLES=off \
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
..
make install
popd
pushd thirdparty/libarchive pushd thirdparty/libarchive
clearAndEnterBuild clearAndEnterBuild
cmake ${COMMON} \ cmake ${COMMON} \
@ -336,7 +357,7 @@ fi
clearAndEnterBuild clearAndEnterBuild
cmake ${COMMON} ${G_BUILDROOT} cmake ${COMMON} ${G_BUILDROOT}
make make
#upx -9 --force singe2${SUFFIX} upx -9 --force singe2${SUFFIX}
mv -f singe2${SUFFIX} ${G_BUILDROOT}/${G_BUILDDIR}/Singe-v2.10-${OS^}-${ARCH}${SUFFIX} mv -f singe2${SUFFIX} ${G_BUILDROOT}/${G_BUILDDIR}/Singe-v2.10-${OS^}-${ARCH}${SUFFIX}
popd popd
} }

View file

@ -3841,7 +3841,8 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
progTrace("Creating Lua context for Singe setup"); progTrace("Creating Lua context for Singe setup");
_global.luaContext = luaL_newstate(); _global.luaContext = luaL_newstate();
startLuaContext(_global.luaContext); startLuaContext(_global.luaContext);
// Load framework // Load framework - NOTE! SINGE API NOT AVAILABLE AT THIS POINT!
// Any calls in the framework need to be wrapped with nil checks!
progTrace("Loading Singe framework"); progTrace("Loading Singe framework");
if (luaL_loadbuffer(_global.luaContext, (char *)Framework_singe, Framework_singe_len, "Input Mappings") || lua_pcall(_global.luaContext, 0, 0, 0)) utilDie("%s", lua_tostring(_global.luaContext, -1)); if (luaL_loadbuffer(_global.luaContext, (char *)Framework_singe, Framework_singe_len, "Input Mappings") || lua_pcall(_global.luaContext, 0, 0, 0)) utilDie("%s", lua_tostring(_global.luaContext, -1));
// Load default mappings // Load default mappings
@ -3938,6 +3939,119 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
_global.luaContext = luaL_newstate(); _global.luaContext = luaL_newstate();
startLuaContext(_global.luaContext); startLuaContext(_global.luaContext);
// Lua API for Singe
lua_register(_global.luaContext, "colorBackground", apiColorBackground);
lua_register(_global.luaContext, "colorForeground", apiColorForeground);
lua_register(_global.luaContext, "controllerGetAxis", apiControllerGetAxis);
lua_register(_global.luaContext, "debugPrint", apiDebugPrint);
lua_register(_global.luaContext, "discAudio", apiDiscAudio);
lua_register(_global.luaContext, "discChangeSpeed", apiDiscChangeSpeed);
lua_register(_global.luaContext, "discGetFrame", apiDiscGetFrame);
lua_register(_global.luaContext, "discGetHeight", apiDiscGetHeight);
lua_register(_global.luaContext, "discGetState", apiDiscGetState);
lua_register(_global.luaContext, "discGetWidth", apiDiscGetWidth);
lua_register(_global.luaContext, "discPause", apiDiscPause);
lua_register(_global.luaContext, "discPauseAtFrame", apiDiscPauseAtFrame);
lua_register(_global.luaContext, "discPlay", apiDiscPlay);
lua_register(_global.luaContext, "discSearch", apiDiscSearch);
lua_register(_global.luaContext, "discSearchBlanking", apiDiscSearchBlanking);
lua_register(_global.luaContext, "discSetFPS", apiDiscSetFps);
lua_register(_global.luaContext, "discSkipBackward", apiDiscSkipBackward);
lua_register(_global.luaContext, "discSkipBlanking", apiDiscSkipBlanking);
lua_register(_global.luaContext, "discSkipForward", apiDiscSkipForward);
lua_register(_global.luaContext, "discSkipToFrame", apiDiscSkipToFrame);
lua_register(_global.luaContext, "discStepBackward", apiDiscStepBackward);
lua_register(_global.luaContext, "discStepForward", apiDiscStepForward);
lua_register(_global.luaContext, "discStop", apiDiscStop);
lua_register(_global.luaContext, "fontLoad", apiFontLoad);
lua_register(_global.luaContext, "fontPrint", apiFontPrint);
lua_register(_global.luaContext, "fontQuality", apiFontQuality);
lua_register(_global.luaContext, "fontSelect", apiFontSelect);
lua_register(_global.luaContext, "fontToSprite", apiFontToSprite);
lua_register(_global.luaContext, "fontUnload", apiFontUnload);
lua_register(_global.luaContext, "keyboardGetMode", apiKeyboardGetMode);
lua_register(_global.luaContext, "keyboardSetMode", apiKeyboardSetMode);
lua_register(_global.luaContext, "mouseEnable", apiMouseEnable);
lua_register(_global.luaContext, "mouseDisable", apiMouseDisable);
lua_register(_global.luaContext, "mouseGetPosition", apiMouseGetPosition);
lua_register(_global.luaContext, "mouseHowMany", apiMouseHowMany);
lua_register(_global.luaContext, "mouseSetCaptured", apiMouseSetCaptured);
lua_register(_global.luaContext, "mouseSetMode", apiMouseSetMode);
lua_register(_global.luaContext, "overlayBox", apiOverlayBox);
lua_register(_global.luaContext, "overlayCircle", apiOverlayCircle);
lua_register(_global.luaContext, "overlayClear", apiOverlayClear);
lua_register(_global.luaContext, "overlayEllipse", apiOverlayEllipse);
lua_register(_global.luaContext, "overlayGetHeight", apiOverlayGetHeight);
lua_register(_global.luaContext, "overlayGetWidth", apiOverlayGetWidth);
lua_register(_global.luaContext, "overlayLine", apiOverlayLine);
lua_register(_global.luaContext, "overlayPlot", apiOverlayPlot);
lua_register(_global.luaContext, "overlayPrint", apiOverlayPrint);
lua_register(_global.luaContext, "overlaySetResolution", apiOverlaySetResolution);
lua_register(_global.luaContext, "scriptExecute", apiScriptExecute);
lua_register(_global.luaContext, "scriptPush", apiScriptPush);
lua_register(_global.luaContext, "singeDisablePauseKey", apiSingeDisablePauseKey);
lua_register(_global.luaContext, "singeEnablePauseKey", apiSingeEnablePauseKey);
lua_register(_global.luaContext, "singeGetDataPath", apiSingeGetDataPath);
lua_register(_global.luaContext, "singeGetHeight", apiSingeGetHeight);
lua_register(_global.luaContext, "singeGetPauseFlag", apiSingeGetPauseFlag);
lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath);
lua_register(_global.luaContext, "singeGetWidth", apiSingeGetWidth);
lua_register(_global.luaContext, "singeScreenshot", apiSingeScreenshot);
lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName);
lua_register(_global.luaContext, "singeSetPauseFlag", apiSingeSetPauseFlag);
lua_register(_global.luaContext, "singeQuit", apiSingeQuit);
lua_register(_global.luaContext, "singeVersion", apiSingeVersion);
lua_register(_global.luaContext, "singeWantsCrosshairs", apiSingeWantsCrosshairs);
lua_register(_global.luaContext, "soundFullStop", apiSoundFullStop);
lua_register(_global.luaContext, "soundGetVolume", apiSoundGetVolume);
lua_register(_global.luaContext, "soundIsPlaying", apiSoundIsPlaying);
lua_register(_global.luaContext, "soundLoad", apiSoundLoad);
lua_register(_global.luaContext, "soundPause", apiSoundPause);
lua_register(_global.luaContext, "soundPlay", apiSoundPlay);
lua_register(_global.luaContext, "soundResume", apiSoundResume);
lua_register(_global.luaContext, "soundSetVolume", apiSoundSetVolume);
lua_register(_global.luaContext, "soundStop", apiSoundStop);
lua_register(_global.luaContext, "soundUnload", apiSoundUnload);
lua_register(_global.luaContext, "spriteDraw", apiSpriteDraw);
lua_register(_global.luaContext, "spriteGetHeight", apiSpriteGetHeight);
lua_register(_global.luaContext, "spriteGetWidth", apiSpriteGetWidth);
lua_register(_global.luaContext, "spriteLoad", apiSpriteLoad);
lua_register(_global.luaContext, "spriteQuality", apiSpriteQuality);
lua_register(_global.luaContext, "spriteRotate", apiSpriteRotate);
lua_register(_global.luaContext, "spriteRotateAndScale", apiSpriteRotateAndScale);
lua_register(_global.luaContext, "spriteScale", apiSpriteScale);
lua_register(_global.luaContext, "spriteUnload", apiSpriteUnload);
lua_register(_global.luaContext, "videoDraw", apiVideoDraw);
lua_register(_global.luaContext, "videoGetFrame", apiVideoGetFrame);
lua_register(_global.luaContext, "videoGetFrameCount", apiVideoGetFrameCount);
lua_register(_global.luaContext, "videoGetHeight", apiVideoGetHeight);
lua_register(_global.luaContext, "videoGetVolume", apiVideoGetVolume);
lua_register(_global.luaContext, "videoGetWidth", apiVideoGetWidth);
lua_register(_global.luaContext, "videoIsPlaying", apiVideoIsPlaying);
lua_register(_global.luaContext, "videoLoad", apiVideoLoad);
lua_register(_global.luaContext, "videoPause", apiVideoPause);
lua_register(_global.luaContext, "videoPlay", apiVideoPlay);
lua_register(_global.luaContext, "videoSeek", apiVideoSeek);
lua_register(_global.luaContext, "videoSetVolume", apiVideoSetVolume);
lua_register(_global.luaContext, "videoUnload", apiVideoUnload);
lua_register(_global.luaContext, "vldpGetHeight", apiVldpGetHeight);
lua_register(_global.luaContext, "vldpGetPixel", apiVldpGetPixel);
lua_register(_global.luaContext, "vldpGetWidth", apiVldpGetWidth);
lua_register(_global.luaContext, "vldpSetVerbose", apiVldpVerbose);
// Open main video file // Open main video file
progTrace("Opening main video file"); progTrace("Opening main video file");
doIndexDisplay(-1); doIndexDisplay(-1);
@ -4587,119 +4701,6 @@ void startLuaContext(lua_State *L) {
lua_rawseti(L, -2, 1); lua_rawseti(L, -2, 1);
// Remove the seachers and the package tables from the stack // Remove the seachers and the package tables from the stack
lua_pop(L, 2); lua_pop(L, 2);
// Lua API for Singe
lua_register(_global.luaContext, "colorBackground", apiColorBackground);
lua_register(_global.luaContext, "colorForeground", apiColorForeground);
lua_register(_global.luaContext, "controllerGetAxis", apiControllerGetAxis);
lua_register(_global.luaContext, "debugPrint", apiDebugPrint);
lua_register(_global.luaContext, "discAudio", apiDiscAudio);
lua_register(_global.luaContext, "discChangeSpeed", apiDiscChangeSpeed);
lua_register(_global.luaContext, "discGetFrame", apiDiscGetFrame);
lua_register(_global.luaContext, "discGetHeight", apiDiscGetHeight);
lua_register(_global.luaContext, "discGetState", apiDiscGetState);
lua_register(_global.luaContext, "discGetWidth", apiDiscGetWidth);
lua_register(_global.luaContext, "discPause", apiDiscPause);
lua_register(_global.luaContext, "discPauseAtFrame", apiDiscPauseAtFrame);
lua_register(_global.luaContext, "discPlay", apiDiscPlay);
lua_register(_global.luaContext, "discSearch", apiDiscSearch);
lua_register(_global.luaContext, "discSearchBlanking", apiDiscSearchBlanking);
lua_register(_global.luaContext, "discSetFPS", apiDiscSetFps);
lua_register(_global.luaContext, "discSkipBackward", apiDiscSkipBackward);
lua_register(_global.luaContext, "discSkipBlanking", apiDiscSkipBlanking);
lua_register(_global.luaContext, "discSkipForward", apiDiscSkipForward);
lua_register(_global.luaContext, "discSkipToFrame", apiDiscSkipToFrame);
lua_register(_global.luaContext, "discStepBackward", apiDiscStepBackward);
lua_register(_global.luaContext, "discStepForward", apiDiscStepForward);
lua_register(_global.luaContext, "discStop", apiDiscStop);
lua_register(_global.luaContext, "fontLoad", apiFontLoad);
lua_register(_global.luaContext, "fontPrint", apiFontPrint);
lua_register(_global.luaContext, "fontQuality", apiFontQuality);
lua_register(_global.luaContext, "fontSelect", apiFontSelect);
lua_register(_global.luaContext, "fontToSprite", apiFontToSprite);
lua_register(_global.luaContext, "fontUnload", apiFontUnload);
lua_register(_global.luaContext, "keyboardGetMode", apiKeyboardGetMode);
lua_register(_global.luaContext, "keyboardSetMode", apiKeyboardSetMode);
lua_register(_global.luaContext, "mouseEnable", apiMouseEnable);
lua_register(_global.luaContext, "mouseDisable", apiMouseDisable);
lua_register(_global.luaContext, "mouseGetPosition", apiMouseGetPosition);
lua_register(_global.luaContext, "mouseHowMany", apiMouseHowMany);
lua_register(_global.luaContext, "mouseSetCaptured", apiMouseSetCaptured);
lua_register(_global.luaContext, "mouseSetMode", apiMouseSetMode);
lua_register(_global.luaContext, "overlayBox", apiOverlayBox);
lua_register(_global.luaContext, "overlayCircle", apiOverlayCircle);
lua_register(_global.luaContext, "overlayClear", apiOverlayClear);
lua_register(_global.luaContext, "overlayEllipse", apiOverlayEllipse);
lua_register(_global.luaContext, "overlayGetHeight", apiOverlayGetHeight);
lua_register(_global.luaContext, "overlayGetWidth", apiOverlayGetWidth);
lua_register(_global.luaContext, "overlayLine", apiOverlayLine);
lua_register(_global.luaContext, "overlayPlot", apiOverlayPlot);
lua_register(_global.luaContext, "overlayPrint", apiOverlayPrint);
lua_register(_global.luaContext, "overlaySetResolution", apiOverlaySetResolution);
lua_register(_global.luaContext, "scriptExecute", apiScriptExecute);
lua_register(_global.luaContext, "scriptPush", apiScriptPush);
lua_register(_global.luaContext, "singeDisablePauseKey", apiSingeDisablePauseKey);
lua_register(_global.luaContext, "singeEnablePauseKey", apiSingeEnablePauseKey);
lua_register(_global.luaContext, "singeGetDataPath", apiSingeGetDataPath);
lua_register(_global.luaContext, "singeGetHeight", apiSingeGetHeight);
lua_register(_global.luaContext, "singeGetPauseFlag", apiSingeGetPauseFlag);
lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath);
lua_register(_global.luaContext, "singeGetWidth", apiSingeGetWidth);
lua_register(_global.luaContext, "singeScreenshot", apiSingeScreenshot);
lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName);
lua_register(_global.luaContext, "singeSetPauseFlag", apiSingeSetPauseFlag);
lua_register(_global.luaContext, "singeQuit", apiSingeQuit);
lua_register(_global.luaContext, "singeVersion", apiSingeVersion);
lua_register(_global.luaContext, "singeWantsCrosshairs", apiSingeWantsCrosshairs);
lua_register(_global.luaContext, "soundFullStop", apiSoundFullStop);
lua_register(_global.luaContext, "soundGetVolume", apiSoundGetVolume);
lua_register(_global.luaContext, "soundIsPlaying", apiSoundIsPlaying);
lua_register(_global.luaContext, "soundLoad", apiSoundLoad);
lua_register(_global.luaContext, "soundPause", apiSoundPause);
lua_register(_global.luaContext, "soundPlay", apiSoundPlay);
lua_register(_global.luaContext, "soundResume", apiSoundResume);
lua_register(_global.luaContext, "soundSetVolume", apiSoundSetVolume);
lua_register(_global.luaContext, "soundStop", apiSoundStop);
lua_register(_global.luaContext, "soundUnload", apiSoundUnload);
lua_register(_global.luaContext, "spriteDraw", apiSpriteDraw);
lua_register(_global.luaContext, "spriteGetHeight", apiSpriteGetHeight);
lua_register(_global.luaContext, "spriteGetWidth", apiSpriteGetWidth);
lua_register(_global.luaContext, "spriteLoad", apiSpriteLoad);
lua_register(_global.luaContext, "spriteQuality", apiSpriteQuality);
lua_register(_global.luaContext, "spriteRotate", apiSpriteRotate);
lua_register(_global.luaContext, "spriteRotateAndScale", apiSpriteRotateAndScale);
lua_register(_global.luaContext, "spriteScale", apiSpriteScale);
lua_register(_global.luaContext, "spriteUnload", apiSpriteUnload);
lua_register(_global.luaContext, "videoDraw", apiVideoDraw);
lua_register(_global.luaContext, "videoGetFrame", apiVideoGetFrame);
lua_register(_global.luaContext, "videoGetFrameCount", apiVideoGetFrameCount);
lua_register(_global.luaContext, "videoGetHeight", apiVideoGetHeight);
lua_register(_global.luaContext, "videoGetVolume", apiVideoGetVolume);
lua_register(_global.luaContext, "videoGetWidth", apiVideoGetWidth);
lua_register(_global.luaContext, "videoIsPlaying", apiVideoIsPlaying);
lua_register(_global.luaContext, "videoLoad", apiVideoLoad);
lua_register(_global.luaContext, "videoPause", apiVideoPause);
lua_register(_global.luaContext, "videoPlay", apiVideoPlay);
lua_register(_global.luaContext, "videoSeek", apiVideoSeek);
lua_register(_global.luaContext, "videoSetVolume", apiVideoSetVolume);
lua_register(_global.luaContext, "videoUnload", apiVideoUnload);
lua_register(_global.luaContext, "vldpGetHeight", apiVldpGetHeight);
lua_register(_global.luaContext, "vldpGetPixel", apiVldpGetPixel);
lua_register(_global.luaContext, "vldpGetWidth", apiVldpGetWidth);
lua_register(_global.luaContext, "vldpSetVerbose", apiVldpVerbose);
} }

View file

@ -57,7 +57,7 @@ extern "C" {
// to leverage in-development code without breaking their stable builds. // to leverage in-development code without breaking their stable builds.
#define AVIF_VERSION_MAJOR 1 #define AVIF_VERSION_MAJOR 1
#define AVIF_VERSION_MINOR 0 #define AVIF_VERSION_MINOR 0
#define AVIF_VERSION_PATCH 1 #define AVIF_VERSION_PATCH 2
#define AVIF_VERSION_DEVEL 0 #define AVIF_VERSION_DEVEL 0
#define AVIF_VERSION \ #define AVIF_VERSION \
((AVIF_VERSION_MAJOR * 1000000) + (AVIF_VERSION_MINOR * 10000) + (AVIF_VERSION_PATCH * 100) + AVIF_VERSION_DEVEL) ((AVIF_VERSION_MAJOR * 1000000) + (AVIF_VERSION_MINOR * 10000) + (AVIF_VERSION_PATCH * 100) + AVIF_VERSION_DEVEL)

View file

@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.0.2] - 2023-11-16
### Changed
* Update avifCropRectConvertCleanApertureBox() to the revised requirements in
ISO/IEC 23000-22:2019/Amd. 2:2021 Section 7.3.6.7.
* Fix memory errors reported in crbug.com/1501766 and crbug.com/1501770.
## [1.0.1] - 2023-08-29 ## [1.0.1] - 2023-08-29
### Changed ### Changed
@ -980,6 +987,7 @@ code.
- `avifVersion()` function - `avifVersion()` function
[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v1.0.0...HEAD [Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v1.0.0...HEAD
[1.0.2]: https://github.com/AOMediaCodec/libavif/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/AOMediaCodec/libavif/compare/v1.0.0...v1.0.1 [1.0.1]: https://github.com/AOMediaCodec/libavif/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/AOMediaCodec/libavif/compare/v0.11.1...v1.0.0 [1.0.0]: https://github.com/AOMediaCodec/libavif/compare/v0.11.1...v1.0.0
[0.11.1]: https://github.com/AOMediaCodec/libavif/compare/v0.11.0...v0.11.1 [0.11.1]: https://github.com/AOMediaCodec/libavif/compare/v0.11.0...v0.11.1

View file

@ -11,7 +11,7 @@ endif()
# Specify search path for CMake modules to be loaded by include() and find_package() # Specify search path for CMake modules to be loaded by include() and find_package()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
project(libavif LANGUAGES C VERSION 1.0.1) project(libavif LANGUAGES C VERSION 1.0.2)
# Set C99 as the default # Set C99 as the default
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
@ -25,7 +25,7 @@ set(CMAKE_C_STANDARD 99)
# Increment PATCH. # Increment PATCH.
set(LIBRARY_VERSION_MAJOR 16) set(LIBRARY_VERSION_MAJOR 16)
set(LIBRARY_VERSION_MINOR 0) set(LIBRARY_VERSION_MINOR 0)
set(LIBRARY_VERSION_PATCH 1) set(LIBRARY_VERSION_PATCH 2)
set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR}) set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})

View file

@ -57,7 +57,7 @@ extern "C" {
// to leverage in-development code without breaking their stable builds. // to leverage in-development code without breaking their stable builds.
#define AVIF_VERSION_MAJOR 1 #define AVIF_VERSION_MAJOR 1
#define AVIF_VERSION_MINOR 0 #define AVIF_VERSION_MINOR 0
#define AVIF_VERSION_PATCH 1 #define AVIF_VERSION_PATCH 2
#define AVIF_VERSION_DEVEL 0 #define AVIF_VERSION_DEVEL 0
#define AVIF_VERSION \ #define AVIF_VERSION \
((AVIF_VERSION_MAJOR * 1000000) + (AVIF_VERSION_MINOR * 10000) + (AVIF_VERSION_PATCH * 100) + AVIF_VERSION_DEVEL) ((AVIF_VERSION_MAJOR * 1000000) + (AVIF_VERSION_MINOR * 10000) + (AVIF_VERSION_PATCH * 100) + AVIF_VERSION_DEVEL)

View file

@ -624,16 +624,15 @@ static avifBool overflowsInt32(int64_t x)
static avifBool avifCropRectIsValid(const avifCropRect * cropRect, uint32_t imageW, uint32_t imageH, avifPixelFormat yuvFormat, avifDiagnostics * diag) static avifBool avifCropRectIsValid(const avifCropRect * cropRect, uint32_t imageW, uint32_t imageH, avifPixelFormat yuvFormat, avifDiagnostics * diag)
{ {
// ISO/IEC 23000-22:2019/DAM 2:2021, Section 7.3.6.7: // ISO/IEC 23000-22:2019/Amd. 2:2021, Section 7.3.6.7:
// The clean aperture property is restricted according to the chroma // The clean aperture property is restricted according to the chroma
// sampling format of the input image (4:4:4, 4:2:2:, 4:2:0, or 4:0:0) as // sampling format of the input image (4:4:4, 4:2:2:, 4:2:0, or 4:0:0) as
// follows: // follows:
// - when the image is 4:0:0 (monochrome) or 4:4:4, the horizontal and // ...
// vertical cropped offsets and widths shall be integers; // - If chroma is subsampled horizontally (i.e., 4:2:2 and 4:2:0), the
// - when the image is 4:2:2 the horizontal cropped offset and width // leftmost pixel of the clean aperture shall be even numbers;
// shall be even numbers and the vertical values shall be integers; // - If chroma is subsampled vertically (i.e., 4:2:0), the topmost line
// - when the image is 4:2:0 both the horizontal and vertical cropped // of the clean aperture shall be even numbers.
// offsets and widths shall be even numbers.
if ((cropRect->width == 0) || (cropRect->height == 0)) { if ((cropRect->width == 0) || (cropRect->height == 0)) {
avifDiagnosticsPrintf(diag, "[Strict] crop rect width and height must be nonzero"); avifDiagnosticsPrintf(diag, "[Strict] crop rect width and height must be nonzero");
@ -646,14 +645,14 @@ static avifBool avifCropRectIsValid(const avifCropRect * cropRect, uint32_t imag
} }
if ((yuvFormat == AVIF_PIXEL_FORMAT_YUV420) || (yuvFormat == AVIF_PIXEL_FORMAT_YUV422)) { if ((yuvFormat == AVIF_PIXEL_FORMAT_YUV420) || (yuvFormat == AVIF_PIXEL_FORMAT_YUV422)) {
if (((cropRect->x % 2) != 0) || ((cropRect->width % 2) != 0)) { if ((cropRect->x % 2) != 0) {
avifDiagnosticsPrintf(diag, "[Strict] crop rect X offset and width must both be even due to this image's YUV subsampling"); avifDiagnosticsPrintf(diag, "[Strict] crop rect X offset must be even due to this image's YUV subsampling");
return AVIF_FALSE; return AVIF_FALSE;
} }
} }
if (yuvFormat == AVIF_PIXEL_FORMAT_YUV420) { if (yuvFormat == AVIF_PIXEL_FORMAT_YUV420) {
if (((cropRect->y % 2) != 0) || ((cropRect->height % 2) != 0)) { if ((cropRect->y % 2) != 0) {
avifDiagnosticsPrintf(diag, "[Strict] crop rect Y offset and height must both be even due to this image's YUV subsampling"); avifDiagnosticsPrintf(diag, "[Strict] crop rect Y offset must be even due to this image's YUV subsampling");
return AVIF_FALSE; return AVIF_FALSE;
} }
} }

View file

@ -769,6 +769,8 @@ static void avifMetaDestroy(avifMeta * meta)
avifFree(meta); avifFree(meta);
} }
// CAUTION: This function could potentially resize the meta->items array thereby invalidating all existing pointers that are being
// stored locally. So if this function is being called, exercise caution in the caller to not use invalid pointers.
static avifDecoderItem * avifMetaFindItem(avifMeta * meta, uint32_t itemID) static avifDecoderItem * avifMetaFindItem(avifMeta * meta, uint32_t itemID)
{ {
if (itemID == 0) { if (itemID == 0) {
@ -1417,7 +1419,7 @@ static avifBool avifDecoderGenerateImageGridTiles(avifDecoder * decoder, avifIma
if (tilesAvailable != grid->rows * grid->columns) { if (tilesAvailable != grid->rows * grid->columns) {
avifDiagnosticsPrintf(&decoder->diag, avifDiagnosticsPrintf(&decoder->diag,
"Grid image of dimensions %ux%u requires %u tiles, and only %u were found", "Grid image of dimensions %ux%u requires %u tiles, but %u were found",
grid->columns, grid->columns,
grid->rows, grid->rows,
grid->rows * grid->columns, grid->rows * grid->columns,
@ -3614,17 +3616,20 @@ static avifBool avifDecoderItemIsAlphaAux(avifDecoderItem * item, uint32_t color
return auxCProp && isAlphaURN(auxCProp->u.auxC.auxType); return auxCProp && isAlphaURN(auxCProp->u.auxC.auxType);
} }
// Finds the alpha item whose parent item is colorItem and sets it in the alphaItem output parameter. Returns AVIF_RESULT_OK on // Finds the alpha item whose parent item is *colorItemPtr and sets it in the alphaItem output parameter. Returns AVIF_RESULT_OK
// success. Note that *alphaItem can be NULL even if the return value is AVIF_RESULT_OK. If the colorItem is a grid and the alpha // on success. Note that *alphaItem can be NULL even if the return value is AVIF_RESULT_OK. If the *colorItemPtr is a grid and the
// item is represented as a set of auxl items to each color tile, then a fake item will be created and *isAlphaItemInInput will be // alpha item is represented as a set of auxl items to each color tile, then a fake item will be created and *isAlphaItemInInput
// set to AVIF_FALSE. In this case, the alpha item merely exists to hold the locations of the alpha tile items. The data of this // will be set to AVIF_FALSE. In this case, the alpha item merely exists to hold the locations of the alpha tile items. The data
// item need not be read and the pixi property cannot be validated. Otherwise, *isAlphaItemInInput will be set to AVIF_TRUE when // of this item need not be read and the pixi property cannot be validated. Otherwise, *isAlphaItemInInput will be set to
// *alphaItem is not NULL. // AVIF_TRUE when *alphaItem is not NULL. If the data->meta->items array is resized, then the value in *colorItemPtr could become
// invalid. This function also resets *colorItemPtr to the right value if an alpha item was found and added to the data->meta->items
// array.
static avifResult avifDecoderDataFindAlphaItem(avifDecoderData * data, static avifResult avifDecoderDataFindAlphaItem(avifDecoderData * data,
avifDecoderItem * colorItem, avifDecoderItem ** colorItemPtr,
avifDecoderItem ** alphaItem, avifDecoderItem ** alphaItem,
avifBool * isAlphaItemInInput) avifBool * isAlphaItemInInput)
{ {
const avifDecoderItem * colorItem = *colorItemPtr;
for (uint32_t itemIndex = 0; itemIndex < data->meta->items.count; ++itemIndex) { for (uint32_t itemIndex = 0; itemIndex < data->meta->items.count; ++itemIndex) {
avifDecoderItem * item = &data->meta->items.item[itemIndex]; avifDecoderItem * item = &data->meta->items.item[itemIndex];
if (avifDecoderItemShouldBeSkipped(item)) { if (avifDecoderItemShouldBeSkipped(item)) {
@ -3659,27 +3664,53 @@ static avifResult avifDecoderDataFindAlphaItem(avifDecoderData * data,
maxItemID = item->id; maxItemID = item->id;
} }
if (item->dimgForID == colorItem->id) { if (item->dimgForID == colorItem->id) {
avifBool seenAlphaForCurrentItem = AVIF_FALSE;
for (uint32_t j = 0; j < colorItem->meta->items.count; ++j) { for (uint32_t j = 0; j < colorItem->meta->items.count; ++j) {
avifDecoderItem * auxlItem = &colorItem->meta->items.item[j]; avifDecoderItem * auxlItem = &colorItem->meta->items.item[j];
if (avifDecoderItemIsAlphaAux(auxlItem, item->id)) { if (avifDecoderItemIsAlphaAux(auxlItem, item->id)) {
if (seenAlphaForCurrentItem || auxlItem->dimgForID != 0) {
// One of the following invalid cases:
// * Multiple items are claiming to be the alpha auxiliary of the current item.
// * Alpha auxiliary is dimg for another item.
avifFree(alphaItemIndices);
*alphaItem = NULL;
*isAlphaItemInInput = AVIF_FALSE;
return AVIF_RESULT_INVALID_IMAGE_GRID;
}
alphaItemIndices[alphaItemCount++] = j; alphaItemIndices[alphaItemCount++] = j;
seenAlphaForCurrentItem = AVIF_TRUE;
} }
} }
if (!seenAlphaForCurrentItem) {
// No alpha auxiliary item was found for the current item. Treat this as an image without alpha.
avifFree(alphaItemIndices);
*alphaItem = NULL;
*isAlphaItemInInput = AVIF_FALSE;
return AVIF_RESULT_OK;
}
} }
} }
if (alphaItemCount != colorItemCount) { assert(alphaItemCount == colorItemCount);
// Not all the color items had an alpha auxiliary attached to it. Report this case as an image without alpha channel.
avifFree(alphaItemIndices); int colorItemIndex = -1;
*alphaItem = NULL; for (uint32_t i = 0; i < data->meta->items.count; ++i) {
*isAlphaItemInInput = AVIF_FALSE; if (colorItem->id == data->meta->items.item[i].id) {
return AVIF_RESULT_OK; colorItemIndex = i;
break;
}
} }
assert(colorItemIndex >= 0);
*alphaItem = avifMetaFindItem(colorItem->meta, maxItemID + 1); *alphaItem = avifMetaFindItem(colorItem->meta, maxItemID + 1);
if (*alphaItem == NULL) { if (*alphaItem == NULL) {
avifFree(alphaItemIndices); avifFree(alphaItemIndices);
*isAlphaItemInInput = AVIF_FALSE; *isAlphaItemInInput = AVIF_FALSE;
return AVIF_RESULT_OUT_OF_MEMORY; return AVIF_RESULT_OUT_OF_MEMORY;
} }
// avifMetaFindItem() could invalidate all existing item pointers. So reset the colorItem pointers.
*colorItemPtr = &data->meta->items.item[colorItemIndex];
colorItem = *colorItemPtr;
memcpy((*alphaItem)->type, "grid", 4); memcpy((*alphaItem)->type, "grid", 4);
(*alphaItem)->width = colorItem->width; (*alphaItem)->width = colorItem->width;
(*alphaItem)->height = colorItem->height; (*alphaItem)->height = colorItem->height;
@ -3918,6 +3949,16 @@ avifResult avifDecoderReset(avifDecoder * decoder)
decoder->imageDimensionLimit, decoder->imageDimensionLimit,
data->diag), data->diag),
AVIF_RESULT_INVALID_IMAGE_GRID); AVIF_RESULT_INVALID_IMAGE_GRID);
// Validate that there are exactly the same number of dimg items to form the grid.
uint32_t dimgItemCount = 0;
for (uint32_t i = 0; i < colorItem->meta->items.count; ++i) {
if (colorItem->meta->items.item[i].dimgForID == colorItem->id) {
++dimgItemCount;
}
}
if (dimgItemCount != data->color.grid.rows * data->color.grid.columns) {
return AVIF_RESULT_INVALID_IMAGE_GRID;
}
colorCodecType = avifDecoderItemGetGridCodecType(colorItem); colorCodecType = avifDecoderItemGetGridCodecType(colorItem);
if (colorCodecType == AVIF_CODEC_TYPE_UNKNOWN) { if (colorCodecType == AVIF_CODEC_TYPE_UNKNOWN) {
return AVIF_RESULT_INVALID_IMAGE_GRID; return AVIF_RESULT_INVALID_IMAGE_GRID;
@ -3929,7 +3970,7 @@ avifResult avifDecoderReset(avifDecoder * decoder)
avifBool isAlphaItemInInput; avifBool isAlphaItemInInput;
avifDecoderItem * alphaItem; avifDecoderItem * alphaItem;
AVIF_CHECKRES(avifDecoderDataFindAlphaItem(data, colorItem, &alphaItem, &isAlphaItemInInput)); AVIF_CHECKRES(avifDecoderDataFindAlphaItem(data, &colorItem, &alphaItem, &isAlphaItemInInput));
avifCodecType alphaCodecType = AVIF_CODEC_TYPE_UNKNOWN; avifCodecType alphaCodecType = AVIF_CODEC_TYPE_UNKNOWN;
if (alphaItem) { if (alphaItem) {
if (!memcmp(alphaItem->type, "grid", 4)) { if (!memcmp(alphaItem->type, "grid", 4)) {

View file

@ -65,6 +65,15 @@ constexpr InvalidClapPropertyParam kInvalidClapPropertyTestParams[] = {
722, 722,
AVIF_PIXEL_FORMAT_YUV420, AVIF_PIXEL_FORMAT_YUV420,
{330, 1, 385, 1, static_cast<uint32_t>(-308), 1, 103, 1}}, {330, 1, 385, 1, static_cast<uint32_t>(-308), 1, 103, 1}},
// pcX = -1/2 + (99 - 1)/2 = 48.5
// pcY = -1/2 + (99 - 1)/2 = 48.5
// leftmost = 48.5 - (99 - 1)/2 = -0.5 (not an integer)
// topmost = 48.5 - (99 - 1)/2 = -0.5 (not an integer)
{99,
99,
AVIF_PIXEL_FORMAT_YUV420,
{99, 1, 99, 1, static_cast<uint32_t>(-1), 2, static_cast<uint32_t>(-1),
2}},
}; };
using InvalidClapPropertyTest = using InvalidClapPropertyTest =
@ -112,6 +121,15 @@ constexpr ValidClapPropertyParam kValidClapPropertyTestParams[] = {
{60, 1, 80, 1, static_cast<uint32_t>(-30), 1, static_cast<uint32_t>(-40), {60, 1, 80, 1, static_cast<uint32_t>(-30), 1, static_cast<uint32_t>(-40),
1}, 1},
{0, 0, 60, 80}}, {0, 0, 60, 80}},
// pcX = -1/2 + (100 - 1)/2 = 49
// pcY = -1/2 + (100 - 1)/2 = 49
// leftmost = 49 - (99 - 1)/2 = 0
// topmost = 49 - (99 - 1)/2 = 0
{100,
100,
AVIF_PIXEL_FORMAT_YUV420,
{99, 1, 99, 1, static_cast<uint32_t>(-1), 2, static_cast<uint32_t>(-1), 2},
{0, 0, 99, 99}},
}; };
using ValidClapPropertyTest = ::testing::TestWithParam<ValidClapPropertyParam>; using ValidClapPropertyTest = ::testing::TestWithParam<ValidClapPropertyParam>;
@ -126,7 +144,8 @@ TEST_P(ValidClapPropertyTest, ValidateClapProperty) {
avifDiagnostics diag; avifDiagnostics diag;
EXPECT_TRUE(avifCropRectConvertCleanApertureBox(&crop_rect, &param.clap, EXPECT_TRUE(avifCropRectConvertCleanApertureBox(&crop_rect, &param.clap,
param.width, param.height, param.width, param.height,
param.yuv_format, &diag)); param.yuv_format, &diag))
<< diag.error;
EXPECT_EQ(crop_rect.x, param.expected_crop_rect.x); EXPECT_EQ(crop_rect.x, param.expected_crop_rect.x);
EXPECT_EQ(crop_rect.y, param.expected_crop_rect.y); EXPECT_EQ(crop_rect.y, param.expected_crop_rect.y);
EXPECT_EQ(crop_rect.width, param.expected_crop_rect.width); EXPECT_EQ(crop_rect.width, param.expected_crop_rect.width);

View file

@ -1290,7 +1290,7 @@ static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opac
if (grad->nstops == 0) { if (grad->nstops == 0) {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
cache->colors[i] = 0; cache->colors[i] = 0;
} if (grad->nstops == 1) { } else if (grad->nstops == 1) {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity); cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
} else { } else {