Implement discrete dynamic NEAR ladder strategy
This commit is contained in:
@@ -189,7 +189,13 @@ Responsibilities:
|
||||
- Keep NEAR at 0 for `ratio=0` and invalid ratio values.
|
||||
- For `ratio=1/2/3`, update the next strip's NEAR after the current strip
|
||||
output byte count is known.
|
||||
- Clamp NEAR to `0..31`.
|
||||
- Use the discrete NEAR ladder `{0, 1, 2, 4, 8, 16, 31}` instead of linear
|
||||
`+1/-1` arithmetic.
|
||||
- After strip 0, choose a coarse NEAR rung from the first strip's
|
||||
actual-vs-target ratio bucket.
|
||||
- For later strips, apply cumulative-bit micro-adjustments of `+2`, `+1`, `0`,
|
||||
`-1`, or `-2` rungs using shift-add threshold bands.
|
||||
- Clamp the resulting rung to the supported ladder endpoints.
|
||||
- Report a sticky target-miss condition when the cumulative actual bits still
|
||||
exceed cumulative target bits while NEAR is already 31.
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ flowchart TB
|
||||
SCAN["S01 jls_scan_ctrl\nIn: pixel event, current_near\nDo: start/finish one standalone strip frame, choose first-strip NEAR=0\nOut: enc pixel event, strip_start/finish, strip width/height/near\nStd: Annex A.8, Annex D.1-D.3"]
|
||||
PRESET["S02 jls_preset_defaults + jls_coding_params\nIn: PIX_WIDTH, strip NEAR\nDo: default MAXVAL/T1/T2/T3/RESET, RANGE/qbpp/LIMIT lookup\nOut: header preset fields, active coding params\nStd: Annex A.2, Annex C.2.4.1.1, Annex G.2"]
|
||||
HDR["S03 jls_header_writer\nIn: strip_start/finish, strip size, NEAR, preset params\nDo: emit SOI/SOF55/LSE/SOS and EOI, big-endian marker fields\nOut: header/eoi byte stream, original_image_start sideband\nStd: Annex C.1-C.4, Annex D.3"]
|
||||
NEAR["S04 jls_near_ctrl\nIn: image_start, strip_done, strip pixels, output bytes, ratio\nDo: cumulative actual-vs-target NEAR update and clamp 0..31\nOut: current_near, target_miss_at_max_near\nStd: NEAR usage in Annex A/C/D; dynamic policy is project-specific"]
|
||||
NEAR["S04 jls_near_ctrl\nIn: image_start, strip_done, strip pixels, output bytes, ratio\nDo: first-strip ratio bucket jump to NEAR ladder {0,1,2,4,8,16,31}; later strips use cumulative actual-vs-target +/-1 or +/-2 rung updates\nOut: current_near, target_miss_at_max_near\nStd: NEAR usage in Annex A/C/D; dynamic policy is project-specific"]
|
||||
end
|
||||
|
||||
subgraph PIX["Pixel neighborhood and mode decision"]
|
||||
@@ -87,7 +87,7 @@ flowchart TB
|
||||
| S01 | `jls_scan_ctrl` | Pixel event, `current_near`, downstream readiness. | Split the original image into standalone strip frames, emit strip start/finish commands, force the first strip NEAR to 0. | Encode pixel event, strip start/finish event, `strip_width`, `strip_height`, `strip_near`, strip pixel count. | Annex A.8; Annex D.1-D.3 scan control. |
|
||||
| S02 | `jls_preset_defaults`, `jls_coding_params` | `PIX_WIDTH`, strip `NEAR`. | Compute default `MAXVAL/T1/T2/T3/RESET`; lookup `RANGE/qbpp/LIMIT` for the active strip. | Preset fields for LSE/header and active coding parameters for regular/run mode. | Annex A.2; Annex C.2.4.1.1 preset parameters; Annex G.2 coding parameters. |
|
||||
| S03 | `jls_header_writer` | Strip start/finish, strip size, `NEAR`, preset fields. | Emit `SOI/SOF55/LSE/SOS` at strip start and `EOI` after payload flush. | Header/EOI byte stream and `original_image_start` sideband. | Annex C.1-C.4 marker syntax; Annex D.3 scan syntax. |
|
||||
| S04 | `jls_near_ctrl` | Image start ratio, strip output byte count, strip pixel count. | Project dynamic policy: cumulative actual-vs-target bits, step `NEAR` up/down, clamp to `0..31`. | `current_near`, cumulative bit counters, target-miss flag. | Standard NEAR usage is Annex A/C/D; dynamic ratio policy is project-specific. |
|
||||
| S04 | `jls_near_ctrl` | Image start ratio, strip output byte count, strip pixel count. | Project dynamic policy: use strip 0 actual-vs-target ratio bucket to jump onto the discrete NEAR ladder `{0,1,2,4,8,16,31}`, then use cumulative actual-vs-target shift-add bands to move `NEAR` by `+2`, `+1`, `0`, `-1`, or `-2` ladder steps. | `current_near`, cumulative bit counters, target-miss flag. | Standard NEAR usage is Annex A/C/D; dynamic ratio policy is project-specific. |
|
||||
| S10 | `jls_neighbor_provider` | Encode pixel event, reconstructed writeback `Rx`, active strip width, `NEAR`. | Maintain reconstructed line history in two banks, apply top/left/right edge rules, produce JPEG-LS neighbors. For `NEAR=0`, commit `X` as `Rx` immediately. For `NEAR>0`, a non-EOL writeback can overlap the next same-row pixel accept by bypassing returned `Rx` as that pixel's `Ra`; row transitions still wait one clock. Regular-mode true `Rx` returns immediately after S24 accepts the `Errval/Rx` result rather than after Golomb completion. | Neighbor event with `X`, `x/y`, `Ra/Rb/Rc/Rd`, strip flags. | Annex A.3 local gradients; Annex A.4 prediction neighborhood. |
|
||||
| S11 | `jls_mode_router` | Neighbor event, `strip_width`, `NEAR`. | Determine regular/run entry from gradients, then stay in the Annex A.7 run loop while `run_length_accum` is non-zero; accumulate matching run pixels, reconstruct them as `Ra`, and form run segments at EOL/interruption. Later non-EOL matching run pixels may overlap an outstanding run segment because they emit no entropy yet. | Regular event or run segment; direct run-pixel reconstruction. | Annex A.3 context determination; Annex A.7 run mode. |
|
||||
| S20 | `jls_predictor` | Regular event `X,Ra,Rb,Rc,Rd`. | Compute MED prediction `Px`. | Predicted event with `Px` and neighbor metadata. | Annex A.4 MED predictor pseudocode. |
|
||||
|
||||
Reference in New Issue
Block a user