Theoretically:
If you would calculate a histogram with 16384 cells, then you would find Pmax1 and Pmax2 also in the histogram. Right?
Not sure how much you lose, if you calculate the histogram for 1024 cells and uses Pmax1 and Pmax2 from this histogram.
Yes, that's exactly what I do in my original, Tlapser.lua script. You can find pmax1 by finding the largest non-zero histogram array index.
The advantage of the extra precision is with underexposed images, when pmax2 tells you how much to increase the exposure on the next shot. But i don't think that's very important in practice, so 10 bit images would work almost as well.
If I understand you correctly, even at time-lapse in the sun you exposure to the right with no overexposure at all?
I do the same with rawopint with moon time-lapse by setting the Overexposure threshold to 0.005%. That gives me nearly ETTR.
If I use these parameters for the sun, I got massive underexposed pictures. On my G1x (at focal length 28mm) I set Overexposure threshold to 1%. In this case, approximately only the core of the sun is overexposed. I’m not sure how much EV steps between 0.005%. and 1%.
I’m thinking about of additional logging Pmax1 and Pmax2 in rawopint. In cases of overexposed scene of 1%, Pmax1 and Pmax2 would be always white correct? To see how much there are floating, I have to use a scene with no overexposure or I have set Overexposure threshold to 0.005%.
I think the "overexposure threshold" sets a limit to how many pixels can be overexposed at the top of the histogram. I tried it that way in Tlapser.lua, but it was difficult to hit that number accurately. For the Sun and Moon, the overexposure threshold depends on their size in the frame.
I ended up using a parameter that sets a limit to how much pmax2 can reduce the exposure below the mean. For sunsets, I usually use 2.5 ev. But even with no limit, it's not possible to get to ETTR with the Sun without a solar filter. You always hit the minimum exposure.
If you define overexposed as having totally white pixels, then pmax1, and pmax2 will be white. That's why I also counted the number of white pixels in my changes to rawop_meter. It's a measurement of how badly overexposed the image is, without having to calculate the entire histogram.
By the way, in addition to finding pmax1 and pmax2 from the histogram, you could also find the mean from it, eliminating the need to call rawop_meter. But computing pmax2 in rawop_meter eliminates the need for a histogram, which is better yet.
===
Many thanks for doing those tests, especially checking that rawopint works with my build. Would you mind running the massively overexposed test again, but this time check the box that says "Overflow Test?" That sets the step size to 1, which takes 10 seconds or so for each shot (be patient).
I added a 2 variable 64 bit accumulator to add up all the pixels in the image for computing the mean in rawop_meter. That eliminates the possibility of overflow, allowing you to use a smaller step size. That will be useful, say, when the Moon is in a wide angle shot, where its width is smaller than the normal step size.