Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp316262imm; Tue, 7 Aug 2018 19:49:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwaIdwoFO1sc1jsvW6+bnDiwPZmXG+ScXo+BLlsoLhWW3Md0krPJIf29CgWnzWFw9L2cJHS X-Received: by 2002:a63:d74f:: with SMTP id w15-v6mr772371pgi.306.1533696558333; Tue, 07 Aug 2018 19:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533696558; cv=none; d=google.com; s=arc-20160816; b=h3jZlrgSZpMwNYMEv53a2DPSRumimxM6ClwzfCYr3Itun+aiL8DCs49cDfnfTVFlYs QZo0R4WTeB1vwqLl8EqW7NIHGCtGWAaPeEX5+E9OcvRTwxyLoPh9FB4zTLLSjJxQuah3 Onxe/fl6rtrK1ooOl/N/0CDsAD90mvgHukeI8kUoHCyPJmMUETTowB25stP2h6ky3yu1 qCTDhY3hyg5/FyMQ8mjOONhq2BPLvbpVdR/sBIcW8d+5tBzVJ0UTNovu1s2DxjtAiC92 MAxq4J+9rWR6DG51AMfsgbXS+hQJc3K6zilpiyjiiS8pGMiH9OPYfJoQ+zBuubFhE4Dn M/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=GnT4SNAIMYcDVD4ag0hqUdD5QqsAPSIRI5+RpszpjfQ=; b=xoXmPUrXsG2B3UG5+xcv1tVAW4OkSDEzaVhDWIwI176fsbIHHLwkKepWb/LvjJoXNP wn75+V9F1mJvXe+COvBY0pjbt0Bg8a001MRzvoMOnkFzlTOtALFsAbRM/b9nKaUasr7t 4ySxL8Uw4jBQOFTjrkrq8e5x/jdCWZQFbNkH1LAMZ1SwDS9/9l2CquvuGJ7zStAAsOud QbkMsjpByHjWH45rgxH4hHijGdY1q+86+e5xS+ryqmCpD/hZ0jg4iG+hp+xUa/0IC1AT xMfHGQkjaX0HILKy/ri86JCIUrlvZWqD+jqyi2aWf/l6K+IFG6T/xCcXqq3TYsp4CAIm we8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ROb0WP+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p77-v6si3323951pfj.294.2018.08.07.19.49.03; Tue, 07 Aug 2018 19:49:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ROb0WP+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbeHHFEQ (ORCPT + 99 others); Wed, 8 Aug 2018 01:04:16 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:42653 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbeHHFEP (ORCPT ); Wed, 8 Aug 2018 01:04:15 -0400 Received: by mail-yw1-f66.google.com with SMTP id y203-v6so507741ywd.9 for ; Tue, 07 Aug 2018 19:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GnT4SNAIMYcDVD4ag0hqUdD5QqsAPSIRI5+RpszpjfQ=; b=ROb0WP+qEw8maCE6tsp9wI7tBxBAk/RIAJwIokliXwHBKBt7rhH3W4drbrvwzDaj+L cQ+xsutBtr6MWfs09dUFBkZ2BxMrIVtwT+iai6KOBN37vwA6ZnUtsQCVhV0HxtnZxE0J 190WigJrbLEKrUpEDTQhaflYm1ilaQF0Kx0Do= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GnT4SNAIMYcDVD4ag0hqUdD5QqsAPSIRI5+RpszpjfQ=; b=B87AZilevB0kqjqInlsEaL/VTMCRWXsQucQLoWENsk/BQIViKeCbmTsHuH6REqBdy9 nb9b68ie7S05GU2J8Hec1ya06Hk+V6CiTYkrgGIQX8+7w/kx0YLoUmB8/QVus6/NsnXK QS6zcASYmW/0KDvUZbPyy5Vybmkt039E+lQIuwejhS+fpVSZ0WM8AYYhwe4kFKzlucNh vZ1nJxNldtlQap6p6vuWFhyv7O31U5QK1dGO5Ub0k4yNohMHVzydQvQjBc9eFcjTELxl HeTSgoH0y+3azznOTmBEw9L2W4S3XNzVYGcv11cQP8P+Z4EXb+sixpx/ditF8LvVLbHP 9KaA== X-Gm-Message-State: AOUpUlELtq6Rn3PTrFygWa6T8m7pK2NbaJnkhmuCEbAKetyxffZWEY1Z EfjGY2a4yQhNkd4iAcYW9ygJZRuMzvs= X-Received: by 2002:a0d:fc41:: with SMTP id m62-v6mr514777ywf.210.1533696411651; Tue, 07 Aug 2018 19:46:51 -0700 (PDT) Received: from mail-yw1-f52.google.com (mail-yw1-f52.google.com. [209.85.161.52]) by smtp.gmail.com with ESMTPSA id f82-v6sm3711118ywf.58.2018.08.07.19.46.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 19:46:50 -0700 (PDT) Received: by mail-yw1-f52.google.com with SMTP id z143-v6so510342ywa.7 for ; Tue, 07 Aug 2018 19:46:50 -0700 (PDT) X-Received: by 2002:a25:4b01:: with SMTP id y1-v6mr476013yba.344.1533696409570; Tue, 07 Aug 2018 19:46:49 -0700 (PDT) MIME-Version: 1.0 References: <20180724140621.59624-1-tfiga@chromium.org> <20180724140621.59624-2-tfiga@chromium.org> In-Reply-To: <20180724140621.59624-2-tfiga@chromium.org> From: Tomasz Figa Date: Wed, 8 Aug 2018 11:46:38 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] media: docs-rst: Document memory-to-memory video decoder interface To: Maxime Jourdan Cc: Linux Kernel Mailing List , Linux Media Mailing List , Stanimir Varbanov , Mauro Carvalho Chehab , Hans Verkuil , Pawel Osciak , Alexandre Courbot , kamil@wypas.org, a.hajda@samsung.com, Kyungmin Park , jtp.park@samsung.com, Philipp Zabel , =?UTF-8?B?VGlmZmFueSBMaW4gKOael+aFp+ePiik=?= , =?UTF-8?B?QW5kcmV3LUNUIENoZW4gKOmZs+aZuui/qik=?= , todor.tomov@linaro.org, nicolas@ndufresne.ca, Paul Kocialkowski , Laurent Pinchart , dave.stevenson@raspberrypi.org, Ezequiel Garcia Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Tue, Aug 7, 2018 at 5:32 AM Maxime Jourdan wro= te: > > Hi Tomasz, > > Sorry for sending this email only to you, I subscribed to linux-media > after you posted this and I'm not sure how to respond to everybody. > No worries. Let me reply with other recipients added back. Thanks for your comments. > I'm currently developing a V4L2 M2M decoder driver for Amlogic SoCs so > my comments are somewhat biased towards it > (https://github.com/Elyotna/linux) > > > +Seek > > +=3D=3D=3D=3D > > + > > +Seek is controlled by the ``OUTPUT`` queue, as it is the source of > > +bitstream data. ``CAPTURE`` queue remains unchanged/unaffected. > > + > > +1. Stop the ``OUTPUT`` queue to begin the seek sequence via > > + :c:func:`VIDIOC_STREAMOFF`. > > + > > + * **Required fields:** > > + > > + ``type`` > > + a ``V4L2_BUF_TYPE_*`` enum appropriate for ``OUTPUT`` > > + > > + * The driver must drop all the pending ``OUTPUT`` buffers and they = are > > + treated as returned to the client (following standard semantics). > > + > > +2. Restart the ``OUTPUT`` queue via :c:func:`VIDIOC_STREAMON` > > + > > + * **Required fields:** > > + > > + ``type`` > > + a ``V4L2_BUF_TYPE_*`` enum appropriate for ``OUTPUT`` > > + > > + * The driver must be put in a state after seek and be ready to > > + accept new source bitstream buffers. > > + > > +3. Start queuing buffers to ``OUTPUT`` queue containing stream data af= ter > > + the seek until a suitable resume point is found. > > + > > + .. note:: > > + > > + There is no requirement to begin queuing stream starting exactly= from > > + a resume point (e.g. SPS or a keyframe). The driver must handle = any > > + data queued and must keep processing the queued buffers until it > > + finds a suitable resume point. While looking for a resume point,= the > > + driver processes ``OUTPUT`` buffers and returns them to the clie= nt > > + without producing any decoded frames. > > + > > + For hardware known to be mishandling seeks to a non-resume point= , > > + e.g. by returning corrupted decoded frames, the driver must be a= ble > > + to handle such seeks without a crash or any fatal decode error. > > This is unfortunately my case, apart from parsing the bitstream > manually - which is a no-no -, there is no way to know when I'll be > writing in an IDR frame to the HW bitstream parser. I think it would > be much preferable that the client starts sending in an IDR frame for > sure. Most of the hardware, which have upstream drivers, deal with this correctly and there is existing user space that relies on this, so we cannot simply add such requirement. However, when sending your driver upstream, feel free to include a patch that adds a read-only control that tells the user space that it needs to do seeks to resume points. Obviously this will work only with user space aware of this requirement, but I don't think we can do anything better here. > > > +4. After a resume point is found, the driver will start returning > > + ``CAPTURE`` buffers with decoded frames. > > + > > + * There is no precise specification for ``CAPTURE`` queue of when i= t > > + will start producing buffers containing decoded data from buffers > > + queued after the seek, as it operates independently > > + from ``OUTPUT`` queue. > > + > > + * The driver is allowed to and may return a number of remaining > > + ``CAPTURE`` buffers containing decoded frames from before the s= eek > > + after the seek sequence (STREAMOFF-STREAMON) is performed. > > + > > + * The driver is also allowed to and may not return all decoded fr= ames > > + queued but not decode before the seek sequence was initiated. F= or > > + example, given an ``OUTPUT`` queue sequence: QBUF(A), QBUF(B), > > + STREAMOFF(OUT), STREAMON(OUT), QBUF(G), QBUF(H), any of the > > + following results on the ``CAPTURE`` queue is allowed: {A=E2=80= =99, B=E2=80=99, G=E2=80=99, > > + H=E2=80=99}, {A=E2=80=99, G=E2=80=99, H=E2=80=99}, {G=E2=80=99,= H=E2=80=99}. > > + > > + .. note:: > > + > > + To achieve instantaneous seek, the client may restart streaming = on > > + ``CAPTURE`` queue to discard decoded, but not yet dequeued buffe= rs. > > Overall, I think Drain followed by V4L2_DEC_CMD_START is a more > applicable scenario for seeking. > Heck, simply starting to queue buffers at the seek - starting with an > IDR - without doing any kind of streamon/off or cmd_start(stop) will > do the trick. Why do you think so? For a seek, as expected by a typical device user, the result should be discarding anything already queued and just start decoding new frames as soon as possible. Actually, this section doesn't describe any specific sequence, just possible ways to do a seek using existing primitives. Best regards, Tomasz