mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 09:45:48 +01:00
Add ability to change quality of BPTC encoder.
This commit is contained in:
parent
add2f6fd96
commit
fc4cf7758b
@ -41,7 +41,7 @@ int main(int argc, char **argv) {
|
||||
if(strcmp(argv[fileArg], "-q") == 0) {
|
||||
fileArg++;
|
||||
|
||||
if(fileArg == argc || (quality = atoi(argv[fileArg])) < 1) {
|
||||
if(fileArg == argc || (quality = atoi(argv[fileArg])) < 0) {
|
||||
PrintUsage();
|
||||
exit(1);
|
||||
}
|
||||
@ -62,6 +62,7 @@ int main(int argc, char **argv) {
|
||||
SCompressionSettings settings;
|
||||
settings.bUseSIMD = bUseSIMD;
|
||||
settings.iNumThreads = numThreads;
|
||||
settings.iQuality = quality;
|
||||
|
||||
CompressedImage *ci = CompressImage(file, settings);
|
||||
|
||||
|
@ -9,6 +9,7 @@ struct SCompressionSettings {
|
||||
ECompressionFormat format;
|
||||
bool bUseSIMD;
|
||||
int iNumThreads;
|
||||
int iQuality;
|
||||
};
|
||||
|
||||
extern CompressedImage * CompressImage(
|
||||
|
@ -5,16 +5,35 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
template <typename T>
|
||||
static T min(const T &a, const T &b) {
|
||||
return (a < b)? a : b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T max(const T &a, const T &b) {
|
||||
return (a > b)? a : b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void clamp(T &x, const T &minX, const T &maxX) {
|
||||
x = max(min(maxX, x), minX);
|
||||
}
|
||||
|
||||
SCompressionSettings:: SCompressionSettings()
|
||||
: format(eCompressionFormat_BPTC)
|
||||
, bUseSIMD(false)
|
||||
, iNumThreads(1)
|
||||
{}
|
||||
, iQuality(50)
|
||||
{
|
||||
clamp(iQuality, 0, 256);
|
||||
}
|
||||
|
||||
static CompressionFunc ChooseFuncFromSettings(const SCompressionSettings &s) {
|
||||
switch(s.format) {
|
||||
case eCompressionFormat_BPTC:
|
||||
{
|
||||
BC7C::SetQualityLevel(s.iQuality);
|
||||
if(s.bUseSIMD) {
|
||||
return BC7C::CompressImageBC7SIMD;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user