From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AE12F40054 for ; Sat, 18 Jan 2025 01:38:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBED268B7AE; Sat, 18 Jan 2025 03:38:30 +0200 (EET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 416A368B6FC for ; Sat, 18 Jan 2025 03:38:24 +0200 (EET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21644aca3a0so65192045ad.3 for ; Fri, 17 Jan 2025 17:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737164301; x=1737769101; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=G9laLl9Cv2TXcIc8GqCWZWvXE2gyc/OebwBUg7cE8p4=; b=b7sPBgK/m/M6PUDksoDc7gqGaaLhjypNY0uCvOvyv7ZGY24AoBAPMMVcJvETuKY+Un Zz1uc2oAz2t0M7PYfVqbZnnI/0cAFb/VGvUkWycGFXyXSyScWPpxpUOCMo4bQG4sLu/T BVcXwBHDGQHPFfzxnOnH+2EOrLsmALvRRqpegrpiEzdDSy/foHo9mtp9hlKgjPJDUvJI rZRPPDyW5kYyJxW2zYFIZs+avxEg4oMrkhzSiToldpVDyAwKPy0ZwBaUR6hehbJXc4bE aUC+8YSUrXRFBSfhntpK3Kv6dyLRQDaGMF4MhMIkQE97JrdsxwcC78AAA0qiqDiquaE7 F6Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737164301; x=1737769101; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G9laLl9Cv2TXcIc8GqCWZWvXE2gyc/OebwBUg7cE8p4=; b=IOhjVCaDL4uwc8sGWH0OOMKHIKUHswfjknzs+ryGZyLqdClP92lgHswlVHFxNTxjV6 Mj82UN2+o3XBlQ9j0CNEPgeux6P8utGog9vVTSw07h9gt14xaDQou0/yuhHs5Vy9LgTc kLQsz2II4SAhdSrjoQYlWrgzxzj3MsDzWacvFhDdKIheNCvXeQZ+TZh8YGIspHBfkFDO g5Y4ymWPvG7r4pCskG+zUzmMBf1fT7WSV5H5P4F/OftAAYtho2/iWuSoNTaOViSK6pU1 6K5IVyVM7AEE34Dj1yktrQutTPKUH7K+xk2tkUXVJMp8wFFaP/U5jUk0CHN22Cww1WNM 8ukQ== X-Gm-Message-State: AOJu0YytQlUGuQ1al/h24ED2cABZIWy0SK2ccVnDi0A2OOB6MuPign/e MR5zOK76ObqUB0dvEwuqBHg4uyemDpE4Ztqa7DCvsZiL+maXkw61a5n1qQ== X-Gm-Gg: ASbGncsZfAOvfdeVycfzA5lSZ38lz7bFtsvLNMehvSfCIoOx7icbQWgJBUlg3wEr4/C LtfgX8YfAkyNIjhvTb03cj6yFgFw+Xp8lvzbqAdAbYcolFnhACuk7LRRyKoYdbmCdc3Y59ngKHA tL/Qch7PZVTlnjpzm/NTmxjGYyIUNBqWDTfE/lYiRa+JC1uaE5HDTbtb5tKhR4BTj6q1RpgdHmE C8ujYpF01g1a3kgbio7zNSim96Qy7XNpsgGklzDGKn+we5UYI6Va+48gE2qNIAUxGXqY6nMpfUm qTEeMYYGYRU= X-Google-Smtp-Source: AGHT+IEukZqB7dWMkwWC/C2Yq73U4h3zzXyu0gwrZRF+QuIV14gtj1qvGcKcTRwGKXmF/HlaoSwrxw== X-Received: by 2002:a17:902:f70d:b0:215:7fad:49ab with SMTP id d9443c01a7336-21c352ddfcemr82100675ad.10.1737164301317; Fri, 17 Jan 2025 17:38:21 -0800 (PST) Received: from localhost.localdomain ([2800:2121:b040:c:ec44:c25e:6a24:aee7]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d402e5esm22112665ad.210.2025.01.17.17.38.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 17:38:20 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Jan 2025 22:38:03 -0300 Message-ID: <20250118013803.3018-1-jamrial@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] swscale/swscale: don't reject scaling when color parameters are not supported but conversion is not required 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Values in csp, prim, trc, etc, are irrelevant if there's no conversion needed. Signed-off-by: James Almer --- ./ffmpeg -i https://0x0.st/8Hr_.mp4 -vf "scale=1920:1080" -f null - Fails without this patch, because swscale lacks conversion for the signaled color primaries. libswscale/swscale.c | 13 +++++-------- libswscale/utils.h | 16 +++++++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 30fbc590fd..70667ebd1c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1442,6 +1442,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src) for (int field = 0; field < 2; field++) { SwsFormat src_fmt = ff_fmt_from_frame(src, field); SwsFormat dst_fmt = ff_fmt_from_frame(dst, field); + int src_ret, dst_ret; if ((src->flags ^ dst->flags) & AV_FRAME_FLAG_INTERLACED) { err_msg = "Cannot convert interlaced to progressive frames or vice versa.\n"; @@ -1449,14 +1450,10 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src) goto fail; } - if (!ff_test_fmt(&src_fmt, 0)) { - err_msg = "Unsupported input"; - ret = AVERROR(ENOTSUP); - goto fail; - } - - if (!ff_test_fmt(&dst_fmt, 1)) { - err_msg = "Unsupported output"; + src_ret = ff_test_fmt(&src_fmt, 0); + dst_ret = ff_test_fmt(&dst_fmt, 1); + if ((!src_ret || !dst_ret) && !ff_props_equal(&src_fmt, &dst_fmt)) { + err_msg = src_ret ? "Unsupported output" : "Unsupported input"; ret = AVERROR(ENOTSUP); goto fail; } diff --git a/libswscale/utils.h b/libswscale/utils.h index d76fea1133..8e0cdf26ec 100644 --- a/libswscale/utils.h +++ b/libswscale/utils.h @@ -98,12 +98,10 @@ static inline int ff_color_equal(const SwsColor *c1, const SwsColor *c2) ff_prim_equal(&c1->gamut, &c2->gamut); } -/* Tests only the static components of a colorspace, ignoring per-frame data */ -static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) +/* Tests only the static components of a colorspace, ignoring dimensions and per-frame data */ +static inline int ff_props_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) { - return fmt1->width == fmt2->width && - fmt1->height == fmt2->height && - fmt1->interlaced == fmt2->interlaced && + return fmt1->interlaced == fmt2->interlaced && fmt1->format == fmt2->format && fmt1->range == fmt2->range && fmt1->csp == fmt2->csp && @@ -111,6 +109,14 @@ static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) ff_color_equal(&fmt1->color, &fmt2->color); } +/* Tests only the static components of a colorspace, ignoring per-frame data */ +static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) +{ + return fmt1->width == fmt2->width && + fmt1->height == fmt2->height && + ff_props_equal(fmt1, fmt2); +} + static inline int ff_fmt_align(enum AVPixelFormat fmt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); -- 2.48.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".