← Documents Documentation/userspace-api/media/v4l/dev-meta.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

Metadata 인터페이스

비영상 metadata의 capture/output capability, format 협상과 line-based v4l2_meta_format layout을 정의합니다.

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

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

1. 요약·해설

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

요약·해설

dev-meta.rst:1-88

Metadata node는 image 외의 통계·capture parameter·device parameter를 전송합니다. line-based format에서는 width, height, bytesperline이 행 구조를 함께 정의합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _metadata:
4
5 ******************
6 Metadata Interface
7 ******************
8
9 Metadata refers to any non-image data that supplements video frames with
10 additional information. This may include statistics computed over the image,
11 frame capture parameters supplied by the image source or device specific
12 parameters for specifying how the device processes images. This interface is
13 intended for transfer of metadata between the userspace and the hardware and
14 control of that operation.
15
16 The metadata interface is implemented on video device nodes. The device can be
17 dedicated to metadata or can support both video and metadata as specified in its
18 reported capabilities.
19
20 Querying Capabilities
21 =====================
22
23 Device nodes supporting the metadata capture interface set the
24 ``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
25 :c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
26 ioctl. That flag means the device can capture metadata to memory. Similarly,
27 device nodes supporting metadata output interface set the
28 ``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
29 :c:type:`v4l2_capability` structure. That flag means the device can read
30 metadata from memory.
31
32 At least one of the read/write or streaming I/O methods must be supported.
33
34
35 Data Format Negotiation
36 =======================
37
38 The metadata device uses the :ref:`format` ioctls to select the capture format.
39 The metadata buffer content format is bound to that selected format. In addition
40 to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
41 supported as well.
42
43 To use the :ref:`format` ioctls applications set the ``type`` field of the
44 :c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
45 ``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
46 member of the ``fmt`` union as needed per the desired operation. Both drivers
47 and applications must set the remainder of the :c:type:`v4l2_format` structure
48 to 0.
49
50 Devices that capture metadata by line have the struct v4l2_fmtdesc
51 ``V4L2_FMT_FLAG_META_LINE_BASED`` flag set for :c:func:`VIDIOC_ENUM_FMT`. Such
52 devices can typically also :ref:`capture image data <capture>`. This primarily
53 involves devices that receive the data from a different devices such as a camera
54 sensor.
55
56 .. c:type:: v4l2_meta_format
57
58 .. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}|
59
60 .. flat-table:: struct v4l2_meta_format
61 :header-rows: 0
62 :stub-columns: 0
63 :widths: 1 1 2
64
65 * - __u32
66 - ``dataformat``
67 - The data format, set by the application. This is a little endian
68 :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
69 in :ref:`meta-formats`.
70 * - __u32
71 - ``buffersize``
72 - Maximum buffer size in bytes required for data. The value is set by the
73 driver.
74 * - __u32
75 - ``width``
76 - Width of a line of metadata in Data Units. Valid when
77 :c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is set,
78 otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.
79 * - __u32
80 - ``height``
81 - Number of rows of metadata. Valid when :c:type`v4l2_fmtdesc` flag
82 ``V4L2_FMT_FLAG_META_LINE_BASED`` is set, otherwise zero. See
83 :c:func:`VIDIOC_ENUM_FMT`.
84 * - __u32
85 - ``bytesperline``
86 - Offset in bytes between the beginning of two consecutive lines. Valid
87 when :c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is
88 set, otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.
89

3. 한국어 전문 번역

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

Metadata 전송과 capability

1-34

metadata는 비디오 frame을 추가 정보로 보완하는 모든 비영상 데이터를 뜻합니다. 영상에서 계산한 통계, image source가 제공하는 frame capture parameter, 장치가 영상을 처리하는 방식을 지정하는 device-specific parameter 등이 포함됩니다.

이 인터페이스는 userspace와 hardware 사이에서 metadata를 전송하고 그 동작을 제어하기 위한 것입니다. video device node가 metadata 전용일 수도 있고, 보고된 capability에 따라 video와 metadata를 함께 지원할 수도 있습니다.

metadata capture를 지원하는 node는 `VIDIOC_QUERYCAP`이 반환하는 `struct v4l2_capability.device_caps`에 `V4L2_CAP_META_CAPTURE`를 설정합니다. 이는 장치가 metadata를 memory로 capture할 수 있다는 뜻입니다.

metadata output을 지원하는 node는 같은 필드에 `V4L2_CAP_META_OUTPUT`을 설정하며, 이는 장치가 memory에서 metadata를 읽을 수 있다는 뜻입니다. read/write 또는 streaming I/O 방식 중 적어도 하나를 지원해야 합니다.

Metadata capability 방향
항목설명
V4L2_CAP_META_CAPTUREhardware에서 metadata를 memory로 capture
V4L2_CAP_META_OUTPUTmemory에서 metadata를 읽어 hardware에 공급
device_capsv4l2_capability에서 node별 기능을 보고하는 필드
I/O 요구read/write 또는 streaming 가운데 적어도 하나

hardware와 memory 사이의 metadata 이동 방향입니다.

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

.. _metadata:

******************
Metadata Interface
******************

Metadata refers to any non-image data that supplements video frames with
additional information. This may include statistics computed over the image,
frame capture parameters supplied by the image source or device specific
parameters for specifying how the device processes images. This interface is
intended for transfer of metadata between the userspace and the hardware and
control of that operation.

The metadata interface is implemented on video device nodes. The device can be
dedicated to metadata or can support both video and metadata as specified in its
reported capabilities.

Querying Capabilities
=====================

Device nodes supporting the metadata capture interface set the
``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
ioctl. That flag means the device can capture metadata to memory. Similarly,
device nodes supporting metadata output interface set the
``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
:c:type:`v4l2_capability` structure. That flag means the device can read
metadata from memory.

At least one of the read/write or streaming I/O methods must be supported.

Metadata format 협상과 line-based flag

35-55

metadata 장치는 format ioctl로 capture format을 선택하며 metadata buffer 내용의 형식은 이 선택에 묶입니다. 기본 format ioctl뿐 아니라 `VIDIOC_ENUM_FMT`도 반드시 지원해야 합니다.

format ioctl을 사용할 때 애플리케이션은 `struct v4l2_format.type`을 `V4L2_BUF_TYPE_META_CAPTURE` 또는 `V4L2_BUF_TYPE_META_OUTPUT`으로 설정하고, 원하는 동작에 따라 `fmt` union의 `struct v4l2_meta_format meta` 멤버를 사용합니다. driver와 애플리케이션 모두 v4l2_format 구조체의 나머지를 0으로 설정해야 합니다.

line 단위로 metadata를 capture하는 장치는 `VIDIOC_ENUM_FMT`의 `struct v4l2_fmtdesc`에 `V4L2_FMT_FLAG_META_LINE_BASED` flag를 설정합니다. 이런 장치는 보통 image data도 함께 capture할 수 있으며, camera sensor 같은 다른 장치에서 데이터를 받는 유형이 주 대상입니다.

Metadata format 협상
VIDIOC_ENUM_FMT로 metadata format 열거v4l2_format 전체를 0으로 초기화type에 META_CAPTURE 또는 META_OUTPUT 지정fmt.meta의 dataformat과 관련 필드 설정format ioctl로 실제 format 협상

buffer type과 meta union을 선택하는 순서입니다.

Line-based metadata
항목설명
V4L2_FMT_FLAG_META_LINE_BASEDmetadata가 row와 line stride를 갖는 format
v4l2_fmtdescENUM_FMT가 format flag를 반환하는 구조체
일반 조합image capture와 metadata capture를 함께 지원
대표 sourcecamera sensor 같은 다른 device에서 들어오는 data

행 단위 metadata format의 식별과 관련 기능입니다.

Data Format Negotiation
=======================

The metadata device uses the :ref:`format` ioctls to select the capture format.
The metadata buffer content format is bound to that selected format. In addition
to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
supported as well.

To use the :ref:`format` ioctls applications set the ``type`` field of the
:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
member of the ``fmt`` union as needed per the desired operation. Both drivers
and applications must set the remainder of the :c:type:`v4l2_format` structure
to 0.

Devices that capture metadata by line have the struct v4l2_fmtdesc
``V4L2_FMT_FLAG_META_LINE_BASED`` flag set for :c:func:`VIDIOC_ENUM_FMT`. Such
devices can typically also :ref:`capture image data <capture>`. This primarily
involves devices that receive the data from a different devices such as a camera
sensor.

struct v4l2_meta_format

56-88

`struct v4l2_meta_format`은 metadata fourcc, 필요한 최대 buffer 크기와 line-based layout을 표현합니다.

v4l2_meta_format 필드
필드의미
dataformat애플리케이션이 설정하는 little-endian four character code. V4L2 metadata format을 식별
buffersizedata에 필요한 최대 buffer 크기(byte). driver가 설정
widthmetadata 한 line의 Data Unit 폭. META_LINE_BASED일 때 유효, 아니면 0
heightmetadata row 수. META_LINE_BASED일 때 유효, 아니면 0
bytesperline연속 두 line 시작점 사이의 byte offset. META_LINE_BASED일 때 유효, 아니면 0

모든 필드는 `__u32`이며 line-based가 아니면 기하 필드는 0입니다.

Line-based buffer 주소 계산
dataformat으로 Data Unit 의미 결정width로 한 행의 Data Unit 수 결정height로 metadata row 수 결정bytesperline으로 다음 행 시작 offset 계산buffersize 한도 안에서 전체 metadata 저장

width·height와 bytesperline이 metadata 행 배치를 정의합니다.

.. c:type:: v4l2_meta_format

.. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}|

.. flat-table:: struct v4l2_meta_format
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2

    * - __u32
      - ``dataformat``
      - The data format, set by the application. This is a little endian
        :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
        in :ref:`meta-formats`.
    * - __u32
      - ``buffersize``
      - Maximum buffer size in bytes required for data. The value is set by the
        driver.
    * - __u32
      - ``width``
      - Width of a line of metadata in Data Units. Valid when
	:c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is set,
	otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.
    * - __u32
      - ``height``
      - Number of rows of metadata. Valid when :c:type`v4l2_fmtdesc` flag
	``V4L2_FMT_FLAG_META_LINE_BASED`` is set, otherwise zero. See
	:c:func:`VIDIOC_ENUM_FMT`.
    * - __u32
      - ``bytesperline``
      - Offset in bytes between the beginning of two consecutive lines. Valid
	when :c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is
	set, otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.