← Documents Documentation/userspace-api/media/v4l/vidioc-cropcap.rst GitHub 원문 ↗

Linux 6.18.37 · 사용자 공간 API

VIDIOC_CROPCAP ioctl

VIDIOC_CROPCAP으로 크롭 경계, 기본 사각형, 픽셀 종횡비와 멀티플레인 type 호환 규칙을 조회하는 방법을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-cropcap.rst:1-133

VIDIOC_CROPCAP으로 크롭 경계, 기본 사각형, 픽셀 종횡비와 멀티플레인 type 호환 규칙을 조회하는 방법을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_CROPCAP:
5
6 ********************
7 ioctl VIDIOC_CROPCAP
8 ********************
9
10 Name
11 ====
12
13 VIDIOC_CROPCAP - Information about the video cropping and scaling abilities
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_CROPCAP
19
20 ``int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)``
21
22 Arguments
23 =========
24
25 ``fd``
26 File descriptor returned by :c:func:`open()`.
27
28 ``argp``
29 Pointer to struct :c:type:`v4l2_cropcap`.
30
31 Description
32 ===========
33
34 Applications use this function to query the cropping limits, the pixel
35 aspect of images and to calculate scale factors. They set the ``type``
36 field of a v4l2_cropcap structure to the respective buffer (stream)
37 type and call the :ref:`VIDIOC_CROPCAP` ioctl with a pointer to this
38 structure. Drivers fill the rest of the structure. The results are
39 constant except when switching the video standard. Remember this switch
40 can occur implicit when switching the video input or output.
41
42 This ioctl must be implemented for video capture or output devices that
43 support cropping and/or scaling and/or have non-square pixels, and for
44 overlay devices.
45
46 .. c:type:: v4l2_cropcap
47
48 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
49
50 .. flat-table:: struct v4l2_cropcap
51 :header-rows: 0
52 :stub-columns: 0
53 :widths: 1 1 2
54
55 * - __u32
56 - ``type``
57 - Type of the data stream, set by the application. Only these types
58 are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
59 ``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
60 ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below.
61 * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
62 - ``bounds``
63 - Defines the window within capturing or output is possible, this
64 may exclude for example the horizontal and vertical blanking
65 areas. The cropping rectangle cannot exceed these limits. Width
66 and height are defined in pixels, the driver writer is free to
67 choose origin and units of the coordinate system in the analog
68 domain.
69 * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
70 - ``defrect``
71 - Default cropping rectangle, it shall cover the "whole picture".
72 Assuming pixel aspect 1/1 this could be for example a 640 × 480
73 rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM
74 centered over the active picture area. The same coordinate system
75 as for ``bounds`` is used.
76 * - struct :c:type:`v4l2_fract`
77 - ``pixelaspect``
78 - This is the pixel aspect (y / x) when no scaling is applied, the
79 ratio of the actual sampling frequency and the frequency required
80 to get square pixels.
81
82 When cropping coordinates refer to square pixels, the driver sets
83 ``pixelaspect`` to 1/1. Other common values are 54/59 for PAL and
84 SECAM, 11/10 for NTSC sampled according to [:ref:`itu601`].
85
86 .. note::
87 Unfortunately in the case of multiplanar buffer types
88 (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)
89 this API was messed up with regards to how the :c:type:`v4l2_cropcap` ``type`` field
90 should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while
91 other drivers only accepted a non-multiplanar buffer type (i.e. without the
92 ``_MPLANE`` at the end).
93
94 Starting with kernel 4.13 both variations are allowed.
95
96
97 .. _v4l2-rect-crop:
98
99 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
100
101 .. flat-table:: struct v4l2_rect
102 :header-rows: 0
103 :stub-columns: 0
104 :widths: 1 1 2
105
106 * - __s32
107 - ``left``
108 - Horizontal offset of the top, left corner of the rectangle, in
109 pixels.
110 * - __s32
111 - ``top``
112 - Vertical offset of the top, left corner of the rectangle, in
113 pixels.
114 * - __u32
115 - ``width``
116 - Width of the rectangle, in pixels.
117 * - __u32
118 - ``height``
119 - Height of the rectangle, in pixels.
120
121 Return Value
122 ============
123
124 On success 0 is returned, on error -1 and the ``errno`` variable is set
125 appropriately. The generic error codes are described at the
126 :ref:`Generic Error Codes <gen-errors>` chapter.
127
128 EINVAL
129 The struct :c:type:`v4l2_cropcap` ``type`` is
130 invalid.
131
132 ENODATA
133 Cropping is not supported for this input or output.
134

3. 한국어 전문 번역

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

이름, 호출 형식과 인자

1-29

`VIDIOC_CROPCAP`은 비디오 크롭과 스케일링 능력에 관한 정보를 조회합니다. 호출 형식은 `int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)`입니다.

`fd`는 `open()`이 반환한 파일 디스크립터이고, `argp`는 응용 프로그램이 스트림 유형을 지정하고 드라이버가 나머지 정보를 채우는 `struct v4l2_cropcap`을 가리킵니다.

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

.. _VIDIOC_CROPCAP:

********************
ioctl VIDIOC_CROPCAP
********************

Name
====

VIDIOC_CROPCAP - Information about the video cropping and scaling abilities

Synopsis
========

.. c:macro:: VIDIOC_CROPCAP

``int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)``

Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``
    Pointer to struct :c:type:`v4l2_cropcap`.

조회 범위와 구현 조건

30-44

응용 프로그램은 이 ioctl로 크롭 한계와 영상의 픽셀 종횡비를 조회하고 스케일 배율을 계산합니다. `v4l2_cropcap.type`에 대상 버퍼 또는 스트림 유형을 넣어 호출하면 드라이버가 나머지 필드를 채웁니다.

결과는 비디오 표준을 바꾸지 않는 한 일정합니다. 입력 또는 출력을 전환할 때 비디오 표준도 암시적으로 바뀔 수 있으므로 그 뒤에는 capability를 다시 조회해야 합니다.

크롭, 스케일링 또는 비정사각형 픽셀을 지원하는 비디오 캡처·출력 장치와 overlay 장치는 이 ioctl을 구현해야 합니다.


Description
===========

Applications use this function to query the cropping limits, the pixel
aspect of images and to calculate scale factors. They set the ``type``
field of a v4l2_cropcap structure to the respective buffer (stream)
type and call the :ref:`VIDIOC_CROPCAP` ioctl with a pointer to this
structure. Drivers fill the rest of the structure. The results are
constant except when switching the video standard. Remember this switch
can occur implicit when switching the video input or output.

This ioctl must be implemented for video capture or output devices that
support cropping and/or scaling and/or have non-square pixels, and for
overlay devices.

v4l2_cropcap 필드

45-87

구조체는 응용 프로그램이 지정하는 스트림 유형, 크롭 가능한 전체 경계, 기본 크롭 사각형과 스케일링하지 않았을 때의 픽셀 종횡비를 담습니다.

struct v4l2_cropcap
형식필드의미
`__u32``type`캡처·출력 단일/멀티플레인 또는 비디오 overlay 스트림 유형
`struct v4l2_rect``bounds`캡처나 출력이 가능한 창의 최대 경계; blanking 영역은 제외될 수 있음
`struct v4l2_rect``defrect`전체 그림을 덮는 기본 크롭 사각형이며 `bounds`와 같은 좌표계 사용
`struct v4l2_fract``pixelaspect`스케일링하지 않을 때의 픽셀 종횡비 y/x

원문 필드별 좌표계와 종횡비 규칙입니다.

`bounds`의 너비와 높이는 픽셀 단위이며 크롭 사각형은 이 범위를 넘을 수 없습니다. 아날로그 영역의 좌표 원점과 단위는 드라이버 작성자가 정할 수 있습니다. 정사각 픽셀을 가정하면 `defrect`는 NTSC의 640×480, PAL·SECAM의 768×576처럼 활성 영상 영역 가운데에 놓인 전체 화면 사각형이 될 수 있습니다.

크롭 좌표가 정사각 픽셀 기준이면 `pixelaspect`는 1/1입니다. 일반적인 비정사각 값은 PAL·SECAM 54/59, ITU-R BT.601 방식으로 샘플링한 NTSC 11/10입니다. 이 값은 실제 샘플링 주파수와 정사각 픽셀을 얻는 데 필요한 주파수의 비율입니다.


.. c:type:: v4l2_cropcap

.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|

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

    * - __u32
      - ``type``
      - Type of the data stream, set by the application. Only these types
	are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
	``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
	``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below.
    * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
      - ``bounds``
      - Defines the window within capturing or output is possible, this
	may exclude for example the horizontal and vertical blanking
	areas. The cropping rectangle cannot exceed these limits. Width
	and height are defined in pixels, the driver writer is free to
	choose origin and units of the coordinate system in the analog
	domain.
    * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
      - ``defrect``
      - Default cropping rectangle, it shall cover the "whole picture".
	Assuming pixel aspect 1/1 this could be for example a 640 × 480
	rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM
	centered over the active picture area. The same coordinate system
	as for ``bounds`` is used.
    * - struct :c:type:`v4l2_fract`
      - ``pixelaspect``
      - This is the pixel aspect (y / x) when no scaling is applied, the
	ratio of the actual sampling frequency and the frequency required
	to get square pixels.

	When cropping coordinates refer to square pixels, the driver sets
	``pixelaspect`` to 1/1. Other common values are 54/59 for PAL and
	SECAM, 11/10 for NTSC sampled according to [:ref:`itu601`].

.. note::
   Unfortunately in the case of multiplanar buffer types

멀티플레인 type 호환성 주의

88-97

멀티플레인 버퍼 유형에서는 역사적으로 `v4l2_cropcap.type`을 채우는 방법이 일관되지 않았습니다. 일부 드라이버는 이름 끝에 `_MPLANE`이 붙은 유형만 받았고, 다른 드라이버는 대응하는 비멀티플레인 유형만 받았습니다.

커널 4.13부터는 `V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`·`V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`과 대응하는 비멀티플레인 유형 양쪽 표현을 모두 허용합니다.

   (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)
   this API was messed up with regards to how the :c:type:`v4l2_cropcap` ``type`` field
   should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while
   other drivers only accepted a non-multiplanar buffer type (i.e. without the
   ``_MPLANE`` at the end).

   Starting with kernel 4.13 both variations are allowed.


.. _v4l2-rect-crop:

v4l2_rect 사각형 좌표

98-121
struct v4l2_rect
형식필드의미
`__s32``left`사각형 왼쪽 위 모서리의 수평 오프셋
`__s32``top`사각형 왼쪽 위 모서리의 수직 오프셋
`__u32``width`사각형 너비
`__u32``height`사각형 높이

왼쪽 위 모서리와 크기를 픽셀 단위로 표현합니다.

`left`와 `top`은 음수가 될 수 있는 signed 32비트 오프셋이고, `width`와 `height`는 음수가 될 수 없는 unsigned 32비트 크기입니다. 네 값은 모두 픽셀 단위입니다.


.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|

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

    * - __s32
      - ``left``
      - Horizontal offset of the top, left corner of the rectangle, in
	pixels.
    * - __s32
      - ``top``
      - Vertical offset of the top, left corner of the rectangle, in
	pixels.
    * - __u32
      - ``width``
      - Width of the rectangle, in pixels.
    * - __u32
      - ``height``
      - Height of the rectangle, in pixels.

Return Value

반환값과 오류

122-133

성공하면 0을 반환하고, 실패하면 -1과 적절한 `errno`를 반환합니다. 일반 오류 코드는 Generic Error Codes 절에 정의되어 있습니다.

VIDIOC_CROPCAP 전용 오류
errno의미
`EINVAL``struct v4l2_cropcap.type`이 유효하지 않음
`ENODATA`현재 입력 또는 출력이 크롭을 지원하지 않음

유형 오류와 기능 미지원 상태를 구분합니다.

============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.

EINVAL
    The struct :c:type:`v4l2_cropcap` ``type`` is
    invalid.

ENODATA
    Cropping is not supported for this input or output.