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

Commit e406ac08 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "camera: Add OisSamples synthetic key"

parents f9e35bc6 c804d1cc
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -16276,9 +16276,7 @@ package android.hardware.camera2 {
    field public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.LensShadingMap> STATISTICS_LENS_SHADING_CORRECTION_MAP;
    field public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.LensShadingMap> STATISTICS_LENS_SHADING_CORRECTION_MAP;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_LENS_SHADING_MAP_MODE;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_LENS_SHADING_MAP_MODE;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_OIS_DATA_MODE;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_OIS_DATA_MODE;
    field public static final android.hardware.camera2.CaptureResult.Key<long[]> STATISTICS_OIS_TIMESTAMPS;
    field public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.OisSample[]> STATISTICS_OIS_SAMPLES;
    field public static final android.hardware.camera2.CaptureResult.Key<float[]> STATISTICS_OIS_X_SHIFTS;
    field public static final android.hardware.camera2.CaptureResult.Key<float[]> STATISTICS_OIS_Y_SHIFTS;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_SCENE_FLICKER;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> STATISTICS_SCENE_FLICKER;
    field public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.TonemapCurve> TONEMAP_CURVE;
    field public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.TonemapCurve> TONEMAP_CURVE;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Float> TONEMAP_GAMMA;
    field public static final android.hardware.camera2.CaptureResult.Key<java.lang.Float> TONEMAP_GAMMA;
@@ -16374,6 +16372,13 @@ package android.hardware.camera2.params {
    field public static final int METERING_WEIGHT_MIN = 0; // 0x0
    field public static final int METERING_WEIGHT_MIN = 0; // 0x0
  }
  }
  public final class OisSample {
    ctor public OisSample(long, float, float);
    method public long getTimestamp();
    method public float getXshift();
    method public float getYshift();
  }
  public final class OutputConfiguration implements android.os.Parcelable {
  public final class OutputConfiguration implements android.os.Parcelable {
    ctor public OutputConfiguration(android.view.Surface);
    ctor public OutputConfiguration(android.view.Surface);
    ctor public OutputConfiguration(int, android.view.Surface);
    ctor public OutputConfiguration(int, android.view.Surface);
+4 −0
Original line number Original line Diff line number Diff line
@@ -2646,6 +2646,10 @@ public abstract class CameraMetadata<TKey> {


    /**
    /**
     * <p>Include OIS data in the capture result.</p>
     * <p>Include OIS data in the capture result.</p>
     * <p>{@link CaptureResult#STATISTICS_OIS_SAMPLES android.statistics.oisSamples} provides OIS sample data in the
     * output result metadata.</p>
     *
     * @see CaptureResult#STATISTICS_OIS_SAMPLES
     * @see CaptureRequest#STATISTICS_OIS_DATA_MODE
     * @see CaptureRequest#STATISTICS_OIS_DATA_MODE
     */
     */
    public static final int STATISTICS_OIS_DATA_MODE_ON = 1;
    public static final int STATISTICS_OIS_DATA_MODE_ON = 1;
+0 −5
Original line number Original line Diff line number Diff line
@@ -2784,9 +2784,6 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
    /**
    /**
     * <p>A control for selecting whether OIS position information is included in output
     * <p>A control for selecting whether OIS position information is included in output
     * result metadata.</p>
     * result metadata.</p>
     * <p>When set to ON,
     * {@link CaptureResult#STATISTICS_OIS_TIMESTAMPS android.statistics.oisTimestamps}, android.statistics.oisShiftPixelX,
     * and android.statistics.oisShiftPixelY provide OIS data in the output result metadata.</p>
     * <p><b>Possible values:</b>
     * <p><b>Possible values:</b>
     * <ul>
     * <ul>
     *   <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
     *   <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
@@ -2795,8 +2792,6 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
     * <p><b>Available values for this device:</b><br>
     * <p><b>Available values for this device:</b><br>
     * android.Statistics.info.availableOisDataModes</p>
     * android.Statistics.info.availableOisDataModes</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     * @see CaptureResult#STATISTICS_OIS_TIMESTAMPS
     * @see #STATISTICS_OIS_DATA_MODE_OFF
     * @see #STATISTICS_OIS_DATA_MODE_OFF
     * @see #STATISTICS_OIS_DATA_MODE_ON
     * @see #STATISTICS_OIS_DATA_MODE_ON
     */
     */
+24 −16
Original line number Original line Diff line number Diff line
@@ -3911,9 +3911,6 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
    /**
    /**
     * <p>A control for selecting whether OIS position information is included in output
     * <p>A control for selecting whether OIS position information is included in output
     * result metadata.</p>
     * result metadata.</p>
     * <p>When set to ON,
     * {@link CaptureResult#STATISTICS_OIS_TIMESTAMPS android.statistics.oisTimestamps}, android.statistics.oisShiftPixelX,
     * and android.statistics.oisShiftPixelY provide OIS data in the output result metadata.</p>
     * <p><b>Possible values:</b>
     * <p><b>Possible values:</b>
     * <ul>
     * <ul>
     *   <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
     *   <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
@@ -3922,8 +3919,6 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
     * <p><b>Available values for this device:</b><br>
     * <p><b>Available values for this device:</b><br>
     * android.Statistics.info.availableOisDataModes</p>
     * android.Statistics.info.availableOisDataModes</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     * @see CaptureResult#STATISTICS_OIS_TIMESTAMPS
     * @see #STATISTICS_OIS_DATA_MODE_OFF
     * @see #STATISTICS_OIS_DATA_MODE_OFF
     * @see #STATISTICS_OIS_DATA_MODE_ON
     * @see #STATISTICS_OIS_DATA_MODE_ON
     */
     */
@@ -3939,8 +3934,8 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     *
     * @see CaptureResult#SENSOR_TIMESTAMP
     * @see CaptureResult#SENSOR_TIMESTAMP
     * @hide
     */
     */
    @PublicKey
    public static final Key<long[]> STATISTICS_OIS_TIMESTAMPS =
    public static final Key<long[]> STATISTICS_OIS_TIMESTAMPS =
            new Key<long[]>("android.statistics.oisTimestamps", long[].class);
            new Key<long[]>("android.statistics.oisTimestamps", long[].class);


@@ -3948,16 +3943,14 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
     * <p>An array of shifts of OIS samples, in x direction.</p>
     * <p>An array of shifts of OIS samples, in x direction.</p>
     * <p>The array contains the amount of shifts in x direction, in pixels, based on OIS samples.
     * <p>The array contains the amount of shifts in x direction, in pixels, based on OIS samples.
     * A positive value is a shift from left to right in active array coordinate system. For
     * A positive value is a shift from left to right in active array coordinate system. For
     * example, if the optical center is (1000, 500) in active array coordinates, an shift of
     * example, if the optical center is (1000, 500) in active array coordinates, a shift of
     * (3, 0) puts the new optical center at (1003, 500).</p>
     * (3, 0) puts the new optical center at (1003, 500).</p>
     * <p>The number of shifts must match the number of timestamps in
     * <p>The number of shifts must match the number of timestamps in
     * {@link CaptureResult#STATISTICS_OIS_TIMESTAMPS android.statistics.oisTimestamps}.</p>
     * android.statistics.oisTimestamps.</p>
     * <p><b>Units</b>: Pixels in active array.</p>
     * <p><b>Units</b>: Pixels in active array.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     * @hide
     * @see CaptureResult#STATISTICS_OIS_TIMESTAMPS
     */
     */
    @PublicKey
    public static final Key<float[]> STATISTICS_OIS_X_SHIFTS =
    public static final Key<float[]> STATISTICS_OIS_X_SHIFTS =
            new Key<float[]>("android.statistics.oisXShifts", float[].class);
            new Key<float[]>("android.statistics.oisXShifts", float[].class);


@@ -3965,19 +3958,34 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
     * <p>An array of shifts of OIS samples, in y direction.</p>
     * <p>An array of shifts of OIS samples, in y direction.</p>
     * <p>The array contains the amount of shifts in y direction, in pixels, based on OIS samples.
     * <p>The array contains the amount of shifts in y direction, in pixels, based on OIS samples.
     * A positive value is a shift from top to bottom in active array coordinate system. For
     * A positive value is a shift from top to bottom in active array coordinate system. For
     * example, if the optical center is (1000, 500) in active array coordinates, an shift of
     * example, if the optical center is (1000, 500) in active array coordinates, a shift of
     * (0, 5) puts the new optical center at (1000, 505).</p>
     * (0, 5) puts the new optical center at (1000, 505).</p>
     * <p>The number of shifts must match the number of timestamps in
     * <p>The number of shifts must match the number of timestamps in
     * {@link CaptureResult#STATISTICS_OIS_TIMESTAMPS android.statistics.oisTimestamps}.</p>
     * android.statistics.oisTimestamps.</p>
     * <p><b>Units</b>: Pixels in active array.</p>
     * <p><b>Units</b>: Pixels in active array.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     *
     * @hide
     * @see CaptureResult#STATISTICS_OIS_TIMESTAMPS
     */
     */
    @PublicKey
    public static final Key<float[]> STATISTICS_OIS_Y_SHIFTS =
    public static final Key<float[]> STATISTICS_OIS_Y_SHIFTS =
            new Key<float[]>("android.statistics.oisYShifts", float[].class);
            new Key<float[]>("android.statistics.oisYShifts", float[].class);


    /**
     * <p>An array of OIS samples.</p>
     * <p>Each OIS sample contains the timestamp and the amount of shifts in x and y direction,
     * in pixels, of the OIS sample.</p>
     * <p>A positive value for a shift in x direction is a shift from left to right in active array
     * coordinate system. For example, if the optical center is (1000, 500) in active array
     * coordinates, a shift of (3, 0) puts the new optical center at (1003, 500).</p>
     * <p>A positive value for a shift in y direction is a shift from top to bottom in active array
     * coordinate system. For example, if the optical center is (1000, 500) in active array
     * coordinates, a shift of (0, 5) puts the new optical center at (1000, 505).</p>
     * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
     */
    @PublicKey
    @SyntheticKey
    public static final Key<android.hardware.camera2.params.OisSample[]> STATISTICS_OIS_SAMPLES =
            new Key<android.hardware.camera2.params.OisSample[]>("android.statistics.oisSamples", android.hardware.camera2.params.OisSample[].class);

    /**
    /**
     * <p>Tonemapping / contrast / gamma curve for the blue
     * <p>Tonemapping / contrast / gamma curve for the blue
     * channel, to use when {@link CaptureRequest#TONEMAP_MODE android.tonemap.mode} is
     * channel, to use when {@link CaptureRequest#TONEMAP_MODE android.tonemap.mode} is
+57 −3
Original line number Original line Diff line number Diff line
@@ -22,12 +22,12 @@ import android.graphics.Rect;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.marshal.Marshaler;
import android.hardware.camera2.marshal.MarshalQueryable;
import android.hardware.camera2.marshal.MarshalQueryable;
import android.hardware.camera2.marshal.MarshalRegistry;
import android.hardware.camera2.marshal.MarshalRegistry;
import android.hardware.camera2.marshal.Marshaler;
import android.hardware.camera2.marshal.impl.MarshalQueryableArray;
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.MarshalQueryableBlackLevelPattern;
import android.hardware.camera2.marshal.impl.MarshalQueryableBoolean;
import android.hardware.camera2.marshal.impl.MarshalQueryableColorSpaceTransform;
import android.hardware.camera2.marshal.impl.MarshalQueryableColorSpaceTransform;
import android.hardware.camera2.marshal.impl.MarshalQueryableEnum;
import android.hardware.camera2.marshal.impl.MarshalQueryableEnum;
import android.hardware.camera2.marshal.impl.MarshalQueryableHighSpeedVideoConfiguration;
import android.hardware.camera2.marshal.impl.MarshalQueryableHighSpeedVideoConfiguration;
@@ -48,6 +48,7 @@ import android.hardware.camera2.marshal.impl.MarshalQueryableString;
import android.hardware.camera2.params.Face;
import android.hardware.camera2.params.Face;
import android.hardware.camera2.params.HighSpeedVideoConfiguration;
import android.hardware.camera2.params.HighSpeedVideoConfiguration;
import android.hardware.camera2.params.LensShadingMap;
import android.hardware.camera2.params.LensShadingMap;
import android.hardware.camera2.params.OisSample;
import android.hardware.camera2.params.ReprocessFormatsMap;
import android.hardware.camera2.params.ReprocessFormatsMap;
import android.hardware.camera2.params.StreamConfiguration;
import android.hardware.camera2.params.StreamConfiguration;
import android.hardware.camera2.params.StreamConfigurationDuration;
import android.hardware.camera2.params.StreamConfigurationDuration;
@@ -56,8 +57,8 @@ import android.hardware.camera2.params.TonemapCurve;
import android.hardware.camera2.utils.TypeReference;
import android.hardware.camera2.utils.TypeReference;
import android.location.Location;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationManager;
import android.os.Parcelable;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.ServiceSpecificException;
import android.os.ServiceSpecificException;
import android.util.Log;
import android.util.Log;
import android.util.Size;
import android.util.Size;
@@ -614,6 +615,15 @@ public class CameraMetadataNative implements Parcelable {
                        return (T) metadata.getLensShadingMap();
                        return (T) metadata.getLensShadingMap();
                    }
                    }
                });
                });
        sGetCommandMap.put(
                CaptureResult.STATISTICS_OIS_SAMPLES.getNativeKey(),
                        new GetCommand() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
                        return (T) metadata.getOisSamples();
                    }
                });
    }
    }


    private int[] getAvailableFormats() {
    private int[] getAvailableFormats() {
@@ -962,6 +972,50 @@ public class CameraMetadataNative implements Parcelable {
        return tc;
        return tc;
    }
    }


    private OisSample[] getOisSamples() {
        long[] timestamps = getBase(CaptureResult.STATISTICS_OIS_TIMESTAMPS);
        float[] xShifts = getBase(CaptureResult.STATISTICS_OIS_X_SHIFTS);
        float[] yShifts = getBase(CaptureResult.STATISTICS_OIS_Y_SHIFTS);

        if (timestamps == null) {
            if (xShifts != null) {
                throw new AssertionError("timestamps is null but xShifts is not");
            }

            if (yShifts != null) {
                throw new AssertionError("timestamps is null but yShifts is not");
            }

            return null;
        }

        if (xShifts == null) {
            throw new AssertionError("timestamps is not null but xShifts is");
        }

        if (yShifts == null) {
            throw new AssertionError("timestamps is not null but yShifts is");
        }

        if (xShifts.length != timestamps.length) {
            throw new AssertionError(String.format(
                    "timestamps has %d entries but xShifts has %d", timestamps.length,
                    xShifts.length));
        }

        if (yShifts.length != timestamps.length) {
            throw new AssertionError(String.format(
                    "timestamps has %d entries but yShifts has %d", timestamps.length,
                    yShifts.length));
        }

        OisSample[] samples = new OisSample[timestamps.length];
        for (int i = 0; i < timestamps.length; i++) {
            samples[i] = new OisSample(timestamps[i], xShifts[i], yShifts[i]);
        }
        return samples;
    }

    private <T> void setBase(CameraCharacteristics.Key<T> key, T value) {
    private <T> void setBase(CameraCharacteristics.Key<T> key, T value) {
        setBase(key.getNativeKey(), value);
        setBase(key.getNativeKey(), value);
    }
    }
Loading