Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

Checking Packing and Row Stride When an Industrial Camera's RAW10 Image Skews | Crystal & Oscillator Handbook

A raw export from an industrial camera is readable, but rows shift diagonally from the second line. Another pixel format works. Check whether four samples share five bytes or each sample occupies a 16-bit storage word, then verify actual bytes per row. Both formats can contain ten valid bits per sample while using different strides. A correct clock reading cannot tell the application where a row starts.

Use offline synthetic blocks and digital test images. This example records neither people nor real environments and does not operate field cameras, control networks, or running systems. Its values illustrate memory layout and do not specify sensor or link performance.

Ten bits of precision do not determine storage layout

Some packed Bayer formats combine four ten-bit samples in five bytes. In the example packing, the first four bytes carry one sample's upper eight bits each, and the fifth holds two low bits from each sample. An unpacked layout may place each sample in a 16-bit word with remaining bits specified by the format. One must be decoded by group and the other by word. Verify bit alignment and byte order from the defined format.

The format on the sensor link can differ from the driver's output buffer. Capture hardware may preserve or unpack it, and some modes pad data for alignment. An application that assumes wire packing can unpack twice. An application that uses only bit depth can mistake packed data for words. Check sensor, capture driver, and application separately when interface hardware, software, or capture modes change.

Bayer order is another variable. Color errors may come from an incorrect starting color or a crop that changes the assumed phase. First interpret pixel placement, row stride, and packing correctly, then check color order. Changing both together obscures the cause.

A width of 1920 samples can yield three different row lengths

Suppose an active line has 1920 pixels and no embedded data. Four pixels per five-byte group means 480 groups and 2400 active bytes. If the ten-bit pixels occupy 16-bit words, they use 3840 bytes. Neither calculation establishes the actual offset of the next row.

Suppose the driver reports a packed stride of 2560 bytes. There are 2400 active bytes and 160 bytes of hypothetical padding. Row one begins at zero and row two at 2560. Advancing by 2400 starts row two 160 bytes early, with another 160 bytes of accumulated error per row. The image may show diagonal bands or block displacement depending on data and parser behavior. These are illustrative offsets and not device measurements.

Use one set of four samples that vary only in the low two bits and another set that varies in the upper bits. Verify which sample receives each part of the fifth byte. Periodic errors affecting one pixel per group or the four lowest brightness codes suggest unpacking. A valid first row followed by systematic shifts suggests stride. Use known expected values rather than judging a natural-looking picture.

Symptom with synthetic inputCheck first
Periodic group errors already in row onePacked versus expanded layout, group size, high and low bits
First row works and later rows progressively shiftReported row bytes, padding, and buffer boundaries
Positions match but color changes after croppingBayer phase and crop conventions
Raw input is incomplete and the link has other faultsCapture integrity, supply, reference, and interface state
Preview is blurry but offline pixels matchApplication preview, interpolation, or display mode

Qualify the format and the 24 MHz reference separately

A hypothetical active 24 MHz reference may feed an image device's external clock input. Internal circuits can then generate acquisition and link clocks. That frequency does not set bytes per row or imply that all serial signals share the same rate. If capture is complete and the same file renders differently under different parsers, isolate interpretation first. Verify the local clock separately. If the buffer is short or unstable before parsing, investigate acquisition and reception using hardware evidence.

SCTF's mainland China 2C series lists SX2M24.000B10F20TNN as an active 24 MHz candidate. This makes no claim about installed hardware or stock. Verify order code, supply, output load, temperature range, tolerance, pins, and startup. Measure reference frequency and level at the appropriate point against the imaging device's requirements. Keep driver memory formats and sensor precision separate from oscillator attributes.

Retain a minimal test frame, original bytes, reported format, active dimensions, stride, color order, and passing and failing parser results. Keep software conditions fixed when comparing lots. Record driver and component changes independently. Some formats require a separate byte count for each plane, so apply the example only to its single-plane layout.

Frequently asked questions

If total file size matches, are all rows correctly aligned? Headers, metadata, and per-row padding can produce the expected total even when row starts are wrong. Verify boundaries with a known pattern.

Can we ship a narrower image if reducing width removes the bands? This can make an incorrect stride happen to match the buffer. Establish actual layout and active dimensions before accepting the original image and other modes.

Check input length before decoding. Use the row count and stride to locate the last active row. If remaining data cannot hold a full group, report truncation or unverified layout without reading beyond the buffer. For leading metadata, calculate image start offset separately from row stride.

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.