From df36fb4abb37c216d1eaf60a1772047b5205d0b7 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Fri, 7 May 2021 12:37:27 +0100 Subject: 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/ipa/raspberrypi/md_parser.hpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/ipa/raspberrypi/md_parser.hpp') 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 +#include + /* 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 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 buffer, uint32_t regs[], int offsets[], unsigned int num_regs); }; -- cgit v1.2.1