-
Notifications
You must be signed in to change notification settings - Fork 154
ipa: rpi: pisp: Add decompand support using PiSP hardware block #284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c85c7a3
ipa: rpi: pisp: Add decompand support using PiSP hardware block
asofam 0f53708
ipa: rpi: pisp: Remove 'pad' field from decompand config path
asofam 7545d16
ipa: rpi: pisp: Fix formatting issues in decompand
asofam 4254d34
ipa: rpi: pisp: Remove initialValues() from decompand algorithm
asofam 6261e5d
ipa: rpi: pisp: Use PWL representation for decompand instead of hard…
asofam 74f9aaa
ipa: rpi: pisp: Enable decompand algorithm based on bit depth
asofam 01399bd
ipa: rpi: pisp: Fix decompand PWL endpoint and remove redundant clipping
asofam f8c57d9
ipa: rpi: pisp: Restore clip at 65535 in decompand LUT
asofam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
|
|
||
| #include "algorithm.h" | ||
|
|
||
| namespace RPiController { | ||
|
|
||
| class DecompandAlgorithm : public Algorithm | ||
| { | ||
| public: | ||
| DecompandAlgorithm(Controller *controller) : Algorithm(controller) {} | ||
| virtual void initialValues(uint16_t lut[]) | ||
| { | ||
| static const uint16_t defaultLut[] = { | ||
| 3072, 3072, 3072, 3072, 3136, 3200, 3264, 3328, | ||
| 3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840, | ||
| 3904, 3968, 4032, 4096, 4608, 5120, 5632, 6144, | ||
| 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, | ||
| 10752, 11264, 11776, 12288, 12800, 13312, 13824, 14336, | ||
| 14848, 15360, 17408, 19456, 21504, 23552, 25600, 27648, | ||
| 29696, 31744, 33792, 35840, 37888, 39936, 41984, 44032, | ||
| 46080, 48128, 50176, 52224, 54272, 56320, 58368, 60416, | ||
| 62464 | ||
| }; | ||
|
|
||
| for (size_t i = 0; i < sizeof(defaultLut) / sizeof(defaultLut[0]); ++i) | ||
| lut[i] = defaultLut[i]; | ||
| } | ||
| }; | ||
| } /* namespace RPiController */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| struct DecompandStatus { | ||
| uint16_t lut[65]; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #include <libcamera/base/log.h> | ||
|
|
||
| #include "../decompand_status.h" | ||
|
|
||
| #include "decompand.h" | ||
|
|
||
| using namespace RPiController; | ||
| using namespace libcamera; | ||
|
|
||
| LOG_DEFINE_CATEGORY(RPiDecompand) | ||
|
|
||
| #define NAME "rpi.decompand" | ||
|
|
||
| Decompand::Decompand(Controller *controller) | ||
| : DecompandAlgorithm(controller) | ||
| { | ||
| } | ||
|
|
||
| char const *Decompand::name() const | ||
| { | ||
| return NAME; | ||
| } | ||
|
|
||
| int Decompand::read(const libcamera::YamlObject ¶ms) | ||
| { | ||
| if (!params.contains("lut") || !params["lut"].isList() || params["lut"].size() != 65) { | ||
| LOG(RPiDecompand, Error) << "Expected LUT with 65 elements"; | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| for (unsigned int i = 0; i < 65; ++i) { | ||
| std::optional<uint16_t> value = params["lut"][i].get<uint16_t>(); | ||
| if (!value.has_value()) { | ||
| LOG(RPiDecompand, Error) << "Invalid LUT value at index " << i; | ||
| return -EINVAL; | ||
| } | ||
| decompandLUT_[i] = value.value(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| void Decompand::initialValues(uint16_t LUT[]) | ||
| { | ||
| for (size_t i = 0; i < sizeof(decompandLUT_) / sizeof(decompandLUT_[0]); ++i) | ||
| { | ||
| LUT[i] = decompandLUT_[i]; | ||
| } | ||
| } | ||
|
|
||
| void Decompand::prepare(Metadata *imageMetadata) | ||
| { | ||
| struct DecompandStatus status; | ||
| for (size_t i = 0; i < sizeof(decompandLUT_) / sizeof(decompandLUT_[0]); ++i) | ||
| { | ||
| status.lut[i] = decompandLUT_[i]; | ||
| } | ||
|
|
||
| imageMetadata->set("decompand.status", status); | ||
| } | ||
|
|
||
| /* Register algorithm with the system. */ | ||
| static Algorithm *create(Controller *controller) | ||
| { | ||
| return new Decompand(controller); | ||
| } | ||
|
|
||
| static RegisterAlgorithm reg(NAME, &create); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #pragma once | ||
|
|
||
| #include "../decompand_algorithm.h" | ||
| #include "../decompand_status.h" | ||
|
|
||
| namespace RPiController { | ||
|
|
||
| class Decompand : public DecompandAlgorithm | ||
| { | ||
| public: | ||
| Decompand(Controller *controller); | ||
| char const *name() const override; | ||
| int read(const libcamera::YamlObject ¶ms) override; | ||
| void initialValues(uint16_t LUT[]) override; | ||
| void prepare(Metadata *imageMetadata) override; | ||
|
|
||
| private: | ||
| uint16_t decompandLUT_[65]; | ||
| }; | ||
|
|
||
| } /* namespace RPiController */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few formatting issues like this that will need to be fixed up before we can merge. There is a handy git commit hook that can be setup to run a check and give you the formatting errors. You can find more details here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out. I wasn't aware of such a helpful tool!
I've run checkstyle.py and corrected the formatting issues accordingly.