Skip to content

Commit

Permalink
Add default config file to the BE constructor config
Browse files Browse the repository at this point in the history
The filename is now passed to the BE constructor in the Config struct.
An empty string will revert to using the installed backend_default_config.json
file.
  • Loading branch information
naushir committed Sep 12, 2023
1 parent d3becd6 commit a91849c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libpisp/backend/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ BackEnd::BackEnd(Config const &config, PiSPVariant const &variant)
smart_resize_.resize(2, { 0, 0 });
smart_resize_dirty_ = 0;

InitialiseConfig();
initialiseDefaultConfig(config.defaults_file);
}

BackEnd::~BackEnd()
Expand Down
10 changes: 7 additions & 3 deletions src/libpisp/backend/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ class BackEnd
HIGH_PRIORITY = 2 // Not currently implemented
};

Config(unsigned int _max_stripe_height = 0, unsigned int _max_tile_width = 0, unsigned int _flags = 0)
: max_stripe_height(_max_stripe_height), max_tile_width(_max_tile_width), flags(_flags)
Config(unsigned int _max_stripe_height = 0, unsigned int _max_tile_width = 0, unsigned int _flags = 0,
std::string _defaults_file = {})
: max_stripe_height(_max_stripe_height), max_tile_width(_max_tile_width), flags(_flags),
defaults_file(_defaults_file)
{
}

unsigned int max_stripe_height; // Use zero to get "default behaviour"
unsigned int max_tile_width; // Can only go larger than h/w defined limit in simulations
unsigned int flags; // An "or" of the Flags above
std::string defaults_file; // json file for default IQ settings
};

struct SmartResize
Expand Down Expand Up @@ -114,7 +117,6 @@ class BackEnd
void InitialiseResample(const std::string &filter, pisp_be_resample_config &resample);
void InitialiseResample(double downscale, pisp_be_resample_config &resample);
void InitialiseSharpen(pisp_be_sharpen_config &sharpen, pisp_be_sh_fc_combine_config &shfc);
void InitialiseConfig(const std::string filename = {});

void Prepare(pisp_be_tiles_config *config);
void MergeConfig(const pisp_be_config &config);
Expand Down Expand Up @@ -151,6 +153,8 @@ class BackEnd
void finaliseTiling();
void getOutputSize(int output_num, uint16_t *width, uint16_t *height, pisp_image_format_config const &ifmt) const;

void initialiseDefaultConfig(const std::string &filename);

Config config_;
const PiSPVariant &variant_;
pisp_be_config be_config_;
Expand Down
2 changes: 1 addition & 1 deletion src/libpisp/backend/backend_default_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void BackEnd::InitialiseSharpen(pisp_be_sharpen_config &sharpen, pisp_be_sh_fc_c
shfc = default_shfc_;
}

void BackEnd::InitialiseConfig(const std::string filename)
void BackEnd::initialiseDefaultConfig(const std::string &filename)
{
std::string file = filename.empty() ? std::string(PISP_BE_CONFIG_DIR) + "/" + "backend_default_config.json"
: filename;
Expand Down

0 comments on commit a91849c

Please sign in to comment.