← Documents Documentation/userspace-api/media/v4l/ext-ctrls-jpeg.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

JPEG Control Reference

JPEG codec의 chroma subsampling, restart interval, quality와 marker를 설명합니다.

Source pathDocumentation/userspace-api/media/v4l/ext-ctrls-jpeg.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

ext-ctrls-jpeg.rst:1-105

JPEG 제어는 chroma sampling 비율과 독립 decoding 단위, 품질 목표, encoder가 넣을 marker를 명시합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _jpeg-controls:
4
5 **********************
6 JPEG Control Reference
7 **********************
8
9 The JPEG class includes controls for common features of JPEG encoders
10 and decoders. Currently it includes features for codecs implementing
11 progressive baseline DCT compression process with Huffman entropy
12 coding.
13
14
15 .. _jpeg-control-id:
16
17 JPEG Control IDs
18 ================
19
20 ``V4L2_CID_JPEG_CLASS (class)``
21 The JPEG class descriptor. Calling
22 :ref:`VIDIOC_QUERYCTRL` for this control will
23 return a description of this control class.
24
25 ``V4L2_CID_JPEG_CHROMA_SUBSAMPLING (menu)``
26 The chroma subsampling factors describe how each component of an
27 input image is sampled, in respect to maximum sample rate in each
28 spatial dimension. See :ref:`itu-t81`, clause A.1.1. for more
29 details. The ``V4L2_CID_JPEG_CHROMA_SUBSAMPLING`` control determines
30 how Cb and Cr components are downsampled after converting an input
31 image from RGB to Y'CbCr color space.
32
33 .. tabularcolumns:: |p{7.5cm}|p{10.0cm}|
34
35 .. flat-table::
36 :header-rows: 0
37 :stub-columns: 0
38
39 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_444``
40 - No chroma subsampling, each pixel has Y, Cr and Cb values.
41 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_422``
42 - Horizontally subsample Cr, Cb components by a factor of 2.
43 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_420``
44 - Subsample Cr, Cb components horizontally and vertically by 2.
45 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_411``
46 - Horizontally subsample Cr, Cb components by a factor of 4.
47 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_410``
48 - Subsample Cr, Cb components horizontally by 4 and vertically by 2.
49 * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY``
50 - Use only luminance component.
51
52
53
54 ``V4L2_CID_JPEG_RESTART_INTERVAL (integer)``
55 The restart interval determines an interval of inserting RSTm
56 markers (m = 0..7). The purpose of these markers is to additionally
57 reinitialize the encoder process, in order to process blocks of an
58 image independently. For the lossy compression processes the restart
59 interval unit is MCU (Minimum Coded Unit) and its value is contained
60 in DRI (Define Restart Interval) marker. If
61 ``V4L2_CID_JPEG_RESTART_INTERVAL`` control is set to 0, DRI and RSTm
62 markers will not be inserted.
63
64 .. _jpeg-quality-control:
65
66 ``V4L2_CID_JPEG_COMPRESSION_QUALITY (integer)``
67 Determines trade-off between image quality and size.
68 It provides simpler method for applications to control image quality,
69 without a need for direct reconfiguration of luminance and chrominance
70 quantization tables. In cases where a driver uses quantization tables
71 configured directly by an application, using interfaces defined
72 elsewhere, ``V4L2_CID_JPEG_COMPRESSION_QUALITY`` control should be set by
73 driver to 0.
74
75 The value range of this control is driver-specific. Only positive,
76 non-zero values are meaningful. The recommended range is 1 - 100,
77 where larger values correspond to better image quality.
78
79 .. _jpeg-active-marker-control:
80
81 ``V4L2_CID_JPEG_ACTIVE_MARKER (bitmask)``
82 Specify which JPEG markers are included in compressed stream. This
83 control is valid only for encoders.
84
85
86
87 .. flat-table::
88 :header-rows: 0
89 :stub-columns: 0
90
91 * - ``V4L2_JPEG_ACTIVE_MARKER_APP0``
92 - Application data segment APP\ :sub:`0`.
93 * - ``V4L2_JPEG_ACTIVE_MARKER_APP1``
94 - Application data segment APP\ :sub:`1`.
95 * - ``V4L2_JPEG_ACTIVE_MARKER_COM``
96 - Comment segment.
97 * - ``V4L2_JPEG_ACTIVE_MARKER_DQT``
98 - Quantization tables segment.
99 * - ``V4L2_JPEG_ACTIVE_MARKER_DHT``
100 - Huffman tables segment.
101
102
103
104 For more details about JPEG specification, refer to :ref:`itu-t81`,
105 :ref:`jfif`, :ref:`w3c-jpeg-jfif`.
106

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

JPEG codec 클래스

1-23

JPEG 클래스는 JPEG encoder와 decoder의 공통 기능을 제어합니다. 현재 Huffman entropy coding을 사용하는 progressive baseline DCT 압축 과정을 구현한 codec 기능을 포함합니다.

`V4L2_CID_JPEG_CLASS`는 JPEG 클래스 설명자이며 `VIDIOC_QUERYCTRL`로 조회하면 이 제어 클래스의 설명을 반환합니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later

.. _jpeg-controls:

**********************
JPEG Control Reference
**********************

The JPEG class includes controls for common features of JPEG encoders
and decoders. Currently it includes features for codecs implementing
progressive baseline DCT compression process with Huffman entropy
coding.


.. _jpeg-control-id:

JPEG Control IDs
================

``V4L2_CID_JPEG_CLASS (class)``
    The JPEG class descriptor. Calling
    :ref:`VIDIOC_QUERYCTRL` for this control will
    return a description of this control class.

Chroma subsampling

24-58

Chroma subsampling factor는 각 공간 축의 최대 sample rate에 비해 입력 이미지의 각 성분을 얼마나 자주 sampling하는지 나타냅니다. 자세한 정의는 ITU-T T.81 A.1.1을 따릅니다. `V4L2_CID_JPEG_CHROMA_SUBSAMPLING`은 RGB를 Y'CbCr로 변환한 뒤 Cb와 Cr을 어떤 비율로 downsample할지 정합니다.

JPEG chroma subsampling
항목설명
`V4L2_JPEG_CHROMA_SUBSAMPLING_444`Subsampling 없이 모든 pixel이 Y, Cr, Cb 값을 가집니다.
`V4L2_JPEG_CHROMA_SUBSAMPLING_422`Cr과 Cb를 수평 방향으로 2분의 1 sampling합니다.
`V4L2_JPEG_CHROMA_SUBSAMPLING_420`Cr과 Cb를 수평과 수직 모두 2분의 1 sampling합니다.
`V4L2_JPEG_CHROMA_SUBSAMPLING_411`Cr과 Cb를 수평 방향으로 4분의 1 sampling합니다.
`V4L2_JPEG_CHROMA_SUBSAMPLING_410`Cr과 Cb를 수평 4분의 1, 수직 2분의 1로 sampling합니다.
`V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY`Luminance 성분만 사용합니다.

Luma 해상도에 대한 chroma의 수평·수직 sampling 비율을 선택합니다.

`V4L2_CID_JPEG_RESTART_INTERVAL`은 RSTm marker 삽입 간격을 정합니다. m은 0부터 7까지 순환하며 encoder 상태를 다시 초기화해 이미지 block들을 독립적으로 처리하게 합니다.


``V4L2_CID_JPEG_CHROMA_SUBSAMPLING (menu)``
    The chroma subsampling factors describe how each component of an
    input image is sampled, in respect to maximum sample rate in each
    spatial dimension. See :ref:`itu-t81`, clause A.1.1. for more
    details. The ``V4L2_CID_JPEG_CHROMA_SUBSAMPLING`` control determines
    how Cb and Cr components are downsampled after converting an input
    image from RGB to Y'CbCr color space.

.. tabularcolumns:: |p{7.5cm}|p{10.0cm}|

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_444``
      - No chroma subsampling, each pixel has Y, Cr and Cb values.
    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_422``
      - Horizontally subsample Cr, Cb components by a factor of 2.
    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_420``
      - Subsample Cr, Cb components horizontally and vertically by 2.
    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_411``
      - Horizontally subsample Cr, Cb components by a factor of 4.
    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_410``
      - Subsample Cr, Cb components horizontally by 4 and vertically by 2.
    * - ``V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY``
      - Use only luminance component.



``V4L2_CID_JPEG_RESTART_INTERVAL (integer)``
    The restart interval determines an interval of inserting RSTm
    markers (m = 0..7). The purpose of these markers is to additionally
    reinitialize the encoder process, in order to process blocks of an
    image independently. For the lossy compression processes the restart

Restart interval, quality와 marker

59-105

Lossy JPEG에서 restart interval의 단위는 MCU(Minimum Coded Unit)이고 값은 DRI(Define Restart Interval) marker에 기록됩니다. 제어값이 0이면 DRI와 RSTm marker를 삽입하지 않습니다.

`V4L2_CID_JPEG_COMPRESSION_QUALITY`는 이미지 품질과 크기의 trade-off를 정하며 application이 luminance와 chrominance quantization table을 직접 다시 구성하지 않아도 되는 단순한 인터페이스입니다. Application이 다른 인터페이스로 quantization table을 직접 제공하는 드라이버는 이 제어를 0으로 설정해야 합니다.

Quality 범위는 드라이버별이며 양의 0이 아닌 값만 의미가 있습니다. 권장 범위는 1부터 100까지이고 값이 클수록 이미지 품질이 좋습니다.

`V4L2_CID_JPEG_ACTIVE_MARKER`는 압축 stream에 포함할 JPEG marker를 bitmask로 지정하며 encoder에서만 유효합니다.

활성 JPEG marker
항목설명
`V4L2_JPEG_ACTIVE_MARKER_APP0`Application data APP0 segment를 포함합니다.
`V4L2_JPEG_ACTIVE_MARKER_APP1`Application data APP1 segment를 포함합니다.
`V4L2_JPEG_ACTIVE_MARKER_COM`Comment segment를 포함합니다.
`V4L2_JPEG_ACTIVE_MARKER_DQT`Quantization table segment를 포함합니다.
`V4L2_JPEG_ACTIVE_MARKER_DHT`Huffman table segment를 포함합니다.

Encoder가 출력 stream에 넣을 부가 segment와 table을 선택합니다.

JPEG 규격의 세부 사항은 ITU-T T.81, JFIF와 W3C JPEG JFIF 참조 문서를 따릅니다.

    interval unit is MCU (Minimum Coded Unit) and its value is contained
    in DRI (Define Restart Interval) marker. If
    ``V4L2_CID_JPEG_RESTART_INTERVAL`` control is set to 0, DRI and RSTm
    markers will not be inserted.

.. _jpeg-quality-control:

``V4L2_CID_JPEG_COMPRESSION_QUALITY (integer)``
    Determines trade-off between image quality and size.
    It provides simpler method for applications to control image quality,
    without a need for direct reconfiguration of luminance and chrominance
    quantization tables. In cases where a driver uses quantization tables
    configured directly by an application, using interfaces defined
    elsewhere, ``V4L2_CID_JPEG_COMPRESSION_QUALITY`` control should be set by
    driver to 0.

    The value range of this control is driver-specific. Only positive,
    non-zero values are meaningful. The recommended range is 1 - 100,
    where larger values correspond to better image quality.

.. _jpeg-active-marker-control:

``V4L2_CID_JPEG_ACTIVE_MARKER (bitmask)``
    Specify which JPEG markers are included in compressed stream. This
    control is valid only for encoders.



.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    * - ``V4L2_JPEG_ACTIVE_MARKER_APP0``
      - Application data segment APP\ :sub:`0`.
    * - ``V4L2_JPEG_ACTIVE_MARKER_APP1``
      - Application data segment APP\ :sub:`1`.
    * - ``V4L2_JPEG_ACTIVE_MARKER_COM``
      - Comment segment.
    * - ``V4L2_JPEG_ACTIVE_MARKER_DQT``
      - Quantization tables segment.
    * - ``V4L2_JPEG_ACTIVE_MARKER_DHT``
      - Huffman tables segment.



For more details about JPEG specification, refer to :ref:`itu-t81`,
:ref:`jfif`, :ref:`w3c-jpeg-jfif`.