From patchwork Sun Jul 17 19:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36815 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp706115pzb; Sun, 17 Jul 2022 12:28:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYu+ejQJvGefgnIRS45KFQ/gVn3Ibskw9X2sU3tie3b78BkF9CnuadZY/NewiGUp3HTR2T X-Received: by 2002:a17:907:2c68:b0:72b:3a2c:e5b5 with SMTP id ib8-20020a1709072c6800b0072b3a2ce5b5mr22793803ejc.619.1658086091315; Sun, 17 Jul 2022 12:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658086091; cv=none; d=google.com; s=arc-20160816; b=fH64af60B0n+Dnde0OZ3hJ40yLFvD/mLamwKariW17d5RrAMLc9qgOEhXo7bSvLOTh JgP5x/4OWbuIZ8FKIxW+zP8IPlCIYi6zKhqc35jBEhz6bFKK55Lz0WJd22J+pNClXCRW d71Ibb0CLgOcl7L8n35T7i9UB7pWIgJiH16wCWoeydA49LVyHQaE8/QXWR2MT2NLGhcd e2srbHhljafyj7stXBsNTKxbKcr7DXAKjqU/d2Ab4C5hOWr0vMYRcp5WXgCbmdedG0Po Qzshh5KeTzr17klRhkGlWOzg/hdDN9N4O5qmT4fgILkY8QlO8QJYLeGTT03J3RFGn8wP f7LA== 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:message-id:date:to:from :delivered-to; bh=NT6RMDRDhE5sjhGxk11ZzDwSKnT6/hhwb/1wElZRJrM=; b=Y3mxkZO9c7J2bvrYoLlXMRlVcOSgV614HFFfM+CbalFGPzAMZsiiQJ2AGrsALMc7oh C6yXuCQaNr7QrdoLsdozT1FZVRiXyneB3ImyiTM9kNQu5rqmRN5tmbqfQ+zXYuKJZp9G +iKJoMnNEXLzCs64PW/oXkrZNS/nsC5AezRBzG6Ucla0TG5PfTCTjX9jTWRv2SoB69tO G97nfusnUxITf39NTsDf6zoUWPDnZ8uy0giC1SPgyE0ZqkrMesMhusXwwwdzzJbfXhk0 YGCX5wMWld5u+e82nP0o6ebcBK3nisV4HNW4yhNvXJyKG89q2RgU6WZLXp9gSux8qv20 /Gvw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bs8-20020a056402304800b0043a10e5e81asi11399333edb.66.2022.07.17.12.28.10; Sun, 17 Jul 2022 12:28:11 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E371768B5DD; Sun, 17 Jul 2022 22:27:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 38AD368B49A for ; Sun, 17 Jul 2022 22:27:41 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B9E9624017C for ; Sun, 17 Jul 2022 21:27:40 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NbFIdK84p510 for ; Sun, 17 Jul 2022 21:27:40 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 01B1D24017E for ; Sun, 17 Jul 2022 21:27:38 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 4F1E53A03A9; Sun, 17 Jul 2022 21:27:36 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Jul 2022 21:26:57 +0200 Message-Id: <20220717192700.1077-1-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavu/frame: allow calling av_frame_make_writable() on non-refcounted frames 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: UOg5ytNE6y3h This is an easy way to make a refcounted frame from a non-refcounted one. --- doc/APIchanges | 5 +++++ libavutil/frame.c | 3 --- libavutil/frame.h | 3 ++- libavutil/version.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f9a1484bbc..4e218af94e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,11 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-07-xx - xxxxxxxxxx - lavu 57.30.100 - frame.h + av_frame_make_writable() may now be called on non-refcounted + frames and will make a refcounted copy out of them. + Previously an error was returned in such cases. + -------- 8< --------- FFmpeg 5.1 was cut here -------- 8< --------- 2022-06-12 - 7cae3d8b76 - lavf 59.25.100 - avio.h diff --git a/libavutil/frame.c b/libavutil/frame.c index 4c16488c66..7408817e1f 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -542,9 +542,6 @@ int av_frame_make_writable(AVFrame *frame) AVFrame tmp; int ret; - if (!frame->buf[0]) - return AVERROR(EINVAL); - if (av_frame_is_writable(frame)) return 0; diff --git a/libavutil/frame.h b/libavutil/frame.h index 33fac2054c..cc55d67e3c 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -818,7 +818,8 @@ int av_frame_is_writable(AVFrame *frame); * Ensure that the frame data is writable, avoiding data copy if possible. * * Do nothing if the frame is writable, allocate new buffers and copy the data - * if it is not. + * if it is not. Non-refcounted frames behave as non-writable, i.e. a copy + * is always made. * * @return 0 on success, a negative AVERROR on error. * diff --git a/libavutil/version.h b/libavutil/version.h index f185322550..734d3f8330 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 29 +#define LIBAVUTIL_VERSION_MINOR 30 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \