edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Auto colour: one correction read off a picture, as the colour card's Auto |
| 2 | //! button and the `auto_color` edit op set it. |
| 3 | //! |
| 4 | //! Two readings, both on the clip as shot (the ungraded frame), so the values |
| 5 | //! it writes are absolute and a second press lands where the first did: |
| 6 | //! |
| 7 | //! * grey-world white balance: each channel's mean is moved to the average of |
| 8 | //! the three means, by the wheels' per-channel gain (`1 + gain`, so the |
| 9 | //! correction is a multiplier in R'G'B'), |
| 10 | //! * a luma stretch: after that balance, the 0.5 % and 99.5 % luma percentiles |
| 11 | //! are carried to 0.02 and 0.98 by the contrast and brightness sliders. The |
| 12 | //! sliders pivot on mid grey and move in luma-range units, so a linear stretch |
| 13 | //! `v' = a v + b` is exactly `contrast = a` with `brightness = b + (a - 1) / 2`. |
| 14 | //! |
| 15 | //! Nothing else is touched: saturation, tint, lift, gamma, curves and the LUT |
| 16 | //! keep what the clip has. A flat frame, one with no luma spread to stretch, |
| 17 | //! gets no stretch at all. |
| 18 | |
| 19 | use crateColorParams; |
| 20 | |
| 21 | /// Luma the low percentile lands on. |
| 22 | pub const LOW_TARGET: f32 = 0.02; |
| 23 | /// Luma the high percentile lands on. |
| 24 | pub const HIGH_TARGET: f32 = 0.98; |
| 25 | /// Percentiles read off the balanced frame. |
| 26 | const LOW_PCT: f32 = 0.005; |
| 27 | const HIGH_PCT: f32 = 0.995; |
| 28 | /// Pixels read per frame, at most: a strided grid, as the scopes read theirs. |
| 29 | const MAX_SAMPLES: usize = 65_536; |
| 30 | /// Bins of the luma histogram the percentiles are read from. |
| 31 | const BINS: usize = 1024; |
| 32 | |
| 33 | /// The correction one frame calls for. Plain numbers, so the card and the MCP |
| 34 | /// op can both say what they set. |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | /// Reads the correction off one packed RGB8 frame (`width * height` pixels, |
| 50 | /// three bytes each). `None` when the buffer does not hold that many pixels or |
| 51 | /// there are none. |
| 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 | /// The luma at `pct` of the histogram, as 0..1. |
| 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 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 |