mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Tomasz Figa <tfiga@chromium.org>
Cc: "Pawel Osciak" <posciak@chromium.org>,
	"Linux Media Mailing List" <linux-media@vger.kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Alexandre Courbot" <acourbot@chromium.org>,
	kamil@wypas.org, a.hajda@samsung.com,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	jtp.park@samsung.com,
	"Tiffany Lin (林慧珊)" <tiffany.lin@mediatek.com>,
	"Andrew-CT Chen (陳智迪)" <andrew-ct.chen@mediatek.com>,
	"Stanimir Varbanov" <stanimir.varbanov@linaro.org>,
	todor.tomov@linaro.org, nicolas@ndufresne.ca,
	"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>
Subject: Re: [RFC PATCH 2/2] media: docs-rst: Add encoder UAPI specification to Codec Interfaces
Date: Wed, 06 Jun 2018 11:40:03 +0200	[thread overview]
Message-ID: <1528278003.3438.3.camel@pengutronix.de> (raw)
In-Reply-To: <CAAFQd5DqHj65AdzfYmvHWkqHnZntiiA2AhAfgHbLA3AuWvsOTQ@mail.gmail.com>

On Wed, 2018-06-06 at 18:17 +0900, Tomasz Figa wrote:
> On Tue, Jun 5, 2018 at 11:23 PM Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > 
> > On Tue, 2018-06-05 at 21:31 +0900, Tomasz Figa wrote:
> > [...]
> > > +Initialization
> > > > > +--------------
> > > > > +
> > > > > +1. (optional) Enumerate supported formats and resolutions. See
> > > > > +   capability enumeration.
> > > > > +
> > > > > +2. Set a coded format on the CAPTURE queue via :c:func:`VIDIOC_S_FMT`
> > > > > +
> > > > > +   a. Required fields:
> > > > > +
> > > > > +      i.  type = CAPTURE
> > > > > +
> > > > > +      ii. fmt.pix_mp.pixelformat set to a coded format to be produced
> > > > > +
> > > > > +   b. Return values:
> > > > > +
> > > > > +      i.  EINVAL: unsupported format.
> > > > > +
> > > > > +      ii. Others: per spec
> > > > > +
> > > > > +   c. Return fields:
> > > > > +
> > > > > +      i. fmt.pix_mp.width, fmt.pix_mp.height should be 0.
> > > > > +
> > > > > +   .. note::
> > > > > +
> > > > > +      After a coded format is set, the set of raw formats
> > > > > +      supported as source on the OUTPUT queue may change.
> > > > 
> > > > So setting CAPTURE potentially also changes OUTPUT format?
> > > 
> > > Yes, but at this point userspace hasn't yet set the desired format.
> > > 
> > > > If the encoded stream supports colorimetry information, should that
> > > > information be taken from the CAPTURE queue?
> > > 
> > > What's colorimetry? Is it something that is included in
> > > v4l2_pix_format(_mplane)? Is it something that can vary between raw
> > > input and encoded output?
> > 
> > FTR, yes, I meant the colorspace, ycbcr_enc, quantization, and xfer_func
> > fields of the v4l2_pix_format(_mplane) structs. GStreamer uses the term
> > "colorimetry" to pull these fields together into a single parameter.
> > 
> > The codecs usually don't care at all about this information, except some
> > streams (such as h.264 in the VUI parameters section of the SPS header)
> > may optionally contain a representation of these fields, so it may be
> > desirable to let encoders write the configured colorimetry or to let
> > decoders return the detected colorimetry via G_FMT(CAP) after a source
> > change event.
> > 
> > I think it could be useful to enforce the same colorimetry on CAPTURE
> > and OUTPUT queue if the hardware doesn't do any colorspace conversion.
> 
> After thinking a bit more on this, I guess it wouldn't overly
> complicate things if we require that the values from OUTPUT queue are
> copied to CAPTURE queue, if the stream doesn't include such
> information or the hardware just can't parse them.

And for encoders it would be copied from CAPTURE queue to OUTPUT queue?

> Also, userspace
> that can't parse them wouldn't have to do anything, as the colorspace
> default on OUTPUT would be V4L2_COLORSPACE_DEFAULT and if hardware
> can't parse it either, it would just be propagated to CAPTURE.

I wonder if this wouldn't change the meaning of V4L2_COLORSPACE_DEFAULT?
Documentation/media/uapi/v4l/colorspaces-defs.rst states:

      - The default colorspace. This can be used by applications to let
        the driver fill in the colorspace.

This sounds to me like it is intended to be used by the application
only, like V4L2_FIELD_ANY. If we let decoders return
V4L2_COLORSPACE_DEFAULT on the CAPTURE queue to indicate they have no
idea about colorspace, it should be mentioned explicitly and maybe
clarify in colorspaces-defs.rst as well.

[...]
> > > > > +Encoding parameter changes
> > > > > +--------------------------
> > > > > +
> > > > > +The client is allowed to use :c:func:`VIDIOC_S_CTRL` to change encoder
> > > > > +parameters at any time. The driver must apply the new setting starting
> > > > > +at the next frame queued to it.
> > > > > +
> > > > > +This specifically means that if the driver maintains a queue of buffers
> > > > > +to be encoded and at the time of the call to :c:func:`VIDIOC_S_CTRL` not all the
> > > > > +buffers in the queue are processed yet, the driver must not apply the
> > > > > +change immediately, but schedule it for when the next buffer queued
> > > > > +after the :c:func:`VIDIOC_S_CTRL` starts being processed.
> > > > 
> > > > Does this mean that hardware that doesn't support changing parameters at
> > > > runtime at all must stop streaming and restart streaming internally with
> > > > every parameter change? Or is it acceptable to not allow the controls to
> > > > be changed during streaming?
> > > 
> > > That's a good question. I'd be leaning towards the latter (not allow),
> > > as to keep kernel code simple, but maybe we could have others
> > > (especially Pawel) comment on this.
> > 
> > Same here.
> 
> Same as where? :)

I'd be leaning towards the latter (not allow) as well.

> > [...]
> > > > > +2. Enumerating formats on OUTPUT queue must only return OUTPUT formats
> > > > > +   supported for the CAPTURE format currently set.
> > > > > +
> > > > > +3. Setting/changing format on OUTPUT queue does not change formats
> > > > > +   available on CAPTURE queue. An attempt to set OUTPUT format that
> > > > > +   is not supported for the currently selected CAPTURE format must
> > > > > +   result in an error (-EINVAL) from :c:func:`VIDIOC_S_FMT`.
> > > > 
> > > > Same as for decoding, is this limited to pixel format? Why isn't the
> > > > pixel format corrected to a supported choice? What about
> > > > width/height/colorimetry?
> > > 
> > > Width/height/colorimetry(Do you mean color space?) is a part of
> > > v4l2_pix_format(_mplane). I believe that's what this point was about.
> > 
> > Yes. My question was more about whether this should return -EINVAL or
> > whether TRY_FMT/S_FMT should change the parameters to valid values.
> 
> As per the standard semantics of TRY_/S_FMT, they should adjust the
> format on given queue. We only require that the state on other queue
> is left intact.

This contradicts 3. above, which says S_FMT(OUT) should instead return
-EINVAL if the format doesn't match.

regards
Philipp

  reply	other threads:[~2018-06-06  9:40 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 10:33 [RFC PATCH 0/2] Document the V4L2 (stateful) Codec API Tomasz Figa
2018-06-05 10:33 ` [RFC PATCH 1/2] media: docs-rst: Add decoder UAPI specification to Codec Interfaces Tomasz Figa
2018-06-05 11:41   ` Philipp Zabel
2018-06-05 13:42     ` Tomasz Figa
2018-06-06 10:44       ` Philipp Zabel
2018-06-07  7:27         ` Tomasz Figa
2018-06-07 17:49           ` Nicolas Dufresne
2018-06-06 13:02       ` Alexandre Courbot
2018-06-05 13:10   ` Dave Stevenson
2018-06-06  9:03     ` Tomasz Figa
2018-06-06 13:13       ` Alexandre Courbot
2018-06-07  7:21     ` Hans Verkuil
2018-06-07  7:30       ` Tomasz Figa
2018-06-07 17:53         ` Nicolas Dufresne
2018-06-07 19:36           ` Hans Verkuil
2018-06-07  8:47   ` Hans Verkuil
2018-06-07 11:01     ` Philipp Zabel
2018-06-08  9:03     ` Tomasz Figa
2018-06-08 10:13       ` Hans Verkuil
2018-06-07 17:30   ` Nicolas Dufresne
2018-06-08 10:42     ` Tomasz Figa
2018-06-14 12:34   ` Stanimir Varbanov
2018-06-14 13:56     ` Nicolas Dufresne
2018-06-15  8:02     ` Tomasz Figa
2018-09-11  2:26   ` Nicolas Dufresne
2018-09-11  3:10     ` Tomasz Figa
2018-06-05 10:33 ` [RFC PATCH 2/2] media: docs-rst: Add encoder " Tomasz Figa
2018-06-05 11:53   ` Philipp Zabel
2018-06-05 12:31     ` Tomasz Figa
2018-06-05 14:22       ` Philipp Zabel
2018-06-06  9:17         ` Tomasz Figa
2018-06-06  9:40           ` Philipp Zabel [this message]
2018-06-06 10:37             ` Tomasz Figa
2018-06-07  7:27               ` Hans Verkuil
2018-06-07 10:32                 ` Philipp Zabel
2018-06-07 10:54                   ` Hans Verkuil
2018-06-07 11:02                     ` Philipp Zabel
2018-06-07  9:21   ` Hans Verkuil
2018-06-07 10:39     ` Philipp Zabel
2018-06-11  7:49     ` Tomasz Figa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1528278003.3438.3.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=a.hajda@samsung.com \
    --cc=acourbot@chromium.org \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jtp.park@samsung.com \
    --cc=kamil@wypas.org \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=posciak@chromium.org \
    --cc=stanimir.varbanov@linaro.org \
    --cc=tfiga@chromium.org \
    --cc=tiffany.lin@mediatek.com \
    --cc=todor.tomov@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®