[sane-devel] genesys: OpticFilm 8200i SE (GL128) blue offset overwritten before each scan, patch attached

Aidan Siegel aidansiegel at mac.com
Fri Nov 6 22:24:04 GMT 2026


Hello, 

> I scanned 66 frames of 35 mm color negatives on a Plustek OpticFilm 8200i SE (USB 07b3:1825) using sane-backends master from Nov 4. The backend's warning asks for reports, so here's one. Every frame came back with blue clipped to zero in places, while red and green never reach zero. On a dense Kodak GC 400 roll, 86-97% of the blue samples in the middle of three frames are exactly 0.
> 
> The cause looks like a cached register write that overwrites the blue offset right before the scan. A patch with two regression tests is attached (gl128-afe-port-replay.diff). It passes the unit tests but hasn't been tried on the scanner yet, so a second set of eyes would help.
> 
> CommandSetGl128::asic_boot() writes each BOOT_REGS entry to the scanner and also caches it in dev->reg. One of those entries is 0x5e=0x1f. On GL128, 0x51/0x5d/0x5e (REG_FE_INDEX/REG_FE_HIGH/REG_FE_LOW) are the frontend bridge: 0x51 selects an AFE register, and a write to 0x5e commits 0x5d:0x5e to it.
> 
> set_fe() programs AFE registers 0-7 in order and leaves index 7 selected. When genesys_start_scan() then writes dev->reg, the cached 0x5e=0x1f goes out again and AFE register 7, the blue offset, changes from 61 to 31. begin_scan() doesn't reprogram the AFE, so the image is acquired with that value. genesys_warmup_lamp() and the calibration error paths in genesys.cpp write the same cached set.
> 
> (On this AFE, registers 5-7 are the 9-bit offsets and 2-4 the 6-bit gains. The gain/offset labels in tables_frontend.cpp for this model are the other way round; that doesn't affect behavior.)
> 
> With the patch, asic_boot() still writes every boot value to the scanner in the same order, but no longer caches REG_FE_INDEX, REG_FE_HIGH or REG_FE_LOW in dev->reg. Only 0x5e is in the boot table today; excluding all three keeps it correct if the table changes. Fixing it at the cache covers every path that writes dev->reg, not just scan start.
> 
> The patch also adds two tests. One checks that dev->reg holds none of the bridge registers after asic_boot(). The other uses a test interface that tracks AFE registers through the bridge, runs asic_boot() and set_fe(), writes dev->reg the way genesys_start_scan() does, and checks that every AFE register is unchanged.
> 
> Here's genesys_unit_tests on master b2268a78 (macOS, Apple clang, BACKENDS=genesys):
> 
>     Master with the new tests: 1060 pass, 2 fail (AFE register 7: 31 != 61)
>     Patched: 1062 pass, 0 fail
> 
> Details are in validation.txt, and the full runs are in unit-tests-master.log.gz and unit-tests-patched.log.gz.
> 
> All 66 captures used default options, and the build had no local patches. capture-record.txt has the build, the command and the full option listing. The scans were made with master 6b5186ad; gl128.cpp differs from b2268a78 only by the cf0d9839 build fix.
> 
> In the opaque area around the film, red reads about 510 and green about 460, while blue is 0 for 100% of samples. Blue's black level is sitting below zero and getting clamped. water-tower-channel-comparison.png shows the three channels of a cropped portion of one frame from the GC 400 roll, unprocessed and over the same linear range: 79% of the blue samples in the crop are exactly 0, and red and green have none. water-tower-visual-comparison.png only illustrates the visible color shift in that frame (the right side is a post-processing correction, not a rescan).
> 
> pool-channel-comparison.png is a cropped portion of a second frame from the same roll, where 99.4% of the blue samples in the crop are exactly 0. Crop coordinates, source checksums and the exact counts for both are in sample-notes.txt and the two *-measurements.json files.
> 
> I can't say the overwrite is the only cause until the same frame is rescanned with and without the patch. That will take a while: the scanner belongs to a library, and I only get time on it twice a month for a short session, so I can't do much experimenting. If there's a specific test that would tell you the most, let me know and I'll try to fit it into a visit.
> 
> The same replay was reported against pyopticfilm and fixed there, with an A/B hardware comparison on this model:
> 
>     https://github.com/jboneng/pyopticfilm/issues/97
>     https://github.com/jboneng/pyopticfilm/pull/118
> 
> SANE's GL128 support (MR !1030) predates that fix. The open MR !1059 changes this model's calibration but still caches the boot 0x5e write. I couldn't find an existing SANE issue or MR for this.
> 
> Issue #886 compares SANE's output with the standalone plustek8200i backend on the same scanner and finds the genesys colors greener. A low blue offset would do that, though I haven't checked it against those scans.
> 
> AI notice: the bug was found by Codex (Sol 6.1) while analyzing my scans and verified independently by Claude Opus 5.5, which also wrote the patch and tests.
> 
> The unprocessed 16-bit TIFF crops behind both figures are too big for the list, so they're here if anyone wants to check the counts, along with a copy of the color comparison:
> 
>     https://aidansiegel.com/sane/gl128-blue/water-tower-crop-rgb16.tif
>     https://aidansiegel.com/sane/gl128-blue/pool-crop-rgb16.tif
>     https://aidansiegel.com/sane/gl128-blue/water-tower-visual-comparison.png
>     https://aidansiegel.com/sane/gl128-blue/SHA256SUMS
> 
> The TIFFs are the raw linear negative data, so they look almost black in an image viewer (and most browsers won't display TIFF at all): the brightest channel in the pool crop peaks at 6588 of 65535, about 10% of full scale. The channel-comparison PNGs show the same pixels stretched to 0-6000.
> 
> Thanks,
> Aidan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0012.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gl128-afe-port-replay.diff
Type: application/x-apple-msg-attachment
Size: 5302 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0003.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0013.htm>
-------------- next part --------------
Base revision: b2268a787797a308c1bf53ef4036626a8c0e3bc9 (upstream master, 2026-11-05)

 backend/genesys/gl128.cpp                 | 10 +++-
 testsuite/backend/genesys/tests_gl128.cpp | 96 +++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 2 deletions(-)

git diff --check: PASS
git apply --check against a clean checkout of the base revision: PASS

Build: ./autogen.sh; BACKENDS=genesys ./configure; make in include, lib, sanei, backend;
make -C testsuite/backend/genesys genesys_unit_tests (macOS, Apple clang).

Master driver with the new tests:
  Finished tests. Successes: 1060 failures: 2
  FAILURE at tests_gl128.cpp:235 in test_gl128_boot_does_not_cache_fe_bridge
  FAILURE at tests_gl128.cpp:309 in test_gl128_afe_survives_register_flush : 31 != 61

Patched:
  Finished tests. Successes: 1062 failures: 0

No physical scanner test of the patch has been performed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0014.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unit-tests-master.log.gz
Type: application/x-gzip
Size: 2518 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0004.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0015.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unit-tests-patched.log.gz
Type: application/x-gzip
Size: 2481 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0005.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0016.htm>
-------------- next part --------------
Capture record

Scanner: PLUSTEK OpticFilm 8200i SE (USB 07b3:1825), transparency adapter, macOS.
Captures: 66 frames of 35 mm color negative film, 2026-11-04. All used the same command and options.

Build
  Source: sane-backends master tarball, built 2026-11-04; branch head at the time 6b5186adb14a8c83a74383068ef3c1f0d4c20c4e.
  Local patches: none.
  Backends: genesys, test.
  CFLAGS: -O1 -g0   CXXFLAGS: -O1 -g0 -std=c++14
  (C++14 because Apple libc++ rejected the GL128 constexpr std::pair table under C++11; fixed upstream by cf0d9839.)
  configure: --disable-static --enable-local-backends --with-usb=yes --without-gphoto2 --without-snmp --without-avahi --without-systemd --disable-locking
  Between this revision and b2268a78 (the revision the patch is tested on), backend/genesys/gl128.cpp differs only by cf0d9839.

Version: scanimage (sane-backends) 1.4.0-dev; backend version 1.4.0

Command
  scanimage --device-name=genesys "--source=Transparency Adapter" --mode=Color --depth=16 --resolution=7200 --format=tiff --progress

Backend output during each scan (progress lines omitted)
  WARNING: Your scanner is not fully supported or at least
           had only limited testing. Please be careful and
           report any failure/success to
           sane-devel at alioth-lists.debian.net. Please provide as many
           details as possible, e.g. the exact name of your
           scanner and what does (not) work.

Options as reported by scanimage --help with the above settings
  All options specific to device `genesys':
    Scan Mode:
      --mode Color|Gray [Color]
          Selects the scan mode (e.g., lineart, monochrome, or color).
      --source Transparency Adapter [Transparency Adapter]
          Selects the scan source (such as a document-feeder).
      --preview[=(yes|no)] [no]
          Request a preview-quality scan.
      --depth 16 [16]
          Number of bits per sample, typical values are 1 for "line-art" and 8
          for multibit scans.
      --resolution 7200|3600|2400|1800|1440|1200|900|720|600|300|150dpi [7200]
          Sets the resolution of the scanned image.
    Geometry:
      -l 0..36.58mm [0]
          Top-left x position of scan area.
      -t 0..25mm [0]
          Top-left y position of scan area.
      -x 0..36.58mm [36.58]
          Width of scan-area.
      -y 0..25mm [25]
          Height of scan-area.
    Enhancement:
      --custom-gamma[=(yes|no)] [inactive]
          Determines whether a builtin or a custom gamma-table should be used.
      --gamma-table 0..65535,... [inactive]
          Gamma-correction table.  In color mode this option equally affects the
          red, green, and blue channels simultaneously (i.e., it is an intensity
          gamma table).
      --red-gamma-table 0..65535,... [inactive]
          Gamma-correction table for the red band.
      --green-gamma-table 0..65535,... [inactive]
          Gamma-correction table for the green band.
      --blue-gamma-table 0..65535,... [inactive]
          Gamma-correction table for the blue band.
      --brightness -100..100 (in steps of 1) [inactive]
          Controls the brightness of the acquired image.
      --contrast -100..100 (in steps of 1) [inactive]
          Controls the contrast of the acquired image.
    Extras:
      --lamp-off-time 0..60 [15]
          The lamp will be turned off after the given time (in minutes). A value
          of 0 means, that the lamp won't be turned off.
      --lamp-off-scan[=(yes|no)] [no]
          The lamp will be turned off during scan. 
      --color-filter Red|Green|Blue [inactive]
          When using gray or lineart this option selects the used color.
      --calibration-file <string> [] [advanced]
          Specify the calibration file to use
      --expiration-time -1..30000 (in steps of 1) [60]
          Time (in minutes) before a cached calibration expires. A value of 0
          means cache is not used. A negative value means cache never expires.
    Sensors:
    Buttons:
      --clear-calibration [advanced]
          Clear calibration cache
      --force-calibration [advanced]
          Force calibration ignoring all and any calibration caches
      --ignore-internal-offsets [advanced]
          Acquires the image including the internal calibration areas of the
          scanner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0017.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: water-tower-channel-comparison.png
Type: image/png
Size: 245513 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0003.png>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0018.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: water-tower-visual-comparison.png
Type: image/png
Size: 657358 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0004.png>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0019.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: water-tower-crop-measurements.json
Type: application/json
Size: 883 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0002.json>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0020.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool-channel-comparison.png
Type: image/png
Size: 269666 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0005.png>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0021.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool-crop-measurements.json
Type: application/json
Size: 868 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0003.json>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0022.htm>
-------------- next part --------------
Image sample notes

Water tower frame

Original source TIFF SHA-256: 59e7bbafebb5a22d3124c5511e395426b3d3845e2b0183be31c5d5d7fd357969
Original dimensions: 10369 x 7034, unsigned 16-bit RGB.
Crop in original unrotated coordinates, origin top-left: x=2720, y=2880, width=2176, height=1760 (right/bottom exclusive: 4896, 4640).
The crop is then rotated 90 degrees clockwise so the photograph is upright. No interpolation, color conversion, resizing, or numerical sample modification is used for water-tower-crop-rgb16.tif. Lossless Deflate compression is used. The saved TIFF was decoded and verified pixel-for-pixel against the rotated source rectangle.

Pixels: 3829760
Red exact zeros: 0
Green exact zeros: 0
Blue exact zeros: 3028001 (79.06504%)

water-tower-channel-comparison.png: grayscale channel displays from the raw crop, all three over the same display range, 0 to 6000 raw counts, mapped linearly to 0 to 255; values above 6000 are white. The panels are reduced for display. Zero percentages are calculated at original 16-bit precision.

water-tower-visual-comparison.png: an illustrative comparison, separate from the numerical evidence. Left: processed Plustek viewing copy of the water tower frame. Right: reference-guided color correction of the same scan, guided by an earlier scan of a print copy. This post-processing correction approximates how the scan would look with the blue tones shown in the print copy. It borrows color and broad tones from that reference and keeps fine brightness detail from the Plustek scan; it does not recover the lost blue measurements and is not a rescan with the patched driver. Both panels are resized for display.


Pool

Original source TIFF SHA-256: 04d0fa0ff85584e898adaa710104a14efb33e71ee85bba738c54a9ba3c4c9d44
Original dimensions: 10369 x 7034, unsigned 16-bit RGB.
Crop in original unrotated coordinates, origin top-left: x=1700, y=2300, width=1024, height=1536 (right/bottom exclusive: 2724, 3836).
The crop is then rotated 180 degrees by reversing pixel rows and columns. No interpolation, color conversion, resizing, or numerical sample modification is used for pool-crop-rgb16.tif. Lossless Deflate compression is used. The saved TIFF was decoded and verified pixel-for-pixel against the source rectangle after that rotation.

Pixels: 1572864
Red exact zeros: 0
Green exact zeros: 0
Blue exact zeros: 1563519 (99.40586090%)

pool-channel-comparison.png: grayscale channel displays from the raw crop. All three use the same display range, 0 to 6000 raw counts, mapped linearly to 0 to 255 for the figure; values above 6000 are white. The panels are reduced for display. Zero percentages are calculated at original 16-bit precision before display scaling.

No people appear in the submitted crops.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20261106/c9a40fab/attachment-0023.htm>


More information about the sane-devel mailing list