From patchwork Wed Oct 12 13:08:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 38704 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp1367258pzb; Wed, 12 Oct 2022 06:09:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7oev8XxW/xTc/z4w7l0w0eg+2JzAUL6G9XhyTH08wDkiIB/idU5Ym4MAVBkXGUb1O5Zihv X-Received: by 2002:a17:907:94d6:b0:78d:f947:7cf5 with SMTP id dn22-20020a17090794d600b0078df9477cf5mr1478663ejc.446.1665580176944; Wed, 12 Oct 2022 06:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665580176; cv=none; d=google.com; s=arc-20160816; b=qBNvoHbRFrvqH90MYyGT1ugTXurF1phrBspm1yzDaOYivRrhelKZuuI1qSJ3Al5Ivw As1on3IBoXg1lzK/ZTfZYRMfzqSpBrws9lQUyEzJ8u4mh78wZJgAzOOmINSlPOuwUNqk RyWZot2t1Tt/XNFhUqBLsryBDeAfnNMC4QNAveAWkV93x5md0GoqEuj4+ZYn9cEFIW0N cXLj5GROh/RyM9+lVW1WeDAe7h+c5v2ICe/2tvrYaXPWqWWut+gmrbDMrlzcIprjSUXg H97nZCEYu4bJUjIeTQlmLf5DHZXn2EovAhm0HDrsDzCuU8wenO6s6VkfckA52tYKTAh4 4h1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=3hP6LHyYg7MMZBxEaibDgtfEUGyFovZAFTJopa7EUy0=; b=WOTc+k/baUdbZExNJ+AgjmFiBf1Zd1qxfqIjarABDloDz26qm8zBMy55FMe/ZnHBiX RV8Sy1n8dC5yiF9vADlD7AO9k6lwgiwBdEwRy47lagcdkWvV/kuCROJ+D1SbGIIOTC0D stcS+pNYirqSWa/k4CfLYCz3xqLJDu99CNzf9ZDim+jGI1Cx6FUgyeFOh78PX+OBqHAf M21CPqVwgaAQzBOkpWi568jMtutWOEAVWdirio374/oWMARLtzKsQGT1U9a8UllhRo2P 6w0dqwtxAXg2Rfn6T8xBDLMz4ji3O1N3Cc5rN7HRxk9mxhxsV2Y89AqCT2o0q/X5AzqJ B7zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=fKmmq3c7; 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 k18-20020a05640212d200b0044e78dbb615si13753920edx.379.2022.10.12.06.09.36; Wed, 12 Oct 2022 06:09:36 -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=fKmmq3c7; 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 BDBB168BD3B; Wed, 12 Oct 2022 16:09:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8856868BD37 for ; Wed, 12 Oct 2022 16:09:09 +0300 (EEST) Received: by mail-oi1-f174.google.com with SMTP id y72so12320323oia.3 for ; Wed, 12 Oct 2022 06:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DwD8Sg5Hh6Yr5hhj7OE4eJIuFMh2IAlYbym+5tbtpC4=; b=fKmmq3c7w2gKQ9vGr2ZblqqAUMI3IT997c2RzmtPTBszE/VBkaxamhrn33ZzQ8SSW/ hX/nm3A9nIoujaK7wj46rt8OlmFa0klXumwxpb34YTUzI3nyom11wNA0nHTKWyNl9OLp E2O4c2tJMVdPDYYjJGMVpe7R6KZdi49NNCBfFhREpO82qjXBueXUpEVPPt7mHDu+Qval ex7IJEVvlTp0nSM9nhcXm7SeRirAVVddAFpy5awEhH3DIVc+pQj15x441PEeCKNR72q2 HPwOyQcCPZMnx4Q3EKBvPVwhsAUw7jgKzQLwnAjmQRZHI3L6ay1acJ1CjvutdTcWjNGW jkFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DwD8Sg5Hh6Yr5hhj7OE4eJIuFMh2IAlYbym+5tbtpC4=; b=Kl79XNvHKoWOkjcN2dxe3KpE9KRzXz0AM5v0PhL6IomvcgGnxoMNE9DI/WmqcqSuRl PBqhJ6GHi3ar2atjSMUDw1IAWasxhmzZzDMiT3Ct0ofF8gANJh2nwVk0iyQbSEkGvlxD vNima9ev/Hp443vIhkd3+hjhGKzyVhrTbCoA2TIeUDvOaoeZdjFEzpT7syuv0Fbo8crU g4G2zT8olL87Dsc5YDcbMunBqYqy8ajg1oUO5jb14seWgwPOjVT4VoepMFMy/Qj4kGbJ VVLm19xQ4R3RlVd+W6/QoAP5SCx3j64QPeIABGgTNgpsbHX+PmHq2SposJ9hC2ZQq4Gn MlSw== X-Gm-Message-State: ACrzQf0Js5ZYhTJSUSWhvBCbCCXzKde9nodn91pR2avW2zkFvPtU2syF ar4IeDQMOy9P2uPstB1JYW2OWAU778E= X-Received: by 2002:a05:6808:18a9:b0:354:b872:8a0 with SMTP id bi41-20020a05680818a900b00354b87208a0mr2015884oib.197.1665580147543; Wed, 12 Oct 2022 06:09:07 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id ch15-20020a0568081c0f00b0035028730c90sm6664092oib.1.2022.10.12.06.09.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 06:09:06 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Oct 2022 10:08:28 -0300 Message-Id: <20221012130829.2392-3-jamrial@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221012130829.2392-1-jamrial@gmail.com> References: <20221012130829.2392-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4CPMyWvJCclQ This bumps the minimum required version to 0.5.0 Signed-off-by: James Almer --- configure | 2 +- libavcodec/librav1e.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 84641fd03e..96479d48d6 100755 --- a/configure +++ b/configure @@ -6674,7 +6674,7 @@ enabled libopus && { enabled libplacebo && require_pkg_config libplacebo "libplacebo >= 4.192.0" libplacebo/vulkan.h pl_vulkan_create enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection -enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new +enabled librav1e && require_pkg_config librav1e "rav1e >= 0.5.0" rav1e.h rav1e_context_new enabled librist && require_pkg_config librist "librist >= 0.2.7" librist/librist.h rist_receiver_create enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 604115476c..130417622a 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -23,6 +23,7 @@ #include #include "libavutil/internal.h" +#include "libavutil/imgutils.h" #include "libavutil/avassert.h" #include "libavutil/base64.h" #include "libavutil/common.h" @@ -538,6 +539,40 @@ retry: pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque); av_free(rpkt->opaque); + + if (avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { + AVCodecInternal *avci = avctx->internal; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); + ptrdiff_t linesizes[4]; + size_t sizes[4]; + + av_frame_unref(avci->recon_frame); + + avci->recon_frame->format = avctx->pix_fmt; + avci->recon_frame->width = avctx->width; + avci->recon_frame->height = avctx->height; + + ret = av_frame_get_buffer(avci->recon_frame, 0); + if (ret < 0) { + rav1e_packet_unref(rpkt); + return ret; + } + + for (int i = 0; i < 4; i++) + linesizes[i] = avci->recon_frame->linesize[i]; + + ret = av_image_fill_plane_sizes(sizes, avctx->pix_fmt, avctx->height, linesizes); + if (ret < 0) { + rav1e_packet_unref(rpkt); + return ret; + } + + for (int i = 0; i < desc->nb_components; i++) { + rav1e_frame_extract_plane(rpkt->rec, i, avci->recon_frame->data[i], + sizes[i], linesizes[i], desc->comp[i].step); + } + } + rav1e_packet_unref(rpkt); return 0; @@ -601,7 +636,7 @@ const FFCodec ff_librav1e_encoder = { .defaults = librav1e_defaults, .p.pix_fmts = librav1e_pix_fmts, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | - AV_CODEC_CAP_DR1, + AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_RECON_FRAME, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .p.wrapper_name = "librav1e",