Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5075857imm; Tue, 7 Aug 2018 12:12:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfecXWYdLYvfRSTaSuTPmG78h+s2Zu8p/dHn6a28iPuJ1nmI3Y613W9FDHRO7I0m66SF9t8 X-Received: by 2002:a17:902:a9c8:: with SMTP id b8-v6mr18840430plr.343.1533669171077; Tue, 07 Aug 2018 12:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533669171; cv=none; d=google.com; s=arc-20160816; b=01Cz1zZSHkuLr+hTHUZYb6GnewhtqvixJ++qy2Jc33Jng7SbR2CxgNc8RMIEX17QFK QY9FWMt5TY59wp582UZUM7KXBNV2ODrx0N50uXSDMyY+lFhyTftzgRPFKYejGCYmsiaf 1Lx5rYipG9MRqqs2JREhFyFcA+uvabVQt6ek86KM/xe9V4ve2a44ubfXgsGbmr3iGMSO VWxK8iT+Huy4j4V0OAbhV4F9YqPBZyhs/tuIVIAhRyYbaca8pypaZocn1UkY0bcFsfAJ 0+d1IfV2kaACLIPJFcUWrmBB5OUDugoTRbye8zgytAofjvDH9jn2a7F1LVUVrpZWX4OA li/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=/NiXIjwxMQa5tocBPW+oRDYBUANgn/nIykBkv6CLB3s=; b=SrbpXPPIDkD96/9icFN3fD6KIy3n3uxQsZWA7sioqH4IIcxzANf0PJ7GhZQ06YDjU4 Uo9nkpB3XfbKFJ15dfJAJqx1XsenMT0uMiInjmtlOAzPGACgU8ICCdWbSFzND0pDxc0D ge2uMeAHZRdnzVjs2GygCV3Y//DumR8Lbh89TfhT4qOe2M7iOvjs/gaue5+Dsy3yQEJN 4rRzmCEocuohXg3qcpOzQ+OY2PmMNcuUUj2qsvyY5/l+UYPokeMPfleilSBzj/Qv6vD5 dGZzCIF9wfN3hd/MswxctKYGMQ4qN1VlwsZWewjhmt2Vo4Kb09ysZ+NVCyOiRvXdcnYk c1sw== ARC-Authentication-Results: i=1; mx.google.com; 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 y8-v6si2324463pfk.75.2018.08.07.12.12.36; Tue, 07 Aug 2018 12:12:51 -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; 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 S2389791AbeHGV06 (ORCPT + 99 others); Tue, 7 Aug 2018 17:26:58 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:37556 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388802AbeHGV06 (ORCPT ); Tue, 7 Aug 2018 17:26:58 -0400 Received: from mail-qt0-f173.google.com ([209.85.216.173]) by mwinf5d50 with ME id LKB51y00N3l2wht03KB5DQ; Tue, 07 Aug 2018 21:11:06 +0200 X-ME-Helo: mail-qt0-f173.google.com X-ME-Auth: bWF4aS5qb3VyZGFuQHdhbmFkb28uZnI= X-ME-Date: Tue, 07 Aug 2018 21:11:06 +0200 X-ME-IP: 209.85.216.173 Received: by mail-qt0-f173.google.com with SMTP id m13-v6so19209962qth.1; Tue, 07 Aug 2018 12:11:05 -0700 (PDT) X-Gm-Message-State: AOUpUlEmD+5vtjP4oWDLdMAjD+XV5hsnsH/03QQ5XeH586ogKT2Nmfoa IFuPqkq60NQGwIW39lvFHei2wPcvjgftBpk2Egc= X-Received: by 2002:a0c:881c:: with SMTP id 28-v6mr18309068qvl.109.1533669065197; Tue, 07 Aug 2018 12:11:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:aed:278a:0:0:0:0:0 with HTTP; Tue, 7 Aug 2018 12:11:04 -0700 (PDT) In-Reply-To: References: <20180724140621.59624-1-tfiga@chromium.org> <20180724140621.59624-2-tfiga@chromium.org> <37a8faea-a226-2d52-36d4-f9df194623cc@xs4all.nl> From: Maxime Jourdan Date: Tue, 7 Aug 2018 21:11:04 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] media: docs-rst: Document memory-to-memory video decoder interface To: Hans Verkuil Cc: Tomasz Figa , Linux Media Mailing List , Linux Kernel Mailing List , Stanimir Varbanov , Mauro Carvalho Chehab , 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-08-07 9:13 GMT+02:00 Hans Verkuil : > On 07/26/2018 12:20 PM, Tomasz Figa wrote: >> Hi Hans, >> >> On Wed, Jul 25, 2018 at 8:59 PM Hans Verkuil wrote: >>>> + >>>> +14. Call :c:func:`VIDIOC_STREAMON` to initiate decoding frames. >>>> + >>>> +Decoding >>>> +======== >>>> + >>>> +This state is reached after a successful initialization sequence. In this >>>> +state, client queues and dequeues buffers to both queues via >>>> +:c:func:`VIDIOC_QBUF` and :c:func:`VIDIOC_DQBUF`, following standard >>>> +semantics. >>>> + >>>> +Both queues operate independently, following standard behavior of V4L2 >>>> +buffer queues and memory-to-memory devices. In addition, the order of >>>> +decoded frames dequeued from ``CAPTURE`` queue may differ from the order of >>>> +queuing coded frames to ``OUTPUT`` queue, due to properties of selected >>>> +coded format, e.g. frame reordering. The client must not assume any direct >>>> +relationship between ``CAPTURE`` and ``OUTPUT`` buffers, other than >>>> +reported by :c:type:`v4l2_buffer` ``timestamp`` field. >>> >>> Is there a relationship between capture and output buffers w.r.t. the timestamp >>> field? I am not aware that there is one. >> >> I believe the decoder was expected to copy the timestamp of matching >> OUTPUT buffer to respective CAPTURE buffer. Both s5p-mfc and coda seem >> to be implementing it this way. I guess it might be a good idea to >> specify this more explicitly. > > What about an output buffer producing multiple capture buffers? Or the case > where the encoded bitstream of a frame starts at one output buffer and ends > at another? What happens if you have B frames and the order of the capture > buffers is different from the output buffers? > > In other words, for codecs there is no clear 1-to-1 relationship between an > output buffer and a capture buffer. And we never defined what the 'copy timestamp' > behavior should be in that case or if it even makes sense. > > Regards, > > Hans As it is done right now in userspace (FFmpeg, GStreamer) and most (if not all?) drivers, it's a 1:1 between OUTPUT and CAPTURE. The only thing that changes is the ordering since OUTPUT buffers are in decoding order while CAPTURE buffers are in presentation order. This almost always implies some timestamping kung-fu to match the OUTPUT timestamps with the corresponding CAPTURE timestamps. It's often done indirectly by the firmware on some platforms (rpi comes to mind iirc). The current constructions also imply one video packet per OUTPUT buffer. If a video packet is too big to fit in a buffer, FFmpeg will crop that packet to the maximum buffer size and will discard the remaining packet data. GStreamer will abort the decoding. This is unfortunately one of the shortcomings of having fixed-size buffers. And if they were to split the packet in multiple buffers, then some drivers in their current state wouldn't be able to handle the timestamping issues and/or x:1 OUTPUT:CAPTURE buffer numbers. Maxime