This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VH-Q1: VPAC Demosaic & Undistort Output Differs in Contrast and Sharpness Compared to CPU – Parameter Adjustments

Tool/software:

Hello,

I'm working with the **SVC220 sensor** on the **TDA4 VPAC ISP**, and I noticed that the output from the VPAC differs from my CPU implementation, particularly in contrast and sharpness.

I'm using the VPAC to perform demosaicing and undistortion on raw images. When I compare the results from the VPAC with my CPU implementation, the VPAC output has better contrast and appears sharper. These differences may affect the performance of the neural network, which processes the output images. My concern is that the differences between the VPAC and CPU outputs could impact the consistency of the neural network's results.

Here's the code snippet I'm using for the CPU demosaicing:

```cpp
cv::demosaicing(convImg16.getCpuConst(), demosaicImg16.getCpu(), cv::COLOR_BayerRG2BGR, 3);

```

**SVC220 Sensor Properties**:

```plaintext
SENSOR_ID 250
PRJ_DIR ../svc_output
SENSOR_NAME svc220
SENSOR_DCC_NAME svc220

SENSOR_WIDTH 1920
SENSOR_HEIGHT 1280

# 0=RGGB; 1=GRBG; 2=GBRG; 3=BGGR, 4=MONO
COLOR_PATTERN 3

# Sensor mode: 0 for linear (no decompanding), 1 for WDR (decompanding)
WDR_MODE 0

# Raw sensor image BIT_DEPTH: 8, 10, or 12 for linear sensors; typically 12 for WDR mode
BIT_DEPTH 12

# WDR BIT_DEPTH: Bit depth after decompanding, typically 20 or 24
WDR_BIT_DEPTH 16

# WDR decompanding knee points (comma-separated without spaces)
WDR_KNEE_X 0,512,837,1162,1487,1812,2137,2462,2787,3112,3437,3762,4087,65535
WDR_KNEE_Y 0,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048575,1048575

# Sensor black level to subtract before decompanding (for linear sensors only and some Sony WDR sensors)
BLACK_PRE 0

# Sensor black level to subtract after decompanding (for most WDR sensors and all linear sensors)
BLACK_POST 168

# GAMMA value for compressing 20/24-bit WDR raw to 16-bit ISP internal
# Typically around 50 (0.5) for 24-bit WDR sensors and 70 (0.7) for 20-bit sensors
GAMMA_PRE 50

# LSB location for H3A input bit range (from bit-H3A_INPUT_LSB to bit-H3A_INPUT_LSB+9)
H3A_INPUT_LSB 2
```

**My Question**:
Is there a way to adjust the runtime parameters of the VPAC (such as contrast or sharpness) to make the output closer to that of the CPU? Ideally, I'd like to achieve consistent output between the VPAC and CPU versions to minimize the impact on the neural network's results.

Any suggestions on where I might tune parameters or settings (perhaps related to gamma or black level) would be greatly appreciated!

Thanks in advance for your help!

  • Hi Aviad,

    Is there a way to adjust the runtime parameters of the VPAC (such as contrast or sharpness) to make the output closer to that of the CPU?

    VISS is H/W and we cannot tell how close it can be to your opencv code.

    You may check the black level and gamma correction curve used on both side and make them match first.

    That should make your image brightness closer.

  • Hi Gang,

    Thank you for your response!

    I have two follow-up questions:

    1. Adjusting Gamma and Black Levels:
    I understand that adjusting the gamma correction curve and black level can help match the brightness between the VPAC and CPU outputs. We’re using the properties file and Python script, as you referred us to in the meeting. Since we are not using the DCC tool, we are looking to make these manual adjustments directly in the provided properties file.
    Additionally, could you advise on the best way to test these adjustments and get a “feel” for whether to increase or reduce a value for gamma or black levels? For example, should we look for specific visual cues in the images (e.g., brightness, contrast, shadow detail) when adjusting these parameters? Any tips for iteratively testing and fine-tuning these values would be greatly appreciated.
    2. Demosaic Algorithm Type:
    Regarding the demosaicing process, I understand it’s implemented in hardware, but I assume it follows a known algorithm like bilinear interpolation, edge-aware methods, or another version. Is there any insight into which specific demosaicing algorithm the VPAC is using? If it’s a standard method, I could try to replicate similar behavior in OpenCV by selecting the appropriate algorithm.

    Any advice on these two points would be greatly appreciated!

    Thanks again,
    Aviad

  • Since we are not using the DCC tool, we are looking to make these manual adjustments directly in the provided properties file.

    This is fine with black level.
    Is your raw image linear or WDR BTW?

    You need to first find out what black level correction has been done in opencv if there is any.
    We can use the equivalent value in VISS if necessary.

    2. Demosaic Algorithm Type:

    You may refer to TDA4 TRM VPAC VISS section for demosaicing details.

    If you would like to do simple bilinear interpolation, there is a chance VISS may be able to do that.

  • Hi Gang,

    Thanks for the clarification.

    1. Black Level Adjustment:
    The raw image is linear, not WDR. I’ll check what black level correction, if any, is being applied in OpenCV and share the details with you. Once I know what correction is being done, I’ll match it with the equivalent value in VISS if necessary.
    2. Demosaic Algorithm Type:
    I’m not fully familiar with the TDA4 TRM VPAC VISS section off the top of my head, but I’ll look into it to better understand the demosaicing process. If bilinear interpolation is a feasible option, I’ll explore how to configure VISS for that.

    Thanks again for your help!

    Best regards,
    Aviad

  • Hi Aviad,

    I’ll match it with the equivalent value in VISS if necessary.

    Yes, you may add that in the python script configuration file for linear raw sensor images.

    I’m not fully familiar with the TDA4 TRM

    TRM is available in your device product folder on ti.com.
    If you know exactly how opencv did the bilinear interpolation for demosaicing, please give me a short summary.
    Then, I can help you with demosaicing parameters.

  • Hi Gang,

    Thanks for the response and the details.

    1. Black Level and Gains: I see that the current black level being used in OpenCV is set to 167.5744f, with the following gain values for each channel:

      • Red Gain: 1.05
      • Green Gain: 0.56
      • Blue Gain: 0.966

      Should I directly set these values in the Python script’s configuration file for the linear raw sensor images? If so, could you point me to the exact location in the script or configuration file where these should be applied?

    2. Potential Issue with NV12 Output: I realized we are using the NV12 output format in the VPAC VISS and then converting it to RGB during the saving process. Since the Edge Enhancer module works only on the Luma (Y) channel, I suspect that the enhancement is being applied before the NV12 to RGB conversion, which might be the cause of the difference in sharpness and contrast compared to the CPU output. Does this seem like a plausible reason for the discrepancy? If so, would there be a way to adjust or disable the edge enhancement in the VPAC pipeline?

    Thanks,

    Aviad

  • I see that the current black level being used in OpenCV is set to 167.5744f,

    Using 168 in python script should be fine.

    • Red Gain: 1.05
    • Green Gain: 0.56
    • Blue Gain: 0.966

    This looks like for AWB gains, but it is weird that the value may be less than 1.0.

    Does this seem like a plausible reason for the discrepancy?

    You may bypass EE by settings ee_mode of the tiovx kernel to 0.

    https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/tiovx/docs/user_guide/structtivx__vpac__viss__fcp__params__t.html#a41ed424767032aa77af0ed523e708a96

  • Hi Gang,

    Thank you for the detailed response!

    1. Black Level: I’ll use a value of 168 for the black level in the Python script as suggested.

    2. AWB Gain Values: You mentioned that the values I’m using for Red, Green, and Blue gains (1.05, 0.56, 0.966) seem unusual, especially for values less than 1.0. These were extracted from OpenCV processing, and I would like to discuss this further to understand the implications of using these in the VPAC. Could this affect how the RGB values are being interpreted in the VISS pipeline?

    3. Edge Enhancement: Since the Edge Enhancer (ee_mode) was already set to 0, I assume the differences I’m seeing are not due to edge enhancement. I’ll continue testing with this configuration.

    I believe it would be more efficient to go through the configuration in detail in an online meeting. Could we set up a meeting to review the setup together and align on the best approach to achieve consistent results?

    Please let me know a convenient time for you.

    Best regards,
    Aviad

  • Hi Aviad,

    Could we set up a meeting to review the setup together and align on the best approach to achieve consistent results?

    Yes, we can meet on Tuesday.

    When will you be available?

  • Sorry, this is public forum and I will share the slides and webex recording via email.

  • Implementing Bilinear Demosaicing for RGGB Bayer Pattern Using Convolution Kernels

    In this post, we'll explore the process of implementing bilinear demosaicing for an RGGB Bayer pattern image. We'll start by understanding the Bayer pattern, then explain how bilinear interpolation works to generate RGB pixels from raw Bayer data. We'll provide sample code for demosaicing a 16-bit image and then delve into designing convolution kernels for hardware implementation, including converting the kernels to signed 9-bit integer values suitable for fixed-point arithmetic.


    Table of Contents

    1. Understanding the RGGB Bayer Pattern
    2. Bilinear Interpolation for Demosaicing
    3. Demosaicing Code in C++
    4. Designing Convolution Kernels
    5. Converting Kernels to Signed 9-bit Integers
    6. Conclusion

    Understanding the RGGB Bayer Pattern

    A Bayer pattern is a color filter array (CFA) for arranging RGB color filters on a square grid of photosensors. The RGGB Bayer pattern is one of the most common patterns used in digital cameras. It consists of 50% green, 25% red, and 25% blue filters, arranged as follows:

    +-----+-----+
    |  R  |  G  |
    +-----+-----+
    |  G  |  B  |
    +-----+-----+
    

    This pattern repeats over the entire sensor, so each pixel in the raw image contains only one color component (R, G, or B). The goal of demosaicing is to reconstruct a full-color image by estimating the missing two color components at each pixel.

    Bayer Pattern Coordinates

    Let's define the coordinates (i, j) for each pixel:

    • Even Rows (i is even)
      • Even Columns (j is even): Red pixels
      • Odd Columns (j is odd): Green pixels (on red rows)
    • Odd Rows (i is odd)
      • Even Columns (j is even): Green pixels (on blue rows)
      • Odd Columns (j is odd): Blue pixels

    Bilinear Interpolation for Demosaicing

    Bilinear interpolation is a simple and widely used method for demosaicing. It estimates the missing color components at each pixel by averaging the neighboring known values.

    Generating RGB Pixels from Bayer Data

    We process each pixel based on its position in the Bayer pattern. For each pixel, we compute the missing R, G, and B values using bilinear interpolation.

    Calculations for Each Pixel Type

    1. Red Pixel (Even Row, Even Column)
      • Known: R
      • Estimate G: Average of the four neighboring G pixels
      • Estimate B: Average of the four diagonal B pixels
    2. Green Pixel on Red Row (Even Row, Odd Column)
      • Known: G
      • Estimate R: Average of the left and right R pixels
      • Estimate B: Average of the top and bottom B pixels
    3. Green Pixel on Blue Row (Odd Row, Even Column)
      • Known: G
      • Estimate R: Average of the top and bottom R pixels
      • Estimate B: Average of the left and right B pixels
    4. Blue Pixel (Odd Row, Odd Column)
      • Known: B
      • Estimate G: Average of the four neighboring G pixels
      • Estimate R: Average of the four diagonal R pixels

    Demosaicing Code in C++

    Below is a C++ function that implements bilinear interpolation for a 16-bit RGGB Bayer image.

    #include <opencv2/opencv.hpp>
    #include <stdexcept>
    
    cv::Mat demosaicRGGB_16bit(const cv::Mat& bayerImage) {
        // Check if the input image is single-channel 16-bit
        if (bayerImage.type() != CV_16UC1) {
            throw std::invalid_argument("Input image must be single-channel 16-bit (CV_16UC1).");
        }
    
        int rows = bayerImage.rows;
        int cols = bayerImage.cols;
    
        // Create an output image with 3 channels (RGB), 16-bit unsigned
        cv::Mat rgbImage(rows, cols, CV_16UC3);
    
        for (int i = 1; i < rows - 1; ++i) {
            const ushort* bayerRow = bayerImage.ptr<ushort>(i);
            const ushort* bayerRowPrev = bayerImage.ptr<ushort>(i - 1);
            const ushort* bayerRowNext = bayerImage.ptr<ushort>(i + 1);
            cv::Vec<ushort, 3>* rgbRow = rgbImage.ptr<cv::Vec<ushort, 3>>(i);
    
            for (int j = 1; j < cols - 1; ++j) {
                cv::Vec<ushort, 3>& pixel = rgbRow[j];
    
                bool isEvenRow = (i % 2 == 0);
                bool isEvenCol = (j % 2 == 0);
    
                if (isEvenRow && isEvenCol) {
                    // Red pixel
                    ushort R = bayerRow[j];
                    ushort G = ((bayerRow[j - 1] + bayerRow[j + 1] +
                                 bayerRowPrev[j] + bayerRowNext[j]) + 2) / 4;
                    ushort B = ((bayerRowPrev[j - 1] + bayerRowPrev[j + 1] +
                                 bayerRowNext[j - 1] + bayerRowNext[j + 1]) + 2) / 4;
                    pixel = cv::Vec<ushort, 3>(R, G, B);
                } else if (isEvenRow && !isEvenCol) {
                    // Green pixel on red row
                    ushort G = bayerRow[j];
                    ushort R = ((bayerRow[j - 1] + bayerRow[j + 1]) + 1) / 2;
                    ushort B = ((bayerRowPrev[j] + bayerRowNext[j]) + 1) / 2;
                    pixel = cv::Vec<ushort, 3>(R, G, B);
                } else if (!isEvenRow && isEvenCol) {
                    // Green pixel on blue row
                    ushort G = bayerRow[j];
                    ushort R = ((bayerRowPrev[j] + bayerRowNext[j]) + 1) / 2;
                    ushort B = ((bayerRow[j - 1] + bayerRow[j + 1]) + 1) / 2;
                    pixel = cv::Vec<ushort, 3>(R, G, B);
                } else {
                    // Blue pixel
                    ushort B = bayerRow[j];
                    ushort G = ((bayerRow[j - 1] + bayerRow[j + 1] +
                                 bayerRowPrev[j] + bayerRowNext[j]) + 2) / 4;
                    ushort R = ((bayerRowPrev[j - 1] + bayerRowPrev[j + 1] +
                                 bayerRowNext[j - 1] + bayerRowNext[j + 1]) + 2) / 4;
                    pixel = cv::Vec<ushort, 3>(R, G, B);
                }
            }
        }
    
        return rgbImage;
    }
    

    Notes

    • Data Types: We use ushort for 16-bit unsigned integers.
    • Boundary Handling: The loop skips the first and last rows and columns to avoid out-of-bounds access.
    • Color Order: The output is in RGB order.

    Designing Convolution Kernels

    To optimize the demosaicing process, especially for hardware implementation, we can represent the bilinear interpolation as convolution operations with specific kernels. Each kernel corresponds to computing a color channel at a specific pixel position.

    Overview

    • Kernel Size: We'll use \(6 \times 6\) kernels.
    • Number of Kernels: 4 positions × 3 color channels = 12 kernels.
    • Sparse Kernels: Most of the kernel elements are zeros.

    Defining the Kernels

    We'll represent each kernel as a \(6 \times 6\) matrix with zeros and non-zero coefficients at specific positions.

    Notation

    • K_C_P denotes the kernel for color channel C at pixel position P.
    • Positions in the kernel are relative to the center pixel (position \((3, 3)\)).

    Position 1: Red Pixel (Even Row, Even Column)

    1. Kernel for R at Red Pixel (K_R_R)
      • Purpose: Copy the red value directly.
      • Non-zero Coefficient: 1 at the center.
      K_R_R (6x6):
      
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
      [0 0 0 1 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
              
    2. Kernel for G at Red Pixel (K_G_R)
      • Purpose: Average of four neighboring green pixels.
      K_G_R (6x6):
      
      [0   0    0     0     0   0]
      [0   0  0.25    0   0.25  0]
      [0   0    0     0     0   0]
      [0   0  0.25    0   0.25  0]
      [0   0    0     0     0   0]
      [0   0    0     0     0   0]
              
    3. Kernel for B at Red Pixel (K_B_R)
      • Purpose: Average of four diagonal blue pixels.
      K_B_R (6x6):
      
      [0    0   0.25    0   0.25   0]
      [0    0     0     0     0    0]
      [0    0     0     0     0    0]
      [0    0     0     0     0    0]
      [0    0     0     0     0    0]
      [0    0   0.25    0   0.25   0]
              

    Position 2: Green Pixel on Red Row (Even Row, Odd Column)

    1. Kernel for R at G_R Pixel (K_R_G_R)
      • Purpose: Average of left and right red pixels.
      K_R_G_R (6x6):
      
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0.5 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0.5 0 0]
      [0 0 0 0 0 0]
              
    2. Kernel for G at G_R Pixel (K_G_G_R)
      • Purpose: Copy the green value directly.
      K_G_G_R (6x6):
      
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
      [0 0 0 1 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
      [0 0 0 0 0 0]
              
    3. Kernel for B at G_R Pixel (K_B_G_R)
      • Purpose: Average of top and bottom blue pixels.
      K_B_G_R (6x6):
      
      [0 0 0 0.5 0 0]
      [0 0 0 0   0 0]
      [0 0 0 0   0 0]
      [0 0 0 0.5 0 0]
      [0 0 0 0   0 0]
      [0 0 0 0   0 0]
              

    Similar Kernels for Other Positions

    Define the kernels for the remaining positions (G_B and B pixels) following the same approach.


    Converting Kernels to Signed 9-bit Integers

    To implement these kernels in hardware that requires signed 9-bit integers, we'll scale and quantize the floating-point coefficients.

    Constraints

    • Signed 9-bit Integers: Values from -256 to +255.
    • Normalization: The normalization is inherently included in the floating-point coefficients (e.g., coefficients like 0.25, 0.5).

    Scaling the Coefficients

    We need to convert the floating-point coefficients to integers while maintaining their relative proportions.

    • Choose a Scaling Factor: We can use a scaling factor of 256 (since \(2^8 = 256\)), which fits within the 9-bit signed integer range and preserves precision.

    Why 256?

    • Fits within 9 bits: The maximum coefficient after scaling (1.0 × 256) is 256.
    • Maintains Proportions: Scaling all coefficients by 256 preserves their relative values.
    • Simplifies Normalization: Since the scaling factor is consistent, we can adjust for it uniformly after convolution.

    Scaled Integer Coefficients

    • 1.0 × 256 = 256
    • 0.5 × 256 = 128
    • 0.25 × 256 = 64

    Adjusting the Kernels

    We update the kernels to use these integer coefficients.

    Example: Kernel for B at Red Pixel (K_B_R)

    Original Floating-Point Kernel:

    K_B_R (6x6):
    
    [0    0   0.25    0   0.25   0]
    [0    0     0     0     0    0]
    [0    0     0     0     0    0]
    [0    0     0     0     0    0]
    [0    0     0     0     0    0]
    [0    0   0.25    0   0.25   0]
    

    Scaled Integer Kernel:

    K_B_R_Int (6x6):
    
    [ 0    0    64     0    64    0 ]  // Row 0
    [ 0    0     0     0     0    0 ]  // Row 1
    [ 0    0     0     0     0    0 ]  // Row 2
    [ 0    0     0     0     0    0 ]  // Row 3
    [ 0    0     0     0     0    0 ]  // Row 4
    [ 0    0    64     0    64    0 ]  // Row 5
    

    Adjusting the Convolution Operation

    When applying the integer kernels:

    • Convolution Sum: The convolution result will be scaled by the same factor used in the coefficients (256).
    • Normalization: To obtain the correct pixel values, we need to divide the convolution result by the scaling factor (256).

    This step effectively normalizes the convolution result back to the original scale, compensating for the scaling of the coefficients.

    Implementation

    • Divide by 256: Since we scaled the coefficients by 256, dividing the convolution result by 256 restores the proper scale.
    • Efficient Computation: Division by 256 can be implemented as a right shift by 8 bits, which is efficient in hardware.

    Example of Convolution and Normalization

    // Convolution and normalization at pixel (i, j)
    int sum_B = 0;
    
    // Apply the integer kernel for B at Red Pixel
    for (int m = -3; m <= 2; ++m) {
        for (int n = -3; n <= 2; ++n) {
            int kernelRow = m + 3;
            int kernelCol = n + 3;
            int imageRow = i + m;
            int imageCol = j + n;
    
            // Check bounds
            if (imageRow >= 0 && imageRow < rows && imageCol >= 0 && imageCol < cols) {
                ushort pixelValue = bayerImage.at<ushort>(imageRow, imageCol);
                int coefficient = K_B_R_Int[kernelRow][kernelCol];
    
                // Accumulate sum
                sum_B += coefficient * pixelValue;
            }
        }
    }
    
    // Normalize by dividing by 256 (right shift by 8 bits)
    ushort output_B = sum_B >> 8;
    
    // Assign to output image
    rgbImage.at<cv::Vec<ushort, 3>>(i, j)[2] = output_B;
    

    Summary

    • Normalization is Included: The normalization is inherently included in the floating-point coefficients.
    • Scaling and Compensating: When scaling the coefficients to integers, we scale up the convolution result by the same factor. We compensate for this by dividing the convolution result by the scaling factor, effectively normalizing the output.
    • Preserving Proportions: This method ensures that the relative proportions of the coefficients are maintained, and the final output values are correct.

    Conclusion

    By understanding the RGGB Bayer pattern and applying bilinear interpolation, we can reconstruct full-color RGB images from raw Bayer data. Implementing the demosaicing process using convolution kernels allows for efficient hardware acceleration, especially when the kernels are converted to fixed-point integer representations suitable for hardware constraints.

    Key Takeaways:

    • Bilinear Interpolation: A simple method for estimating missing color components.
    • Convolution Kernels: Represent interpolation operations as kernels applied over the image.
    • Integer Kernels: Scale floating-point coefficients to signed integers within hardware limits.
    • Normalization: Essential to maintain correct output ranges after convolution; the normalization is inherently included in the coefficients.

    Disclaimer: This post was assisted by ChatGPT. The code and explanations have been tested to ensure accuracy.

  • Hi Aviad,

    Thanks for sharing the information!
    The c code is clear enough for me to follow.

    You may use the following filters in your CFAI xml file for bilinear interpolation for RGGB color format.

    					//FirCoefs
    					{
    						//FirCoef 0
    						{      
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0 252   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0 126   0 126   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
    						},
    						//FirCoef 1
    						{
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0 252   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0 126   0 126   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    						},
    						//FirCoef 2
    						{
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0 252   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0 126   0 126   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0 126   0   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    
                                  { 0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0  63   0  63   0   0
                                    0   0   0   0   0   0
                                    0   0   0   0   0   0},
    						},
    
    						//FirCoef 3
    						{
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 4
    						{
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 5
    						{
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0  63   0   0   0
                                0  63   0  63   0   0
                                0   0  63   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    
    						//FirCoef 6
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 7
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 8
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 9
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 10
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						},
    
    						//FirCoef 11
    						{
                               {0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0  63   0  63   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0 126   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0 126   0 126   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    
                               {0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0 252   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0
                                0   0   0   0   0   0},
    						}
    					},//FirCoefs
    

  • To be clear, 256 is not allowed for S9Q8 and we have to use slightly smaller numbers instead.

  • hi Gang,
    here are the images.
    the original pgm file:

    the output with the new params.

  • i cannot upload the PGM file.

  • Hi Aviad,

    i cannot upload the PGM file.

    You shall be able to zip your file in format and then upload it.

  • the output with the new params.

    I have tested it the CFAI parameters on my side before sending.
    Changing the filters in an existing xml file only makes small differences in the output image (a little more blur).

    Could you please share your before and after images as well as the xml files?

  • Hi Aviad,

    Is your sensor raw output pattern in RGGB?
    The filters above were prepared for RGGB.

    "ContiFisheye-Front_1723454404.102021_1_0_5.pgm" in your zip file is in BGGR rather than RGGB.

  • Hi Gang,

    We've encountered a new issue regarding the edges of the image, which seems to be related to the undistortion process.

    I also wanted to clarify that while we know the sensor is in the BGGR pattern, I thought we were fully aligned on that detail.

    I mistakenly flipped RGB to BGR before saving the images, which caused some confusion.

    I've corrected this mistake now, and attached are the updated raw images and outputs from TDA and PC, as well as the outputs of the DCC defaults generated for BGGR.

    Let me know your thoughts, and if you have any suggestions for handling the edge artifacts we're seeing.

    Best regards,

    latest.zipAviad

  • Hi Aviad,

    These are the correct xml files for RGGB or BGGR.
    They should work properly without the brightness issue.

    While I copied the filter sections above, I copied the wrong one without some needed "{" and "}".

    <?xml version="1.0" encoding="utf-8"?>
    <CFG_FLXD_CFA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <!--this is comment-->
      <dcc_name>cfg_flxd_cfa</dcc_name>
      <dcc_header>
        <camera_module_id>     220</camera_module_id>
        <dcc_descriptor_id>   9</dcc_descriptor_id>
        <algorithm_vendor_id>   1</algorithm_vendor_id>
        <tunning_tool_version>       0</tunning_tool_version>
      </dcc_header>
      <!--=======================================================================-->
                  <typedef>
                      <FLXD_FirCoefs type="struct">
                          <matrix type="uint32[4][36]"></matrix>
                      </FLXD_FirCoefs>
                  </typedef>
                  <typedef>
                      <cfg_flxd_cfa_vars type="struct">
                          <image_bits type="uint32"> </image_bits>
                          <lut_enable type="uint32"> </lut_enable>
                          <Set0GradHzMask type="uint32[4]"> </Set0GradHzMask>
                          <Set0GradVtMask type="uint32[4]"> </Set0GradVtMask>
                          <Set0IntensityMask type="uint32[4]"> </Set0IntensityMask>
                          <Set0IntensityShift type="uint32[4]"> </Set0IntensityShift>
                          <Set0Thr type="uint32[7]"> </Set0Thr>
                          <Set1GradHzMask type="uint32[4]"> </Set1GradHzMask>
                          <Set1GradVtMask type="uint32[4]"> </Set1GradVtMask>
                          <Set1IntensityMask type="uint32[4]"> </Set1IntensityMask>
                          <Set1IntensityShift type="uint32[4]"> </Set1IntensityShift>
                          <Set1Thr type="uint32[7]"> </Set1Thr>
                          <blendMode type="uint32[4]"> </blendMode>
                          <bitMaskSel type="uint32[4]"> </bitMaskSel>
                          <FirCoefs type="FLXD_FirCoefs[12]"> </FirCoefs>
                          <cfa_lut type="uint32[639]"> </cfa_lut>
                      </cfg_flxd_cfa_vars>
                    </typedef>    
      <!--=======================================================================-->
    
      <use_case val="65535">
        <n-space>
          <region0 class="0">
            <exposure val="1" min="0" max="100000">  </exposure>
            <gain val="0" min="0" max="250000">  </gain>
          </region0>
        </n-space>
        <parameter_package>
        <!-- Parameters for photospace class: 0 -->
            <cfg_flxd_cfa_dcc type="cfg_flxd_cfa_vars">
            {
                  16,   // image bits 
                   1,   // lut_enable 
                       {255, 255, 255, 255}, //Set0GradHzMask 
                       {255, 255, 255, 255}, //Set0GradVtMask 
                       {15,15,15,15},//Set0IntensityMask 
                       {5,5,5,5}, //Set0IntensityShift 
                       {500,500,500,500,500,500,500}, //Set0Thr 
                       {255, 255, 255, 255}, //Set1GradHzMask 
                       {255, 255, 255, 255}, //Set1GradVtMask 
                       {15,15,15,15},//Set1IntensityMask 
                       {5,5,5,5}, //Set1IntensityShift 
                       {500,500,500,500,500,500,500}, //Set1Thr 
                       {2,2,2,2},//blendMode 
                       {0,0,0,0},//bitMaskSel 
     
    				   //FirCoefs
    				   {
    					   //FirCoef 0
    					   {{      
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    					   }},
    					   //FirCoef 1
    					   {{
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    					   }},
    					   //FirCoef 2
    					   {{
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 3
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 4
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 5
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    
    					   //FirCoef 6
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 7
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 8
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 9
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 10
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 11
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }}
    				   },//FirCoefs
                      { //cfa_lut 
                           #include "lut_cfa_global.txt" 
                       } 
             }
            </cfg_flxd_cfa_dcc>
        </parameter_package>
      </use_case>
    </CFG_FLXD_CFA>
    

    <?xml version="1.0" encoding="utf-8"?>
    <CFG_FLXD_CFA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <!--this is comment-->
      <dcc_name>cfg_flxd_cfa</dcc_name>
      <dcc_header>
        <camera_module_id>     220</camera_module_id>
        <dcc_descriptor_id>   9</dcc_descriptor_id>
        <algorithm_vendor_id>   1</algorithm_vendor_id>
        <tunning_tool_version>       0</tunning_tool_version>
      </dcc_header>
      <!--=======================================================================-->
                  <typedef>
                      <FLXD_FirCoefs type="struct">
                          <matrix type="uint32[4][36]"></matrix>
                      </FLXD_FirCoefs>
                  </typedef>
                  <typedef>
                      <cfg_flxd_cfa_vars type="struct">
                          <image_bits type="uint32"> </image_bits>
                          <lut_enable type="uint32"> </lut_enable>
                          <Set0GradHzMask type="uint32[4]"> </Set0GradHzMask>
                          <Set0GradVtMask type="uint32[4]"> </Set0GradVtMask>
                          <Set0IntensityMask type="uint32[4]"> </Set0IntensityMask>
                          <Set0IntensityShift type="uint32[4]"> </Set0IntensityShift>
                          <Set0Thr type="uint32[7]"> </Set0Thr>
                          <Set1GradHzMask type="uint32[4]"> </Set1GradHzMask>
                          <Set1GradVtMask type="uint32[4]"> </Set1GradVtMask>
                          <Set1IntensityMask type="uint32[4]"> </Set1IntensityMask>
                          <Set1IntensityShift type="uint32[4]"> </Set1IntensityShift>
                          <Set1Thr type="uint32[7]"> </Set1Thr>
                          <blendMode type="uint32[4]"> </blendMode>
                          <bitMaskSel type="uint32[4]"> </bitMaskSel>
                          <FirCoefs type="FLXD_FirCoefs[12]"> </FirCoefs>
                          <cfa_lut type="uint32[639]"> </cfa_lut>
                      </cfg_flxd_cfa_vars>
                    </typedef>    
      <!--=======================================================================-->
    
      <use_case val="65535">
        <n-space>
          <region0 class="0">
            <exposure val="1" min="0" max="100000">  </exposure>
            <gain val="0" min="0" max="250000">  </gain>
          </region0>
        </n-space>
        <parameter_package>
        <!-- Parameters for photospace class: 0 -->
            <cfg_flxd_cfa_dcc type="cfg_flxd_cfa_vars">
            {
                  16,   // image bits 
                   1,   // lut_enable 
                       {255, 255, 255, 255}, //Set0GradHzMask 
                       {255, 255, 255, 255}, //Set0GradVtMask 
                       {15,15,15,15},//Set0IntensityMask 
                       {5,5,5,5}, //Set0IntensityShift 
                       {500,500,500,500,500,500,500}, //Set0Thr 
                       {255, 255, 255, 255}, //Set1GradHzMask 
                       {255, 255, 255, 255}, //Set1GradVtMask 
                       {15,15,15,15},//Set1IntensityMask 
                       {5,5,5,5}, //Set1IntensityShift 
                       {500,500,500,500,500,500,500}, //Set1Thr 
                       {2,2,2,2},//blendMode 
                       {0,0,0,0},//bitMaskSel 
     
    				   //FirCoefs
    				   {
    					   //FirCoef 0
    					   {{      
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    					   }},
    					   //FirCoef 1
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    					   //FirCoef 2
    					   {{
    						  {0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0  63   0  63   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0 126   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0 126   0 126   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 3
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 4
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 5
    					   {{
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0 252   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0  63   0   0   0
    						   0  63   0  63   0   0
    						   0   0  63   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    
    					   //FirCoef 6
    					   {{
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 7
    					   {{
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 8
    					   {{
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0 252   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0 126   0 126   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0 126   0   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    
    							 { 0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0  63   0  63   0   0
    							   0   0   0   0   0   0
    							   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 9
    					   {{
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 10
    					   {{
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }},
    
    					   //FirCoef 11
    					   {{
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    
    						  {0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0
    						   0   0   0   0   0   0},
    					   }}
    				   },//FirCoefs
                      { //cfa_lut 
                           #include "lut_cfa_global.txt" 
                       } 
             }
            </cfg_flxd_cfa_dcc>
        </parameter_package>
      </use_case>
    </CFG_FLXD_CFA>
    

  • This is the sample dummy setting for LDC working with 1920x1280 input.

    <?xml version="1.0" encoding="utf-8"?>
    <cfg_ldc_xml xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">
      <!--this is a comment-->
        <dcc_name>cfg_ldc</dcc_name>
        <dcc_header>
    		<camera_module_id>     220 </camera_module_id>
    	    <dcc_descriptor_id>   5 </dcc_descriptor_id>
    	    <algorithm_vendor_id>  1 </algorithm_vendor_id>
    	    <tunning_tool_version> 0 </tunning_tool_version>
        </dcc_header>
    <!--=======================================================================-->
        <typedef>
      	<cfg_ldc_vars type="struct">
            <ldc_en type="uint16"> </ldc_en>
            <ldc_ldmapen type="uint16"> </ldc_ldmapen>
            <ldc_datamode type="uint16"> </ldc_datamode>
            <ldc_opdatamode type="uint16"> </ldc_opdatamode>
            <ldc_ip_dfmt type="uint16"> </ldc_ip_dfmt>
            <ldc_pwarpen type="uint16"> </ldc_pwarpen>
            <ldc_yint_typ type="uint16"> </ldc_yint_typ>
            <ldc_regmode_en type="uint16"> </ldc_regmode_en>
            <ldc_meshtable_m type="uint16"> </ldc_meshtable_m>
            <ldc_mesh_frsz_w type="uint16"> </ldc_mesh_frsz_w>
            <ldc_mesh_frsz_h type="uint16"> </ldc_mesh_frsz_h>
            <ldc_compute_frsz_w type="uint16"> </ldc_compute_frsz_w>
            <ldc_compute_frsz_h type="uint16"> </ldc_compute_frsz_h>
            <ldc_initx type="uint16"> </ldc_initx>
            <ldc_inity type="uint16"> </ldc_inity>
            <ldc_input_frsz_w type="uint16"> </ldc_input_frsz_w>
            <ldc_input_frsz_h type="uint16"> </ldc_input_frsz_h>
            <ldc_obw type="uint16"> </ldc_obw>
            <ldc_obh type="uint16"> </ldc_obh>
            <ldc_pixpad type="uint16"> </ldc_pixpad>
            <ldc_a type="int16"> </ldc_a>
            <ldc_b type="int16"> </ldc_b>
            <ldc_c type="int16"> </ldc_c>
            <ldc_d type="int16"> </ldc_d>
            <ldc_e type="int16"> </ldc_e>
            <ldc_f type="int16"> </ldc_f>
            <ldc_g type="int16"> </ldc_g>
            <ldc_h type="int16"> </ldc_h>
            <ldc_sf_width type="uint16[3]"> </ldc_sf_width>
            <ldc_sf_height type="uint16[3]"> </ldc_sf_height>
            <ldc_sf_en  type="uint16[3][3]"> </ldc_sf_en>
            <ldc_sf_obw type="uint16[3][3]"> </ldc_sf_obw>
            <ldc_sf_obh type="uint16[3][3]"> </ldc_sf_obh>
            <ldc_sf_pad type="uint16[3][3]"> </ldc_sf_pad>
            <ldc_ylut_en type="uint16"> </ldc_ylut_en>
            <ldc_yin_bitdpth type="uint16"> </ldc_yin_bitdpth>
            <ldc_yout_bitdpth type="uint16"> </ldc_yout_bitdpth>
            <ldc_clut_en type="uint16"> </ldc_clut_en>
            <ldc_cin_bitdpth type="uint16"> </ldc_cin_bitdpth>
            <ldc_cout_bitdpth type="uint16"> </ldc_cout_bitdpth>
            <ldc_y_lut type="uint16[513]"> </ldc_y_lut>
            <ldc_c_lut type="uint16[513]"> </ldc_c_lut>
    		<mesh_table_pitch_in_bytes type="uint32"> </mesh_table_pitch_in_bytes>
    		<mesh_table_size type="uint32"> </mesh_table_size>
    		<mesh_lut type="uint16*"> </mesh_lut>
        </cfg_ldc_vars>
        </typedef>
    <!--=======================================================================-->
    	<use_case val="65535">
            <n-space>
          <region0 class="0">
            <exposure val="1" min="0" max="2000000">  </exposure>
            <gain val="0" min="0" max="100000">  </gain>
          </region0>
        </n-space>
    
            <parameter_package>
                <ldc_dcc type="cfg_ldc_vars">
                {
    				1     // LDC_CTRL              LDC_EN(0)            LDC Enable, 0: Disable,  1: Enable
    				1     // LDC_CTRL              LDMAPEN(1)           LD Mapping enable, 0: disable, 1: enable
    				2     // LDC_CTRL              DATAMODE(4:3)        Input data mode, 0: YUV422,  1: Y only, 2: YUV420, 3: YUV420 UV
    				0     // LDC_CTRL              OP_DATAMODE          Output data mode, 0: keep UYVY; 1: convert to 420
    				0     // LDC_CTRL              IP_DFMT(6:5)         Input pixel format, 0: 8b,  1: 12b packed, 2: 12b unpacked
    				1     // LDC_CTRL              PWARPEN(7)           0: Disable perspective warp. 1: Enable perspective warp
    				1     // LDC_CFG               YINT_TYP(6)          Interpolation type for Y data.  0: Bicubic,  1: Bilinear
    				0     // LDC_CFG               REGMODE_EN           Region mode, 0: disable, 1: enable
    				3     // LDC_MESHTABLE_CFG     M(2:0)               Mesh table subsampling factor (0-7)
    				1920  // LDC_MESH_FRSZ       W(13:0)              Mesh frame width (0-8192)
    				1280   // LDC_MESH_FRSZ       H(29:16)             Mesh frame height (0-8192)
    				1920  // LDC_COMPUTE_FRSZ      W(13:0)              Compute width (0-8192)
    				1280   // LDC_COMPUTE_FRSZ      H(29:16)             Compute height (0-8192)
    				0     // LDC_INITXY            INITX(13:0)          Output starting horizontal coordinate (0-8192)
    				0     // LDC_INITXY            INITY(29:16)         Output starting vertical coordinate (0-8192)
    				1920  // LDC_INPUT_FRSZ        W(29:16)             Input frame width
    				1280   // LDC_INPUT_FRSZ        H(13:0)              Input frame height
    				32    // LDC_BLOCK_SIZE        OBW(7:0)             Output block width (0-255)
    				32    // LDC_BLOCK_SIZE        OBH(15:8)            Output block height (0-255)
    				1     // LDC_BLOCK_SIZE        PIXPAD(19:16)        Pixel pad (0-15)
    				4096  // LDC_AB                A(15:0)              Affine Transform warp, A S16Q12
    				0 // LDC_AB                B(31:16)             Affine Transform warp, B S16Q12
    				0  // LDC_CD                C(15:0)              Affine Transform warp, C S16Q3
    				0    // LDC_CD                D(31:16)             Affine Transform warp, D S16Q12
    				4096 // LDC_EF                E(15:0)              Affine Transform warp, E S16Q12
    				0  // LDC_EF                F(31:16)             Affine Transform warp, F S16Q3
    				0   // LDC_GH                G(15:0)              Affine Transform warp, G S16Q23
    				0 // LDC_GH                H(31:16)             Affine Transform warp, H S16Q23
    			  {0, 0, 0}                             //ldc_sf_width [3]
    			  {0, 0, 0}                             //ldc_sf_height[3]
    			  {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}     //ldc_sf_en [3][3]
    			  {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}     //ldc_sf_obw[3][3]
    			  {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}     //ldc_sf_obh[3][3]
    			  {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}     //ldc_sf_pad[3][3]
    
    				0     // LDC_DUALOUT_CFG       YLUT_EN              Luma LUT enable (0-1)
    				8     // LDC_DUALOUT_CFG       YIN_BITDPTH          Luma input bit depth (8-12)
    				8     // LDC_DUALOUT_CFG       YOUT_BITDPTH         Luma output bit depth (8-12)
    				0     // LDC_DUALOUT_CFG       CLUT_EN              Chroma LUT enable (0-1)
    				8     // LDC_DUALOUT_CFG       CIN_BITDPTH          Chroma input bit depth (8-12)
    				8     // LDC_DUALOUT_CFG       COUT_BITDPTH         Chroma output bit depth (8-12)
    
    				{ //y_lut
    					0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    				}
    				{ //c_lut
    					0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    				}
    				
    				976,    //mesh_table_pitch_in_bytes
    				78568, //mesh_table_size
    				{ //mesh_lut
    					#include "asamplesensor_mesh_lut.txt"
    				}
                }
              </ldc_dcc>
            </parameter_package>
        </use_case>
    <!--=====================================================================-->
    </cfg_ldc_xml>
    
    asamplesensor_mesh_lut.txt

  • Hi Gang,

    I've tried to apply the gamma using the DCC tool. I created a LUT, inserted it into the DCC tool, added the GAMMA LUT XML to the generate DCC script, and included it in the VISS header file. However, it had no effect on the output.

    I've looked through the code, and it seems we're unable to change anything in the CC in Flexible CFAI. I manually changed the black levels in the BLC XLS file, and this had the most significant effect on the image.

    0,
    512,
    645,
    738,
    813,
    875,
    930,
    979,
    1024,
    1065,
    1103,
    1138,
    1172,
    1204,
    1234,
    1262,
    1290,
    1316,
    1341,
    1366,
    1389,
    1412,
    1434,
    1456,
    1477,
    1497,
    1516,
    1536,
    1554,
    1573,
    1591,
    1608,
    1625,
    1642,
    1658,
    1674,
    1690,
    1706,
    1721,
    1736,
    1751,
    1765,
    1779,
    1793,
    1807,
    1821,
    1834,
    1847,
    1860,
    1873,
    1886,
    1898,
    1911,
    1923,
    1935,
    1947,
    1958,
    1970,
    1981,
    1993,
    2004,
    2015,
    2026,
    2037,
    2048,
    2058,
    2069,
    2079,
    2089,
    2099,
    2110,
    2120,
    2129,
    2139,
    2149,
    2159,
    2168,
    2178,
    2187,
    2196,
    2206,
    2215,
    2224,
    2233,
    2242,
    2251,
    2259,
    2268,
    2277,
    2285,
    2294,
    2302,
    2311,
    2319,
    2327,
    2336,
    2344,
    2352,
    2360,
    2368,
    2376,
    2384,
    2392,
    2399,
    2407,
    2415,
    2423,
    2430,
    2438,
    2445,
    2453,
    2460,
    2467,
    2475,
    2482,
    2489,
    2496,
    2504,
    2511,
    2518,
    2525,
    2532,
    2539,
    2546,
    2553,
    2559,
    2566,
    2573,
    2580,
    2586,
    2593,
    2600,
    2606,
    2613,
    2619,
    2626,
    2632,
    2639,
    2645,
    2652,
    2658,
    2664,
    2671,
    2677,
    2683,
    2689,
    2695,
    2701,
    2708,
    2714,
    2720,
    2726,
    2732,
    2738,
    2744,
    2750,
    2756,
    2761,
    2767,
    2773,
    2779,
    2785,
    2790,
    2796,
    2802,
    2808,
    2813,
    2819,
    2824,
    2830,
    2836,
    2841,
    2847,
    2852,
    2858,
    2863,
    2869,
    2874,
    2879,
    2885,
    2890,
    2895,
    2901,
    2906,
    2911,
    2917,
    2922,
    2927,
    2932,
    2938,
    2943,
    2948,
    2953,
    2958,
    2963,
    2968,
    2973,
    2978,
    2983,
    2988,
    2993,
    2998,
    3003,
    3008,
    3013,
    3018,
    3023,
    3028,
    3033,
    3038,
    3043,
    3047,
    3052,
    3057,
    3062,
    3067,
    3071,
    3076,
    3081,
    3085,
    3090,
    3095,
    3099,
    3104,
    3109,
    3113,
    3118,
    3123,
    3127,
    3132,
    3136,
    3141,
    3145,
    3150,
    3154,
    3159,
    3163,
    3168,
    3172,
    3177,
    3181,
    3185,
    3190,
    3194,
    3199,
    3203,
    3207,
    3212,
    3216,
    3220,
    3225,
    3229,
    3233,
    3237,
    3242,
    3246,
    3250,
    3254,
    3259,
    3263,
    3267,
    3271,
    3275,
    3280,
    3284,
    3288,
    3292,
    3296,
    3300,
    3304,
    3308,
    3312,
    3317,
    3321,
    3325,
    3329,
    3333,
    3337,
    3341,
    3345,
    3349,
    3353,
    3357,
    3361,
    3365,
    3369,
    3373,
    3376,
    3380,
    3384,
    3388,
    3392,
    3396,
    3400,
    3404,
    3408,
    3411,
    3415,
    3419,
    3423,
    3427,
    3430,
    3434,
    3438,
    3442,
    3446,
    3449,
    3453,
    3457,
    3461,
    3464,
    3468,
    3472,
    3475,
    3479,
    3483,
    3487,
    3490,
    3494,
    3498,
    3501,
    3505,
    3508,
    3512,
    3516,
    3519,
    3523,
    3527,
    3530,
    3534,
    3537,
    3541,
    3544,
    3548,
    3552,
    3555,
    3559,
    3562,
    3566,
    3569,
    3573,
    3576,
    3580,
    3583,
    3587,
    3590,
    3594,
    3597,
    3600,
    3604,
    3607,
    3611,
    3614,
    3618,
    3621,
    3624,
    3628,
    3631,
    3635,
    3638,
    3641,
    3645,
    3648,
    3651,
    3655,
    3658,
    3661,
    3665,
    3668,
    3671,
    3675,
    3678,
    3681,
    3685,
    3688,
    3691,
    3695,
    3698,
    3701,
    3704,
    3708,
    3711,
    3714,
    3717,
    3721,
    3724,
    3727,
    3730,
    3733,
    3737,
    3740,
    3743,
    3746,
    3749,
    3753,
    3756,
    3759,
    3762,
    3765,
    3768,
    3772,
    3775,
    3778,
    3781,
    3784,
    3787,
    3790,
    3793,
    3797,
    3800,
    3803,
    3806,
    3809,
    3812,
    3815,
    3818,
    3821,
    3824,
    3827,
    3830,
    3833,
    3836,
    3839,
    3842,
    3845,
    3849,
    3852,
    3855,
    3858,
    3861,
    3864,
    3867,
    3870,
    3873,
    3875,
    3878,
    3881,
    3884,
    3887,
    3890,
    3893,
    3896,
    3899,
    3902,
    3905,
    3908,
    3911,
    3914,
    3917,
    3920,
    3923,
    3925,
    3928,
    3931,
    3934,
    3937,
    3940,
    3943,
    3946,
    3949,
    3951,
    3954,
    3957,
    3960,
    3963,
    3966,
    3968,
    3971,
    3974,
    3977,
    3980,
    3983,
    3985,
    3988,
    3991,
    3994,
    3997,
    3999,
    4002,
    4005,
    4008,
    4011,
    4013,
    4016,
    4019,
    4022,
    4024,
    4027,
    4030,
    4033,
    4035,
    4038,
    4041,
    4044,
    4046,
    4049,
    4052,
    4055,
    4057,
    4060,
    4063,
    4065,
    4068,
    4071,
    4074,
    4076,
    4079,
    4082,
    4084,
    4087,
    4090,
    4092,
    4095
    dcc_xmls.tar.gz

    # OUT_PATH=./headers
    DCC_TOOL_PATH=${PSDKR_PATH}/imaging/tools/dcc_tools/
    DCC_TOOL_XML_PATH=${PSDKR_PATH}/imaging/tools/default_DCC_profile_gen
    # Generate VPAC Linear DCC Config Block for the svc220
    SENSOR_NAME=svc220
    OUT_PATH=./${SENSOR_NAME}
    BIN_PATH=${OUT_PATH}/dcc_bins/
    XML_PATH=${DCC_TOOL_XML_PATH}/${SENSOR_NAME}_output/dcc_xmls/linear/
    # Ensure bin directory exists
    mkdir -p "$BIN_PATH"
    # Ensure out directory exists
    mkdir -p "$OUT_PATH"
    
    # Clean up old files
    rm -f ${OUT_PATH}/*.h
    rm -f ${BIN_PATH}/*.bin
    
    
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_rgb2rgb_dcc.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_h3a_aewb_dcc.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_viss_nsf4.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_viss_blc.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_viss_gamma.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_cfa_dcc.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_linear_decompand_dcc.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_h3a_mux_luts_dcc.xml
    mv ${XML_PATH}/*.bin $BIN_PATH/
    cat ${BIN_PATH}/*.bin > ${OUT_PATH}/dcc_viss_${SENSOR_NAME}.bin
    $DCC_TOOL_PATH/dcc_bin2c ${OUT_PATH}/dcc_viss_${SENSOR_NAME}.bin ${OUT_PATH}/dcc_viss_${SENSOR_NAME}.h dcc_viss_${SENSOR_NAME}
    echo; echo
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_awb_alg_ti3_tuning.xml
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_h3a_aewb_dcc.xml
    mv ${XML_PATH}/*.bin ${BIN_PATH}/
    cat ${BIN_PATH}/*.bin > ${OUT_PATH}/dcc_2a_${SENSOR_NAME}.bin
    $DCC_TOOL_PATH/dcc_bin2c ${OUT_PATH}/dcc_2a_${SENSOR_NAME}.bin ${OUT_PATH}/dcc_2a_${SENSOR_NAME}.h dcc_2a_${SENSOR_NAME}
    echo; echo
    $DCC_TOOL_PATH/dcc_gen_linux ${XML_PATH}/${SENSOR_NAME}_mesh_ldc_dcc.xml
    mv ${XML_PATH}/*.bin $BIN_PATH/
    cat $BIN_PATH/*.bin > ${BIN_PATH}/dcc_ldc.bin
    $DCC_TOOL_PATH/dcc_bin2c ${BIN_PATH}/dcc_ldc.bin $OUT_PATH/dcc_ldc_${SENSOR_NAME}.h dcc_ldc_${SENSOR_NAME}
    echo; echo
    
    

  • Hi Aviad,

    I've tried to apply the gamma using the DCC tool. I created a LUT, inserted it into the DCC tool, added the GAMMA LUT XML to the generate DCC script, and included it in the VISS header file. However, it had no effect on the output.

    <?xml version="1.0" encoding="utf-8"?>
    <VISS_cfg_gamma_xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <!--this is comment-->
      <dcc_name>viss_cfg_gamma</dcc_name>
      <dcc_header>
        <camera_module_id>     233 </camera_module_id>
    	  <dcc_descriptor_id>   12 </dcc_descriptor_id>
    	  <algorithm_vendor_id>  1 </algorithm_vendor_id>
    	  <tunning_tool_version> 0 </tunning_tool_version>
      </dcc_header>
      <!--=======================================================================-->
        <typedef>
    		<cfg_viss_gamma type="struct">
    		  <gamma_cfg_enable	    type="uint32">  		</gamma_cfg_enable>
    		  <gamma_cfg_bitdepth	type="uint32">  		</gamma_cfg_bitdepth>
    		  <gamma_cfg_lut	    type="uint32[513]">   	</gamma_cfg_lut>
    		</cfg_viss_gamma>
        </typedef>    
      <!--=======================================================================-->
        
        <use_case val="1023">
            <n-space>
    		
                <region0 class="0">
    				<colortemperature val="2" min="0" max="20000">  </colortemperature>
    				<exposure val="1" min="0" max="10000000">  </exposure>
    				<gain val="0" min="0" max="1024">  </gain>
    			</region0>
    		
    		</n-space>
    		
           <parameter_package>           
                 <viss_cfg_gamma type="cfg_viss_gamma">
    			 {
    				1, // gamma_cfg_enable         0:disable, 1: enable
    				10, // gamma_cfg_bitdepth       10: by default
    				{
    					0,
    9,
    18,
    27,
    36,
    45,
    54,
    63,
    72,
    81,
    90,
    98,
    106,
    114,
    121,
    128,
    135,
    142,
    148,
    154,
    160,
    166,
    172,
    177,
    183,
    188,
    193,
    198,
    203,
    208,
    213,
    217,
    222,
    226,
    231,
    235,
    239,
    244,
    248,
    252,
    256,
    260,
    264,
    268,
    272,
    275,
    279,
    283,
    286,
    290,
    294,
    297,
    301,
    304,
    308,
    311,
    314,
    318,
    321,
    324,
    327,
    331,
    334,
    337,
    340,
    343,
    346,
    349,
    352,
    355,
    358,
    361,
    364,
    367,
    370,
    373,
    376,
    378,
    381,
    384,
    387,
    389,
    392,
    395,
    398,
    400,
    403,
    406,
    408,
    411,
    413,
    416,
    418,
    421,
    423,
    426,
    428,
    431,
    433,
    436,
    438,
    441,
    443,
    446,
    448,
    450,
    453,
    455,
    457,
    460,
    462,
    464,
    467,
    469,
    471,
    473,
    476,
    478,
    480,
    482,
    484,
    487,
    489,
    491,
    493,
    495,
    497,
    500,
    502,
    504,
    506,
    508,
    510,
    512,
    514,
    516,
    518,
    520,
    522,
    524,
    527,
    529,
    531,
    533,
    535,
    537,
    538,
    540,
    542,
    544,
    546,
    548,
    550,
    552,
    554,
    556,
    558,
    560,
    562,
    564,
    565,
    567,
    569,
    571,
    573,
    575,
    577,
    578,
    580,
    582,
    584,
    586,
    587,
    589,
    591,
    593,
    595,
    596,
    598,
    600,
    602,
    603,
    605,
    607,
    609,
    610,
    612,
    614,
    616,
    617,
    619,
    621,
    622,
    624,
    626,
    627,
    629,
    631,
    633,
    634,
    636,
    637,
    639,
    641,
    642,
    644,
    646,
    647,
    649,
    651,
    652,
    654,
    655,
    657,
    659,
    660,
    662,
    663,
    665,
    667,
    668,
    670,
    671,
    673,
    674,
    676,
    678,
    679,
    681,
    682,
    684,
    685,
    687,
    688,
    690,
    691,
    693,
    694,
    696,
    697,
    699,
    700,
    702,
    703,
    705,
    706,
    708,
    709,
    711,
    712,
    714,
    715,
    717,
    718,
    720,
    721,
    722,
    724,
    725,
    727,
    728,
    730,
    731,
    733,
    734,
    735,
    737,
    738,
    740,
    741,
    742,
    744,
    745,
    747,
    748,
    749,
    751,
    752,
    754,
    755,
    756,
    758,
    759,
    760,
    762,
    763,
    765,
    766,
    767,
    769,
    770,
    771,
    773,
    774,
    775,
    777,
    778,
    779,
    781,
    782,
    783,
    785,
    786,
    787,
    789,
    790,
    791,
    793,
    794,
    795,
    797,
    798,
    799,
    800,
    802,
    803,
    804,
    806,
    807,
    808,
    809,
    811,
    812,
    813,
    815,
    816,
    817,
    818,
    820,
    821,
    822,
    823,
    825,
    826,
    827,
    828,
    830,
    831,
    832,
    833,
    835,
    836,
    837,
    838,
    840,
    841,
    842,
    843,
    845,
    846,
    847,
    848,
    849,
    851,
    852,
    853,
    854,
    855,
    857,
    858,
    859,
    860,
    861,
    863,
    864,
    865,
    866,
    867,
    869,
    870,
    871,
    872,
    873,
    875,
    876,
    877,
    878,
    879,
    880,
    882,
    883,
    884,
    885,
    886,
    887,
    889,
    890,
    891,
    892,
    893,
    894,
    895,
    897,
    898,
    899,
    900,
    901,
    902,
    903,
    905,
    906,
    907,
    908,
    909,
    910,
    911,
    912,
    914,
    915,
    916,
    917,
    918,
    919,
    920,
    921,
    923,
    924,
    925,
    926,
    927,
    928,
    929,
    930,
    931,
    932,
    934,
    935,
    936,
    937,
    938,
    939,
    940,
    941,
    942,
    943,
    944,
    945,
    947,
    948,
    949,
    950,
    951,
    952,
    953,
    954,
    955,
    956,
    957,
    958,
    959,
    960,
    962,
    963,
    964,
    965,
    966,
    967,
    968,
    969,
    970,
    971,
    972,
    973,
    974,
    975,
    976,
    977,
    978,
    979,
    980,
    981,
    983,
    984,
    985,
    986,
    987,
    988,
    989,
    990,
    991,
    992,
    993,
    994,
    995,
    996,
    997,
    998,
    999,
    1000,
    1001,
    1002,
    1003,
    1004,
    1005,
    1006,
    1007,
    1008,
    1009,
    1010,
    1011,
    1012,
    1013,
    1014,
    1015,
    1016,
    1017,
    1018,
    1019,
    1020,
    1021,
    1022,
    1023,
    1023, //gamma_cfg_lut Gamma LUT
    				}
    			}
    			</viss_cfg_gamma>
            </parameter_package>
    		
        </use_case>
    	
      <!--=====================================================================-->
    </VISS_cfg_gamma_xml>
    

    This is one example gamma curve I have for your reference.
    Do you have any issue or error message in the process?

    I've looked through the code, and it seems we're unable to change anything in the CC in Flexible CFAI.

    Do you see this line below getting called for setting up the gamma curve you provided?

    https://git.ti.com/cgit/processor-sdk/imaging/tree/kernels/hwa/vpac_viss/vx_vpac_viss_target_dcc.c?h=main#n1195

    I manually changed the black levels in the BLC XLS file, and this had the most significant effect on the image.

    This means that your xml file changes for BLC goes into the VISS kernel and H/W.
    But somehow, gamma curve changes do not.

  • This is one example gamma curve I have for your reference.
    Do you have any issue or error message in the process?

    no, no issues and errors.

    Do you see this line below getting called for setting up the gamma curve you provided?

    https://git.ti.com/cgit/processor-sdk/imaging/tree/kernels/hwa/vpac_viss/vx_vpac_viss_target_dcc.c?h=main#n1195

    this is firmware code.

    This means that your xml file changes for BLC goes into the VISS kernel and H/W.
    But somehow, gamma curve changes do not.

    this is the issue. 

  • this is firmware code.

    Do you mean that you are not able to check if that part of the code exists or runs?

    Are you on RTOS SDK or edgeai platform?