Make AVIF optional
parent
406f0b3036
commit
bf5689574d
|
@ -43,7 +43,7 @@ jobs:
|
|||
-password "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- name: 'Install dependencies'
|
||||
run: vcpkg --triplet=${{matrix.platform}}-windows install --recurse libpng libjpeg-turbo gettext luajit fmt libepoxy eigen3 freetype cspice qt5-base libavif
|
||||
run: vcpkg --triplet=${{matrix.platform}}-windows install --recurse libpng libjpeg-turbo gettext luajit fmt libepoxy eigen3 freetype cspice qt5-base
|
||||
|
||||
- name: 'Checkout source code'
|
||||
uses: actions/checkout@v2
|
||||
|
|
|
@ -179,6 +179,13 @@ if(ENABLE_FFMPEG)
|
|||
add_definitions(-DUSE_FFMPEG)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBAVIF)
|
||||
find_package(Libavif REQUIRED)
|
||||
link_libraries(libavif::libavif)
|
||||
include_directories(${LIBAVIF_INCLUDE_DIR})
|
||||
add_definitions(-DUSE_LIBAVIF)
|
||||
endif()
|
||||
|
||||
if(_UNIX)
|
||||
find_package(PkgConfig)
|
||||
endif()
|
||||
|
@ -212,10 +219,6 @@ find_package(JPEG REQUIRED) # -DJPEG_LIBRARY=...
|
|||
include_directories(${JPEG_INCLUDE_DIRS})
|
||||
link_libraries(${JPEG_LIBRARIES})
|
||||
|
||||
find_package(Libavif REQUIRED)
|
||||
link_libraries(libavif::libavif)
|
||||
include_directories(${LIBAVIF_INCLUDE_DIR})
|
||||
|
||||
if(ENABLE_CELX)
|
||||
add_definitions(-DCELX)
|
||||
|
||||
|
|
18
INSTALL.md
18
INSTALL.md
|
@ -83,18 +83,19 @@ First you need a C++ compiler able to compile C++11 code (GCC 4.8.1 or later,
|
|||
Clang 3.3 or later), CMake, GNU Make or Ninja.
|
||||
|
||||
Then you need to have the following devel components installed before Celestia
|
||||
will build: OpenGL, libepoxy, fmtlib, Eigen3, freetype, libjpeg, libpng and libavif
|
||||
Optional packages are gettext, Qt5, Gtk2 or Gtk3, sdl2, ffmpeg, glu and glut.
|
||||
will build: OpenGL, libepoxy, fmtlib, Eigen3, freetype, libjpeg, and libpng.
|
||||
Optional packages are gettext, Qt5, Gtk2 or Gtk3, sdl2, ffmpeg, libavif, glu and glut.
|
||||
|
||||
For example on modern Debian-derived system you need to install the following
|
||||
packages: libepoxy-dev, libjpeg-dev, libpng-dev, libgl1-mesa-dev, libavif-dev
|
||||
packages: libepoxy-dev, libjpeg-dev, libpng-dev, libgl1-mesa-dev,
|
||||
libeigen3-dev, libfmt-dev, libfreetype6-dev. Then you may want to install
|
||||
libglu1-mesa-dev, required by some tools; qtbase5-dev, qtbase5-dev-tools and
|
||||
libqt5opengl5-dev if you want to build with Qt5 interface; libgtk2.0-dev and
|
||||
libgtkglext1-dev to build with legacy Gtk2 interface; libgtk3.0-dev to build
|
||||
Gtk3 interface, libsdl2-dev to build SDL interface or freeglut3-dev to build
|
||||
with glut interface. libavcodec-dev, libavformat-dev, libavutil-dev and
|
||||
libswscale-dev are required to build with video capture support.
|
||||
libswscale-dev are required to build with video capture support. libavif-dev
|
||||
is required to build to AVIF texture support.
|
||||
|
||||
|
||||
OK, assuming you've collected all the necessary libraries, here's
|
||||
|
@ -155,13 +156,13 @@ and vcpkg (*).
|
|||
Install required packages:
|
||||
|
||||
```
|
||||
vcpkg --triplet=TRIPLET install --recurse libpng libjpeg-turbo gettext luajit fmt libepoxy eigen3 freetype libavif
|
||||
vcpkg --triplet=TRIPLET install --recurse libpng libjpeg-turbo gettext luajit fmt libepoxy eigen3 freetype
|
||||
```
|
||||
|
||||
Install optional packages:
|
||||
|
||||
```
|
||||
vcpkg --triplet=TRIPLET install --recurse qt5-base ffmpeg cspice
|
||||
vcpkg --triplet=TRIPLET install --recurse qt5-base ffmpeg cspice libavif
|
||||
```
|
||||
|
||||
Replace TRIPLET with `x86-windows` to build 32-bit versions or `x64-windows`
|
||||
|
@ -281,13 +282,13 @@ Install Homebrew
|
|||
Install required packages:
|
||||
|
||||
```
|
||||
brew install pkg-config cmake fmt gettext libepoxy libpng lua qt5 jpeg eigen freetype ffmpeg libavif
|
||||
brew install pkg-config cmake fmt gettext libepoxy libpng lua qt5 jpeg eigen freetype
|
||||
```
|
||||
|
||||
Install optional packages:
|
||||
|
||||
```
|
||||
brew install cspice
|
||||
brew install cspice ffmpeg libavif
|
||||
```
|
||||
|
||||
Follow common building instructions to fetch the source.
|
||||
|
@ -335,6 +336,7 @@ List of supported parameters (passed as `-DPARAMETER=VALUE`):
|
|||
| ENABLE_SDL | bool | OFF | Build SQL frontend
|
||||
| ENABLE_WIN | bool | \*\*\*ON | Build Windows native frontend
|
||||
| ENABLE_FFMPEG | bool | \*\*ON | Support video capture using ffmpeg
|
||||
| ENABLE_LIBAVIF | bool | OFF | Support AVIF texture using libavif
|
||||
| ENABLE_TOOLS | bool | OFF | Build tools for Celestia data files
|
||||
| ENABLE_DATA | bool | OFF | Use CelestiaContent submodule for data
|
||||
| ENABLE_GLES | bool | OFF | Use OpenGL ES 2.0 in rendering code
|
||||
|
|
|
@ -5,8 +5,10 @@ strategy:
|
|||
matrix:
|
||||
Linux:
|
||||
imageName: 'ubuntu-latest'
|
||||
enableLibavif: 'OFF'
|
||||
Mac:
|
||||
imageName: 'macos-latest'
|
||||
enableLibavif: 'ON'
|
||||
|
||||
pool:
|
||||
vmImage: $(imageName)
|
||||
|
@ -37,8 +39,7 @@ steps:
|
|||
libfreetype6-dev \
|
||||
libsdl2-dev \
|
||||
libluajit-5.1-dev \
|
||||
libfmt-dev \
|
||||
libavif-dev
|
||||
libfmt-dev
|
||||
displayName: 'Install Linux dependencies'
|
||||
condition: eq( variables['Agent.OS'], 'Linux' )
|
||||
|
||||
|
@ -67,7 +68,7 @@ steps:
|
|||
- script: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DENABLE_SPICE=ON -DENABLE_TOOLS=ON -DENABLE_TESTS=ON -DENABLE_SDL=ON -DENABLE_GTK=ON -DENABLE_FFMPEG=ON ..
|
||||
cmake -DENABLE_SPICE=ON -DENABLE_TOOLS=ON -DENABLE_TESTS=ON -DENABLE_SDL=ON -DENABLE_GTK=ON -DENABLE_FFMPEG=ON -DENABLE_LIBAVIF=$(enableLibavif) ..
|
||||
make -j $(nproc || echo 4)
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest
|
||||
workingDirectory: "$(system.defaultworkingdirectory)"
|
||||
|
|
|
@ -299,9 +299,11 @@ Image* LoadImageFromFile(const fs::path& filename)
|
|||
case Content_PNG:
|
||||
img = LoadPNGImage(filename);
|
||||
break;
|
||||
#ifdef USE_LIBAVIF
|
||||
case Content_AVIF:
|
||||
img = LoadAVIFImage(filename);
|
||||
break;
|
||||
#endif
|
||||
case Content_DDS:
|
||||
case Content_DXT5NormalMap:
|
||||
img = LoadDDSImage(filename);
|
||||
|
|
|
@ -26,15 +26,23 @@ static std::array<const char*, 3> directories =
|
|||
"hires"
|
||||
};
|
||||
|
||||
static std::array<const char*, 7> extensions =
|
||||
#ifdef USE_LIBAVIF
|
||||
static constexpr size_t nExt = 7;
|
||||
#else
|
||||
static constexpr size_t nExt = 6;
|
||||
#endif
|
||||
|
||||
static std::array<const char*, nExt> extensions =
|
||||
{
|
||||
#ifdef USE_LIBAVIF
|
||||
"avif",
|
||||
#endif
|
||||
"png",
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"dds",
|
||||
"dxt5nm",
|
||||
"ctx",
|
||||
"avif"
|
||||
"ctx"
|
||||
};
|
||||
|
||||
TextureManager* GetTextureManager()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
set(CELIMAGE_SOURCES
|
||||
avif.cpp
|
||||
bmp.cpp
|
||||
dds.cpp
|
||||
dds_decompress.cpp
|
||||
|
@ -9,4 +8,10 @@ set(CELIMAGE_SOURCES
|
|||
png.cpp
|
||||
)
|
||||
|
||||
if(ENABLE_LIBAVIF)
|
||||
list(APPEND CELIMAGE_SOURCES
|
||||
avif.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(celimage OBJECT ${CELIMAGE_SOURCES})
|
||||
|
|
|
@ -15,14 +15,12 @@ extern "C" {
|
|||
#include <avif/avif.h>
|
||||
}
|
||||
|
||||
using std::ifstream;
|
||||
using std::ios;
|
||||
using celestia::PixelFormat;
|
||||
|
||||
Image* LoadAVIFImage(const fs::path& filename)
|
||||
{
|
||||
avifDecoder* decoder = avifDecoderCreate();
|
||||
avifResult result = avifDecoderSetIOFile(decoder, filename.c_str());
|
||||
avifResult result = avifDecoderSetIOFile(decoder, filename.string().c_str());
|
||||
if (result != AVIF_RESULT_OK)
|
||||
{
|
||||
DPRINTF(LOG_LEVEL_ERROR, "Cannot open file for read: '%s'\n", filename);
|
||||
|
@ -46,6 +44,7 @@ Image* LoadAVIFImage(const fs::path& filename)
|
|||
}
|
||||
|
||||
avifRGBImage rgb;
|
||||
rgb.format = AVIF_RGB_FORMAT_RGBA;
|
||||
avifRGBImageSetDefaults(&rgb, decoder->image);
|
||||
|
||||
Image* image = new Image(PixelFormat::RGBA, rgb.width, rgb.height);
|
||||
|
|
|
@ -17,7 +17,9 @@ Image* LoadJPEGImage(const fs::path& filename,
|
|||
Image* LoadBMPImage(const fs::path& filename);
|
||||
Image* LoadPNGImage(const fs::path& filename);
|
||||
Image* LoadDDSImage(const fs::path& filename);
|
||||
#ifdef USE_LIBAVIF
|
||||
Image* LoadAVIFImage(const fs::path& filename);
|
||||
#endif
|
||||
|
||||
bool SaveJPEGImage(const fs::path& filename, Image& image);
|
||||
bool SavePNGImage(const fs::path& filename, Image& image);
|
||||
|
|
|
@ -667,8 +667,10 @@ void CommandCapture::process(ExecutionEnvironment& env)
|
|||
_type = Content_JPEG;
|
||||
else if (type == "png")
|
||||
_type = Content_PNG;
|
||||
#ifdef USE_LIBAVIF
|
||||
else if (type == "avif")
|
||||
_type = Content_AVIF;
|
||||
#endif
|
||||
env.getCelestiaCore()->saveScreenShot(filename, _type);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ static const char JFIFExt[] = ".jif";
|
|||
static const char BMPExt[] = ".bmp";
|
||||
static const char TargaExt[] = ".tga";
|
||||
static const char PNGExt[] = ".png";
|
||||
#ifdef USE_LIBAVIF
|
||||
static const char AVIFExt[] = ".avif";
|
||||
#endif
|
||||
static const char ThreeDSExt[] = ".3ds";
|
||||
static const char CelestiaTextureExt[] = ".ctx";
|
||||
static const char CelestiaMeshExt[] = ".cms";
|
||||
|
@ -53,8 +55,10 @@ ContentType DetermineFileType(const fs::path& filename)
|
|||
return Content_Targa;
|
||||
if (compareIgnoringCase(PNGExt, ext) == 0)
|
||||
return Content_PNG;
|
||||
#ifdef USE_LIBAVIF
|
||||
if (compareIgnoringCase(AVIFExt, ext) == 0)
|
||||
return Content_AVIF;
|
||||
#endif
|
||||
if (compareIgnoringCase(ThreeDSExt, ext) == 0)
|
||||
return Content_3DStudio;
|
||||
if (compareIgnoringCase(CelestiaTextureExt, ext) == 0)
|
||||
|
|
|
@ -37,7 +37,9 @@ enum ContentType
|
|||
Content_CelestiaParticleSystem = 20,
|
||||
Content_WarpMesh = 21,
|
||||
Content_CelestiaXYZVBinary = 22,
|
||||
#ifdef USE_LIBAVIF
|
||||
Content_AVIF = 23,
|
||||
#endif
|
||||
Content_Unknown = -1,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue