Release 0.13.3

This commit is contained in:
matze19999 committed 2026-10-12 18:23:52 +02:00
1 parent 2f6efd9864
commit ef03258e22
12 files changed
+58 -13

No files matched your search

+25 -2
View File
@@ -4,14 +4,17 @@
* or dark frame so darkness alone cannot switch the active capture mode. */
static inline int letterbox_candidate(const unsigned black[16], const unsigned char color[16][3]) {
const unsigned interior[] = {2, 6, 10, 15};
unsigned lit = 0;
unsigned lit = 0, interior_black = 0, interior_peak = 0;
for (unsigned i = 0; i < 4; i++) {
unsigned r = interior[i], peak = color[r][0];
for (unsigned c = 1; c < 3; c++)
if (color[r][c] > peak)
peak = color[r][c];
if (black[r] < 20 && peak > 35)
if (black[r] < 20 && peak > 35) {
lit++;
interior_black += black[r];
interior_peak += peak;
}
}
if (lit < 2)
return -1;
@@ -19,6 +22,26 @@ static inline int letterbox_candidate(const unsigned black[16], const unsigned c
unsigned bottom = (black[1] + black[5] + black[9]) / 3;
if (top >= 55 && bottom >= 25)
return 1;
/* Thin bars occupy only part of an edge probe. Require a broad upper
* dark edge, lower-edge support and contrast against lit interior probes.
* This remains a histogram heuristic, not a pixel-accurate crop. */
const unsigned top_regions[] = {3, 11, 12};
const unsigned bottom_regions[] = {1, 5, 9};
unsigned top_support = 0, bottom_support = 0, top_peak = 0;
for (unsigned i = 0; i < 3; i++) {
unsigned r = top_regions[i], peak = color[r][0];
for (unsigned c = 1; c < 3; c++)
if (color[r][c] > peak)
peak = color[r][c];
top_peak += peak;
top_support += black[r] >= 12;
bottom_support += black[bottom_regions[i]] >= 8;
}
unsigned baseline = interior_black / lit;
if (top_support == 3 && bottom_support >= 2 && top >= 12 && bottom >= 10 &&
top >= baseline + 8 && bottom >= baseline + 8 &&
(unsigned long)top_peak * lit * 100 <= (unsigned long)interior_peak * 3 * 60)
return 1;
if (top < 20 && bottom < 20)
return 0;
return -1;
+18 -1
View File
@@ -11,5 +11,22 @@ int main(void){
for(unsigned i=0;i<16;i++)black[i]=100;
memset(color,0,sizeof(color));assert(letterbox_candidate(black,color)==-1);
memset(black,0,sizeof(black));assert(letterbox_candidate(black,color)==-1);
puts("PASS: full frame, measured letterbox, one edge only, black frame, dark frame");
unsigned thin_black[16]={12,23,1,21,9,6,6,16,18,12,26,23,23,22,37,8};
unsigned char thin_color[16][3]={{57,52,48},{97,94,92},{51,42,35},{25,24,21},
{71,65,60},{128,122,118},{84,74,67},{34,32,27},{47,41,36},{59,47,43},
{37,29,25},{19,18,15},{22,20,16},{22,19,15},{14,13,11},{78,75,72}};
assert(letterbox_candidate(thin_black,thin_color)==1);
thin_black[1]=thin_black[5]=thin_black[9]=0;
assert(letterbox_candidate(thin_black,thin_color)!=1);
thin_black[1]=23;thin_black[5]=6;thin_black[9]=12;
thin_black[11]=0;
assert(letterbox_candidate(thin_black,thin_color)!=1);
thin_black[11]=23;
memset(thin_color,10,sizeof(thin_color));
assert(letterbox_candidate(thin_black,thin_color)==-1);
memset(thin_color,100,sizeof(thin_color));
assert(letterbox_candidate(thin_black,thin_color)!=1);
memset(thin_black,15,sizeof(thin_black));
assert(letterbox_candidate(thin_black,thin_color)!=1);
puts("PASS: measured wide/thin bars, full frame, one-sided/isolated edges, dark frame and low contrast");
}
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef HYPERDRM_VERSION_H
#define HYPERDRM_VERSION_H
#define HYPERDRM_VERSION "0.13.2"
#define HYPERDRM_VERSION "0.13.3"
#endif