[libcamera-devel] [PATCH 01/17] DNI: ipa: raspberrypi: Code refactoring to match style guidelines

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jul 27 03:47:20 CEST 2022


Actually, one comment.

On Tue, Jul 26, 2022 at 01:45:33PM +0100, Naushir Patuck via libcamera-devel wrote:
> Refactor the source files in src/ipa/raspberrypi/ to match the
> recommended formatting guidelines for the libcamera project. The vast majority
> of changes in this commit comprise of switching from snake_case to CamelCase,
> and starting class member functions with a lower case character.
> 
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
>  .../controller/sharpen_algorithm.hpp          |   2 +-
>  .../raspberrypi/controller/sharpen_status.h   |   2 +-
>  src/ipa/raspberrypi/md_parser.hpp             |  44 +--
>  src/ipa/raspberrypi/md_parser_smia.cpp        | 108 +++----
>  src/ipa/raspberrypi/raspberrypi.cpp           | 272 +++++++++---------
>  5 files changed, 214 insertions(+), 214 deletions(-)

[snip]

> diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp
> index ea5eac414b36..9fab6594baac 100644
> --- a/src/ipa/raspberrypi/md_parser_smia.cpp
> +++ b/src/ipa/raspberrypi/md_parser_smia.cpp

[snip]

> @@ -76,74 +76,74 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>
>  {
>  	ASSERT(offsets_.size());
>  
> -	if (buffer[0] != LINE_START)
> -		return NO_LINE_START;
> +	if (buffer[0] != LineStart)
> +		return NoLineStart;
>  
> -	unsigned int current_offset = 1; /* after the LINE_START */
> -	unsigned int current_line_start = 0, current_line = 0;
> -	unsigned int reg_num = 0, regs_done = 0;
> +	unsigned int currentOffset = 1; /* after the LineStart */
> +	unsigned int currentLineStart = 0, currentLine = 0;
> +	unsigned int regNum = 0, regsDone = 0;
>  
>  	while (1) {
> -		int tag = buffer[current_offset++];
> -
> -		if ((bits_per_pixel_ == 10 &&
> -		     (current_offset + 1 - current_line_start) % 5 == 0) ||
> -		    (bits_per_pixel_ == 12 &&
> -		     (current_offset + 1 - current_line_start) % 3 == 0)) {
> -			if (buffer[current_offset++] != REG_SKIP)
> -				return BAD_DUMMY;
> +		int tag = buffer[currentOffset++];
> +
> +		if ((bitsPerPixel_ == 10 &&
> +		     (currentOffset + 1 - currentLineStart) % 5 == 0) ||
> +		    (bitsPerPixel_ == 12 &&
> +		     (currentOffset + 1 - currentLineStart) % 3 == 0)) {
> +			if (buffer[currentOffset++] != RegSkip)
> +				return BadDummy;
>  		}
>  
> -		int data_byte = buffer[current_offset++];
> +		int dataByte = buffer[currentOffset++];
>  
> -		if (tag == LINE_END_TAG) {
> -			if (data_byte != LINE_END_TAG)
> -				return BAD_LINE_END;
> +		if (tag == LineEndTag) {
> +			if (dataByte != LineEndTag)
> +				return BadLineEnd;
>  
> -			if (num_lines_ && ++current_line == num_lines_)
> -				return MISSING_REGS;
> +			if (numLines_ && ++currentLine == numLines_)
> +				return MissingRegs;
>  
> -			if (line_length_bytes_) {
> -				current_offset = current_line_start + line_length_bytes_;
> +			if (lineLengthBytes_) {
> +				currentOffset = currentLineStart + lineLengthBytes_;
>  
>  				/* Require whole line to be in the buffer (if buffer size set). */
>  				if (buffer.size() &&
> -				    current_offset + line_length_bytes_ > buffer.size())
> -					return MISSING_REGS;
> +				    currentOffset + lineLengthBytes_ > buffer.size())
> +					return MissingRegs;
>  
> -				if (buffer[current_offset] != LINE_START)
> -					return NO_LINE_START;
> +				if (buffer[currentOffset] != LineStart)
> +					return NoLineStart;
>  			} else {
>  				/* allow a zero line length to mean "hunt for the next line" */
> -				while (current_offset < buffer.size() &&
> -				       buffer[current_offset] != LINE_START)
> -					current_offset++;
> +				while (currentOffset < buffer.size() &&
> +				       buffer[currentOffset] != LineStart)
> +					currentOffset++;
>  
> -				if (current_offset == buffer.size())
> -					return NO_LINE_START;
> +				if (currentOffset == buffer.size())
> +					return NoLineStart;
>  			}
>  
> -			/* inc current_offset to after LINE_START */
> -			current_line_start = current_offset++;
> +			/* inc current_offset to after LineStart */

s/current_offset/currentOffset*/

> +			currentLineStart = currentOffset++;
>  		} else {
> -			if (tag == REG_HI_BITS)
> -				reg_num = (reg_num & 0xff) | (data_byte << 8);
> -			else if (tag == REG_LOW_BITS)
> -				reg_num = (reg_num & 0xff00) | data_byte;
> -			else if (tag == REG_SKIP)
> -				reg_num++;
> -			else if (tag == REG_VALUE) {
> -				auto reg = offsets_.find(reg_num);
> +			if (tag == RegHiBits)
> +				regNum = (regNum & 0xff) | (dataByte << 8);
> +			else if (tag == RegLowBits)
> +				regNum = (regNum & 0xff00) | dataByte;
> +			else if (tag == RegSkip)
> +				regNum++;
> +			else if (tag == RegValue) {
> +				auto reg = offsets_.find(regNum);
>  
>  				if (reg != offsets_.end()) {
> -					offsets_[reg_num] = current_offset - 1;
> +					offsets_[regNum] = currentOffset - 1;
>  
> -					if (++regs_done == offsets_.size())
> -						return PARSE_OK;
> +					if (++regsDone == offsets_.size())
> +						return ParseOk;
>  				}
> -				reg_num++;
> +				regNum++;
>  			} else
> -				return ILLEGAL_TAG;
> +				return IllegalTag;
>  		}
>  	}
>  }

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list