xie
2024-11-23 3fdfdea0721fe7a36f6aaa509075f01a194f6748
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * 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 com.android.camera.one;
 
import android.hardware.camera2.params.MeteringRectangle;
 
/**
 * Contains 3A parameters common to all camera flavors. TODO: Move to
 * GservicesHelper.
 */
public class Settings3A {
 
    /**
     * Width of touch AF region in [0,1] relative to shorter edge of the current
     * crop region. Multiply this number by the number of pixels along the
     * shorter edge of the current crop region's width to get a value in pixels.
     * <p>
     * This value has been tested on Nexus 5 and Shamu, but will need to be
     * tuned per device depending on how its ISP interprets the metering box and
     * weight.
     * 
     * <pre>
     * Values prior to L release:
     * Normal mode: 0.125 * longest edge
     * Gcam: Fixed at 300px x 300px.
     */
    private static final float AF_REGION_BOX = 0.2f;
 
    /**
     * Width of touch metering region in [0,1] relative to shorter edge of the
     * current crop region. Multiply this number by the number of pixels along
     * shorter edge of the current crop region's width to get a value in pixels.
     * <p>
     * This value has been tested on Nexus 5 and Shamu, but will need to be
     * tuned per device depending on how its ISP interprets the metering box and
     * weight.
     * 
     * <pre>
     * Values prior to L release:
     * Normal mode: 0.1875 * longest edge
     * Gcam: Fixed  ffat 300px x 300px.
     */
    private static final float AE_REGION_BOX = 0.3f;
 
    /**
     * Metering region weight between 0 and 1.
     * <p>
     * This value has been tested on Nexus 5 and Shamu, but will need to be
     * tuned per device depending on how its ISP interprets the metering box and
     * weight.
     * </p>
     */
    private static final float REGION_WEIGHT = 0.022f;
 
    /** Duration to hold after manual tap to focus. */
    private static final int FOCUS_HOLD_MILLIS = 3000;
 
    /**
     * The number of milliseconds to hold tap-to-expose/metering after the last
     * payload frame is received before returning to continuous 3A.
     */
    private static final int GCAM_POST_SHOT_FOCUS_HOLD_MILLIS = 1000;
 
    /**
     * Width of touch metering region in [0,1] relative to shorter edge of the
     * current crop region. Multiply this number by the number of pixels along
     * shorter edge of the current crop region's width to get a value in pixels.
     * <p>
     * This value has been tested on Nexus 5 and Shamu, but will need to be
     * tuned per device depending on how its ISP interprets the metering box and
     * weight.
     * </p>
     * <p>
     * Was fixed at 300px x 300px prior to L release.
     * </p>
     */
    private static final float GCAM_METERING_REGION_FRACTION = 0.1225f;
 
    /**
     * Weight of a touch metering region, in [0, \inf).
     * <p>
     * This value has been tested on Nexus 5 and Shamu, but will need to be
     * tuned per device.
     * </p>
     * <p>
     * Was fixed at 15.0f prior to L release.
     * </p>
     */
    private static final float GCAM_METERING_REGION_WEIGHT = 45.0f;
 
    /**
     * @Return The weight to use for {@link MeteringRectangle}s for 3A.
     */
    public int getMeteringWeight() {
        // TODO Determine the optimal metering region for non-HDR photos.
        int weightMin = MeteringRectangle.METERING_WEIGHT_MIN;
        int weightRange = MeteringRectangle.METERING_WEIGHT_MAX
                - MeteringRectangle.METERING_WEIGHT_MIN;
        return (int) (weightMin + GCAM_METERING_REGION_FRACTION * weightRange);
    }
 
    /**
     * @return The size of (square) metering regions, normalized with respect to
     *         the smallest dimension of the current crop-region.
     */
    public float getMeteringRegionFraction() {
        // TODO Determine the optimal metering weight for non-HDR photos.
        return GCAM_METERING_REGION_FRACTION;
    }
 
    @Deprecated
    public static float getAutoFocusRegionWidth() {
        return AF_REGION_BOX;
    }
 
    @Deprecated
    public static float getMeteringRegionWidth() {
        return AE_REGION_BOX;
    }
 
    @Deprecated
    public static float getMeteringRegionWeight() {
        return REGION_WEIGHT;
    }
 
    @Deprecated
    public static float getGcamMeteringRegionFraction() {
        return GCAM_METERING_REGION_FRACTION;
    }
 
    @Deprecated
    public static float getGcamMeteringRegionWeight() {
        return GCAM_METERING_REGION_WEIGHT;
    }
 
    @Deprecated
    public static int getFocusHoldMillis() {
        return FOCUS_HOLD_MILLIS;
    }
 
    @Deprecated
    public static int getGcamPostShotFocusHoldMillis() {
        return GCAM_POST_SHOT_FOCUS_HOLD_MILLIS;
    }
}