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

Commit 52842e7a authored by Ruben Brunk's avatar Ruben Brunk
Browse files

camera2: Add BlackLevelPattern class.

Bug: 15448889

- Adds BlackLevelPattern class and marshaller.
- Updates BlackLevelPattern tag to use this class.

Change-Id: I5d3393f4a1695664bc5315eb592fb0a4e154d22e
parent f924e950
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -12833,6 +12833,12 @@ package android.hardware.camera2 {
package android.hardware.camera2.params {
  public final class BlackLevelPattern {
    method public void copyTo(int[], int);
    method public int getOffsetForIndex(int, int);
    field public static final int COUNT = 4; // 0x4
  }
  public final class ColorSpaceTransform {
    ctor public ColorSpaceTransform(android.util.Rational[]);
    ctor public ColorSpaceTransform(int[]);
+7 −4
Original line number Diff line number Diff line
@@ -1680,14 +1680,17 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * <p>This tag specifies the zero light value for each of the CFA mosaic
     * channels in the camera sensor.  The maximal value output by the
     * sensor is represented by the value in {@link CameraCharacteristics#SENSOR_INFO_WHITE_LEVEL android.sensor.info.whiteLevel}.</p>
     * <p>The values are given in row-column scan order, with the first value
     * corresponding to the element of the CFA in row=0, column=0.</p>
     * <p>The values are given in the same order as channels listed for the CFA
     * layout tag (see {@link CameraCharacteristics#SENSOR_INFO_COLOR_FILTER_ARRANGEMENT android.sensor.info.colorFilterArrangement}), i.e. the
     * nth value given corresponds to the black level offset for the nth
     * color channel listed in the CFA.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     * @see CameraCharacteristics#SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
     * @see CameraCharacteristics#SENSOR_INFO_WHITE_LEVEL
     */
    public static final Key<int[]> SENSOR_BLACK_LEVEL_PATTERN =
            new Key<int[]>("android.sensor.blackLevelPattern", int[].class);
    public static final Key<android.hardware.camera2.params.BlackLevelPattern> SENSOR_BLACK_LEVEL_PATTERN =
            new Key<android.hardware.camera2.params.BlackLevelPattern>("android.sensor.blackLevelPattern", android.hardware.camera2.params.BlackLevelPattern.class);

    /**
     * <p>Maximum sensitivity that is implemented
+2 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,8 @@ public abstract class CameraMetadata<TKey> {
     * image while recording video) use case.</p>
     * <p>The camera device should take the highest-quality image
     * possible (given the other settings) without disrupting the
     * frame rate of video recording.  </p>
     * frame rate of video recording.<br />
     * </p>
     * @see CaptureRequest#CONTROL_CAPTURE_INTENT
     */
    public static final int CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT = 4;
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.hardware.camera2.marshal.MarshalQueryable;
import android.hardware.camera2.marshal.MarshalRegistry;
import android.hardware.camera2.marshal.impl.MarshalQueryableArray;
import android.hardware.camera2.marshal.impl.MarshalQueryableBoolean;
import android.hardware.camera2.marshal.impl.MarshalQueryableBlackLevelPattern;
import android.hardware.camera2.marshal.impl.MarshalQueryableColorSpaceTransform;
import android.hardware.camera2.marshal.impl.MarshalQueryableEnum;
import android.hardware.camera2.marshal.impl.MarshalQueryableMeteringRectangle;
@@ -1013,6 +1014,7 @@ public class CameraMetadataNative implements Parcelable {
                new MarshalQueryableStreamConfiguration(),
                new MarshalQueryableStreamConfigurationDuration(),
                new MarshalQueryableRggbChannelVector(),
                new MarshalQueryableBlackLevelPattern(),

                // generic parcelable marshaler (MUST BE LAST since it has lowest priority)
                new MarshalQueryableParcelable(),
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.marshal.impl;

import android.hardware.camera2.marshal.MarshalQueryable;
import android.hardware.camera2.marshal.Marshaler;
import android.hardware.camera2.params.BlackLevelPattern;
import android.hardware.camera2.utils.TypeReference;

import java.nio.ByteBuffer;

import static android.hardware.camera2.impl.CameraMetadataNative.TYPE_INT32;
import static android.hardware.camera2.marshal.MarshalHelpers.SIZEOF_INT32;

/**
 * Marshal {@link BlackLevelPattern} to/from {@link #TYPE_INT32} {@code x 4}
 */
public class MarshalQueryableBlackLevelPattern implements MarshalQueryable<BlackLevelPattern> {
    private static final int SIZE = SIZEOF_INT32 * BlackLevelPattern.COUNT;

    private class MarshalerBlackLevelPattern extends Marshaler<BlackLevelPattern> {
        protected MarshalerBlackLevelPattern(TypeReference<BlackLevelPattern> typeReference,
                                               int nativeType) {
            super(MarshalQueryableBlackLevelPattern.this, typeReference, nativeType);
        }

        @Override
        public void marshal(BlackLevelPattern value, ByteBuffer buffer) {
            for (int i = 0; i < BlackLevelPattern.COUNT / 2; ++i) {
                for (int j = 0; j < BlackLevelPattern.COUNT / 2; ++j) {
                    buffer.putInt(value.getOffsetForIndex(j, i));
                }
            }
        }

        @Override
        public BlackLevelPattern unmarshal(ByteBuffer buffer) {
            int[] channelOffsets = new int[BlackLevelPattern.COUNT];
            for (int i = 0; i < BlackLevelPattern.COUNT; ++i) {
                channelOffsets[i] = buffer.getInt();
            }
            return new BlackLevelPattern(channelOffsets);
        }

        @Override
        public int getNativeSize() {
            return SIZE;
        }
    }

    @Override
    public Marshaler<BlackLevelPattern> createMarshaler(
            TypeReference<BlackLevelPattern> managedType, int nativeType) {
        return new MarshalerBlackLevelPattern(managedType, nativeType);
    }

    @Override
    public boolean isTypeMappingSupported(
            TypeReference<BlackLevelPattern> managedType, int nativeType) {
        return nativeType == TYPE_INT32 &&
                (BlackLevelPattern.class.equals(managedType.getType()));
    }
}
Loading