요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. _v4l2-pix-fmt-pisp-comp1-rggb:
.. _v4l2-pix-fmt-pisp-comp1-grbg:
.. _v4l2-pix-fmt-pisp-comp1-gbrg:
.. _v4l2-pix-fmt-pisp-comp1-bggr:
.. _v4l2-pix-fmt-pisp-comp1-mono:
.. _v4l2-pix-fmt-pisp-comp2-rggb:
.. _v4l2-pix-fmt-pisp-comp2-grbg:
.. _v4l2-pix-fmt-pisp-comp2-gbrg:
.. _v4l2-pix-fmt-pisp-comp2-bggr:
.. _v4l2-pix-fmt-pisp-comp2-mono:
**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
V4L2_PIX_FMT_PISP_COMP1_RGGB ('PC1R'), V4L2_PIX_FMT_PISP_COMP1_GRBG ('PC1G'), V4L2_PIX_FMT_PISP_COMP1_GBRG ('PC1g'), V4L2_PIX_FMT_PISP_COMP1_BGGR ('PC1B), V4L2_PIX_FMT_PISP_COMP1_MONO ('PC1M'), V4L2_PIX_FMT_PISP_COMP2_RGGB ('PC2R'), V4L2_PIX_FMT_PISP_COMP2_GRBG ('PC2G'), V4L2_PIX_FMT_PISP_COMP2_GBRG ('PC2g'), V4L2_PIX_FMT_PISP_COMP2_BGGR ('PC2B), V4L2_PIX_FMT_PISP_COMP2_MONO ('PC2M')
**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
================================================
Raspberry Pi PiSP compressed 8-bit Bayer formats
================================================
Description
===========
The Raspberry Pi ISP (PiSP) uses a family of three fixed-rate compressed Bayer
formats. A black-level offset may be subtracted to improve compression
efficiency; the nominal black level and amount of offset must be signalled out
of band. Each scanline is padded to a multiple of 8 pixels wide, and each block
of 8 horizontally-contiguous pixels is coded using 8 bytes.
Mode 1 uses a quantization and delta-based coding scheme which preserves up to
12 significant bits. Mode 2 is a simple sqrt-like companding scheme with 6 PWL
chords, preserving up to 12 significant bits. Mode 3 combines both companding
(with 4 chords) and the delta scheme, preserving up to 14 significant bits.
The remainder of this description applies to Modes 1 and 3.
Each block of 8 pixels is separated into even and odd phases of 4 pixels,
coded independently by 32-bit words at successive locations in memory.
The two LS bits of each 32-bit word give its "quantization mode".
In quantization mode 0, the lowest 321 quantization levels are multiples of
FSD/4096 and the remaining levels are successive multiples of FSD/2048.
Quantization modes 1 and 2 use linear quantization with step sizes of
FSD/1024 and FSD/512 respectively. Each of the four pixels is quantized
independently, with rounding to the nearest level.
In quantization mode 2 where the middle two samples have quantized values
(q1,q2) both in the range [384..511], they are coded using 9 bits for q1
followed by 7 bits for (q2 & 127). Otherwise, for quantization modes
0, 1 and 2: a 9-bit field encodes MIN(q1,q2) which must be in the range
[0..511] and a 7-bit field encodes (q2-q1+64) which must be in [0..127].
Each of the outer samples (q0,q3) is encoded using a 7-bit field based
on its inner neighbour q1 or q2. In quantization mode 2 where the inner
sample has a quantized value in the range [448..511], the field value is
(q0-384). Otherwise for quantization modes 0, 1 and 2: The outer sample
is encoded as (q0-MAX(0,q1-64)). q3 is likewise coded based on q2.
Each of these values must be in the range [0..127]. All these fields
of 2, 9, 7, 7, 7 bits respectively are packed in little-endian order
to give a 32-bit word with LE byte order.
Quantization mode 3 has a "7.5-bit" escape, used when none of the above
encodings will fit. Each pixel value is quantized to the nearest of 176
levels, where the lowest 95 levels are multiples of FSD/256 and the
remaining levels are multiples of FSD/128 (level 175 represents values
very close to FSD and may require saturating arithmetic to decode).
Each pair of quantized pixels (q0,q1) or (q2,q3) is jointly coded
by a 15-bit field: 2816*(q0>>4) + 16*q1 + (q0&15).
Three fields of 2, 15, 15 bits are packed in LE order {15,15,2}.
An implementation of a software decoder of compressed formats is available
in `Raspberry Pi camera applications code base
<https://github.com/raspberrypi/rpicam-apps/blob/main/image/dng.cpp>`_.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
PiSP FourCC, block 크기와 세 compression mode
1-36Raspberry Pi ISP(PiSP)는 고정률 압축 Bayer 형식 세 종류를 사용합니다. 이 문서는 COMP1/COMP2의 RGGB, GRBG, GBRG, BGGR, MONO FourCC 열 개를 나열합니다. Compression 효율을 높이기 위해 black-level offset을 뺄 수 있지만 nominal black level과 offset 양은 별도 경로(out of band)로 전달해야 합니다.
각 scanline width는 8 pixel의 배수로 padding하고 가로로 연속된 8 pixel block 하나를 8 byte로 encoding합니다. Mode 1은 quantization과 delta coding으로 유효 bit를 최대 12개 보존합니다. Mode 2는 6개 PWL chord를 쓰는 단순 sqrt-like companding으로 최대 12개를 보존합니다. Mode 3은 4개 chord companding과 delta scheme을 결합해 최대 14개의 유효 bit를 보존합니다. 이후 원문 설명은 mode 1과 3에 적용됩니다.
각 mode의 coding 방식과 보존 정밀도입니다.
8 pixel이 8 byte로 고정률 encoding됩니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. _v4l2-pix-fmt-pisp-comp1-rggb:
.. _v4l2-pix-fmt-pisp-comp1-grbg:
.. _v4l2-pix-fmt-pisp-comp1-gbrg:
.. _v4l2-pix-fmt-pisp-comp1-bggr:
.. _v4l2-pix-fmt-pisp-comp1-mono:
.. _v4l2-pix-fmt-pisp-comp2-rggb:
.. _v4l2-pix-fmt-pisp-comp2-grbg:
.. _v4l2-pix-fmt-pisp-comp2-gbrg:
.. _v4l2-pix-fmt-pisp-comp2-bggr:
.. _v4l2-pix-fmt-pisp-comp2-mono:
**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
V4L2_PIX_FMT_PISP_COMP1_RGGB ('PC1R'), V4L2_PIX_FMT_PISP_COMP1_GRBG ('PC1G'), V4L2_PIX_FMT_PISP_COMP1_GBRG ('PC1g'), V4L2_PIX_FMT_PISP_COMP1_BGGR ('PC1B), V4L2_PIX_FMT_PISP_COMP1_MONO ('PC1M'), V4L2_PIX_FMT_PISP_COMP2_RGGB ('PC2R'), V4L2_PIX_FMT_PISP_COMP2_GRBG ('PC2G'), V4L2_PIX_FMT_PISP_COMP2_GBRG ('PC2g'), V4L2_PIX_FMT_PISP_COMP2_BGGR ('PC2B), V4L2_PIX_FMT_PISP_COMP2_MONO ('PC2M')
**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
================================================
Raspberry Pi PiSP compressed 8-bit Bayer formats
================================================
Description
===========
The Raspberry Pi ISP (PiSP) uses a family of three fixed-rate compressed Bayer
formats. A black-level offset may be subtracted to improve compression
efficiency; the nominal black level and amount of offset must be signalled out
of band. Each scanline is padded to a multiple of 8 pixels wide, and each block
of 8 horizontally-contiguous pixels is coded using 8 bytes.
Mode 1 uses a quantization and delta-based coding scheme which preserves up to
12 significant bits. Mode 2 is a simple sqrt-like companding scheme with 6 PWL
chords, preserving up to 12 significant bits. Mode 3 combines both companding
(with 4 chords) and the delta scheme, preserving up to 14 significant bits.
The remainder of this description applies to Modes 1 and 3.
Quantization mode 0~2와 32-bit field
37-608-pixel block을 even phase와 odd phase의 4 pixel로 나누고, 각각을 연속된 memory 위치의 독립 32-bit word로 encoding합니다. 각 word의 최하위 2 bit가 `quantization mode`입니다.
Mode 0에서는 가장 낮은 321 quantization level이 `FSD/4096`의 배수이고 나머지는 이어지는 `FSD/2048` 배수입니다. Mode 1과 2는 각각 `FSD/1024`, `FSD/512` step size의 linear quantization을 사용합니다. 네 pixel은 각각 가장 가까운 level로 반올림해 독립적으로 quantize합니다.
Mode 2에서 가운데 표본 `(q1,q2)`가 모두 `[384..511]`이면 q1을 9 bit, `(q2 & 127)`을 7 bit로 encoding합니다. 그 밖의 mode 0~2에서는 9-bit field가 `[0..511]` 범위의 `MIN(q1,q2)`를, 7-bit field가 `[0..127]` 범위의 `(q2-q1+64)`를 담습니다.
바깥 표본 q0과 q3은 각각 이웃한 q1 또는 q2를 기준으로 7-bit field에 encoding합니다. Mode 2에서 inner sample이 `[448..511]`이면 q0 field는 `(q0-384)`입니다. 그 밖의 mode 0~2에서는 `(q0-MAX(0,q1-64))`이고 q3도 q2를 기준으로 같은 방식입니다. 값 범위는 `[0..127]`이어야 합니다. `2, 9, 7, 7, 7` bit field를 little-endian 순서로 packing해 LE byte order의 32-bit word를 만듭니다.
Level 간격과 special middle-sample encoding을 구분합니다.
원문의 field 폭 순서입니다.
Each block of 8 pixels is separated into even and odd phases of 4 pixels,
coded independently by 32-bit words at successive locations in memory.
The two LS bits of each 32-bit word give its "quantization mode".
In quantization mode 0, the lowest 321 quantization levels are multiples of
FSD/4096 and the remaining levels are successive multiples of FSD/2048.
Quantization modes 1 and 2 use linear quantization with step sizes of
FSD/1024 and FSD/512 respectively. Each of the four pixels is quantized
independently, with rounding to the nearest level.
In quantization mode 2 where the middle two samples have quantized values
(q1,q2) both in the range [384..511], they are coded using 9 bits for q1
followed by 7 bits for (q2 & 127). Otherwise, for quantization modes
0, 1 and 2: a 9-bit field encodes MIN(q1,q2) which must be in the range
[0..511] and a 7-bit field encodes (q2-q1+64) which must be in [0..127].
Each of the outer samples (q0,q3) is encoded using a 7-bit field based
on its inner neighbour q1 or q2. In quantization mode 2 where the inner
sample has a quantized value in the range [448..511], the field value is
(q0-384). Otherwise for quantization modes 0, 1 and 2: The outer sample
is encoded as (q0-MAX(0,q1-64)). q3 is likewise coded based on q2.
Each of these values must be in the range [0..127]. All these fields
of 2, 9, 7, 7, 7 bits respectively are packed in little-endian order
to give a 32-bit word with LE byte order.
Mode 3 escape, pair 수식과 decoder
61-74위 encoding 어느 것도 맞지 않을 때 quantization mode 3의 `7.5-bit` escape를 사용합니다. 각 pixel 값을 176 level 가운데 가장 가까운 값으로 quantize합니다. 가장 낮은 95 level은 `FSD/256`의 배수이고 나머지는 `FSD/128`의 배수입니다. Level 175는 FSD에 매우 가까운 값을 나타내므로 decode할 때 saturating arithmetic이 필요할 수 있습니다.
Quantized pixel pair `(q0,q1)` 또는 `(q2,q3)`는 `2816*(q0>>4) + 16*q1 + (q0&15)` 수식의 15-bit field 하나로 공동 encoding합니다. 폭이 `2, 15, 15`인 세 field를 little-endian 순서 `{15,15,2}`로 packing합니다.
압축 형식의 software decoder 구현은 Raspberry Pi camera applications 코드의 `image/dng.cpp`에서 확인할 수 있습니다: `https://github.com/raspberrypi/rpicam-apps/blob/main/image/dng.cpp`.
두 pixel pair와 mode를 32 bit에 넣습니다.
Quantization mode 3 has a "7.5-bit" escape, used when none of the above
encodings will fit. Each pixel value is quantized to the nearest of 176
levels, where the lowest 95 levels are multiples of FSD/256 and the
remaining levels are multiples of FSD/128 (level 175 represents values
very close to FSD and may require saturating arithmetic to decode).
Each pair of quantized pixels (q0,q1) or (q2,q3) is jointly coded
by a 15-bit field: 2816*(q0>>4) + 16*q1 + (q0&15).
Three fields of 2, 15, 15 bits are packed in LE order {15,15,2}.
An implementation of a software decoder of compressed formats is available
in `Raspberry Pi camera applications code base
<https://github.com/raspberrypi/rpicam-apps/blob/main/image/dng.cpp>`_.
요약·해설
pixfmt-srggb8-pisp-comp.rst:1-748-pixel/8-byte fixed-rate block과 quantization mode 0~3의 encoding을 설명합니다.