From patchwork Sat Aug 20 02:14:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37364 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp116006pzh; Fri, 19 Aug 2022 19:15:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR4c9A1NQi9hcAkiXanr0TjICEeXv8rEifaP5uiMgdrgvHJiehEPjpa+kG07+kT+VSqHQIk0 X-Received: by 2002:a17:907:60c7:b0:739:52ba:cbd0 with SMTP id hv7-20020a17090760c700b0073952bacbd0mr6597902ejc.152.1660961715759; Fri, 19 Aug 2022 19:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660961715; cv=none; d=google.com; s=arc-20160816; b=EFKOYQxjwkkL50pshowrtEQhP/eo3slztp7V7hZYfvWpfjgHq0EZCqDj9ckD3guKOF hkpfdeewvB/KHHvDpK/I9wii/2a+lSZZqGg2cMONNKqUlRFnlwc0fK+pfSxAIwXbhgvX S2AFs50dv6m+rLyYSIDBvT0NTvIiO5aaM9n19/TWwsxT1r5AyyOCPGfmzMuE6o2jE0Ww 6e4ZdMNCFZIUsICGtSx1wsd5VvtRoViREIyUJeOhXfze64sQ+NFW7lmDj99McJURKQ8t hABYwnpqRjoRiUhrJO8hgXcRS+y/WoH8GcB1Q839Ms74Di7am0z7oHYo/R4zlj+9YHfr nEMQ== 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=dxLS8Fu1eZyrvhI+ybRA1//TxGhbzziXsC+QWSc7nps=; b=N+QF+N6POFPx3qpqGhPTmZ2IZ/i6SPgPOPUajIMxslF4UUKXAuQ910wHGM9Qc5nGWD GZiQBj72Z1ihKDMeszbhwYlXmY2pfuaDW9DUKkoiuhoAPu+UYp5hi5gDwqEM53xOyZ33 3PrF8pLgkquBIAltRQf9A0h5W7ksH59WL4qpVmfqDgcI/120Cri3qSddP4pN17JVyK5O nP6NY6+9TDL2uufC+7Oui2P63zxlipcezsOe/kIqYKBxmiB5HWbbaMbNM5uq9HR8k8z0 RY9ht5Rrh3NkK2GCXHtj8AsjfNpjoRMQVQwc61aqeu32aLlRK2sCbW5AM28cIiCBiyhT YyeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=gv95Vk2z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l3-20020a170907914300b00730a1a86524si3023626ejs.112.2022.08.19.19.15.15; Fri, 19 Aug 2022 19:15:15 -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=@overt.org header.s=mail header.b=gv95Vk2z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01DC868B993; Sat, 20 Aug 2022 05:14:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFA4068B67D for ; Sat, 20 Aug 2022 05:14:46 +0300 (EEST) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 98E8F3F3EB; Fri, 19 Aug 2022 21:14:45 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1660961685; bh=iuZPdX/9PoMGFPMqIV5hxq1ZjVSVSlbRq+oyJmSobZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gv95Vk2zEoZq9rD0J8vUtswK77vvtUEbU8KBNKRQV/aj/LwRNoQzTAN9M4GY4uL6l hkZadWdSSdImwldmos7Va5JWgc5Qq3gtNe64QeJiFygcJrpqfzS0w2RmFXZtjphLuZ P2eQ5AtXoEcLHU/gENy/hwTteOAE7xM0qtMpjUEI97Kc5wX2SFkQT02luxm99wI73z 5cXXqqfuG62FMPiogUMbHInlprcnIr4ZovK3oW1LCY2zBMaRlcTpxuc5weIbTnBQ2x NpYjlL+IVi24RmIw+fLvfaBQWJGDrZzOnFnHJZvU/TLTPq2XHu7XsAtxbSS6AeqXAR ycuOOTjs+8d9A== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Aug 2022 19:14:35 -0700 Message-Id: <20220820021436.1224908-3-philipl@overt.org> In-Reply-To: <20220820021436.1224908-1-philipl@overt.org> References: <20220820021436.1224908-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] libswscale: add support for VUYX format 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: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1LeIxy8x2EdZ As we already have support for VUYA, I figured I should do the small amount of work to support VUYX as well. That means a little refactoring to share code. Signed-off-by: Philip Langdale --- libswscale/input.c | 10 ++++--- libswscale/output.c | 35 +++++++++++++++++++++--- libswscale/utils.c | 1 + tests/ref/fate/filter-pixdesc-vuyx | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-pad | 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 15 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-vuyx diff --git a/libswscale/input.c b/libswscale/input.c index 1077d01e91..92681c9c53 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -659,7 +659,7 @@ static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *u AV_WN16(dst + i * 2, AV_RL16(src + i * 8)); } -static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, +static void read_vuyx_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { int i; @@ -669,7 +669,7 @@ static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, } } -static void read_vuya_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, +static void read_vuyx_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { int i; @@ -1375,7 +1375,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) break; #endif case AV_PIX_FMT_VUYA: - c->chrToYV12 = read_vuya_UV_c; + case AV_PIX_FMT_VUYX: + c->chrToYV12 = read_vuyx_UV_c; break; case AV_PIX_FMT_AYUV64LE: c->chrToYV12 = read_ayuv64le_UV_c; @@ -1752,7 +1753,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = read_ya16be_gray_c; break; case AV_PIX_FMT_VUYA: - c->lumToYV12 = read_vuya_Y_c; + case AV_PIX_FMT_VUYX: + c->lumToYV12 = read_vuyx_Y_c; break; case AV_PIX_FMT_AYUV64LE: c->lumToYV12 = read_ayuv64le_Y_c; diff --git a/libswscale/output.c b/libswscale/output.c index 74f992ae80..40a4476c6d 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2585,13 +2585,14 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, } static void -yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, +yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, int y) + const int16_t **alpSrc, uint8_t *dest, int dstW, int y, + int destHasAlpha) { - int hasAlpha = !!alpSrc; + int hasAlpha = destHasAlpha && (!!alpSrc); int i; for (i = 0; i < dstW; i++) { @@ -2634,10 +2635,33 @@ yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, dest[4 * i ] = V; dest[4 * i + 1] = U; dest[4 * i + 2] = Y; - dest[4 * i + 3] = A; + if (destHasAlpha) + dest[4 * i + 3] = A; } } +static void +yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + yuv2vuyX_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, + chrUSrc, chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 1); +} + +static void +yuv2vuyx_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + yuv2vuyX_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, + chrUSrc, chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 0); +} + av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, @@ -3143,5 +3167,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_VUYA: *yuv2packedX = yuv2vuya_X_c; break; + case AV_PIX_FMT_VUYX: + *yuv2packedX = yuv2vuyx_X_c; + break; } } diff --git a/libswscale/utils.c b/libswscale/utils.c index 9ef157c006..a621a35862 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -259,6 +259,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_P416LE] = { 1, 1 }, [AV_PIX_FMT_NV16] = { 1, 1 }, [AV_PIX_FMT_VUYA] = { 1, 1 }, + [AV_PIX_FMT_VUYX] = { 1, 1 }, [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, }; diff --git a/tests/ref/fate/filter-pixdesc-vuyx b/tests/ref/fate/filter-pixdesc-vuyx new file mode 100644 index 0000000000..99871e05d0 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-vuyx @@ -0,0 +1 @@ +pixdesc-vuyx ebc83f9793eb4eddbb0a37fdcb67a33d diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 93dd611f97..371b94c62e 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -90,6 +90,7 @@ rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d vuya 3d5e934651cae1ce334001cb1829ad22 +vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 739b99713a..364e881aef 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -87,6 +87,7 @@ rgba 9488ac85abceaf99a9309eac5a87697e rgba64be 89910046972ab3c68e2a348302cc8ca9 rgba64le fea8ebfc869b52adf353778f29eac7a7 vuya 76578a705ff3a37559653c1289bd03dd +vuyx 5d2bae51a2f4892bd5f177f190cc323b x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 xyz12be cb4571f9aaa7b59f999ef327276104b7 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index e08161bc0d..768b3f474a 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -90,6 +90,7 @@ rgba64be 23c8c0edaabe3eaec89ce69633fb0048 rgba64le dfdba4de4a7cac9abf08852666c341d3 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e vuya f72bcf29d75cd143d0c565f7cc49119a +vuyx 6257cd1ce11330660e9fa9c675acbdcc x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index de5c4fe59b..258c8563f0 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -81,6 +81,7 @@ rgba64be 5598f44514d122b9a57c5c92c20bbc61 rgba64le b34e6e30621ae579519a2d91a96a0acf uyvy422 75de70e31c435dde878002d3f22b238a vuya a3891d4168ff208948fd0b3ba0910495 +vuyx d7a900e970c9a69ed41f8b220114b9fa x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index b0f6754bbf..6fbc472a4e 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -87,6 +87,7 @@ rgba 51961c723ea6707e0a410cd3f21f15d3 rgba64be c910444019f4cfbf4d995227af55da8d rgba64le 0c810d8b3a6bca10321788e1cb145340 vuya 7e530261e7ac4eae4fd616fd7572d0b8 +vuyx 3ce9890363cad3984521293be1eb679c x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f xyz12be 25f90259ff8a226befdaec3dfe82996e diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 04efcb8a56..09748c2d08 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -89,6 +89,7 @@ rgba64be db70d33aa6c06f3e0a1c77bd11284261 rgba64le a8a2daae04374a27219bc1c890204007 uyvy422 d6ee3ca43356d08c392382b24b22cda5 vuya b9deab5ba249dd608b709c09255a4932 +vuyx 49cc92fcc002ec0f312017014dd68c0c x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 93dd611f97..371b94c62e 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -90,6 +90,7 @@ rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d vuya 3d5e934651cae1ce334001cb1829ad22 +vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad index 0f00affdce..07aaea6b06 100644 --- a/tests/ref/fate/filter-pixfmts-pad +++ b/tests/ref/fate/filter-pixfmts-pad @@ -36,6 +36,7 @@ rgb0 0984eb985dabbe757ed6beb53db84eff rgb24 17f9e2e0c609009acaf2175c42d4a2a5 rgba b157c90191463d34fb3ce77b36c96386 vuya 44368c0a758ee68e24ce976e3b1b8535 +vuyx bc7c4f693a22cd1ac95e33d473086474 xyz12le 23dadbbba70b2925ce75fb8ba8080ba3 ya16le 8dbfcb586abf626da7d1aca887a581b9 ya8 495daaca2dcb4f7aeba7652768b41ced diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index f4822f5bae..e1bbe961e1 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -90,6 +90,7 @@ rgba64be ee73e57923af984b31cc7795d13929da rgba64le 783d2779adfafe3548bdb671ec0de69e uyvy422 aeb4ba4f9f003ae21f6d18089198244f vuya ffa817e283bf6a0b6fba21b07523ccaa +vuyx ba182200e20e0c82765eba15217848d3 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 xyz12be c7ba8345998c0141ddc079cdd29b1a40 diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index b3f2d5c5a0..0c2993d5b0 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -81,6 +81,7 @@ rgba 4d76a9542143752a4ac30f82f88f68f1 rgba64be a60041217f4c0cd796d19d3940a12a41 rgba64le ad47197774858858ae7b0c177dffa459 vuya 9ece18a345beb17cd19e09e443eca4bf +vuyx 4c2929cd1c6e5512f62e802f482f0ef2 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 xyz12be 68e5cba640f6e4ef72dff950e88b5342 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 9081ce4f18..5cac61a9d2 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -90,6 +90,7 @@ rgba64be 17e6273323b5779b5f3f775f150c1011 rgba64le 48f45b10503b7dd140329c3dd0d54c98 uyvy422 3a237e8376264e0cfa78f8a3fdadec8a vuya fb849f76e56181e005c31fce75d7038c +vuyx 7a8079a97610e2c1c97aa8832b58a102 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 xyz12be 810644e008deb231850d779aaa27cc7e