Fix calibration/alignment with larger frame buffers

pull/61/head
IanSB 2019-03-23 17:15:54 +00:00
rodzic e7c680fdfd
commit 628e24be9e
1 zmienionych plików z 16 dodań i 12 usunięć

Wyświetl plik

@ -857,9 +857,9 @@ int *diff_N_frames_by_sample(capture_info_t *capinfo, int n, int mode7, int elk)
t = _get_cycle_counter(); t = _get_cycle_counter();
#endif #endif
// Compare the frames // Compare the frames
uint32_t *fbp = (uint32_t *)(capinfo->fb + ((ret >> OFFSET_LAST_BUFFER) & 3) * capinfo->height * capinfo->pitch); uint32_t *fbp = (uint32_t *)(capinfo->fb + ((ret >> OFFSET_LAST_BUFFER) & 3) * capinfo->height * capinfo->pitch + capinfo->v_adjust * capinfo->pitch);
uint32_t *lastp = (uint32_t *)last; uint32_t *lastp = (uint32_t *)last + capinfo->v_adjust * (capinfo->pitch >> 2);
for (int y = 0; y < capinfo->height; y++) { for (int y = 0; y < (capinfo->nlines << capinfo->heightx2); y++) {
int skip = 0; int skip = 0;
// Calculate the capture scan line number (allowing for a double hight framebuffer) // Calculate the capture scan line number (allowing for a double hight framebuffer)
// (capinfo->height is the framebuffer height after any doubling) // (capinfo->height is the framebuffer height after any doubling)
@ -993,18 +993,21 @@ signed int analyze_mode7_alignment(capture_info_t *capinfo) {
int ret = rgb_to_fb(capinfo, flags); int ret = rgb_to_fb(capinfo, flags);
// Work out the base address of the frame buffer that was used // Work out the base address of the frame buffer that was used
uint32_t *fbp = (uint32_t *)(capinfo->fb + ((ret >> OFFSET_LAST_BUFFER) & 3) * capinfo->height * capinfo->pitch); uint32_t *fbp = (uint32_t *)(capinfo->fb + ((ret >> OFFSET_LAST_BUFFER) & 3) * capinfo->height * capinfo->pitch + capinfo->v_adjust * capinfo->pitch + capinfo->h_adjust);
// Initialize the counters // Initialize the counters
for (int i = 0; i < MODE7_CHAR_WIDTH; i++) { for (int i = 0; i < MODE7_CHAR_WIDTH; i++) {
counts[i] = 0; counts[i] = 0;
} }
// Count the pixels // Count the pixels
for (int line = 0; line < capinfo->height; line++) { uint32_t *fbp_line;
for (int line = 0; line < capinfo->nlines << capinfo->heightx2; line++) {
int index = 0; int index = 0;
for (int byte = 0; byte < capinfo->pitch; byte += 4) { fbp_line = fbp;
uint32_t word = *fbp++; for (int byte = 0; byte < (capinfo->chars_per_line << 2); byte += 4) {
uint32_t word = *fbp_line++;
int *offset = px_offset_map; int *offset = px_offset_map;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
int px = (word >> (*offset++)) & 7; int px = (word >> (*offset++)) & 7;
@ -1014,6 +1017,7 @@ signed int analyze_mode7_alignment(capture_info_t *capinfo) {
index = (index + 1) % MODE7_CHAR_WIDTH; index = (index + 1) % MODE7_CHAR_WIDTH;
} }
} }
fbp += capinfo->pitch >> 2;
} }
// Log the raw counters // Log the raw counters
@ -1046,9 +1050,9 @@ signed int analyze_mode7_alignment(capture_info_t *capinfo) {
} }
} }
log_info("minima at index: %d", min_i); log_info("minima at index: %d", min_i);
// That minima should occur in pixels 0 and 1, so compute a delay to make this so // That minima should occur in pixels 0 and 1, so compute a delay to make this so
return MODE7_CHAR_WIDTH - min_i; return (MODE7_CHAR_WIDTH - min_i);
} }
#define DEFAULT_CHAR_WIDTH 8 #define DEFAULT_CHAR_WIDTH 8