Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5438170imu; Tue, 29 Jan 2019 20:03:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN72vH0QrHkLBbCAwb/Nxnz4jTpK9KoruBEujuHr20a4TKAcbY6BbDctoDMCuw5pD30PwT7p X-Received: by 2002:a62:1043:: with SMTP id y64mr29308587pfi.78.1548820983529; Tue, 29 Jan 2019 20:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548820983; cv=none; d=google.com; s=arc-20160816; b=0Tcuc0ISG1X2wn1h2jZZ+s8D4GzalggwLZVuKWdGH2a8nwwzHLZltDA2oPy88PQPsM DFLa+b8zDS+TKRXItAFbApY4Muks8SEY3wboiIjjhLr2czIQIXhansE9u3DQd6H3KC6d 9qNiQdAzFhOM+4/HUEEvgLeax7tobp6Gc+uWrUbgZSwqdLeJatMwjpV7psdmNLO1N5bP PqD4+NtH1B+tKzm/YRKuHt5445wLUY25gtFuziFpItmAU8FQr9GFLFHY7Uiyy2AW49za trEYRooDkFbycsLO0aO2aN9NtsKexabSrCAzE4mfIVutSHuJhYZknSihM+fITpbFye1t FK2w== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=mpAyJ6A+4zaq0y6PQ+k7WfMDxV/WMZyQex98KcwNFrc=; b=IZZme3CF0gYs3uvU52amWI2hzUVKCd+QVzpVQg0qJd7ZLR6Q3On5/y8/wRSZkYCZ6m zkGXw+MxTHzBsGAVgxC0DdnnnmCB3mFd+3WUa5rTqiYh7uzMSjAHc4cVTEPZyezO53g+ Q4BaE8W/PXNFaPh/bHLSZlb56HI9vQ5inVCMDrWmy7pAzid8R2V1qw83vOMdsTERzF19 vZXvCr1eNsuwHgCESX1KUxbguGBFiicmbD3MuHX7xpdoT7PN+x6EXVxTNQm2CooaqCnN /w7rqN8cbWSff0pHQ7zwErSBIi7SxB2Tr1Fg/Sir9FYKiS5ZOWj/ODqIfBf1+wLxn1RC 6zyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=peYpHg6e; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si306358plp.304.2019.01.29.20.02.47; Tue, 29 Jan 2019 20:03:03 -0800 (PST) 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=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=peYpHg6e; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729169AbfA3ECm (ORCPT + 99 others); Tue, 29 Jan 2019 23:02:42 -0500 Received: from mail-qt1-f174.google.com ([209.85.160.174]:46291 "EHLO mail-qt1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbfA3ECm (ORCPT ); Tue, 29 Jan 2019 23:02:42 -0500 Received: by mail-qt1-f174.google.com with SMTP id y20so24794535qtm.13 for ; Tue, 29 Jan 2019 20:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=mpAyJ6A+4zaq0y6PQ+k7WfMDxV/WMZyQex98KcwNFrc=; b=peYpHg6e9zxANg71FCvjlY+J/nOX+aNC3OKf3IKw8pTL8bchvs6AM3M37QAchtaMKi baYaZEysPvjzu0RhGvA2A5XdapqWYOsnzJHL89qz6yl5kosfAu5kjr/TQQ3303LXomE3 zP/6lOm4XltjVZBReWbvpiZmuad4EaWgcO+G6jDioLNMQux+umIXwbQksoad0WJD1iVo zsqiPPEd2Qk9rKawHL8UMzXTuRDyVa4RQZ4GPynu1l7zIrRM+IDonmZ0miEDo8aB7N3R oZmYJR9NKthRF/EUHC+sRrCq7oYoRr8Dd2wIL78yIaCj2nf45G6+TPfZVqUoGTj9ngXw vxEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=mpAyJ6A+4zaq0y6PQ+k7WfMDxV/WMZyQex98KcwNFrc=; b=WSvgv8PWAbkOeP2RX7/aL3Wm1QYObJ4tVtfP1qp8WRFjvcF3SOR5XZnYxayCOsaw+N OizeXvhQeyS+3mS/yVKLdk0fB/luQFAplxX5ue/mN+VS9ta6htOCmdci5q2ItFTcx6YC XhMxxeVIn7keb3CAGmP+Sj1wg/s9IwbaFdzRCRI/EKD0c7569K7vVPId3yQWRcPmZHL5 g9ff9jHdoJ8KM6KXmupgcUZq3c4Ny9bw4WF9f7EYlJ646Gw5CzRkB08MZUDF+Dnkebc3 pIJx0LzqkKs18JIE194U1Oh9OO0SphSaby15s/mSImSD2Wxd+iaffwSZfo9b0eejdnS3 R8gw== X-Gm-Message-State: AJcUukfRY3QYP5JZ58EB73uxoJoUnjL2IbB/2cCNh5JT8NWQhQgZMNei w/0/dMZAN7kcuWPma+I36gkyOg== X-Received: by 2002:a0c:e394:: with SMTP id a20mr26413478qvl.42.1548820960990; Tue, 29 Jan 2019 20:02:40 -0800 (PST) Received: from skullcanyon ([192.222.193.21]) by smtp.gmail.com with ESMTPSA id y4sm670810qtc.47.2019.01.29.20.02.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 20:02:39 -0800 (PST) Message-ID: Subject: Re: [PATCH v2 1/2] media: docs-rst: Document memory-to-memory video decoder interface From: Nicolas Dufresne To: Tomasz Figa Cc: Hans Verkuil , Linux Media Mailing List , Linux Kernel Mailing List , Mauro Carvalho Chehab , Pawel Osciak , Alexandre Courbot , Kamil Debski , Andrzej Hajda , Kyungmin Park , Jeongtae Park , Philipp Zabel , Tiffany Lin =?UTF-8?Q?=28=E6=9E=97=E6=85=A7=E7=8F=8A=29?= , Andrew-CT Chen =?UTF-8?Q?=28=E9=99=B3=E6=99=BA=E8=BF=AA=29?= , Stanimir Varbanov , Todor Tomov , Paul Kocialkowski , Laurent Pinchart , dave.stevenson@raspberrypi.org, Ezequiel Garcia , Maxime Jourdan Date: Tue, 29 Jan 2019 23:02:38 -0500 In-Reply-To: References: <20181022144901.113852-1-tfiga@chromium.org> <20181022144901.113852-2-tfiga@chromium.org> <9b7c1385-d482-6e92-2222-2daa835dbc91@xs4all.nl> <3ea3bf5bf9904ce877142c41f595207752172d27.camel@ndufresne.ca> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.4 (3.30.4-1.fc29) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le vendredi 25 janvier 2019 à 12:27 +0900, Tomasz Figa a écrit : > On Fri, Jan 25, 2019 at 4:55 AM Nicolas Dufresne wrote: > > Le jeudi 24 janvier 2019 à 18:06 +0900, Tomasz Figa a écrit : > > > > Actually I just realized the last point might not even be achievable > > > > for some of the decoders (s5p-mfc, mtk-vcodec), as they don't report > > > > which frame originates from which bitstream buffer and the driver just > > > > picks the most recently consumed OUTPUT buffer to copy the timestamp > > > > from. (s5p-mfc actually "forgets" to set the timestamp in some cases > > > > too...) > > > > > > > > I need to think a bit more about this. > > > > > > Actually I misread the code. Both s5p-mfc and mtk-vcodec seem to > > > correctly match the buffers. > > > > Ok good, since otherwise it would have been a regression in MFC driver. > > This timestamp passing thing could in theory be made optional though, > > it lives under some COPY_TIMESTAMP kind of flag. What that means though > > is that a driver without such a capability would need to signal dropped > > frames using some other mean. > > > > In userspace, the main use is to match the produced frame against a > > userspace specific list of frames. At least this seems to be the case > > in Gst and Chromium, since the userspace list contains a superset of > > the metadata found in the v4l2_buffer. > > > > Now, using the produced timestamp, userspace can deduce frame that the > > driver should have produced but didn't (could be a deadline case codec, > > or simply the frames where corrupted). It's quite normal for a codec to > > just keep parsing until it finally find something it can decode. > > > > That's at least one way to do it, but there is other possible > > mechanism. The sequence number could be used, or even producing buffers > > with the ERROR flag set. What matters is just to give userspace a way > > to clear these frames, which would simply grow userspace memory usage > > over time. > > Is it just me or we were missing some consistent error handling then? > > I feel like the drivers should definitely return the bitstream buffers > with the ERROR flag, if there is a decode failure of data in the > buffer. Still, that could become more complicated if there is more > than 1 frame in that piece of bitstream, but only 1 frame is corrupted > (or whatever). I agree, but it might be more difficult then it looks (even FFMPEG does not do that). I believe the code that is processing the bitstream in stateful codecs is mostly unrelated from the code actually doing the decoding. So what might happen is that the decoding part will never actually allocate a buffer for the skipped / corrupted part of the bitstream. Also, the notion of a skipped frame is not always evident in when parsing H264 or HEVC NALs. There is still a full page of text just to explain how to detect that start of a new frame. Yet, it would be interesting to study the firmwares we have and see what they provide that would help making decode errors more explicit. > > Another case is when the bitstream, even if corrupted, is still enough > to produce some output. My intuition tells me that such CAPTURE buffer > should be then returned with the ERROR flag. That wouldn't still be > enough for any more sophisticated userspace error concealment, but > could still let the userspace know to perhaps drop the frame. You mean if a frame was concealed (typically the frame was decoded from a closed by reference instead of the expected reference). That is something signalled by FFPEG. We should document this possibility. I actually have something implemented in GStreamer. Basically if we have the ERROR flag with a payload size smaller then expected, I drop the frame and produce a drop event message, while if I have a frame with ERROR flag but of the right payload size, I assume it is corrupted, and simply flag it as corrupted, leaving to the application the decision to display it or not. This is a case that used to happen with some UVC cameras (though some have been fixed, and the UVC camera should drop smaller payload size buffers now). > > Best regards, > Tomasz