blob: 8f9d41682595c3fd9d06bf253a6c7fa08347082e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Video Standards</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Video for Linux Two API Specification"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Common API Elements"
HREF="c174.htm"><LINK
REL="PREVIOUS"
TITLE="Tuners and Modulators"
HREF="x394.htm"><LINK
REL="NEXT"
TITLE="User Controls"
HREF="x542.htm"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Video for Linux Two API Specification: Revision 0.24</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x394.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 1. Common API Elements</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x542.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="STANDARD"
>1.7. Video Standards</A
></H1
><P
>Video devices typically support one or more different video
standards or variations of standards. Each video input and output may
support another set of standards. This set is reported by the
<CODE
CLASS="STRUCTFIELD"
>std</CODE
> field of struct&nbsp;<A
HREF="r8936.htm#V4L2-INPUT"
>v4l2_input</A
> and
struct&nbsp;<A
HREF="r9149.htm#V4L2-OUTPUT"
>v4l2_output</A
> returned by the <A
HREF="r8936.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMINPUT</CODE
></A
> and
<A
HREF="r9149.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMOUTPUT</CODE
></A
> ioctl, respectively.</P
><P
>V4L2 defines one bit for each analog video standard
currently in use worldwide, and sets aside bits for driver defined
standards, e.&nbsp;g. hybrid standards to watch NTSC video tapes on PAL TVs
and vice versa. Applications can use the predefined bits to select a
particular standard, although presenting the user a menu of supported
standards is preferred. To enumerate and query the attributes of the
supported standards applications use the <A
HREF="r9288.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMSTD</CODE
></A
> ioctl.</P
><P
>Many of the defined standards are actually just variations
of a few major standards. The hardware may in fact not distinguish
between them, or do so internal and switch automatically. Therefore
enumerated standards also contain sets of one or more standard
bits.</P
><P
>Assume a hypothetic tuner capable of demodulating B/PAL,
G/PAL and I/PAL signals. The first enumerated standard is a set of B
and G/PAL, switched automatically depending on the selected radio
frequency in UHF or VHF band. Enumeration gives a "PAL-B/G" or "PAL-I"
choice. Similar a Composite input may collapse standards, enumerating
"PAL-B/G/H/I", "NTSC-M" and "SECAM-D/K".<A
NAME="AEN463"
HREF="x448.htm#FTN.AEN463"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></P
><P
>To query and select the standard used by the current video
input or output applications call the <A
HREF="r12265.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_G_STD</CODE
></A
> and
<A
HREF="r12265.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_S_STD</CODE
></A
> ioctl, respectively. The <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>received</I
></SPAN
>
standard can be sensed with the <A
HREF="r13641.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_QUERYSTD</CODE
></A
> ioctl. Note parameter of all these ioctls is a pointer to a <A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
> type (a standard set), <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> an index into the standard enumeration.<A
NAME="AEN475"
HREF="x448.htm#FTN.AEN475"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
> Drivers must implement all video standard ioctls
when the device has one or more video inputs or outputs.</P
><P
>Special rules apply to USB cameras where the notion of video
standards makes little sense. More generally any capture device,
output devices accordingly, which is <P
></P
><UL
><LI
><P
>incapable of capturing fields or frames at the nominal
rate of the video standard, or</P
></LI
><LI
><P
>where <A
HREF="x5953.htm"
>timestamps</A
> refer
to the instant the field or frame was received by the driver, not the
capture time, or</P
></LI
><LI
><P
>where <A
HREF="x5953.htm"
>sequence numbers</A
>
refer to the frames received by the driver, not the captured
frames.</P
></LI
></UL
> Here the driver shall set the
<CODE
CLASS="STRUCTFIELD"
>std</CODE
> field of struct&nbsp;<A
HREF="r8936.htm#V4L2-INPUT"
>v4l2_input</A
> and struct&nbsp;<A
HREF="r9149.htm#V4L2-OUTPUT"
>v4l2_output</A
>
to zero, the <CODE
CLASS="CONSTANT"
>VIDIOC_G_STD</CODE
>,
<CODE
CLASS="CONSTANT"
>VIDIOC_S_STD</CODE
>,
<CODE
CLASS="CONSTANT"
>VIDIOC_QUERYSTD</CODE
> and
<CODE
CLASS="CONSTANT"
>VIDIOC_ENUMSTD</CODE
> ioctls shall return the
<SPAN
CLASS="ERRORCODE"
>EINVAL</SPAN
> error code.<A
NAME="AEN507"
HREF="x448.htm#FTN.AEN507"
><SPAN
CLASS="footnote"
>[3]</SPAN
></A
></P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN510"
></A
><P
><B
>Example 1-5. Information about the current video standard</B
></P
><PRE
CLASS="PROGRAMLISTING"
><A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
> std_id;
struct&nbsp;<A
HREF="r9288.htm#V4L2-STANDARD"
>v4l2_standard</A
> standard;
if (-1 == ioctl (fd, <A
HREF="r12265.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_G_STD</CODE
></A
>, &amp;std_id)) {
/* Note when VIDIOC_ENUMSTD always returns EINVAL this
is no video device or it falls under the USB exception,
and VIDIOC_G_STD returning EINVAL is no error. */
perror ("VIDIOC_G_STD");
exit (EXIT_FAILURE);
}
memset (&amp;standard, 0, sizeof (standard));
standard.index = 0;
while (0 == ioctl (fd, <A
HREF="r9288.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMSTD</CODE
></A
>, &amp;standard)) {
if (standard.id &amp; std_id) {
printf ("Current video standard: %s\n", standard.name);
exit (EXIT_SUCCESS);
}
standard.index++;
}
/* EINVAL indicates the end of the enumeration, which cannot be
empty unless this device falls under the USB exception. */
if (errno == EINVAL || standard.index == 0) {
perror ("VIDIOC_ENUMSTD");
exit (EXIT_FAILURE);
}
</PRE
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN519"
></A
><P
><B
>Example 1-6. Listing the video standards supported by the current
input</B
></P
><PRE
CLASS="PROGRAMLISTING"
>struct&nbsp;<A
HREF="r8936.htm#V4L2-INPUT"
>v4l2_input</A
> input;
struct&nbsp;<A
HREF="r9288.htm#V4L2-STANDARD"
>v4l2_standard</A
> standard;
memset (&amp;input, 0, sizeof (input));
if (-1 == ioctl (fd, <A
HREF="r11217.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_G_INPUT</CODE
></A
>, &amp;input.index)) {
perror ("VIDIOC_G_INPUT");
exit (EXIT_FAILURE);
}
if (-1 == ioctl (fd, <A
HREF="r8936.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMINPUT</CODE
></A
>, &amp;input)) {
perror ("VIDIOC_ENUM_INPUT");
exit (EXIT_FAILURE);
}
printf ("Current input %s supports:\n", input.name);
memset (&amp;standard, 0, sizeof (standard));
standard.index = 0;
while (0 == ioctl (fd, <A
HREF="r9288.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMSTD</CODE
></A
>, &amp;standard)) {
if (standard.id &amp; input.std)
printf ("%s\n", standard.name);
standard.index++;
}
/* EINVAL indicates the end of the enumeration, which cannot be
empty unless this device falls under the USB exception. */
if (errno != EINVAL || standard.index == 0) {
perror ("VIDIOC_ENUMSTD");
exit (EXIT_FAILURE);
}
</PRE
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN530"
></A
><P
><B
>Example 1-7. Selecting a new video standard</B
></P
><PRE
CLASS="PROGRAMLISTING"
>struct&nbsp;<A
HREF="r8936.htm#V4L2-INPUT"
>v4l2_input</A
> input;
<A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
> std_id;
memset (&amp;input, 0, sizeof (input));
if (-1 == ioctl (fd, <A
HREF="r11217.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_G_INPUT</CODE
></A
>, &amp;input.index)) {
perror ("VIDIOC_G_INPUT");
exit (EXIT_FAILURE);
}
if (-1 == ioctl (fd, <A
HREF="r8936.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_ENUMINPUT</CODE
></A
>, &amp;input)) {
perror ("VIDIOC_ENUM_INPUT");
exit (EXIT_FAILURE);
}
if (0 == (input.std &amp; V4L2_STD_PAL_BG)) {
fprintf (stderr, "Oops. B/G PAL is not supported.\n");
exit (EXIT_FAILURE);
}
/* Note this is also supposed to work when only B
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>or</I
></SPAN
> G/PAL is supported. */
std_id = V4L2_STD_PAL_BG;
if (-1 == ioctl (fd, <A
HREF="r12265.htm"
><CODE
CLASS="CONSTANT"
>VIDIOC_S_STD</CODE
></A
>, &amp;std_id)) {
perror ("VIDIOC_S_STD");
exit (EXIT_FAILURE);
}
</PRE
></DIV
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN463"
HREF="x448.htm#AEN463"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>Some users are already confused by technical terms PAL,
NTSC and SECAM. There is no point asking them to distinguish between
B, G, D, or K when the software or hardware can do that
automatically.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN475"
HREF="x448.htm#AEN475"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>An alternative to the current scheme is to use pointers
to indices as arguments of <CODE
CLASS="CONSTANT"
>VIDIOC_G_STD</CODE
> and
<CODE
CLASS="CONSTANT"
>VIDIOC_S_STD</CODE
>, the struct&nbsp;<A
HREF="r8936.htm#V4L2-INPUT"
>v4l2_input</A
> and
struct&nbsp;<A
HREF="r9149.htm#V4L2-OUTPUT"
>v4l2_output</A
> <CODE
CLASS="STRUCTFIELD"
>std</CODE
> field would be a set of
indices like <CODE
CLASS="STRUCTFIELD"
>audioset</CODE
>.</P
><P
>Indices are consistent with the rest of the API
and identify the standard unambiguously. In the present scheme of
things an enumerated standard is looked up by <A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
>. Now the
standards supported by the inputs of a device can overlap. Just
assume the tuner and composite input in the example above both
exist on a device. An enumeration of "PAL-B/G", "PAL-H/I" suggests
a choice which does not exist. We cannot merge or omit sets, because
applications would be unable to find the standards reported by
<CODE
CLASS="CONSTANT"
>VIDIOC_G_STD</CODE
>. That leaves separate enumerations
for each input. Also selecting a standard by <A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
> can be
ambiguous. Advantage of this method is that applications need not
identify the standard indirectly, after enumerating.</P
><P
>So in
summary, the lookup itself is unavoidable. The difference is only
whether the lookup is necessary to find an enumerated standard or to
switch to a standard by <A
HREF="r9288.htm#V4L2-STD-ID"
>v4l2_std_id</A
>.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN507"
HREF="x448.htm#AEN507"
><SPAN
CLASS="footnote"
>[3]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>See <A
HREF="x5953.htm"
>Section 3.5</A
> for a rationale. Probably
even USB cameras follow some well known video standard. It might have
been better to explicitly indicate elsewhere if a device cannot live
up to normal expectations, instead of this exception.</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x394.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x542.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Tuners and Modulators</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c174.htm"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>User Controls</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>