// Port of jxl-render filter/ycbcr.rs (JPEG-style chroma upsampling).

///|
/// `apply_jpeg_upsampling_single` on plain values: `hshift`/`vshift` are the
/// channel's `ChannelShift::hshift()`/`vshift()`, and `target_width` /
/// `target_height` the size of `target_region`.
pub fn apply_jpeg_upsampling_single_raw(
  grid : @grid.SubGrid[Float],
  hshift : Int32,
  vshift : Int32,
  target_width : Int32,
  target_height : Int32,
  tracker : @grid.AllocTracker?,
) -> @grid.Grid[Float] raise @bitstream.JxlError {
  let height = grid.height
  let gw = grid.width
  let out = @grid.Grid::with_alloc_tracker(
    target_width,
    target_height,
    (0.0 : Float),
    tracker,
  )
  let buf = out.buf
  let h_upsampled = hshift == 0
  let v_upsampled = vshift == 0
  let rows = if height < target_height { height } else { target_height }
  for y in 0..= 0; y = y - 1 {
      let idx_base = y * target_width
      let top_base = if idx_base >= target_width {
        idx_base - target_width
      } else {
        0
      }
      for x in 0..