From patchwork Tue Apr 12 15:53:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elie Roudninski X-Patchwork-Id: 34687 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1654071pzh; Tue, 12 Apr 2022 08:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+MpjcdiDYpmU+STYvtJvUgYY7Hzyaubljh3aeSCK9HWUyd1N92wKhbDLi/ROH241AVkvk X-Received: by 2002:a05:6402:4391:b0:419:2f2d:a1da with SMTP id o17-20020a056402439100b004192f2da1damr39516197edc.298.1649778818905; Tue, 12 Apr 2022 08:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649778818; cv=none; d=google.com; s=arc-20160816; b=mEifjrCRJ8Y1UnUipbXpbvBtyPkDSoiQXrM46+TDhxN9OCvXG5IfTaN5w9fK78BlgD 1Vcqnhx9nofgCERoMyavsQOrRp0OQvo7IJUGbGQ+/hBqZ7PsbAUvIam02OR8leLCrOkx AoUthxYAOWrsW9aKfIwCAciCb7Jn0EsAPqvvgZBNTwnIpHBKkswDaHTJv+1xSXZAgGsy N0r+rFaYbEYeWgUvKucWbtskzs2XH6sDWRoTSj+zuiyMOUuZYjFD8I80q7CpaZEGYwKD EC47+PXtzfjplaWWWPT/wlKcwdWlkGC44wrOI/A0YOWLtqa2G03Pf/w7GhiQtTy++b6v OheA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=hcjC85dvuECnIgMsia8sjYIXVB6qUsxr8C+lMikt6AI=; b=nPVtGV7ppOwWCKXKMCRX/r62D/gHRp7R9lLsYTJTI0QDH3yXiJ/Ln7tOuz4vy58+mq VNvMyiAsDhIH6BnHlv6oV8+uCde+iKarQNYLlHyd199qQh/E3LdEKQ501a/HokNEnAdh 9ITgEdENu92H/RuOSq7bFUbb1XTmo4EVxN6lTGGYz92FZwOuM2yB480VE/8HhkbZLxtr DP9Qde4hPtZ1cSQUvoweWws/rzPkHe/Hj9hRaIaY5kQBXJKswAKvX3sWaX0KSRyrDiH/ YcRej0Aloy0DwCfqtha5zyY9oQnBeeWND+V2ZH+CPYIKfbFTTAkGDyPZ8ErsOvuLOENM 8PWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qxst31XX; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bq10-20020a170906d0ca00b006df76385babsi2322220ejb.75.2022.04.12.08.53.37; Tue, 12 Apr 2022 08:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qxst31XX; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 864B168B292; Tue, 12 Apr 2022 18:53:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CBEDA68ABA7 for ; Tue, 12 Apr 2022 18:53:27 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id u17-20020a05600c211100b0038eaf4cdaaeso2097111wml.1 for ; Tue, 12 Apr 2022 08:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q8iLm603flV2qlOThxwlHVWcGQ1YPx1ZF2OKR2cpKek=; b=qxst31XX5jF73prHzvvPP6aE0hgqb1quY1kNbQx5XQB7VYB7apDfJu/UgL+25e0eJM TOmCwWbVJZq2UBou/vjynsN/lAQ0F9bimgLB5VrEnkdzryBY+PZb6mxMuBNKwFY3PBx8 pT7gUll8Twsses5dKr3ykviWCv669dJd3Bspu7IaZQbxdiZ/TuvWbRwlxrMozv7fRZ+8 68kGaSmwd8LIhzaa7KJ9BwaobS7QTxp2nt4Lrp6t1vdM7y5ncRZz/o8r4+5jCTiyLSrG 3K3HpMlBskxgc4Uiyzp7QPogEw0SfWZE0BnymYmciMTt1xolTlypZYgE52XeRR6soTnd Q9wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q8iLm603flV2qlOThxwlHVWcGQ1YPx1ZF2OKR2cpKek=; b=n7jZ5ravXDX1cuGsWsmARpse+gbUkmqL01r1w1FzWsFj1ygu+blORKMc1QfoGKQVyD 2eHJWxFEh27lWitFEMyUHAaCP1A73/sRCaU93tgstKMuktF5qoW2/6DHUh/lkEBBL/DC yGiDAauX7erSwsruHud5mGwd/JI1Fj2VSvTbn7OJ244NLGGHGzfY+Kqo9Jrp8AFecubh W7Fh+ZZDaduXwS3+Y/nzKUEXW//nOkezpbQTn5xGiA6ElJCKcvt+/5vuKYc7sFPPnfve LJ3/qvlqIc95aLX0i8L3TFtTPKcIbybhc5a9fHo/zlq0mXAopPjyfFfSGUje+Iq39zbO zctQ== X-Gm-Message-State: AOAM531bXDaQkMete1yPhJpJrblV2KOkNRhUwplFJ3TXM1+WDh/02/1z TfOlxmY6wdyBCrv1+9m+mR/UTYpE3YI= X-Received: by 2002:a1c:35c1:0:b0:38e:c4f6:1931 with SMTP id c184-20020a1c35c1000000b0038ec4f61931mr4573626wma.161.1649778806687; Tue, 12 Apr 2022 08:53:26 -0700 (PDT) Received: from localhost.localdomain (2a01cb04051815002a7fcffffe8ae6ac.ipv6.abo.wanadoo.fr. [2a01:cb04:518:1500:2a7f:cfff:fe8a:e6ac]) by smtp.gmail.com with ESMTPSA id n2-20020adfb742000000b00205eda3b3c1sm31264590wre.34.2022.04.12.08.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 08:53:26 -0700 (PDT) From: xademax@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 17:53:14 +0200 Message-Id: <20220412155316.22417-1-xademax@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 0/2] Add common V4L2 request API code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Elie ROUDNINSKI Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: L4iRCSTeHnXF From: Elie ROUDNINSKI This is the second iteration of https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=2898 but only covering the common V4L2 request API code without the support for h264 codec. Changes in v2: * Addressed some styling comments * Removed libudev dependency * Device probing has been refactored This code (in one version or another) has been widely used by various projects like LibreELEC[1] for several years already. The uAPI has been stable for several kernel versions too and as of linux5.17, the following codecs are available: * mpeg2 * h264 * vp9 HEVC is in the process of being stabilized too[2]. I have tried to contact the original author of the code but I haven't got an answer so far so I have kept them as commit author but added myself as co-author since I have made substantial modifications to it. Happy to change this either way. It's my first contribution to FFmpeg, so I hope to have done everything right. Additionally, I must confess that I am not an expert of the V4L2 request APIs but since I was frustrated of not being able to use standard FFmpeg on my ARM boards to get hardware decoding working, I figured I might just try to give it a go. There are several comments in the original patch series that I won't have an answer for but I hope that won't be a blocker. That's also why the v4l2-request configure option has been marked as experimental. [1] https://github.com/LibreELEC/LibreELEC.tv/tree/master/packages/multimedia/ffmpeg/patches/v4l2-request [2] https://patchwork.kernel.org/project/linux-media/list/?series=630077 Jonas Karlman (2): avutil/buffer: add av_buffer_pool_flush() avcodec: add common V4L2 request API code configure | 7 + doc/APIchanges | 3 + libavcodec/Makefile | 3 +- libavcodec/hwconfig.h | 2 + libavcodec/v4l2_buffers.c | 8 +- libavcodec/v4l2_context.c | 80 ++-- libavcodec/v4l2_context.h | 5 +- libavcodec/v4l2_device.c | 229 ++++++++++ libavcodec/v4l2_device.h | 60 +++ libavcodec/v4l2_m2m.c | 119 ++--- libavcodec/v4l2_m2m.h | 4 +- libavcodec/v4l2_m2m_dec.c | 10 +- libavcodec/v4l2_m2m_enc.c | 8 +- libavcodec/v4l2_request.c | 892 ++++++++++++++++++++++++++++++++++++++ libavcodec/v4l2_request.h | 87 ++++ libavutil/buffer.c | 7 + libavutil/buffer.h | 5 + libavutil/version.h | 4 +- 18 files changed, 1399 insertions(+), 134 deletions(-) create mode 100644 libavcodec/v4l2_device.c create mode 100644 libavcodec/v4l2_device.h create mode 100644 libavcodec/v4l2_request.c create mode 100644 libavcodec/v4l2_request.h