blob: 9696da281c108fa6c069b1011440139f4c1e524e [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RISP4ML_COMMON_CONSTANTS_H_
#define RISP4ML_COMMON_CONSTANTS_H_
#include <stdint.h>
// Input and output are expected to be 8 bits per pixel
static const uint16_t kPipeInputBpp = 8;
static const uint16_t kPipeOutputBpp = 8;
// TODO(b/149969920): modify sign,bitwidths and internal precision for risp4ml
// Assume 8.8 format
static const uint16_t kRawPipelineBpp = 16;
static const uint16_t kRawPipelineInteger = 8;
static const uint16_t kRawPipelineFraction = 8;
// max = 0xFF.FF = 65535
// represnting 255 + 255/256
static const uint16_t kRawPipelineMaxVal = 0xFFFF;
static const uint16_t kRawPipelineMinVal = 0;
// min fraction = 0x00.01 = 1/256
static const uint16_t kRawPipelineMinFraction = 1;
// BayerIndex defines the order in 2x2 normal Bayer quad.
// +---+---+
// | R | Gr|
// +---+---+
// | Gb| B |
// +---+---+
typedef enum {
kR = 0,
kGr = 1,
kGb = 2,
kB = 3,
} BayerIndex;
typedef enum {
kRggb = 0,
kGrbg = 1,
kGbrg = 2,
kBggr = 3,
} BayerPattern;
#ifndef NUM_BAYER_PATTERNS
#define NUM_BAYER_PATTERNS 4
#endif
#ifndef BAYER_COLOR_CHANNELS
#define BAYER_COLOR_CHANNELS 4
#endif
#ifndef RGB_COLOR_CHANNELS
#define RGB_COLOR_CHANNELS 3
#endif
// TODO(alexkaplan): Add a way to update this based on the image
// or to make sure the BayerType corresponds to the loaded image
static const BayerPattern kBayerType = kRggb;
#endif // RISP4ML_COMMON_CONSTANTS_H_