Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a25279e2 authored by Jag Saund's avatar Jag Saund Committed by Automerger Merge Worker
Browse files

Merge "Camera: Register LensShadingMap marshaler" am: 238f1e28

parents 7b13bb5c 238f1e28
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -88,8 +88,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

@@ -1027,6 +1027,19 @@ public class CameraMetadataNative implements Parcelable {
        return fixedFaceRectangles;
    }

    private boolean setLensShadingMap(LensShadingMap lensShadingMap) {
        if (lensShadingMap == null) {
            return false;
        }
        float[] lsmArray = new float[lensShadingMap.getGainFactorCount()];
        lensShadingMap.copyGainFactors(lsmArray, 0);
        setBase(CaptureResult.STATISTICS_LENS_SHADING_MAP, lsmArray);

        Size s = new Size(lensShadingMap.getRowCount(), lensShadingMap.getColumnCount());
        setBase(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE, s);
        return true;
    }

    private LensShadingMap getLensShadingMap() {
        float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP);
        Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE);
@@ -1851,6 +1864,13 @@ public class CameraMetadataNative implements Parcelable {
                metadata.setAERegions(value);
            }
        });
        sSetCommandMap.put(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP.getNativeKey(),
                new SetCommand() {
                    @Override
                    public <T> void setValue(CameraMetadataNative metadata, T value) {
                        metadata.setLensShadingMap((LensShadingMap) value);
                    }
                });
    }

    private boolean setAvailableFormats(int[] value) {
+1 −0
Original line number Diff line number Diff line
include platform/frameworks/av:/camera/OWNERS
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.camera2.impl;

import static com.google.common.truth.Truth.assertThat;

import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.params.LensShadingMap;
import android.util.Size;

import androidx.test.filters.SmallTest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.util.Arrays;

@SmallTest
@RunWith(JUnit4.class)
/** Tests for {@link CameraMetadataNative} class. */
public class CaptureMetadataNativeTest {

    @Test
    public void setLensShadingMap() {
        final Size s = new Size(10, 10);
        // 4 x rows x columns
        final float[] elements = new float[400];
        Arrays.fill(elements, 42);

        final LensShadingMap lensShadingMap =
                new LensShadingMap(elements, s.getHeight(), s.getWidth());
        CameraMetadataNative captureResults = new CameraMetadataNative();
        captureResults.set(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP, lensShadingMap);

        final LensShadingMap output =
                captureResults.get(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP);

        assertThat(output).isEqualTo(lensShadingMap);
    }
}