diff --git a/src/libpisp/backend/backend.cpp b/src/libpisp/backend/backend.cpp index 6e704be..449ccc2 100644 --- a/src/libpisp/backend/backend.cpp +++ b/src/libpisp/backend/backend.cpp @@ -44,13 +44,13 @@ void BackEnd::SetGlobal(pisp_be_global_config const &global) if (global.rgb_enables & PISP_BE_RGB_ENABLE_HOG) throw std::runtime_error("HOG output is not supported."); - be_config_.dirty_flags_bayer |= + be_config_extra_.dirty_flags_bayer |= (global.bayer_enables & ~be_config_.global.bayer_enables); // label anything newly enabled as dirty - be_config_.dirty_flags_rgb |= + be_config_extra_.dirty_flags_rgb |= (global.rgb_enables & ~be_config_.global.rgb_enables); // label anything newly enabled as dirty be_config_.global = global; be_config_.global.pad[0] = be_config_.global.pad[1] = be_config_.global.pad[2] = 0; - be_config_.dirty_flags_extra |= PISP_BE_DIRTY_GLOBAL; + be_config_extra_.dirty_flags_extra |= PISP_BE_DIRTY_GLOBAL; } void BackEnd::GetGlobal(pisp_be_global_config &global) const @@ -61,7 +61,7 @@ void BackEnd::GetGlobal(pisp_be_global_config &global) const void BackEnd::SetInputFormat(pisp_image_format_config const &input_format) { be_config_.input_format = input_format; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_INPUT; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_INPUT; retile_ = true; } @@ -73,41 +73,41 @@ void BackEnd::SetInputBuffer(pisp_be_input_buffer_config const &input_buffer) void BackEnd::SetDecompress(pisp_decompress_config const &decompress) { be_config_.decompress = decompress; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DECOMPRESS; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DECOMPRESS; } void BackEnd::SetDpc(pisp_be_dpc_config const &dpc) { be_config_.dpc = dpc; be_config_.dpc.pad = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DPC; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DPC; } void BackEnd::SetGeq(pisp_be_geq_config const &geq) { be_config_.geq = geq; be_config_.geq.slope_sharper &= (PISP_BE_GEQ_SLOPE | PISP_BE_GEQ_SHARPER); - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_GEQ; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_GEQ; } void BackEnd::SetTdnInputFormat(pisp_image_format_config const &tdn_input_format) { be_config_.tdn_input_format = tdn_input_format; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_INPUT; // TDN input address will always be written + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_INPUT; // TDN input address will always be written finalise_tiling_ = true; } void BackEnd::SetTdnDecompress(pisp_decompress_config const &tdn_decompress) { be_config_.tdn_decompress = tdn_decompress; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS; } void BackEnd::SetTdn(pisp_be_tdn_config const &tdn) { be_config_.tdn = tdn; be_config_.tdn.pad = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN; } void BackEnd::GetTdn(pisp_be_tdn_config &tdn) const @@ -118,13 +118,13 @@ void BackEnd::GetTdn(pisp_be_tdn_config &tdn) const void BackEnd::SetTdnCompress(pisp_compress_config const &tdn_compress) { be_config_.tdn_compress = tdn_compress; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_COMPRESS; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_COMPRESS; } void BackEnd::SetTdnOutputFormat(pisp_image_format_config const &tdn_output_format) { be_config_.tdn_output_format = tdn_output_format; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_OUTPUT; // TDN output address will always be written + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TDN_OUTPUT; // TDN output address will always be written finalise_tiling_ = true; } @@ -137,14 +137,14 @@ void BackEnd::SetSdn(pisp_be_sdn_config const &sdn) { be_config_.sdn = sdn; be_config_.sdn.pad = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_SDN; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_SDN; } void BackEnd::SetBlc(pisp_bla_config const &blc) { be_config_.blc = blc; be_config_.blc.pad[0] = be_config_.blc.pad[1] = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_BLC; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_BLC; } void BackEnd::GetBlc(pisp_bla_config &blc) const @@ -156,7 +156,7 @@ void BackEnd::SetStitchInputFormat(pisp_image_format_config const &stitch_input_ { be_config_.stitch_input_format = stitch_input_format; be_config_.stitch.pad = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_INPUT; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_INPUT; finalise_tiling_ = true; } @@ -168,25 +168,25 @@ void BackEnd::GetStitchInputFormat(pisp_image_format_config &stitch_input_format void BackEnd::SetStitchDecompress(pisp_decompress_config const &stitch_decompress) { be_config_.stitch_decompress = stitch_decompress; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS; } void BackEnd::SetStitch(pisp_be_stitch_config const &stitch) { be_config_.stitch = stitch; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH; } void BackEnd::SetStitchCompress(pisp_compress_config const &stitch_compress) { be_config_.stitch_compress = stitch_compress; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_COMPRESS; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_COMPRESS; } void BackEnd::SetStitchOutputFormat(pisp_image_format_config const &stitch_output_format) { be_config_.stitch_output_format = stitch_output_format; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_OUTPUT; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_STITCH_OUTPUT; finalise_tiling_ = true; } @@ -198,14 +198,14 @@ void BackEnd::GetStitchOutputFormat(pisp_image_format_config &stitch_output_form void BackEnd::SetCdn(pisp_be_cdn_config const &cdn) { be_config_.cdn = cdn; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_CDN; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_CDN; } void BackEnd::SetWbg(pisp_wbg_config const &wbg) { be_config_.wbg = wbg; be_config_.wbg.pad[0] = be_config_.wbg.pad[1] = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_WBG; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_WBG; } void BackEnd::GetWbg(pisp_wbg_config &wbg) @@ -218,23 +218,23 @@ void BackEnd::SetLsc(pisp_be_lsc_config const &lsc, pisp_be_lsc_extra lsc_extra) // Should not need a finalise_tile if only the cell coefficients have changed. finalise_tiling_ |= be_config_.lsc.grid_step_x != lsc.grid_step_x || be_config_.lsc.grid_step_y != lsc.grid_step_y; be_config_.lsc = lsc; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_LSC; - be_config_.lsc_extra = lsc_extra; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_LSC; + be_config_extra_.lsc = lsc_extra; } void BackEnd::SetCac(pisp_be_cac_config const &cac, pisp_be_cac_extra cac_extra) { finalise_tiling_ |= be_config_.cac.grid_step_x != cac.grid_step_x || be_config_.cac.grid_step_y != cac.grid_step_y; be_config_.cac = cac; - be_config_.cac_extra = cac_extra; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_CAC; + be_config_extra_.cac = cac_extra; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_CAC; } void BackEnd::SetDebin(pisp_be_debin_config const &debin) { be_config_.debin = debin; be_config_.debin.pad[0] = be_config_.debin.pad[1] = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEBIN; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEBIN; } void BackEnd::GetDebin(pisp_be_debin_config &debin) @@ -245,14 +245,14 @@ void BackEnd::GetDebin(pisp_be_debin_config &debin) void BackEnd::SetTonemap(pisp_be_tonemap_config const &tonemap) { be_config_.tonemap = tonemap; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TONEMAP; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_TONEMAP; } void BackEnd::SetDemosaic(pisp_be_demosaic_config const &demosaic) { be_config_.demosaic = demosaic; be_config_.demosaic.pad[0] = be_config_.demosaic.pad[1] = 0; - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEMOSAIC; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEMOSAIC; } void BackEnd::GetDemosaic(pisp_be_demosaic_config &demosaic) const @@ -264,21 +264,21 @@ void BackEnd::SetCcm(pisp_be_ccm_config const &ccm) { be_config_.ccm = ccm; be_config_.ccm.pad[0] = be_config_.ccm.pad[1] = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_CCM; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_CCM; } void BackEnd::SetSatControl(pisp_be_sat_control_config const &sat_control) { be_config_.sat_control = sat_control; be_config_.sat_control.pad = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SAT_CONTROL; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SAT_CONTROL; } void BackEnd::SetYcbcr(pisp_be_ccm_config const &ycbcr) { be_config_.ycbcr = ycbcr; be_config_.ycbcr.pad[0] = be_config_.ycbcr.pad[1] = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR; } void BackEnd::GetYcbcr(pisp_be_ccm_config &ycbcr) @@ -290,7 +290,7 @@ void BackEnd::SetFalseColour(pisp_be_false_colour_config const &false_colour) { be_config_.false_colour = false_colour; be_config_.false_colour.pad[0] = be_config_.false_colour.pad[1] = be_config_.false_colour.pad[2] = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_FALSE_COLOUR; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_FALSE_COLOUR; } void BackEnd::SetSharpen(pisp_be_sharpen_config const &sharpen) @@ -303,7 +303,7 @@ void BackEnd::SetSharpen(pisp_be_sharpen_config const &sharpen) be_config_.sharpen.pad4[0] = be_config_.sharpen.pad4[1] = be_config_.sharpen.pad4[2] = 0; be_config_.sharpen.pad5 = be_config_.sharpen.pad6 = be_config_.sharpen.pad7 = be_config_.sharpen.pad8 = be_config_.sharpen.pad9 = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SHARPEN; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SHARPEN; } void BackEnd::GetSharpen(pisp_be_sharpen_config &sharpen) @@ -315,20 +315,20 @@ void BackEnd::SetShFcCombine(pisp_be_sh_fc_combine_config const &sh_fc_combine) { be_config_.sh_fc_combine = sh_fc_combine; be_config_.sh_fc_combine.pad = 0; - be_config_.dirty_flags_extra |= PISP_BE_DIRTY_SH_FC_COMBINE; + be_config_extra_.dirty_flags_extra |= PISP_BE_DIRTY_SH_FC_COMBINE; } void BackEnd::SetYcbcrInverse(pisp_be_ccm_config const &ycbcr_inverse) { be_config_.ycbcr_inverse = ycbcr_inverse; be_config_.ycbcr_inverse.pad[0] = be_config_.ycbcr_inverse.pad[1] = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR_INVERSE; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR_INVERSE; } void BackEnd::SetGamma(pisp_be_gamma_config const &gamma) { be_config_.gamma = gamma; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_GAMMA; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_GAMMA; } void BackEnd::GetGamma(pisp_be_gamma_config &gamma) @@ -338,15 +338,15 @@ void BackEnd::GetGamma(pisp_be_gamma_config &gamma) void BackEnd::SetCrop(pisp_be_crop_config const &crop) { - be_config_.crop = crop; - be_config_.dirty_flags_extra |= PISP_BE_DIRTY_CROP; + be_config_extra_.crop = crop; + be_config_extra_.dirty_flags_extra |= PISP_BE_DIRTY_CROP; retile_ = true; } void BackEnd::SetCsc(unsigned int i, pisp_be_ccm_config const &csc) { be_config_.csc[i] = csc; - be_config_.dirty_flags_bayer |= PISP_BE_RGB_ENABLE_CSC(i); + be_config_extra_.dirty_flags_bayer |= PISP_BE_RGB_ENABLE_CSC(i); } void BackEnd::GetCsc(unsigned int i, pisp_be_ccm_config &csc) @@ -358,15 +358,15 @@ void BackEnd::SetDownscale(unsigned int i, pisp_be_downscale_config const &downs pisp_be_downscale_extra const &downscale_extra) { be_config_.downscale[i] = downscale; - be_config_.downscale_extra[i] = downscale_extra; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_DOWNSCALE(i); + be_config_extra_.downscale[i] = downscale_extra; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_DOWNSCALE(i); retile_ = true; } void BackEnd::SetDownscale(unsigned int i, pisp_be_downscale_extra const &downscale_extra) { - be_config_.downscale_extra[i] = downscale_extra; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_DOWNSCALE(i); + be_config_extra_.downscale[i] = downscale_extra; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_DOWNSCALE(i); retile_ = true; } @@ -374,15 +374,15 @@ void BackEnd::SetResample(unsigned int i, pisp_be_resample_config const &resampl pisp_be_resample_extra const &resample_extra) { be_config_.resample[i] = resample; - be_config_.resample_extra[i] = resample_extra; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); + be_config_extra_.resample[i] = resample_extra; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); retile_ = true; } void BackEnd::SetResample(unsigned int i, pisp_be_resample_extra const &resample_extra) { - be_config_.resample_extra[i] = resample_extra; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); + be_config_extra_.resample[i] = resample_extra; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); retile_ = true; } @@ -391,7 +391,7 @@ void BackEnd::SetOutputFormat(unsigned int i, pisp_be_output_format_config const PISP_ASSERT(i < variant_.BackEndNumBranches(0)); be_config_.output_format[i] = output_format; be_config_.output_format[i].pad[0] = be_config_.output_format[i].pad[1] = be_config_.output_format[i].pad[2] = 0; - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_OUTPUT(i); + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_OUTPUT(i); // Should only need a retile if the transform has changed, othwise a finalise_tile will do. retile_ = true; } diff --git a/src/libpisp/backend/backend.hpp b/src/libpisp/backend/backend.hpp index 21f9a47..ba817de 100644 --- a/src/libpisp/backend/backend.hpp +++ b/src/libpisp/backend/backend.hpp @@ -148,6 +148,19 @@ class BackEnd final } private: + struct BeConfigExtra + { + // Non-register fields: + pisp_be_lsc_extra lsc; + pisp_be_cac_extra cac; + pisp_be_downscale_extra downscale[PISP_BACK_END_NUM_OUTPUTS]; + pisp_be_resample_extra resample[PISP_BACK_END_NUM_OUTPUTS]; + pisp_be_crop_config crop; + uint32_t dirty_flags_bayer; //these use pisp_be_bayer_enable + uint32_t dirty_flags_rgb; //use pisp_be_rgb_enable + uint32_t dirty_flags_extra; //these use pisp_be_dirty_t + }; + void finaliseConfig(); void updateSmartResize(); void updateTiles(); @@ -160,6 +173,7 @@ class BackEnd final Config config_; const PiSPVariant variant_; pisp_be_config be_config_; + BeConfigExtra be_config_extra_; pisp_image_format_config max_input_; bool retile_; bool finalise_tiling_; diff --git a/src/libpisp/backend/backend_debug.cpp b/src/libpisp/backend/backend_debug.cpp index 9ab9fb9..ace43dd 100644 --- a/src/libpisp/backend/backend_debug.cpp +++ b/src/libpisp/backend/backend_debug.cpp @@ -546,7 +546,7 @@ void BackEnd::SetJsonConfig(const std::string &json_str) } // Clear any dirty flags so no reconfiguration happens on the next Prepare() call. - be_config_.dirty_flags_bayer = be_config_.dirty_flags_rgb = be_config_.dirty_flags_extra = 0; + be_config_extra_.dirty_flags_bayer = be_config_extra_.dirty_flags_rgb = be_config_extra_.dirty_flags_extra = 0; // But do retile the pipeline to get the tile structures setup correctly. retile_ = true; } diff --git a/src/libpisp/backend/backend_default_config.cpp b/src/libpisp/backend/backend_default_config.cpp index aa3fafc..b0163b7 100644 --- a/src/libpisp/backend/backend_default_config.cpp +++ b/src/libpisp/backend/backend_default_config.cpp @@ -338,31 +338,31 @@ void BackEnd::initialiseDefaultConfig(const std::string &filename) memset(&be_config_, 0, sizeof(be_config_)); initialise_debin(be_config_.debin, root); - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEBIN; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEBIN; initialise_demosaic(be_config_.demosaic, root); - be_config_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEMOSAIC; + be_config_extra_.dirty_flags_bayer |= PISP_BE_BAYER_ENABLE_DEMOSAIC; initialise_false_colour(be_config_.false_colour, root); - be_config_.dirty_flags_bayer |= PISP_BE_RGB_ENABLE_FALSE_COLOUR; + be_config_extra_.dirty_flags_bayer |= PISP_BE_RGB_ENABLE_FALSE_COLOUR; initialise_gamma(be_config_.gamma, root); - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_GAMMA; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_GAMMA; read_ycbcr(ycbcr_map_, inverse_ycbcr_map_, root); read_resample(resample_filter_map_, resample_select_list_, root); read_sharpen(default_sharpen_, default_shfc_, root); InitialiseSharpen(be_config_.sharpen, be_config_.sh_fc_combine); - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SHARPEN; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_SHARPEN; // Start with a sensible default YCbCr -- must be full-range on 2712C1 InitialiseYcbcr(be_config_.ycbcr, "jpeg"); InitialiseYcbcrInverse(be_config_.ycbcr, "jpeg"); - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR + PISP_BE_RGB_ENABLE_YCBCR_INVERSE; + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_YCBCR + PISP_BE_RGB_ENABLE_YCBCR_INVERSE; for (unsigned int i = 0; i < variant_.BackEndNumBranches(0); i++) { // Start with a sensible default InitialiseResample(be_config_.resample[i], "lanczos3"); - be_config_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); + be_config_extra_.dirty_flags_rgb |= PISP_BE_RGB_ENABLE_RESAMPLE(i); } } diff --git a/src/libpisp/backend/backend_prepare.cpp b/src/libpisp/backend/backend_prepare.cpp index 6db201d..f24cd2f 100644 --- a/src/libpisp/backend/backend_prepare.cpp +++ b/src/libpisp/backend/backend_prepare.cpp @@ -445,9 +445,9 @@ void calculate_input_addr_offset(int x, int y, pisp_image_format_config const &i void BackEnd::finaliseConfig() { - uint32_t dirty_flags_bayer = be_config_.dirty_flags_bayer & + uint32_t dirty_flags_bayer = be_config_extra_.dirty_flags_bayer & be_config_.global.bayer_enables; // only finalise blocks that are dirty *and* enabled - uint32_t dirty_flags_rgb = be_config_.dirty_flags_rgb & + uint32_t dirty_flags_rgb = be_config_extra_.dirty_flags_rgb & be_config_.global.rgb_enables; // only finalise blocks that are dirty *and* enabled if ((dirty_flags_bayer & PISP_BE_BAYER_ENABLE_INPUT) || (dirty_flags_rgb & PISP_BE_RGB_ENABLE_INPUT)) @@ -459,14 +459,14 @@ void BackEnd::finaliseConfig() if (dirty_flags_bayer & (PISP_BE_BAYER_ENABLE_INPUT | PISP_BE_BAYER_ENABLE_DECOMPRESS)) finalise_decompression(be_config_); - if ((be_config_.dirty_flags_bayer & + if ((be_config_extra_.dirty_flags_bayer & (PISP_BE_BAYER_ENABLE_TDN | PISP_BE_BAYER_ENABLE_TDN_INPUT | PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS | PISP_BE_BAYER_ENABLE_TDN_COMPRESS | PISP_BE_BAYER_ENABLE_TDN_OUTPUT))) { finalise_tdn(be_config_); } - if (be_config_.dirty_flags_bayer & + if (be_config_extra_.dirty_flags_bayer & (PISP_BE_BAYER_ENABLE_STITCH | PISP_BE_BAYER_ENABLE_STITCH_INPUT | PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS | PISP_BE_BAYER_ENABLE_STITCH_COMPRESS | PISP_BE_BAYER_ENABLE_STITCH_OUTPUT)) { @@ -474,11 +474,11 @@ void BackEnd::finaliseConfig() } if (dirty_flags_bayer & PISP_BE_BAYER_ENABLE_LSC) - finalise_lsc(be_config_.lsc, be_config_.lsc_extra, be_config_.input_format.width, + finalise_lsc(be_config_.lsc, be_config_extra_.lsc, be_config_.input_format.width, be_config_.input_format.height); if (dirty_flags_bayer & PISP_BE_BAYER_ENABLE_CAC) - finalise_cac(be_config_.cac, be_config_.cac_extra, be_config_.input_format.width, + finalise_cac(be_config_.cac, be_config_extra_.cac, be_config_.input_format.width, be_config_.input_format.height); for (unsigned int j = 0; j < variant_.BackEndNumBranches(0); j++) @@ -488,13 +488,15 @@ void BackEnd::finaliseConfig() if (enabled) { // crop is enabled when it contains non-zero width/height - uint16_t w = be_config_.crop.width ? be_config_.crop.width : be_config_.input_format.width; - uint16_t h = be_config_.crop.width ? be_config_.crop.height : be_config_.input_format.height; + uint16_t w = be_config_extra_.crop.width ? be_config_extra_.crop.width + : be_config_.input_format.width; + uint16_t h = be_config_extra_.crop.width ? be_config_extra_.crop.height + : be_config_.input_format.height; if (dirty_flags_rgb & PISP_BE_RGB_ENABLE_DOWNSCALE(j)) { if (variant_.BackEndDownscalerAvailable(0, j)) - finalise_downscale(be_config_.downscale[j], be_config_.downscale_extra[j], w, h); + finalise_downscale(be_config_.downscale[j], be_config_extra_.downscale[j], w, h); else throw std::runtime_error("Downscale is not available in output branch " + std::to_string(j)); } @@ -502,12 +504,12 @@ void BackEnd::finaliseConfig() if (be_config_.global.rgb_enables & PISP_BE_RGB_ENABLE_DOWNSCALE(j)) { // If the downscale is enabled, we update the input width/height for the resample stage. - w = be_config_.downscale_extra[j].scaled_width; - h = be_config_.downscale_extra[j].scaled_height; + w = be_config_extra_.downscale[j].scaled_width; + h = be_config_extra_.downscale[j].scaled_height; } if (dirty_flags_rgb & PISP_BE_RGB_ENABLE_RESAMPLE(j)) - finalise_resample(be_config_.resample[j], be_config_.resample_extra[j], w, h); + finalise_resample(be_config_.resample[j], be_config_extra_.resample[j], w, h); if (dirty_flags_rgb & PISP_BE_RGB_ENABLE_OUTPUT(j)) finalise_output(be_config_.output_format[j]); @@ -536,10 +538,10 @@ void BackEnd::updateSmartResize() std::string filter; // First get the size of the input to the rescalers. The crops are zero when not in use. - uint16_t input_width = be_config_.crop.width; + uint16_t input_width = be_config_extra_.crop.width; if (!input_width) input_width = be_config_.input_format.width; - uint16_t input_height = be_config_.crop.height; + uint16_t input_height = be_config_extra_.crop.height; if (!input_height) input_height = be_config_.input_format.height; @@ -547,7 +549,7 @@ void BackEnd::updateSmartResize() // has been requested. for (unsigned int i = 0; i < variant_.BackEndNumBranches(0); i++) { - if ((smart_resize_dirty_ & (1 << i)) || (be_config_.dirty_flags_extra & PISP_BE_DIRTY_CROP)) + if ((smart_resize_dirty_ & (1 << i)) || (be_config_extra_.dirty_flags_extra & PISP_BE_DIRTY_CROP)) { if (smart_resize_[i].width && smart_resize_[i].height) { @@ -681,6 +683,7 @@ void BackEnd::updateTiles() { TilingConfig tiling_config; pisp_be_config const &c = be_config_; + BeConfigExtra const &ce = be_config_extra_; retile_ = false; tiling_config.input_alignment = calculate_input_alignment(c); @@ -688,8 +691,8 @@ void BackEnd::updateTiles() PISP_LOG(debug, "Input alignments are " << tiling_config.input_alignment << " pixels"); tiling_config.input_image_size = tiling::Length2(c.input_format.width, c.input_format.height); - tiling_config.crop = tiling::Interval2(tiling::Interval(c.crop.offset_x, c.crop.width), - tiling::Interval(c.crop.offset_y, c.crop.height)); + tiling_config.crop = tiling::Interval2(tiling::Interval(ce.crop.offset_x, ce.crop.width), + tiling::Interval(ce.crop.offset_y, ce.crop.height)); if (tiling_config.crop.x.length == 0 || tiling_config.crop.y.length == 0) tiling_config.crop = tiling::Interval2(tiling::Interval(0, c.input_format.width), @@ -703,7 +706,7 @@ void BackEnd::updateTiles() tiling_config.resample_factor[i] = tiling::Length2(c.resample[i].scale_factor_h, c.resample[i].scale_factor_v); tiling_config.downscale_image_size[i] = - tiling::Length2(c.downscale_extra[i].scaled_width, c.downscale_extra[i].scaled_height); + tiling::Length2(ce.downscale[i].scaled_width, ce.downscale[i].scaled_height); tiling_config.output_image_size[i] = tiling::Length2(c.output_format[i].image.width, c.output_format[i].image.height); tiling_config.output_max_alignment[i] = @@ -851,9 +854,9 @@ std::vector BackEnd::retilePipeline(TilingConfig const &tiling_config ((interpolated_pix_y % NumPhases) << ScalePrecision) / NumPhases; // Account for any user defined initial phase - this could be negative! t.resample_phase_x[p * variant_.BackEndNumBranches(0) + j] += - be_config_.resample_extra[j].initial_phase_h[p]; + be_config_extra_.resample[j].initial_phase_h[p]; t.resample_phase_y[p * variant_.BackEndNumBranches(0) + j] += - be_config_.resample_extra[j].initial_phase_v[p]; + be_config_extra_.resample[j].initial_phase_v[p]; // Have to be within this range, else some calculation went wrong. PISP_ASSERT(t.resample_phase_x[p * variant_.BackEndNumBranches(0) + j] <= 2 * (UnityScale - 1)); PISP_ASSERT(t.resample_phase_y[p * variant_.BackEndNumBranches(0) + j] <= 2 * (UnityScale - 1)); @@ -909,14 +912,14 @@ void BackEnd::finaliseTiling() if (be_config_.global.bayer_enables & PISP_BE_BAYER_ENABLE_LSC) { - t.lsc_grid_offset_x = (t.input_offset_x + be_config_.lsc_extra.offset_x) * be_config_.lsc.grid_step_x; - t.lsc_grid_offset_y = (t.input_offset_y + be_config_.lsc_extra.offset_y) * be_config_.lsc.grid_step_y; + t.lsc_grid_offset_x = (t.input_offset_x + be_config_extra_.lsc.offset_x) * be_config_.lsc.grid_step_x; + t.lsc_grid_offset_y = (t.input_offset_y + be_config_extra_.lsc.offset_y) * be_config_.lsc.grid_step_y; } if (be_config_.global.bayer_enables & PISP_BE_BAYER_ENABLE_CAC) { - t.cac_grid_offset_x = (t.input_offset_x + be_config_.cac_extra.offset_x) * be_config_.cac.grid_step_x; - t.cac_grid_offset_y = (t.input_offset_y + be_config_.cac_extra.offset_y) * be_config_.cac.grid_step_y; + t.cac_grid_offset_x = (t.input_offset_x + be_config_extra_.cac.offset_x) * be_config_.cac.grid_step_x; + t.cac_grid_offset_y = (t.input_offset_y + be_config_extra_.cac.offset_y) * be_config_.cac.grid_step_y; } for (unsigned int j = 0; j < variant_.BackEndNumBranches(0); j++) @@ -946,11 +949,11 @@ void BackEnd::getOutputSize(int i, uint16_t *width, uint16_t *height, pisp_image if (smart_resize_[i].width && smart_resize_[i].height) *width = smart_resize_[i].width, *height = smart_resize_[i].height; else if (be_config_.global.rgb_enables & PISP_BE_RGB_ENABLE_RESAMPLE(i)) - *width = be_config_.resample_extra[i].scaled_width, *height = be_config_.resample_extra[i].scaled_height; + *width = be_config_extra_.resample[i].scaled_width, *height = be_config_extra_.resample[i].scaled_height; else if (be_config_.global.rgb_enables & PISP_BE_RGB_ENABLE_DOWNSCALE(i)) - *width = be_config_.downscale_extra[i].scaled_width, *height = be_config_.downscale_extra[i].scaled_height; - else if (be_config_.crop.width) // crop width and height will be zero when crop disabled - *width = be_config_.crop.width, *height = be_config_.crop.height; + *width = be_config_extra_.downscale[i].scaled_width, *height = be_config_extra_.downscale[i].scaled_height; + else if (be_config_extra_.crop.width) // crop width and height will be zero when crop disabled + *width = be_config_extra_.crop.width, *height = be_config_extra_.crop.height; else *width = ifmt.width, *height = ifmt.height; } @@ -1021,6 +1024,6 @@ void BackEnd::Prepare(pisp_be_tiles_config *config) config->config = be_config_; // 5. Clear any dirty flags for the next configuration update. - be_config_.dirty_flags_bayer = be_config_.dirty_flags_rgb = be_config_.dirty_flags_extra = 0; + be_config_extra_.dirty_flags_bayer = be_config_extra_.dirty_flags_rgb = be_config_extra_.dirty_flags_extra = 0; } } diff --git a/src/libpisp/backend/pisp_be_config.h b/src/libpisp/backend/pisp_be_config.h index 1fb39ca..7b858f1 100644 --- a/src/libpisp/backend/pisp_be_config.h +++ b/src/libpisp/backend/pisp_be_config.h @@ -445,19 +445,12 @@ typedef struct { output_format[PISP_BACK_END_NUM_OUTPUTS]; pisp_be_hog_config hog; pisp_be_axi_config axi; - /* Non-register fields: */ - pisp_be_lsc_extra lsc_extra; - pisp_be_cac_extra cac_extra; - pisp_be_downscale_extra - downscale_extra[PISP_BACK_END_NUM_OUTPUTS]; - pisp_be_resample_extra resample_extra[PISP_BACK_END_NUM_OUTPUTS]; - pisp_be_crop_config crop; - pisp_image_format_config hog_format; - uint32_t dirty_flags_bayer; /* these use pisp_be_bayer_enable */ - uint32_t dirty_flags_rgb; /* use pisp_be_rgb_enable */ - uint32_t dirty_flags_extra; /* these use pisp_be_dirty_t */ + /* For backward compatibility */ + uint8_t pad1[84]; } pisp_be_config; +static_assert(sizeof(pisp_be_config) == 6476, "pisp_be_config not packed as expected"); + /* * We also need a tile structure to describe the size of the tiles going * through the pipeline.