From patchwork Fri Jan 12 08:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 45576 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bf2f:b0:199:de12:6fa6 with SMTP id gc47csp2204109pzb; Fri, 12 Jan 2024 00:30:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHnnWmyphhJOuP4nZehySV0LXN8wBYIud9L5kJekbzDnBZ8QFXXrChh9MqhHRgp/NdDsJK X-Received: by 2002:a05:6402:22b1:b0:554:dd0d:1955 with SMTP id cx17-20020a05640222b100b00554dd0d1955mr424339edb.62.1705048229424; Fri, 12 Jan 2024 00:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705048229; cv=none; d=google.com; s=arc-20160816; b=boXeBjDSMuEbD0n6LzECynMgpxTodLDnQ2Xk2f7Iz8mO2aPp6LgXIdHU3mTf1tiLzg MgKdrk6KWNa3CZYtgrPNz1tlt8QBrt73uphKztjQ7pv6gEQM6ispH5oZ87XSXpIALw8A p2xOtIpAKY+DHP1Nr7EReVhg68ix2KuVwWCNG6EuuJ2PatB36im6kHSeBNheqbXX1BqL gCfaSkc79GzU/dyyl1jWI+LZgDVLeG9bZJWJzWDsr6S+T3IjqOqjaS59QlTBQZPF880t LGfAOVNKZivVUZRD8nnEwCfmyeCIWL+MubsePvQzlLVIEmIjd9kzrcbEbw7kpDUfpq8r Vybw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=B1iasGV8c9RheU30qhriCmVDciq2EfC4PYK8M7RZMG0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=Bv5cL+pPUDwsBJGm6b4zugvAj4HXIM2qY/MZFQv8EX/Jhj7b1rIcr1U67ybDq/7wz5 sqF0ukJUbuoLg727Idb8Nc3I4l5BfJnEFMtc5sWuGtf0qrUZrq/f+CGtoZbLPLfSCrfb Z5SmwwQ7DJ4TF3MA3FXrqyRywshIUzlJkiF/JKhPSWdAeTYgbJzhql2brTiOoiQflZ0j 31HOuFwTL5Wb8YSBMolN3Oa5sJzD4YvhiJnQGZ6n6kGVghjARvk6cbM+iVJhc2ODn9eV Qw9mq07FaQQVBxx2sxkF/gEE8CNlB+kEGEaIXAu0sHCFRZJhObcI9Vafg4dsADtv08uX 4yvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=utlMh6B2; 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 i16-20020a05640242d000b00558bd08c756si566861edc.104.2024.01.12.00.30.29; Fri, 12 Jan 2024 00:30:29 -0800 (PST) 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=@haasn.xyz header.s=mail header.b=utlMh6B2; 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 CB51F68D07D; Fri, 12 Jan 2024 10:30:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 831FE68CE49 for ; Fri, 12 Jan 2024 10:29:57 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 1D1054A07A; Fri, 12 Jan 2024 09:29:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1705048197; bh=gZBD0Ew4soZTDjWfB7CJSZkNYgvfBkpvpCcIa/sXto0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=utlMh6B2+dOKvsPviSQ9PymUTz70v3gWj4QE1unfWgnvqMnU1Oe5A4UQme2kzXw3n 3cKXHeub3/232FClnlKtGjXwKfRv5HuSHE3yRx5ecNNhaTFlvssm4RCdlLkyDbvHwe xffE7TtM0MAoXUqei25uni52/XPytw+6H059oBuk= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 Jan 2024 09:25:59 +0100 Message-ID: <20240112082950.41637-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240112082950.41637-1-ffmpeg@haasn.xyz> References: <20240112082950.41637-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/11] avfilter/buffersrc: allow promoting color range to MPEG 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: l4H70KOS5Emx From: Niklas Haas Otherwise, passing an UNSPECIFIED frame to am MPEG-only filter graph would trigger insertion of an unnecessary vf_scale filter, which would perform a memcpy to convert between the two. This is safe to do because unspecified YUV frames are already universally assumed to be MPEG range, in particular by swscale. --- libavfilter/buffersrc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index e10653c866..ee0c89ef05 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -492,8 +492,14 @@ static int query_formats(AVFilterContext *ctx) if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 || (ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0) return ret; - if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0 || - (ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0) + if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0) + return ret; + if (c->color_range == AVCOL_RANGE_UNSPECIFIED) { + /* allow implicitly promoting unspecified to mpeg */ + if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_MPEG)) < 0) + return ret; + } + if ((ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0) return ret; } break;