diff options
author | David Plowman <david.plowman@raspberrypi.com> | 2021-05-07 12:37:27 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-05-08 02:49:03 +0300 |
commit | df36fb4abb37c216d1eaf60a1772047b5205d0b7 (patch) | |
tree | b8d4e7088c48eb6a3cc0f2c8b4e2da6cc4bd40ff /src/ipa/raspberrypi/md_parser.hpp | |
parent | 414babb60b5453bf2a2d206088c0b4a1b48da15e (diff) |
ipa: raspberrypi: Make sensor embedded data parser use Span class
Improve MdParser::Parse() by taking a Span, pointing to const data
that it should not change, as its input buffer.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/md_parser.hpp')
-rw-r--r-- | src/ipa/raspberrypi/md_parser.hpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp index 926f676e..8e22b1d7 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.hpp @@ -8,6 +8,8 @@ #include <stdint.h> +#include <libcamera/span.h> + /* Camera metadata parser class. Usage as shown below. Setup: @@ -21,17 +23,15 @@ parser->SetBitsPerPixel(bpp); parser->SetLineLengthBytes(pitch); parser->SetNumLines(2); -Note 1: if you don't know how many lines there are, you can use SetBufferSize -instead to limit the total buffer size. +Note 1: if you don't know how many lines there are, the size of the input +buffer is used as a limit instead. Note 2: if you don't know the line length, you can leave the line length unset -(or set to zero) and the parser will hunt for the line start instead. In this -case SetBufferSize *must* be used so that the parser won't run off the end of -the buffer. +(or set to zero) and the parser will hunt for the line start instead. Then on every frame: -if (parser->Parse(data) != MdParser::OK) +if (parser->Parse(buffer) != MdParser::OK) much badness; unsigned int exposure_lines, gain_code if (parser->GetExposureLines(exposure_lines) != MdParser::OK) @@ -75,11 +75,7 @@ public: { line_length_bytes_ = num_bytes; } - void SetBufferSize(unsigned int num_bytes) - { - buffer_size_bytes_ = num_bytes; - } - virtual Status Parse(void *data) = 0; + virtual Status Parse(libcamera::Span<const uint8_t> buffer) = 0; virtual Status GetExposureLines(unsigned int &lines) = 0; virtual Status GetGainCode(unsigned int &gain_code) = 0; @@ -116,7 +112,7 @@ protected: BAD_LINE_END = -4, BAD_PADDING = -5 }; - ParseStatus findRegs(unsigned char *data, uint32_t regs[], + ParseStatus findRegs(libcamera::Span<const uint8_t> buffer, uint32_t regs[], int offsets[], unsigned int num_regs); }; |