From patchwork Wed Dec 9 20:25:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 24458 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BF1B444BD89 for ; Wed, 9 Dec 2020 22:26:04 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A74868A62A; Wed, 9 Dec 2020 22:26:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from o1.b.az.sendgrid.net (o1.b.az.sendgrid.net [208.117.55.133]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1EFB68A345 for ; Wed, 9 Dec 2020 22:25:56 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:to:cc:content-type:content-transfer-encoding; s=001; bh=HN0IXdr/69Qyumj0cvTClWZoGZt8CQx+Uwk/YM9FyOU=; b=TfPTevMYWTmQJgTiZI2W7J+VRCDGzCcBUnQbs+CD3Mk3RDvUlUtz9JBegA2pr5y17LL9 eIZwNwXGGHZ3djS3L2299mih4a/qoaXZq2WO06ipijV9mJ9jSKguBbH9ljBI/t1yZDVoOy 0GblF8+OF+zSlUVkuPBKhPXqJ/u7yzunQ= Received: by filterdrecv-p3mdw1-6f5f88f6c4-4qs4t with SMTP id filterdrecv-p3mdw1-6f5f88f6c4-4qs4t-21-5FD132AC-31 2020-12-09 20:25:16.430191552 +0000 UTC m=+516163.608784277 Received: from bionic.localdomain (unknown) by ismtpd0005p1lon1.sendgrid.net (SG) with ESMTP id KhxBKeAgR2aISBrsgw4meQ Wed, 09 Dec 2020 20:25:16.176 +0000 (UTC) From: Jonas Karlman Date: Wed, 09 Dec 2020 20:25:16 +0000 (UTC) Message-Id: <20201209202513.27449-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.17.1 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h03i+33fyg7xDj6j1TXtb/MpST5smVaLomGj3cWPVy9x9oz7hYwai1DHd7Zuk+XCC3KrL8baxvR/9y9Lj3IK6+EPkDaQWHvbVmZS9/EdwvMWuVTSKwbs2HlrEfEYX9ym6byr6LlwbRm4IwIQg16N6BMV6qgcdeUajw8me+f9k/0u To: ffmpeg-devel@ffmpeg.org X-Entity-ID: wSPGWgGSXUap++qShBI+ag== Subject: [FFmpeg-devel] [PATCH 0/5] Add V4L2 request API H.264 hwaccel X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Nicolas Dufresne , Jernej Skrabec , Boris Brezillon , Ezequiel Garcia , Jonas Karlman MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hello, This is a follow up to an old RFC [1], adding a new hwaccel using the V4L2 request API for stateless decoding of H.264. The V4L2 ctrls needed for stateless decoding of H.264 is targeted for being de-staged and moved to public linux uapi with linux v5.11. De-stage of MPEG-2 and VP8 stateless codec APIs will hopefully follow in v5.12, HEVC and VP9 will follow later. These patches must be used with latest linux-media or linux-next tree. De-stage H.264 stateless codec APIs pull-request [2] has been merged into linux-media tree and is on track for inclusion in v5.11. Patch 1 contains a new buffer pool function av_buffer_pool_flush() that will free all available buffers in a buffer pool. This can be used to save memory when seeking in e.g. H.264 where a new hwaccel instance may get init:ed before the current one is uninit. The V4L2 request API hwaccel use this function to minimize memory usage. Patch 2 adds common code used in the hwaccel, libudev is used to enumerate media and video devices to locate devices that support stateless decoding. Patch 3-4 add idr_pic_id, ref_pic_marking and pic_order_cnt bit_size in H.264 slice context for use by the V4L2 request API H.264 hwaccel. Patch 5 adds the V4L2 request API H.264 hwaccel. Use --enable-v4l2-request --enable-libdrm --enable-libudev to enable hwaccel. Playback can be tested using kodi-gbm or mpv with any supported device using cedrus, hantro or rkvdec drivers located in staging. This hwaccel has in one form or another been used in LibreELEC community and nightly images since Dec 20th 2018. A copy of this series can also be found at [3]. [1] http://ffmpeg.org/pipermail/ffmpeg-devel/2019-April/242316.html [2] https://patchwork.linuxtv.org/project/linux-media/patch/d68da172-b251-000f-653d-38a8a4c7b715@xs4all.nl/ [3] https://github.com/Kwiboo/FFmpeg/commits/v4l2-request-hwaccel-master-stable Regards, Jonas Boris Brezillon (1): h264dec: add ref_pic_marking and pic_order_cnt bit_size to slice context Ezequiel Garcia (1): h264dec: add idr_pic_id to slice context Jernej Skrabec (1): h264dec: add V4L2 request API hwaccel Jonas Karlman (2): avutil/buffer: add av_buffer_pool_flush() avcodec: add common V4L2 request API code Changelog | 1 + configure | 15 + doc/APIchanges | 3 + libavcodec/Makefile | 2 + libavcodec/h264_slice.c | 12 +- libavcodec/h264dec.c | 3 + libavcodec/h264dec.h | 3 + libavcodec/hwaccels.h | 1 + libavcodec/hwconfig.h | 2 + libavcodec/v4l2_request.c | 987 +++++++++++++++++++++++++++++++++ libavcodec/v4l2_request.h | 77 +++ libavcodec/v4l2_request_h264.c | 457 +++++++++++++++ libavcodec/version.h | 4 +- libavutil/buffer.c | 13 + libavutil/buffer.h | 5 + libavutil/version.h | 2 +- 16 files changed, 1582 insertions(+), 5 deletions(-) create mode 100644 libavcodec/v4l2_request.c create mode 100644 libavcodec/v4l2_request.h create mode 100644 libavcodec/v4l2_request_h264.c