From patchwork Sun Jun 16 22:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49952 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596655vqg; Sun, 16 Jun 2024 15:29:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVui3BJuwBraPkI/Ak7ymglWVCnUTgHxqhWnalC5Dr5HWbKhTD1Vi/m6r4DOrBQPlnJ2Yn5uc/dxSZURtrOqXxkFYZFDbjfuQa7cg== X-Google-Smtp-Source: AGHT+IG4b/2ERRQ7gWBMCJ8z666zca9Mjp2ndS0vGfC/nSe/rw+SKoke9RU+Kq6J6tKQRNqJB0Ce X-Received: by 2002:a05:651c:1025:b0:2ec:23b7:b8ff with SMTP id 38308e7fff4ca-2ec23b7ba3bmr27032931fa.10.1718576945330; Sun, 16 Jun 2024 15:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576945; cv=none; d=google.com; s=arc-20160816; b=uWUGIZTYpX0Vkw0Cktwzb8xrYX9JfWJeBfPnV8XRDOqhJdNeLCbbw8U7mtB/kyCmdD 2h7ovtm+zh2lZSH9/UiSFjrjUr8hXB+KoTBWC3OcsHqIkraMJXkJAvX8ExzV8rU/oYtp PBmgdO5YVl8n0UAEvmWcnR9ubo7lkMgAu1V2R8JUbClVk8Exy0LaGN56Yxu6G3/Ikmg7 pQs7yhsNuxku7jTS7VJ6l1kdvREwOwieTTQONRjVYFqSB2iRCY7VUk6YjTmBG4ixVcVt 4Xz/7NnBDve5IXrW/wTqvUlAuocHUxsOqV1bM+USqYhha1WDAdBbJwTgb5Px0L04v8Lv dycw== 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 :dkim-signature:delivered-to; bh=m1qEfqRTv6xoUSNwtktlAX0qNBUHAouMeXbzNKThVRg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=t4QJIvt/eBeDqLnWwsAJBXUhj7KBQC+ul6/Y5McBQnmzG4eCDAsZirBKzz9YXuZyTT Cwrgyi7Jf+YQH0AoDyCjFRxHFP/eZ4Fvxowytx/DY1+9TDrBvOA8/iKb5L7aPIJ9fAn2 RgcYlDadqOiRNv2hpJkpmTsdYRLCy8bRph0iD3FOMha96BorDBBhCcRDwox3MQQ2s56b +Z38SfAjjAYjrmIVGlGEmdLF13+o9w8e01EiMx8wVoOSTp88e6wvAy5vnmPib+HXf8os fjZO9oylA5Hb5UhSfd+JqPkO5xLcw0MK/PR+9UbjZ4Ioc2SWBfZY8vemoddcEdZX8pF3 EipA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=YQn53bfS; 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 38308e7fff4ca-2ec05c4b7c8si22529741fa.218.2024.06.16.15.29.04; Sun, 16 Jun 2024 15:29:05 -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=20230601 header.b=YQn53bfS; 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 6757F68D73B; Mon, 17 Jun 2024 01:29:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BAA168D602 for ; Mon, 17 Jun 2024 01:28:53 +0300 (EEST) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3609565a1bdso317530f8f.1 for ; Sun, 16 Jun 2024 15:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576932; x=1719181732; 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=zK1wb13zw6tu73uqec2CTVqHy2OT9m6F6sHn40nz83Q=; b=YQn53bfSjYTMWjaIjlwPPzzkBkgR/hm8cCQ/TmDxIt5pCJ5UPlPnT2hK6EW4pbma8x al6xtyKRJLUeOsRMQ6xJl09U+bMMP5bLgu09qGTHL0Dnu+v+nBm7eA7dtnw7X+gHvW8b gRQURRmSanU4cXII0J7HhRpivhASEj2M0mHNo2xQwKpsXQo0qLklfXxg/5p3NJYl2hpU prrkH5aiwH6eLwR4Ui3TLH9mYSOZw9DKik6gQx7x+maeh5nM84zVU0z34F2SvOj8V/bb 9t5V8PgZWZ2/4ml4nGglyXhL/gk1bG/V+y9PNk5clRLCB9UM8uujO034ZAobd7fKf2EA OmnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576932; x=1719181732; 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=zK1wb13zw6tu73uqec2CTVqHy2OT9m6F6sHn40nz83Q=; b=krY/XSi7d/3EE5KLWszDlyEwOykXru/Qm8+d0iM2RyEGBIu9D+yz/gD0nuBCSAKJ+0 ZN25Rg2Y1JoJ0wrPB8NeH/XONOoNnIbFziwSPD2qpP+H8i82ebOJ40ZYmSQf55fVTalw E8qLFup6l+S/OoAXO2g8zLXGWcpCcEMmsM/vtcQwJQG9B9hcR9BUwklvrTHoWxlqp6nF Td3ZCjoTH4uaxNkQiGsAohZimt6g5cf36OdbrzojCj6de8IcfKyRqu0bqGdZaydwRdF2 f/ngWPwNelNibNJkNITq1hzW3A2ir9vbI+hFR6zPCpUlYzXDYnHyXVJyedBjHutUnDGu NDEg== X-Gm-Message-State: AOJu0YwSSW+9i5ofgH2vwMx12+49zGk0d8sfG4h0zcH6S6kC4RwLiyBz Jn3JSZIkzzAHL20oZMF1CEG3OcgYr9JQ/3UrRCAFnavC1DYlTZeBsaZFfA== X-Received: by 2002:adf:fd03:0:b0:35f:2760:aaa0 with SMTP id ffacd0b85a97d-3607a786b07mr6981492f8f.65.1718576931445; Sun, 16 Jun 2024 15:28:51 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:51 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:44 +0200 Message-Id: <20240616222849.420361-1-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] swscale/yuv2rgb: fix conversion for widths not aligned to 8 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: 1onHTZsivBlx The C code for some pixel formats (rgb555, rgb565, rgb444, and monob) was not converting the last pixels on widths not aligned to 8. NOTE: the last pixel for odd widths is still not converted for any of the pixel formats in the C code for yuv2rgb except for monob. --- libswscale/yuv2rgb.c | 101 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index c1d6236f37..e641c765c7 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -172,10 +172,6 @@ const int *sws_getCoefficients(int colorspace) return srcSliceH; \ } -#define CLOSEYUV2RGBFUNC(dst_delta) \ - ENDYUV2RGBLINE(dst_delta, 0) \ - ENDYUV2RGBFUNC() - YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0) LOADCHROMA(0); PUTRGB48(dst_1, py_1, 0); @@ -432,7 +428,27 @@ YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB16(dst_2, py_2, 3, 6 + 8); PUTRGB16(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; + const uint8_t *e16 = ff_dither_2x2_4[y & 1]; + const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; + + LOADCHROMA(0); + PUTRGB16(dst_1, py_1, 0, 0); + PUTRGB16(dst_2, py_2, 0, 0 + 8); + + LOADCHROMA(1); + PUTRGB16(dst_2, py_2, 1, 2 + 8); + PUTRGB16(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; + const uint8_t *e16 = ff_dither_2x2_4[y & 1]; + const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; + + LOADCHROMA(0); + PUTRGB16(dst_1, py_1, 0, 0); + PUTRGB16(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) const uint8_t *d16 = ff_dither_2x2_8[y & 1]; @@ -462,7 +478,25 @@ YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB15(dst_2, py_2, 3, 6 + 8); PUTRGB15(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; + const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; + + LOADCHROMA(0); + PUTRGB15(dst_1, py_1, 0, 0); + PUTRGB15(dst_2, py_2, 0, 0 + 8); + + LOADCHROMA(1); + PUTRGB15(dst_2, py_2, 1, 2 + 8); + PUTRGB15(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; + const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; + + LOADCHROMA(0); + PUTRGB15(dst_1, py_1, 0, 0); + PUTRGB15(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() // r, g, b, dst_1, dst_2 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) @@ -493,7 +527,23 @@ YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB12(dst_2, py_2, 3, 6 + 8); PUTRGB12(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) + const uint8_t *d16 = ff_dither_4x4_16[y & 3]; + + LOADCHROMA(0); + PUTRGB12(dst_1, py_1, 0, 0); + PUTRGB12(dst_2, py_2, 0, 0 + 8); + + LOADCHROMA(1); + PUTRGB12(dst_2, py_2, 1, 2 + 8); + PUTRGB12(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) + const uint8_t *d16 = ff_dither_4x4_16[y & 3]; + + LOADCHROMA(0); + PUTRGB12(dst_1, py_1, 0, 0); + PUTRGB12(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() // r, g, b, dst_1, dst_2 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) @@ -672,7 +722,42 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) dst_1[0] = out_1; dst_2[0] = out_2; -CLOSEYUV2RGBFUNC(1) + + py_1 += 8; + py_2 += 8; + dst_1 += 1; + dst_2 += 1; + } + if (c->dstW & 7) { + int av_unused Y, U, V; + int pixels_left = c->dstW & 7; + const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; + char out_1 = 0, out_2 = 0; + g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; + +#define PUTRGB1_OR00(out, src, i, o) \ + if (pixels_left) { \ + PUTRGB1(out, src, i, o) \ + pixels_left--; \ + } else { \ + out <<= 2; \ + } + + PUTRGB1_OR00(out_1, py_1, 0, 0); + PUTRGB1_OR00(out_2, py_2, 0, 0 + 8); + + PUTRGB1_OR00(out_2, py_2, 1, 2 + 8); + PUTRGB1_OR00(out_1, py_1, 1, 2); + + PUTRGB1_OR00(out_1, py_1, 2, 4); + PUTRGB1_OR00(out_2, py_2, 2, 4 + 8); + + PUTRGB1_OR00(out_2, py_2, 3, 6 + 8); + PUTRGB1_OR00(out_1, py_1, 3, 6); + + dst_1[0] = out_1; + dst_2[0] = out_2; +ENDYUV2RGBFUNC() SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) { From patchwork Sun Jun 16 22:28:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49953 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596681vqg; Sun, 16 Jun 2024 15:29:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUh1cVUlkYBXnOlkWxdAIi+hXH5NAi8gc+H+4PdPFDr3uVgFypOQUYjweYdQm9bbftzae7GrUqVE/moxMZ/ckZQglyzLig6NWy5sg== X-Google-Smtp-Source: AGHT+IExFdu/JWeshHci6MhqjAQ/CSoA637PIoI1QRVTx0VF7uvQef2PYWcNdjx95D/Hbv4SYSmw X-Received: by 2002:a17:906:c29a:b0:a6f:5698:ab61 with SMTP id a640c23a62f3a-a6f60cef734mr533518066b.11.1718576955574; Sun, 16 Jun 2024 15:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576955; cv=none; d=google.com; s=arc-20160816; b=PuvksxH5Oah9ETTtvV9tAUEFU9TdgKKXAqLrh7xxemFRlh+fUR4eMyPS3hKZWD9Sho t7t6QgTMmYqVATtM0oQEd88PXJMyjFb1h/jXaC1zBiOkxi33G/OkDpHilK54QqXpUZCS AsBjTmubQV2PR6nwIX5MD7+Xco+7q/nwG6PoH+Zmndd1tQH20d4p7lUe2jRxUW7Sd8/r x+Km+x0Y6QDoZJexjz26dXAiMQ4RI7t8leC69qewNsaf8UioQ32dSp0H75C7P//aq0gI V0JpQ+ASZBkdfeO1RixwCOWouEjVwzFiATgOdWsB82yGQCUaXZZnjPCNWhlWGkZ0kq6o B6EA== 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=KTj/tDXsasfqBQQDYi4lCZV16DEBONHBo9i0QdRmJok=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OToUsjejFVK/ywxlwucdlwlDSXb5YWIDgM9DBIS/DgiyWd5UZDF5/BV/89gnqG1IUa TJXIYuHr9kzoftPXYO3yAtURyqmC0EoXO2oLQ6d3FHpfJThEocnEuSfZl5eqhPLky53W InzC5gGbK4csKi8ciKifLvj7RSV8rAoQmgb+Pi/2M8Hag+Qx2Cm8c2oRF4cvPh0GuKxM WCzWx57mQdb2+0TpUxZsAn3VPdUI2/A4Zu/qJvqMfI2+pm0Kjqd3uhWI23F/A5XGfeQm ho5Y7dOLcAwbvsppji5xX0kZEdhKw0tf9AEw7jGs8vHy6e2C0/IqAz+JlnL803fhXDYj cs6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=DgmoSBmL; 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 a640c23a62f3a-a6f56df72a2si391671066b.653.2024.06.16.15.29.15; Sun, 16 Jun 2024 15:29: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=@gmail.com header.s=20230601 header.b=DgmoSBmL; 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 9B72B68D746; Mon, 17 Jun 2024 01:29:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB27A68D602 for ; Mon, 17 Jun 2024 01:28:53 +0300 (EEST) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4217926991fso34008835e9.3 for ; Sun, 16 Jun 2024 15:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576933; x=1719181733; darn=ffmpeg.org; 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=t0CkbF7EG3waoBrusOj741ultXpYSR4WkRIgQbibQ9Y=; b=DgmoSBmLuI0eo649uOIelOSn4lwplCQTXfmGJu3A5taJUkrZUUhcxioFhk9NKBF7IA XnpOUnOeMZZKnKhtZLCzOxDIgFTzXEt0vOAFa6XIs+vFT1bUVBHkNH2fZAbHS3RJBPqN TwAw4cFs4txZ3OTzujKRmITSSZScCbnwPEzGnl38GQnrSyExFIXYQ/RIvxcqaJAj0nsL QTt3BaTvwdeI0niW/4FlrDOjyAEO1q9Jn33ETDI9mguCZ8k57duvptVHe6irv/yRZrFI oFcHUAjDCXte8CCAmfWBXy/Ft1p6dKgL1fExdp1Q1ZkO1la4+3YjirT6jv+kTuaxAUzM 0nXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576933; x=1719181733; 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=t0CkbF7EG3waoBrusOj741ultXpYSR4WkRIgQbibQ9Y=; b=LLmoYmT2ZFyF9AAIyX6MgDZdx5AcN+F1isQE/rXh9JCtVjPOrP+u5d6uu46b9ZMasR pixMm19ldceK5m10iBLiSsn2y1VR6OkWnbgIuUkmAdi99P8EMcJiRkD2BKE/XS3ulbZO Qty5W2xmMMs4yzBy4VpowknDG/kbsXv5G6PZ4pGchkCoSLT4D8QfYpZ/FsP1EDGuexzO izWmpHLRCo5cLLFuy4mo6teWYE03Echqe5fGGKEAJcc3/rSfwtRvA+3j3uwTHmNOvnj8 G/vXRlmIfgeuyamFUVneJN7NDneDjHsjeS3HYo9MySt3ci+HNieyfBEr5ZcygYqfk87t sj2g== X-Gm-Message-State: AOJu0YxZzcZT+YHO1eSZFMe0DhXh0mVIuoDo4AjLoKPAUktws1Pz882R u+yamCb8+T6RFaO7ETXl10eW9YtdleDwKzyITzopmUCs6p6GvEKsPnVGCA== X-Received: by 2002:a7b:c44e:0:b0:41b:fc3a:f1ef with SMTP id 5b1f17b1804b1-42304858447mr67614225e9.33.1718576932264; Sun, 16 Jun 2024 15:28:52 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:51 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:45 +0200 Message-Id: <20240616222849.420361-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] swscale/yuv2rgb: add macros to simplify code generation 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: PQARykk4VOgb --- libswscale/yuv2rgb.c | 574 +++++++++---------------------------------- 1 file changed, 113 insertions(+), 461 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index e641c765c7..7386d3a2a2 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -72,13 +72,13 @@ const int *sws_getCoefficients(int colorspace) g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \ b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM]; -#define PUTRGB(dst, src, i) \ +#define PUTRGB(dst, src, asrc, i, abase) \ Y = src[2 * i]; \ dst[2 * i] = r[Y] + g[Y] + b[Y]; \ Y = src[2 * i + 1]; \ dst[2 * i + 1] = r[Y] + g[Y] + b[Y]; -#define PUTRGB24(dst, src, i) \ +#define PUTRGB24(dst, src, asrc, i, abase) \ Y = src[2 * i]; \ dst[6 * i + 0] = r[Y]; \ dst[6 * i + 1] = g[Y]; \ @@ -88,7 +88,7 @@ const int *sws_getCoefficients(int colorspace) dst[6 * i + 4] = g[Y]; \ dst[6 * i + 5] = b[Y]; -#define PUTBGR24(dst, src, i) \ +#define PUTBGR24(dst, src, asrc, i, abase) \ Y = src[2 * i]; \ dst[6 * i + 0] = b[Y]; \ dst[6 * i + 1] = g[Y]; \ @@ -98,13 +98,13 @@ const int *sws_getCoefficients(int colorspace) dst[6 * i + 4] = g[Y]; \ dst[6 * i + 5] = r[Y]; -#define PUTRGBA(dst, ysrc, asrc, i, s) \ +#define PUTRGBA(dst, ysrc, asrc, i, abase) \ Y = ysrc[2 * i]; \ - dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \ + dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << abase); \ Y = ysrc[2 * i + 1]; \ - dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s); + dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << abase); -#define PUTRGB48(dst, src, i) \ +#define PUTRGB48(dst, src, asrc, i, abase) \ Y = src[ 2 * i]; \ dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \ dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ @@ -114,7 +114,7 @@ const int *sws_getCoefficients(int colorspace) dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ dst[12 * i + 10] = dst[12 * i + 11] = b[Y]; -#define PUTBGR48(dst, src, i) \ +#define PUTBGR48(dst, src, asrc, i, abase) \ Y = src[2 * i]; \ dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \ dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ @@ -155,11 +155,15 @@ const int *sws_getCoefficients(int colorspace) while (h_size--) { \ int av_unused U, V, Y; \ -#define ENDYUV2RGBLINE(dst_delta, ss) \ +#define ENDYUV2RGBLINE(dst_delta, ss, alpha) \ pu += 4 >> ss; \ pv += 4 >> ss; \ py_1 += 8 >> ss; \ py_2 += 8 >> ss; \ + if (alpha) { \ + pa_1 += 8 >> ss; \ + pa_2 += 8 >> ss; \ + } \ dst_1 += dst_delta >> ss; \ dst_2 += dst_delta >> ss; \ } \ @@ -172,236 +176,77 @@ const int *sws_getCoefficients(int colorspace) return srcSliceH; \ } -YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0) - LOADCHROMA(0); - PUTRGB48(dst_1, py_1, 0); - PUTRGB48(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB48(dst_2, py_2, 1); - PUTRGB48(dst_1, py_1, 1); - - LOADCHROMA(2); - PUTRGB48(dst_1, py_1, 2); - PUTRGB48(dst_2, py_2, 2); - - LOADCHROMA(3); - PUTRGB48(dst_2, py_2, 3); - PUTRGB48(dst_1, py_1, 3); -ENDYUV2RGBLINE(48, 0) - LOADCHROMA(0); - PUTRGB48(dst_1, py_1, 0); - PUTRGB48(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB48(dst_2, py_2, 1); - PUTRGB48(dst_1, py_1, 1); -ENDYUV2RGBLINE(48, 1) - LOADCHROMA(0); - PUTRGB48(dst_1, py_1, 0); - PUTRGB48(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0) - LOADCHROMA(0); - PUTBGR48(dst_1, py_1, 0); - PUTBGR48(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTBGR48(dst_2, py_2, 1); - PUTBGR48(dst_1, py_1, 1); - - LOADCHROMA(2); - PUTBGR48(dst_1, py_1, 2); - PUTBGR48(dst_2, py_2, 2); - - LOADCHROMA(3); - PUTBGR48(dst_2, py_2, 3); - PUTBGR48(dst_1, py_1, 3); -ENDYUV2RGBLINE(48, 0) - LOADCHROMA(0); - PUTBGR48(dst_1, py_1, 0); - PUTBGR48(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTBGR48(dst_2, py_2, 1); - PUTBGR48(dst_1, py_1, 1); -ENDYUV2RGBLINE(48, 1) - LOADCHROMA(0); - PUTBGR48(dst_1, py_1, 0); - PUTBGR48(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0) - LOADCHROMA(0); - PUTRGB(dst_1, py_1, 0); - PUTRGB(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB(dst_2, py_2, 1); - PUTRGB(dst_1, py_1, 1); - - LOADCHROMA(2); - PUTRGB(dst_1, py_1, 2); - PUTRGB(dst_2, py_2, 2); - - LOADCHROMA(3); - PUTRGB(dst_2, py_2, 3); - PUTRGB(dst_1, py_1, 3); -ENDYUV2RGBLINE(8, 0) - LOADCHROMA(0); - PUTRGB(dst_1, py_1, 0); - PUTRGB(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB(dst_2, py_2, 1); - PUTRGB(dst_1, py_1, 1); -ENDYUV2RGBLINE(8, 1) - LOADCHROMA(0); - PUTRGB(dst_1, py_1, 0); - PUTRGB(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -#if HAVE_BIGENDIAN -YUV2RGBFUNC(yuva2argb_c, uint32_t, 1) -#else -YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1) -#endif - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 24); - PUTRGBA(dst_2, py_2, pa_2, 0, 24); - - LOADCHROMA(1); - PUTRGBA(dst_2, py_2, pa_2, 1, 24); - PUTRGBA(dst_1, py_1, pa_1, 1, 24); - - LOADCHROMA(2); - PUTRGBA(dst_1, py_1, pa_1, 2, 24); - PUTRGBA(dst_2, py_2, pa_2, 2, 24); - - LOADCHROMA(3); - PUTRGBA(dst_2, py_2, pa_2, 3, 24); - PUTRGBA(dst_1, py_1, pa_1, 3, 24); - pa_1 += 8; - pa_2 += 8; -ENDYUV2RGBLINE(8, 0) - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 24); - PUTRGBA(dst_2, py_2, pa_2, 0, 24); - - LOADCHROMA(1); - PUTRGBA(dst_2, py_2, pa_2, 1, 24); - PUTRGBA(dst_1, py_1, pa_1, 1, 24); - pa_1 += 4; - pa_2 += 4; -ENDYUV2RGBLINE(8, 1) - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 24); - PUTRGBA(dst_2, py_2, pa_2, 0, 24); -ENDYUV2RGBFUNC() - -#if HAVE_BIGENDIAN -YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1) -#else -YUV2RGBFUNC(yuva2argb_c, uint32_t, 1) -#endif - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 0); - PUTRGBA(dst_2, py_2, pa_2, 0, 0); - - LOADCHROMA(1); - PUTRGBA(dst_2, py_2, pa_2, 1, 0); - PUTRGBA(dst_1, py_1, pa_1, 1, 0); - - LOADCHROMA(2); - PUTRGBA(dst_1, py_1, pa_1, 2, 0); - PUTRGBA(dst_2, py_2, pa_2, 2, 0); - - LOADCHROMA(3); - PUTRGBA(dst_2, py_2, pa_2, 3, 0); - PUTRGBA(dst_1, py_1, pa_1, 3, 0); - pa_1 += 8; - pa_2 += 8; -ENDYUV2RGBLINE(8, 0) - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 0); - PUTRGBA(dst_2, py_2, pa_2, 0, 0); - - LOADCHROMA(1); - PUTRGBA(dst_2, py_2, pa_2, 1, 0); - PUTRGBA(dst_1, py_1, pa_1, 1, 0); - pa_1 += 4; - pa_2 += 4; -ENDYUV2RGBLINE(8, 1) - LOADCHROMA(0); - PUTRGBA(dst_1, py_1, pa_1, 0, 0); - PUTRGBA(dst_2, py_2, pa_2, 0, 0); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0) - LOADCHROMA(0); - PUTRGB24(dst_1, py_1, 0); - PUTRGB24(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB24(dst_2, py_2, 1); - PUTRGB24(dst_1, py_1, 1); - - LOADCHROMA(2); - PUTRGB24(dst_1, py_1, 2); - PUTRGB24(dst_2, py_2, 2); - - LOADCHROMA(3); - PUTRGB24(dst_2, py_2, 3); - PUTRGB24(dst_1, py_1, 3); -ENDYUV2RGBLINE(24, 0) - LOADCHROMA(0); - PUTRGB24(dst_1, py_1, 0); - PUTRGB24(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTRGB24(dst_2, py_2, 1); - PUTRGB24(dst_1, py_1, 1); -ENDYUV2RGBLINE(24, 1) - LOADCHROMA(0); - PUTRGB24(dst_1, py_1, 0); - PUTRGB24(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -// only trivial mods from yuv2rgb_c_24_rgb -YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0) - LOADCHROMA(0); - PUTBGR24(dst_1, py_1, 0); - PUTBGR24(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTBGR24(dst_2, py_2, 1); - PUTBGR24(dst_1, py_1, 1); - - LOADCHROMA(2); - PUTBGR24(dst_1, py_1, 2); - PUTBGR24(dst_2, py_2, 2); - - LOADCHROMA(3); - PUTBGR24(dst_2, py_2, 3); - PUTBGR24(dst_1, py_1, 3); -ENDYUV2RGBLINE(24, 0) - LOADCHROMA(0); - PUTBGR24(dst_1, py_1, 0); - PUTBGR24(dst_2, py_2, 0); - - LOADCHROMA(1); - PUTBGR24(dst_2, py_2, 1); - PUTBGR24(dst_1, py_1, 1); -ENDYUV2RGBLINE(24, 1) - LOADCHROMA(0); - PUTBGR24(dst_1, py_1, 0); - PUTBGR24(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; - const uint8_t *e16 = ff_dither_2x2_4[y & 1]; +#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ + YUV2RGBFUNC(func_name, dst_type, alpha) \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + \ + LOADCHROMA(1); \ + PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + \ + LOADCHROMA(2); \ + PUTFUNC(dst_1, py_1, pa_1, 2, abase); \ + PUTFUNC(dst_2, py_2, pa_2, 2, abase); \ + \ + LOADCHROMA(3); \ + PUTFUNC(dst_2, py_2, pa_2, 3, abase); \ + PUTFUNC(dst_1, py_1, pa_1, 3, abase); \ + ENDYUV2RGBLINE(dst_delta, 0, alpha) \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + \ + LOADCHROMA(1); \ + PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + ENDYUV2RGBLINE(dst_delta, 1, alpha) \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + ENDYUV2RGBFUNC() + +#define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ + YUV2RGBFUNC(func_name, dst_type, 0) \ + LOADDITHER \ + \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + \ + LOADCHROMA(1); \ + PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + PUTFUNC(dst_1, py_1, 1, 2); \ + \ + LOADCHROMA(2); \ + PUTFUNC(dst_1, py_1, 2, 4); \ + PUTFUNC(dst_2, py_2, 2, 4 + 8); \ + \ + LOADCHROMA(3); \ + PUTFUNC(dst_2, py_2, 3, 6 + 8); \ + PUTFUNC(dst_1, py_1, 3, 6); \ + ENDYUV2RGBLINE(dst_delta, 0, 0) \ + LOADDITHER \ + \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + \ + LOADCHROMA(1); \ + PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + PUTFUNC(dst_1, py_1, 1, 2); \ + ENDYUV2RGBLINE(dst_delta, 1, 0) \ + LOADDITHER \ + \ + LOADCHROMA(0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + ENDYUV2RGBFUNC() + +#define LOADDITHER16 \ + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ + const uint8_t *e16 = ff_dither_2x2_4[y & 1]; \ const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; #define PUTRGB16(dst, src, i, o) \ @@ -413,45 +258,9 @@ YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0) dst[2 * i + 1] = r[Y + d16[1 + o]] + \ g[Y + e16[1 + o]] + \ b[Y + f16[1 + o]]; - LOADCHROMA(0); - PUTRGB16(dst_1, py_1, 0, 0); - PUTRGB16(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB16(dst_2, py_2, 1, 2 + 8); - PUTRGB16(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB16(dst_1, py_1, 2, 4); - PUTRGB16(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB16(dst_2, py_2, 3, 6 + 8); - PUTRGB16(dst_1, py_1, 3, 6); -ENDYUV2RGBLINE(8, 0) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; - const uint8_t *e16 = ff_dither_2x2_4[y & 1]; - const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; - - LOADCHROMA(0); - PUTRGB16(dst_1, py_1, 0, 0); - PUTRGB16(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB16(dst_2, py_2, 1, 2 + 8); - PUTRGB16(dst_1, py_1, 1, 2); -ENDYUV2RGBLINE(8, 1) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; - const uint8_t *e16 = ff_dither_2x2_4[y & 1]; - const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; - LOADCHROMA(0); - PUTRGB16(dst_1, py_1, 0, 0); - PUTRGB16(dst_2, py_2, 0, 0 + 8); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; +#define LOADDITHER15 \ + const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; #define PUTRGB15(dst, src, i, o) \ @@ -463,43 +272,8 @@ YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) dst[2 * i + 1] = r[Y + d16[1 + o]] + \ g[Y + d16[0 + o]] + \ b[Y + e16[1 + o]]; - LOADCHROMA(0); - PUTRGB15(dst_1, py_1, 0, 0); - PUTRGB15(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB15(dst_2, py_2, 1, 2 + 8); - PUTRGB15(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB15(dst_1, py_1, 2, 4); - PUTRGB15(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB15(dst_2, py_2, 3, 6 + 8); - PUTRGB15(dst_1, py_1, 3, 6); -ENDYUV2RGBLINE(8, 0) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; - const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; - - LOADCHROMA(0); - PUTRGB15(dst_1, py_1, 0, 0); - PUTRGB15(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB15(dst_2, py_2, 1, 2 + 8); - PUTRGB15(dst_1, py_1, 1, 2); -ENDYUV2RGBLINE(8, 1) - const uint8_t *d16 = ff_dither_2x2_8[y & 1]; - const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; - - LOADCHROMA(0); - PUTRGB15(dst_1, py_1, 0, 0); - PUTRGB15(dst_2, py_2, 0, 0 + 8); -ENDYUV2RGBFUNC() -// r, g, b, dst_1, dst_2 -YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) +#define LOADDITHER12 \ const uint8_t *d16 = ff_dither_4x4_16[y & 3]; #define PUTRGB12(dst, src, i, o) \ @@ -512,42 +286,8 @@ YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) g[Y + d16[1 + o]] + \ b[Y + d16[1 + o]]; - LOADCHROMA(0); - PUTRGB12(dst_1, py_1, 0, 0); - PUTRGB12(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB12(dst_2, py_2, 1, 2 + 8); - PUTRGB12(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB12(dst_1, py_1, 2, 4); - PUTRGB12(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB12(dst_2, py_2, 3, 6 + 8); - PUTRGB12(dst_1, py_1, 3, 6); -ENDYUV2RGBLINE(8, 0) - const uint8_t *d16 = ff_dither_4x4_16[y & 3]; - - LOADCHROMA(0); - PUTRGB12(dst_1, py_1, 0, 0); - PUTRGB12(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB12(dst_2, py_2, 1, 2 + 8); - PUTRGB12(dst_1, py_1, 1, 2); -ENDYUV2RGBLINE(8, 1) - const uint8_t *d16 = ff_dither_4x4_16[y & 3]; - - LOADCHROMA(0); - PUTRGB12(dst_1, py_1, 0, 0); - PUTRGB12(dst_2, py_2, 0, 0 + 8); -ENDYUV2RGBFUNC() - -// r, g, b, dst_1, dst_2 -YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) - const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; +#define LOADDITHER8 \ + const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; \ const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; #define PUTRGB8(dst, src, i, o) \ @@ -560,46 +300,9 @@ YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) g[Y + d32[1 + o]] + \ b[Y + d64[1 + o]]; - LOADCHROMA(0); - PUTRGB8(dst_1, py_1, 0, 0); - PUTRGB8(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB8(dst_2, py_2, 1, 2 + 8); - PUTRGB8(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB8(dst_1, py_1, 2, 4); - PUTRGB8(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB8(dst_2, py_2, 3, 6 + 8); - PUTRGB8(dst_1, py_1, 3, 6); - -ENDYUV2RGBLINE(8, 0) - const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; - const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; - LOADCHROMA(0); - PUTRGB8(dst_1, py_1, 0, 0); - PUTRGB8(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB8(dst_2, py_2, 1, 2 + 8); - PUTRGB8(dst_1, py_1, 1, 2); - -ENDYUV2RGBLINE(8, 1) - const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; - const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; - LOADCHROMA(0); - PUTRGB8(dst_1, py_1, 0, 0); - PUTRGB8(dst_2, py_2, 0, 0 + 8); - -ENDYUV2RGBFUNC() - - -YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0) - const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; - const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; +#define LOADDITHER4D \ + const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; \ + const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; \ int acc; #define PUTRGB4D(dst, src, i, o) \ @@ -613,45 +316,8 @@ YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0) b[Y + d128[1 + o]]) << 4; \ dst[i] = acc; - LOADCHROMA(0); - PUTRGB4D(dst_1, py_1, 0, 0); - PUTRGB4D(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB4D(dst_2, py_2, 1, 2 + 8); - PUTRGB4D(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB4D(dst_1, py_1, 2, 4); - PUTRGB4D(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB4D(dst_2, py_2, 3, 6 + 8); - PUTRGB4D(dst_1, py_1, 3, 6); - -ENDYUV2RGBLINE(4, 0) - const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; - const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; - int acc; - LOADCHROMA(0); - PUTRGB4D(dst_1, py_1, 0, 0); - PUTRGB4D(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB4D(dst_2, py_2, 1, 2 + 8); - PUTRGB4D(dst_1, py_1, 1, 2); - -ENDYUV2RGBLINE(4, 1) - const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; - const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; - int acc; - LOADCHROMA(0); - PUTRGB4D(dst_1, py_1, 0, 0); - PUTRGB4D(dst_2, py_2, 0, 0 + 8); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0) - const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; +#define LOADDITHER4DB \ + const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; \ const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; #define PUTRGB4DB(dst, src, i, o) \ @@ -664,39 +330,6 @@ YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0) g[Y + d64[1 + o]] + \ b[Y + d128[1 + o]]; - LOADCHROMA(0); - PUTRGB4DB(dst_1, py_1, 0, 0); - PUTRGB4DB(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB4DB(dst_2, py_2, 1, 2 + 8); - PUTRGB4DB(dst_1, py_1, 1, 2); - - LOADCHROMA(2); - PUTRGB4DB(dst_1, py_1, 2, 4); - PUTRGB4DB(dst_2, py_2, 2, 4 + 8); - - LOADCHROMA(3); - PUTRGB4DB(dst_2, py_2, 3, 6 + 8); - PUTRGB4DB(dst_1, py_1, 3, 6); -ENDYUV2RGBLINE(8, 0) - const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; - const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; - LOADCHROMA(0); - PUTRGB4DB(dst_1, py_1, 0, 0); - PUTRGB4DB(dst_2, py_2, 0, 0 + 8); - - LOADCHROMA(1); - PUTRGB4DB(dst_2, py_2, 1, 2 + 8); - PUTRGB4DB(dst_1, py_1, 1, 2); -ENDYUV2RGBLINE(8, 1) - const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; - const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; - LOADCHROMA(0); - PUTRGB4DB(dst_1, py_1, 0, 0); - PUTRGB4DB(dst_2, py_2, 0, 0 + 8); -ENDYUV2RGBFUNC() - YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; char out_1 = 0, out_2 = 0; @@ -759,6 +392,25 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) dst_2[0] = out_2; ENDYUV2RGBFUNC() +YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48) +YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48) +YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8) +#if HAVE_BIGENDIAN +YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8) +YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8) +#else +YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8) +YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8) +#endif +YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24) +YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24) +YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8) +YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8) +YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8) +YUV420FUNC_DITHER(yuv2rgb_c_8_ordered_dither, uint8_t, LOADDITHER8, PUTRGB8, 8) +YUV420FUNC_DITHER(yuv2rgb_c_4_ordered_dither, uint8_t, LOADDITHER4D, PUTRGB4D, 4) +YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) + SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) { SwsFunc t = NULL; From patchwork Sun Jun 16 22:28:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49954 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596717vqg; Sun, 16 Jun 2024 15:29:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJNFCbeTGaNLSz2HJLi+fAZZuYbfk7yuRgyMn0q/eDEGOF+44cGBv0LbYZ6EUsSnmkNU/1JLnf3O/DhC3yF/hri+nC6lNyKlqVdg== X-Google-Smtp-Source: AGHT+IHYWr70M1AbH/d1kd4+5H7ffntVTibbeOZ/0ySWTb+J5dlX9nTMRQ1zFSp2JteOQAELMph7 X-Received: by 2002:a19:5e4f:0:b0:52c:5083:a627 with SMTP id 2adb3069b0e04-52ca6e670cdmr4181568e87.25.1718576966235; Sun, 16 Jun 2024 15:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576966; cv=none; d=google.com; s=arc-20160816; b=e0JAHV8TMGqn52sMGbGWGY0qMpvCi5Q/WKtkhP6uno6W5EbwxfxwOq7Pg3TbGtz60s EtgDMQJlyDPd1PmRmcL3TN++IROMgQvkAES7IReIEQCVFvMI8aiyQMeS12sx6oScER9D uvG4ERAOMAEJwGMMpuXA4htUGD1fOvY8j7/27BaxruNPdgG/tQWG1ANi06zDjrwCzwyX RJj27WMqPsK+XimDOJ4l8UMx2IRD93h31d7PLFKgaw+FVrHiSk5S6o0ts8aQk8fNkETE huAbkoufkjSvSwjhSj/CuAIw8zQU28QMEYlBAD/R66UAf1wfYELUK4aWNbY87d9vNm/a 9pZQ== 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=oVzpDIZ/n1NBC8A65I9bTXWTx9geiA4bgBQ5ptyg2bI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=rvDvHRCQOllzC6JwFLmyVkL8nAz8tKbjeM03NF5eY1c5QZ7LfGIUjnT7S9cTS6mGu4 s4B5eDIaHNZaH6PaaSIyxnDOkMiI40shEJOlNQmOREsZLRHifWvCYbQ6Ko9CzKSaaLFw g4xIkycRQ4Ui01PhbKPVHA4qaPAA2NHZ0xvSoOr/37skZIBNxslljfpfT9x92EE2s0yK gBoN0wtDEkkw1D9fY+GYJs0iT4T6gwfGM/ku8JHPY+E6L21O+mJucWUJFA7uXpRd7s3C fh54BeEvSA5jAWTXz7nGwHk4fJUfFA5o9S91f4N6UEjje/l0DCnWfZgasNHVaBARSdzl jwUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="MhFehoh/"; 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 2adb3069b0e04-52ca287248csi2344910e87.210.2024.06.16.15.29.25; Sun, 16 Jun 2024 15:29:26 -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=20230601 header.b="MhFehoh/"; 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 6D00E68D752; Mon, 17 Jun 2024 01:29:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A622168D708 for ; Mon, 17 Jun 2024 01:28:54 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-421b9068274so34135825e9.1 for ; Sun, 16 Jun 2024 15:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576933; x=1719181733; darn=ffmpeg.org; 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=8N45asuRe5aGO2J6rjeA6eS9+vNSmPO+QAMFMAPc2NI=; b=MhFehoh/CDjTfHdmrjykdz938NRNAHSEeKB8fYPPPoqdJgzyXhxmnY/I53WwaIkhJ1 WnKNStWBmzuDCUFpNfh9/KoBh/LaGVRfk4WQq5rDODIR9e9lnyE0fIQSOjxDb8/Xfl7/ 1QunorduwzDVApl3QXaVQwksfLF9szQFCdeAlhl5ThTMMhJDkb6ZrIawDu2Vb1dtKg1W 1z+S/OcCDn8629d9xMu6oYVwKT1Nx09fLberFPTh+yp8J47okY4FNbhZDFKMy6yRUHI5 WzIdccrYAD4IUX0KMohOm366OM6xLLL6cvhGUqnDoA9jFTeJByMX4p+c71e5rUEwzZYb w7UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576933; x=1719181733; 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=8N45asuRe5aGO2J6rjeA6eS9+vNSmPO+QAMFMAPc2NI=; b=IeKMXvWbPeqMMZQtHwvDzM3LGjdINaZEbU0LU4xED7YEi1un2oVY/oV/iXkeBfRs9G VYpsOThppdouo58zFl/GB/RPywv0hCD1crp6H9z4gf/F/q+bJ/8cNkDxRNxgY7kXwszr WRf25HfBruIKkGdWH7Dh8t3TWXc/Hl0ZEL8h8ak3y6AnYifoNUEY9SSXfXR9V9J0QfVB 7pA/KhTb5qKzBN3brx3cqM8dhEOAGkfwRF4rBcjSKVAipmZhc1KzO/RZnoSBZicjqPPF QtOGcjqjPEUt8G/AgRAzzJZfPruJmDAfvo8MEC4ZJ6hMXq8kJuUbfJMEIjKt+0cnMOFq jy3g== X-Gm-Message-State: AOJu0Yx6hZTmiwiiNULcVyKRPo0WCQty7te5hqR3LIepqC8HWFZ2WAAD fZsllD7b2RclejdXY1eWUHPg7V7bqpH5lw+s956z5dFlsLCzZkMcJSDGOA== X-Received: by 2002:a05:600c:a01:b0:422:4fcd:d4b3 with SMTP id 5b1f17b1804b1-42304858427mr58066255e9.37.1718576933124; Sun, 16 Jun 2024 15:28:53 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:52 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:46 +0200 Message-Id: <20240616222849.420361-3-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] swscale/yuv2rgb: fix yuv422p input in C code 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: Pc2AB9FSXCDm The C code was silently ignoring the second chroma line on yuv422p input. --- libswscale/yuv2rgb.c | 228 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 196 insertions(+), 32 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 7386d3a2a2..1ea87ac17a 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -65,7 +65,7 @@ const int *sws_getCoefficients(int colorspace) return ff_yuv2rgb_coeffs[colorspace]; } -#define LOADCHROMA(i) \ +#define LOADCHROMA(pu, pv, i) \ U = pu[i]; \ V = pv[i]; \ r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \ @@ -124,17 +124,13 @@ const int *sws_getCoefficients(int colorspace) dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ dst[12 * i + 10] = dst[12 * i + 11] = r[Y]; -#define YUV2RGBFUNC(func_name, dst_type, alpha) \ +#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \ static int func_name(SwsContext *c, const uint8_t *src[], \ int srcStride[], int srcSliceY, int srcSliceH, \ uint8_t *dst[], int dstStride[]) \ { \ int y; \ \ - if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \ - srcStride[1] *= 2; \ - srcStride[2] *= 2; \ - } \ for (y = 0; y < srcSliceH; y += 2) { \ int yd = y + srcSliceY; \ dst_type *dst_1 = \ @@ -144,10 +140,15 @@ const int *sws_getCoefficients(int colorspace) dst_type av_unused *r, *g, *b; \ const uint8_t *py_1 = src[0] + y * srcStride[0]; \ const uint8_t *py_2 = py_1 + srcStride[0]; \ - const uint8_t av_unused *pu = src[1] + (y >> 1) * srcStride[1]; \ - const uint8_t av_unused *pv = src[2] + (y >> 1) * srcStride[2]; \ + const uint8_t av_unused *pu_1 = src[1] + (y >> !yuv422) * srcStride[1]; \ + const uint8_t av_unused *pv_1 = src[2] + (y >> !yuv422) * srcStride[2]; \ + const uint8_t av_unused *pu_2, *pv_2; \ const uint8_t av_unused *pa_1, *pa_2; \ unsigned int h_size = c->dstW >> 3; \ + if (yuv422) { \ + pu_2 = pu_1 + srcStride[1]; \ + pv_2 = pv_1 + srcStride[2]; \ + } \ if (alpha) { \ pa_1 = src[3] + y * srcStride[3]; \ pa_2 = pa_1 + srcStride[3]; \ @@ -155,9 +156,13 @@ const int *sws_getCoefficients(int colorspace) while (h_size--) { \ int av_unused U, V, Y; \ -#define ENDYUV2RGBLINE(dst_delta, ss, alpha) \ - pu += 4 >> ss; \ - pv += 4 >> ss; \ +#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \ + pu_1 += 4 >> ss; \ + pv_1 += 4 >> ss; \ + if (yuv422) { \ + pu_2 += 4 >> ss; \ + pv_2 += 4 >> ss; \ + } \ py_1 += 8 >> ss; \ py_2 += 8 >> ss; \ if (alpha) { \ @@ -177,73 +182,169 @@ const int *sws_getCoefficients(int colorspace) } #define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, alpha) \ - LOADCHROMA(0); \ + YUV2RGBFUNC(func_name, dst_type, alpha, 0) \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ \ - LOADCHROMA(1); \ + LOADCHROMA(pu_1, pv_1, 1); \ PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ \ - LOADCHROMA(2); \ + LOADCHROMA(pu_1, pv_1, 2); \ PUTFUNC(dst_1, py_1, pa_1, 2, abase); \ PUTFUNC(dst_2, py_2, pa_2, 2, abase); \ \ - LOADCHROMA(3); \ + LOADCHROMA(pu_1, pv_1, 3); \ PUTFUNC(dst_2, py_2, pa_2, 3, abase); \ PUTFUNC(dst_1, py_1, pa_1, 3, abase); \ - ENDYUV2RGBLINE(dst_delta, 0, alpha) \ - LOADCHROMA(0); \ + ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ \ - LOADCHROMA(1); \ + LOADCHROMA(pu_1, pv_1, 1); \ PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ - ENDYUV2RGBLINE(dst_delta, 1, alpha) \ - LOADCHROMA(0); \ + ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ ENDYUV2RGBFUNC() +#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ + YUV2RGBFUNC(func_name, dst_type, alpha, 1) \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 1); \ + PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + \ + LOADCHROMA(pu_1, pv_1, 1); \ + PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + \ + LOADCHROMA(pu_1, pv_1, 2); \ + PUTFUNC(dst_1, py_1, pa_1, 2, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 2); \ + PUTFUNC(dst_2, py_2, pa_2, 2, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 3); \ + PUTFUNC(dst_2, py_2, pa_2, 3, abase); \ + \ + LOADCHROMA(pu_1, pv_1, 3); \ + PUTFUNC(dst_1, py_1, pa_1, 3, abase); \ + ENDYUV2RGBLINE(dst_delta, 0, alpha, 1) \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 1); \ + PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + \ + LOADCHROMA(pu_1, pv_1, 1); \ + PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + ENDYUV2RGBLINE(dst_delta, 1, alpha, 1) \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + ENDYUV2RGBFUNC() + #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, 0) \ + YUV2RGBFUNC(func_name, dst_type, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(0); \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, 0, 0); \ PUTFUNC(dst_2, py_2, 0, 0 + 8); \ \ - LOADCHROMA(1); \ + LOADCHROMA(pu_1, pv_1, 1); \ PUTFUNC(dst_2, py_2, 1, 2 + 8); \ PUTFUNC(dst_1, py_1, 1, 2); \ \ - LOADCHROMA(2); \ + LOADCHROMA(pu_1, pv_1, 2); \ PUTFUNC(dst_1, py_1, 2, 4); \ PUTFUNC(dst_2, py_2, 2, 4 + 8); \ \ - LOADCHROMA(3); \ + LOADCHROMA(pu_1, pv_1, 3); \ PUTFUNC(dst_2, py_2, 3, 6 + 8); \ PUTFUNC(dst_1, py_1, 3, 6); \ - ENDYUV2RGBLINE(dst_delta, 0, 0) \ + ENDYUV2RGBLINE(dst_delta, 0, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(0); \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, 0, 0); \ PUTFUNC(dst_2, py_2, 0, 0 + 8); \ \ - LOADCHROMA(1); \ + LOADCHROMA(pu_1, pv_1, 1); \ PUTFUNC(dst_2, py_2, 1, 2 + 8); \ PUTFUNC(dst_1, py_1, 1, 2); \ - ENDYUV2RGBLINE(dst_delta, 1, 0) \ + ENDYUV2RGBLINE(dst_delta, 1, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(0); \ + LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, 0, 0); \ PUTFUNC(dst_2, py_2, 0, 0 + 8); \ ENDYUV2RGBFUNC() +#define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ + YUV2RGBFUNC(func_name, dst_type, 0, 1) \ + LOADDITHER \ + \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + \ + LOADCHROMA(pu_2, pv_2, 1); \ + PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + \ + LOADCHROMA(pu_1, pv_1, 1); \ + PUTFUNC(dst_1, py_1, 1, 2); \ + \ + LOADCHROMA(pu_1, pv_1, 2); \ + PUTFUNC(dst_1, py_1, 2, 4); \ + \ + LOADCHROMA(pu_2, pv_2, 2); \ + PUTFUNC(dst_2, py_2, 2, 4 + 8); \ + \ + LOADCHROMA(pu_2, pv_2, 3); \ + PUTFUNC(dst_2, py_2, 3, 6 + 8); \ + \ + LOADCHROMA(pu_1, pv_1, 3); \ + PUTFUNC(dst_1, py_1, 3, 6); \ + ENDYUV2RGBLINE(dst_delta, 0, 0, 1) \ + LOADDITHER \ + \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + \ + LOADCHROMA(pu_2, pv_2, 1); \ + PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + \ + LOADCHROMA(pu_1, pv_1, 1); \ + PUTFUNC(dst_1, py_1, 1, 2); \ + ENDYUV2RGBLINE(dst_delta, 1, 0, 1) \ + LOADDITHER \ + \ + LOADCHROMA(pu_1, pv_1, 0); \ + PUTFUNC(dst_1, py_1, 0, 0); \ + \ + LOADCHROMA(pu_2, pv_2, 0); \ + PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + ENDYUV2RGBFUNC() + #define LOADDITHER16 \ const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ const uint8_t *e16 = ff_dither_2x2_4[y & 1]; \ @@ -330,7 +431,7 @@ const int *sws_getCoefficients(int colorspace) g[Y + d64[1 + o]] + \ b[Y + d128[1 + o]]; -YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) +YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0) const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; char out_1 = 0, out_2 = 0; g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; @@ -392,6 +493,7 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) dst_2[0] = out_2; ENDYUV2RGBFUNC() +// YUV420 YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48) YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48) YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8) @@ -411,6 +513,26 @@ YUV420FUNC_DITHER(yuv2rgb_c_8_ordered_dither, uint8_t, LOADDITHER8, PUTRGB8, YUV420FUNC_DITHER(yuv2rgb_c_4_ordered_dither, uint8_t, LOADDITHER4D, PUTRGB4D, 4) YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) +// YUV422 +YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48) +YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48) +YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8) +#if HAVE_BIGENDIAN +YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8) +YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8) +#else +YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8) +YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8) +#endif +YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24) +YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24) +YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8) +YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8) +YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8) +YUV422FUNC_DITHER(yuv422p_bgr8, uint8_t, LOADDITHER8, PUTRGB8, 8) +YUV422FUNC_DITHER(yuv422p_bgr4, uint8_t, LOADDITHER4D, PUTRGB4D, 4) +YUV422FUNC_DITHER(yuv422p_bgr4_byte, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) + SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) { SwsFunc t = NULL; @@ -430,6 +552,47 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) "No accelerated colorspace conversion found from %s to %s.\n", av_get_pix_fmt_name(c->srcFormat), av_get_pix_fmt_name(c->dstFormat)); + if (c->srcFormat == AV_PIX_FMT_YUV422P) { + switch (c->dstFormat) { + case AV_PIX_FMT_BGR48BE: + case AV_PIX_FMT_BGR48LE: + return yuv422p_bgr48_c; + case AV_PIX_FMT_RGB48BE: + case AV_PIX_FMT_RGB48LE: + return yuv422p_rgb48_c; + case AV_PIX_FMT_ARGB: + case AV_PIX_FMT_ABGR: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) + return yuva422p_argb_c; + case AV_PIX_FMT_RGBA: + case AV_PIX_FMT_BGRA: + return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva422p_rgba_c : yuv422p_rgb32_c; + case AV_PIX_FMT_RGB24: + return yuv422p_rgb24_c; + case AV_PIX_FMT_BGR24: + return yuv422p_bgr24_c; + case AV_PIX_FMT_RGB565: + case AV_PIX_FMT_BGR565: + return yuv422p_bgr16; + case AV_PIX_FMT_RGB555: + case AV_PIX_FMT_BGR555: + return yuv422p_bgr15; + case AV_PIX_FMT_RGB444: + case AV_PIX_FMT_BGR444: + return yuv422p_bgr12; + case AV_PIX_FMT_RGB8: + case AV_PIX_FMT_BGR8: + return yuv422p_bgr8; + case AV_PIX_FMT_RGB4: + case AV_PIX_FMT_BGR4: + return yuv422p_bgr4; + case AV_PIX_FMT_RGB4_BYTE: + case AV_PIX_FMT_BGR4_BYTE: + return yuv422p_bgr4_byte; + case AV_PIX_FMT_MONOBLACK: + return yuv2rgb_c_1_ordered_dither; + } + } else { switch (c->dstFormat) { case AV_PIX_FMT_BGR48BE: case AV_PIX_FMT_BGR48LE: @@ -469,6 +632,7 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) case AV_PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither; } + } return NULL; } From patchwork Sun Jun 16 22:28:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49955 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596760vqg; Sun, 16 Jun 2024 15:29:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcpjhYxloWEm3xx2z50MVQD14+gEz68oCfkVXd69SQQhfs5Jc0p9icxladQklOLG/sZEQqpBM2YcdfbwPv11VeqQpTaP73Y4yzOQ== X-Google-Smtp-Source: AGHT+IH0gXTrGMm6lF3PZqNWhpRJEf4dm4CkooUrjgnDF0PBA5wClpJ5UL2PFVjQ3rX7Gp3IDWY8 X-Received: by 2002:a50:9b4d:0:b0:57c:7826:1dc with SMTP id 4fb4d7f45d1cf-57cbd6778f6mr6706058a12.8.1718576975910; Sun, 16 Jun 2024 15:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576975; cv=none; d=google.com; s=arc-20160816; b=w1uvqhEDb2WZxiag66YlmrzsdflwbPa+fFCjfBMEqSRL1XhCexoETw1lZHLO0RMj5y 1y1CeQu7Lgs2k3tQVB+zrF3TjaXHKvJzcjaOzLNPvILLPDIKmcxvBe8jbNoRAl2HkZBH O1H//ZA7LL8We6nLaUchQt82wi8HuR2DbBzxX2b2syUwGTIYyPOFWWsoYpMJd3MNV0Q+ k/bwMjAeD6VQQGowy5hnaQ1+C83/kOJeyHOESK4yJc6VlLJeOATUMHRM9bMr02HUzFjG kLdfQQUqnQhrbf26Hm6Ve5tJ03NMbn23YzqZNH9A7+7bFXxrijcZex3KsF3C5TYTu/a8 4FqA== 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=lAPLso50UFuudW4sv+CvFACcVvfoIa4DzyVYb1+2NCw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=dQE+gBKlf9CHmq3XNXpde7vtg0cMyvDsFEr04HbmaoH+NVNTwFV+L8zRQA3QnaGO7x w5fGzuqx3E/cBSt0I8Dl1cqgkwUoZKrXHnJhLnmbxyVQB2KLV2e+UEnTkrxc2d9DuTXK 1xenZFW9ii12Z2yCM8W6ERIEcqG7KB59C1ORYqOui4cMR+t6NL/Pqr7xG6Edmj+iLfDZ gut5F5q7Dbn8uW3y5cFHd7hgO5cNjlr1DhVBSRsUzrYhtrINi9sbfuq4xjhCqCmHZwU9 wo8ZN4MCrqvml6AzNOrOnHOzXVmIswYNpyZh80+diQha47HavCjz64WcTqyv87PSp3fB vVQw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=P+TakY2G; 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 4fb4d7f45d1cf-57cb7441715si4093707a12.396.2024.06.16.15.29.34; Sun, 16 Jun 2024 15:29:35 -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=20230601 header.b=P+TakY2G; 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 48B5A68D75B; Mon, 17 Jun 2024 01:29:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4078168D708 for ; Mon, 17 Jun 2024 01:28:55 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-35f225ac23bso3705467f8f.0 for ; Sun, 16 Jun 2024 15:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576934; x=1719181734; darn=ffmpeg.org; 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=AqSMMDvaRg3NH07IJigPqcOnMYd6Aot9ibjscl1y9jE=; b=P+TakY2Gd+1VIKAE2KI3gk3j/bjjlNW6B7bc+zLSeajtnS8ESoBVwx/hx7zVQULgD7 BJYg9pdXRrfhIm4bokv4+BruadGDGmLV56IAuqGV4HcOa99yfn8iJvTVYhC/EjlTigBy SNhfiFdTPsNhiTF/eedTPSKAaoNS4FeNNN+L25QaGCwCAW78hl+fZoFkwZIfyWXw+1+X 6J+MU0KJQJadHQWKQipbtofYysQjt16VYmtAHV4UtnCvknEPpBga1+f8ozI/ZrrdZI4f 7PyrG46L40zG0tOowaxHvC30W8SRGOVRt6Tk2cjWat336zq7lz/d2GqSIMlXryJxxxRI Jy4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576934; x=1719181734; 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=AqSMMDvaRg3NH07IJigPqcOnMYd6Aot9ibjscl1y9jE=; b=sOJ9UTKuw9sSM/FSoXU8f69n+O5heyxC0SwLRFJBEyG2UzsNi6qXCAyxRxWAWQUDm6 Yx1SfZz/HYM7nojDS2r60i9E3Pwjcg7GtwPqkj57bwDYUZOr7nDpb1Q4p++jDSrYA+Wh A9lvCJBYrb2qc8IYk7pSdm7pIA4QLiPTjjTLkJsE9MBLfheDtcgqzTiGT/1Z8jv7e9EH jiIeaEmZzsg7ESPzFrfbDeUXdKYrYWCnByk7AOJcDhHwdq4tZ/X64u1K/9QxTn4n8+X3 Zkjl7JMJ7v6HzUFOapDVEKup7FQWSFnZTMoh+FRPvutNfoPtsLWvxWrf48Q+FNs1Nwdn 5RSA== X-Gm-Message-State: AOJu0YwEHNVWB7ZKmXDUQbhpK4zSPB6Th5rfD8HPM3qus9PuX3Uv6Gki 3OK/GiId1Rv89YK1tG1sPkLQ1aYDBwqPpv5dXESyEdRHVP4/0zSFrrAcLA== X-Received: by 2002:a05:6000:1a86:b0:35f:3189:ddd2 with SMTP id ffacd0b85a97d-3607a7687f8mr9581762f8f.35.1718576933948; Sun, 16 Jun 2024 15:28:53 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:53 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:47 +0200 Message-Id: <20240616222849.420361-4-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] swscale/yuv2rgb: reindent after previous commit 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: mIG89hFC7nGg --- libswscale/yuv2rgb.c | 78 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 1ea87ac17a..977eb3a7dd 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -593,45 +593,45 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) return yuv2rgb_c_1_ordered_dither; } } else { - switch (c->dstFormat) { - case AV_PIX_FMT_BGR48BE: - case AV_PIX_FMT_BGR48LE: - return yuv2rgb_c_bgr48; - case AV_PIX_FMT_RGB48BE: - case AV_PIX_FMT_RGB48LE: - return yuv2rgb_c_48; - case AV_PIX_FMT_ARGB: - case AV_PIX_FMT_ABGR: - if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) - return yuva2argb_c; - case AV_PIX_FMT_RGBA: - case AV_PIX_FMT_BGRA: - return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32; - case AV_PIX_FMT_RGB24: - return yuv2rgb_c_24_rgb; - case AV_PIX_FMT_BGR24: - return yuv2rgb_c_24_bgr; - case AV_PIX_FMT_RGB565: - case AV_PIX_FMT_BGR565: - return yuv2rgb_c_16_ordered_dither; - case AV_PIX_FMT_RGB555: - case AV_PIX_FMT_BGR555: - return yuv2rgb_c_15_ordered_dither; - case AV_PIX_FMT_RGB444: - case AV_PIX_FMT_BGR444: - return yuv2rgb_c_12_ordered_dither; - case AV_PIX_FMT_RGB8: - case AV_PIX_FMT_BGR8: - return yuv2rgb_c_8_ordered_dither; - case AV_PIX_FMT_RGB4: - case AV_PIX_FMT_BGR4: - return yuv2rgb_c_4_ordered_dither; - case AV_PIX_FMT_RGB4_BYTE: - case AV_PIX_FMT_BGR4_BYTE: - return yuv2rgb_c_4b_ordered_dither; - case AV_PIX_FMT_MONOBLACK: - return yuv2rgb_c_1_ordered_dither; - } + switch (c->dstFormat) { + case AV_PIX_FMT_BGR48BE: + case AV_PIX_FMT_BGR48LE: + return yuv2rgb_c_bgr48; + case AV_PIX_FMT_RGB48BE: + case AV_PIX_FMT_RGB48LE: + return yuv2rgb_c_48; + case AV_PIX_FMT_ARGB: + case AV_PIX_FMT_ABGR: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) + return yuva2argb_c; + case AV_PIX_FMT_RGBA: + case AV_PIX_FMT_BGRA: + return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32; + case AV_PIX_FMT_RGB24: + return yuv2rgb_c_24_rgb; + case AV_PIX_FMT_BGR24: + return yuv2rgb_c_24_bgr; + case AV_PIX_FMT_RGB565: + case AV_PIX_FMT_BGR565: + return yuv2rgb_c_16_ordered_dither; + case AV_PIX_FMT_RGB555: + case AV_PIX_FMT_BGR555: + return yuv2rgb_c_15_ordered_dither; + case AV_PIX_FMT_RGB444: + case AV_PIX_FMT_BGR444: + return yuv2rgb_c_12_ordered_dither; + case AV_PIX_FMT_RGB8: + case AV_PIX_FMT_BGR8: + return yuv2rgb_c_8_ordered_dither; + case AV_PIX_FMT_RGB4: + case AV_PIX_FMT_BGR4: + return yuv2rgb_c_4_ordered_dither; + case AV_PIX_FMT_RGB4_BYTE: + case AV_PIX_FMT_BGR4_BYTE: + return yuv2rgb_c_4b_ordered_dither; + case AV_PIX_FMT_MONOBLACK: + return yuv2rgb_c_1_ordered_dither; + } } return NULL; } From patchwork Sun Jun 16 22:28:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49956 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596788vqg; Sun, 16 Jun 2024 15:29:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXVKFP2XBiWHtHUYY9kxVE623ZfynoWigqWqjkJfAqFuCRdbwFDnnWZVFlBT7u2YagnQYTrbp48/vPWNDdEwwqvv6kq5d6GMsTOjw== X-Google-Smtp-Source: AGHT+IG5Cc2laVJLq8EnQ25iofBcGmz3OkmiNYFNYfJ1j8/O05vg7GmE9u55tUk1MFw5/9zBcPdC X-Received: by 2002:a05:6512:220b:b0:52c:9adc:3527 with SMTP id 2adb3069b0e04-52ca6e8fd4cmr6665449e87.47.1718576985042; Sun, 16 Jun 2024 15:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576985; cv=none; d=google.com; s=arc-20160816; b=kWZUWXupq8qR+ETg8zE7DoUIHgQNSW5QMafvbjHLXZVpI8t/WRyVwodSPCeCjtB8kj 2b0gwB0lF/7xCFl6SWclDCQEm55ewZcAZnOxk8Pjw0O5MlkdvuBxlBzomG/S+3LJ1jfY twooP9MNtuhyMIzrtwukHHvGXV8O+uzRny6z5Y5W/qs+iDnz9bLbYOPd2kbqmq5h7Xlk znr98W76bdaysuPL9UX9AsLoyC+Im8R9/8fJeVVZPCH6t+jutCCdsu9XvdCjsfMXNm58 fltTv4TaBMTZJ6k7RAtHesGO47rHmyV+s2fWGVES4KoIgx4qRilL9n/8a5s2kJBflRaa QMTw== 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=w0Qmhw+lUREA90c+iBdNiYfEcxPWrJG7+2apKS7AW8E=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=SuXDqv3udf9LimYAEFPjan190nOB0h8z90zQqkmKibyBuUwEdNVsglAGw19l0xQPnR vTzTaX/X+FiN6BZzh2/JwnYV6HGST3pClt7hbFQOIT/9T6YaT5bn0FDe6LTMdTui+Eye VCWYKyz7y29MC32ds4LLBYbWMDBk3U4u53FKBZ4PXnk4xD8BnLFEwCdz0wJX0Ukewpox O5L0WSQnYO1UcXY7gpEIdQ6lOOiyfQz/2CHWPKV4AUTZWNhXk69xDyQzx0SVwht+K2iO DNJE5GGU9ax0zsA26CGrYkb7WufYPqAGswUgrVB7+sYzkSOiy1emFCg7v0fLdl+4bQoh iD1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=NZ+xLWJU; 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 2adb3069b0e04-52ca2872d11si2363977e87.264.2024.06.16.15.29.44; Sun, 16 Jun 2024 15:29:45 -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=20230601 header.b=NZ+xLWJU; 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 9BB4368D754; Mon, 17 Jun 2024 01:29:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6579D68D602 for ; Mon, 17 Jun 2024 01:28:56 +0300 (EEST) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-421a1b834acso32014665e9.3 for ; Sun, 16 Jun 2024 15:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576935; x=1719181735; darn=ffmpeg.org; 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=102lhfYsYeL4PXusCzWQzuZbXm5lXGq8wj5ER3l8bZc=; b=NZ+xLWJUXrrEStud0UUZWAFeXTX/p/tfKkk+SCyHj3m5/I5qLH3QHD0Tn3qAd2idNy h44cKc3VkghukRHeHtCLmwtj2oAZYBFi6wSM5qFLrzUEtoQ1boLVWPAnaGpscNnA5kD6 u5a/L3l+BkN/lxAL4a5GLxgESPi4+HisyJxKMfTJjV4tHihe3L+e/IPI13LWzM+p7rpf 6BKDEvN4Hgfk+qSxgvm0tagoKGctNluATVWvGvatFlRHeKK7nQI6F+mjyfAj8XQiooK5 LLrCh/JfW/WQOzQdD22hh2ND3nwszG1xuSFBiZe5Iu/FIgLH/9w8tpy8YLsqx9l/PDpP RveA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576935; x=1719181735; 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=102lhfYsYeL4PXusCzWQzuZbXm5lXGq8wj5ER3l8bZc=; b=vw5tSKJl3qlXaeVIUoHcAc87lquz9t08AhWcM0R/3gjzA27nNtxozRAPgeicOHdFh4 eKXtoivQO8hWa4WDxUUkNITJb/kwjy39KWHIXlbthBeDPaVsZMj9df5Kjkv/ddQCkAr6 yISbvKHDZxb4yFPGm+Ki1Pab2KFIgXzKbFxDEgpmY8BVTm//n3P+QXHBCgeB53CxKktI VEl0IjE4oF+IjW0nNWHaC7//fGvSyfujBNltPL0+WMfuPg62pldc9O11YGlTOeI7iSsK 2nHfjUJssZ+2XhlrzYxdY1XIBi+5rRP/CzcKlTRwa1ApY6kx05jGzb+oxLJklIPyJ8hi aW0g== X-Gm-Message-State: AOJu0YykaDRWpkDxCA2lSMlrOpkiXVDpQoV5OimQSSHBMeeOzBr9ghGF jxeUG2X3rOxvWR+R64Dig1DqPVUxCSlaM8pXG9Qrordun2GFa0p8XI8HuA== X-Received: by 2002:a05:600c:3551:b0:41a:b30e:42a3 with SMTP id 5b1f17b1804b1-4230485b9e3mr59518415e9.37.1718576935286; Sun, 16 Jun 2024 15:28:55 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:54 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:48 +0200 Message-Id: <20240616222849.420361-5-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] checkasm: add tests for yuv2rgb 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: iIj78VLFGzHD --- tests/checkasm/Makefile | 2 +- tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sw_yuv2rgb.c | 205 ++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/sw_yuv2rgb.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index f20732b37a..3a7670e24b 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -63,7 +63,7 @@ AVFILTEROBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests -SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o sw_scale.o +SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o sw_scale.o sw_yuv2rgb.o CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 56232ab1e0..d9ac772a08 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -254,6 +254,7 @@ static const struct { { "sw_range_convert", checkasm_check_sw_range_convert }, { "sw_rgb", checkasm_check_sw_rgb }, { "sw_scale", checkasm_check_sw_scale }, + { "sw_yuv2rgb", checkasm_check_sw_yuv2rgb }, #endif #if CONFIG_AVUTIL { "fixed_dsp", checkasm_check_fixed_dsp }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index e544007b67..4d5f3e387e 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -122,6 +122,7 @@ void checkasm_check_sw_gbrp(void); void checkasm_check_sw_range_convert(void); void checkasm_check_sw_rgb(void); void checkasm_check_sw_scale(void); +void checkasm_check_sw_yuv2rgb(void); void checkasm_check_takdsp(void); void checkasm_check_utvideodsp(void); void checkasm_check_v210dec(void); diff --git a/tests/checkasm/sw_yuv2rgb.c b/tests/checkasm/sw_yuv2rgb.c new file mode 100644 index 0000000000..fbe01a7788 --- /dev/null +++ b/tests/checkasm/sw_yuv2rgb.c @@ -0,0 +1,205 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem_internal.h" +#include "libavutil/pixdesc.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +#define randomize_buffers(buf, size) \ + do { \ + for (int j = 0; j < size; j += 4) \ + AV_WN32(buf + j, rnd()); \ + } while (0) + +static const int dst_fmts[] = { +// AV_PIX_FMT_BGR48BE, +// AV_PIX_FMT_BGR48LE, +// AV_PIX_FMT_RGB48BE, +// AV_PIX_FMT_RGB48LE, + AV_PIX_FMT_ARGB, + AV_PIX_FMT_ABGR, + AV_PIX_FMT_RGBA, + AV_PIX_FMT_BGRA, + AV_PIX_FMT_RGB24, + AV_PIX_FMT_BGR24, + AV_PIX_FMT_RGB565, + AV_PIX_FMT_BGR565, + AV_PIX_FMT_RGB555, + AV_PIX_FMT_BGR555, +// AV_PIX_FMT_RGB444, +// AV_PIX_FMT_BGR444, +// AV_PIX_FMT_RGB8, +// AV_PIX_FMT_BGR8, +// AV_PIX_FMT_RGB4, +// AV_PIX_FMT_BGR4, +// AV_PIX_FMT_RGB4_BYTE, +// AV_PIX_FMT_BGR4_BYTE, +// AV_PIX_FMT_MONOBLACK, +}; + +static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ + for (size_t i = 0; i < n; i++) { + if (abs(ref[i] - test[i]) > accuracy) + return 1; + } + return 0; +} + +static int cmp_555_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ + const uint16_t *ref16 = (const uint16_t *) ref; + const uint16_t *test16 = (const uint16_t *) test; + for (size_t i = 0; i < n; i++) { + if (abs(( ref16[i] & 0x1f) - ( test16[i] & 0x1f)) > accuracy) + return 1; + if (abs(((ref16[i] >> 5) & 0x1f) - ((test16[i] >> 5) & 0x1f)) > accuracy) + return 1; + if (abs(((ref16[i] >> 10) & 0x1f) - ((test16[i] >> 10) & 0x1f)) > accuracy) + return 1; + } + return 0; +} + +static int cmp_565_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ + const uint16_t *ref16 = (const uint16_t *) ref; + const uint16_t *test16 = (const uint16_t *) test; + for (size_t i = 0; i < n; i++) { + if (abs(( ref16[i] & 0x1f) - ( test16[i] & 0x1f)) > accuracy) + return 1; + if (abs(((ref16[i] >> 5) & 0x3f) - ((test16[i] >> 5) & 0x3f)) > accuracy) + return 1; + if (abs(((ref16[i] >> 11) & 0x1f) - ((test16[i] >> 11) & 0x1f)) > accuracy) + return 1; + } + return 0; +} + +static void check_yuv2rgb(int src_pix_fmt) +{ + const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); +#define MAX_LINE_SIZE 1920 + static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE}; + + declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, + int, SwsContext *c, const uint8_t *src[], + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[]); + + LOCAL_ALIGNED_8(uint8_t, src_y, [MAX_LINE_SIZE * 2]); + LOCAL_ALIGNED_8(uint8_t, src_u, [MAX_LINE_SIZE]); + LOCAL_ALIGNED_8(uint8_t, src_v, [MAX_LINE_SIZE]); + LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]); + const uint8_t *src[4] = { src_y, src_u, src_v, src_a }; + + LOCAL_ALIGNED_8(uint8_t, dst0_, [2 * MAX_LINE_SIZE * 6]); + uint8_t *dst0[4] = { dst0_ }; + uint8_t *lines0[2] = { dst0_, dst0_ + MAX_LINE_SIZE * 6 }; + + LOCAL_ALIGNED_8(uint8_t, dst1_, [2 * MAX_LINE_SIZE * 6]); + uint8_t *dst1[4] = { dst1_ }; + uint8_t *lines1[2] = { dst1_, dst1_ + MAX_LINE_SIZE * 6 }; + + randomize_buffers(src_y, MAX_LINE_SIZE * 2); + randomize_buffers(src_u, MAX_LINE_SIZE); + randomize_buffers(src_v, MAX_LINE_SIZE); + randomize_buffers(src_a, MAX_LINE_SIZE * 2); + + for (int dfi = 0; dfi < FF_ARRAY_ELEMS(dst_fmts); dfi++) { + int dst_pix_fmt = dst_fmts[dfi]; + const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); + int sample_size = av_get_padded_bits_per_pixel(dst_desc) >> 3; + for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { + struct SwsContext *ctx; + int width = input_sizes[isi]; + int srcSliceY = 0; + int srcSliceH = 2; + int srcStride[4] = { + width, + width >> src_desc->log2_chroma_w, + width >> src_desc->log2_chroma_w, + width, + }; + int dstStride[4] = { MAX_LINE_SIZE * 6 }; + + ctx = sws_getContext(width, srcSliceH, src_pix_fmt, + width, srcSliceH, dst_pix_fmt, + 0, NULL, NULL, NULL); + if (!ctx) + fail(); + + if (check_func(ctx->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) { + memset(dst0_, 0xFF, 2 * MAX_LINE_SIZE * 6); + memset(dst1_, 0xFF, 2 * MAX_LINE_SIZE * 6); + + call_ref(ctx, src, srcStride, srcSliceY, + srcSliceH, dst0, dstStride); + call_new(ctx, src, srcStride, srcSliceY, + srcSliceH, dst1, dstStride); + + if (dst_pix_fmt == AV_PIX_FMT_ARGB || + dst_pix_fmt == AV_PIX_FMT_ABGR || + dst_pix_fmt == AV_PIX_FMT_RGBA || + dst_pix_fmt == AV_PIX_FMT_BGRA || + dst_pix_fmt == AV_PIX_FMT_RGB24 || + dst_pix_fmt == AV_PIX_FMT_BGR24) { + if (cmp_off_by_n(lines0[0], lines1[0], width * sample_size, 3) || + cmp_off_by_n(lines0[1], lines1[1], width * sample_size, 3)) + fail(); + } else if (dst_pix_fmt == AV_PIX_FMT_RGB565 || + dst_pix_fmt == AV_PIX_FMT_BGR565) { + if (cmp_565_by_n(lines0[0], lines1[0], width, 2) || + cmp_565_by_n(lines0[1], lines1[1], width, 2)) + fail(); + } else if (dst_pix_fmt == AV_PIX_FMT_RGB555 || + dst_pix_fmt == AV_PIX_FMT_BGR555) { + if (cmp_555_by_n(lines0[0], lines1[0], width, 2) || + cmp_555_by_n(lines0[1], lines1[1], width, 2)) + fail(); + } else { + fail(); + } + + bench_new(ctx, src, srcStride, srcSliceY, + srcSliceH, dst0, dstStride); + } + sws_freeContext(ctx); + } + } +} + +#undef MAX_LINE_SIZE + +void checkasm_check_sw_yuv2rgb(void) +{ + check_yuv2rgb(AV_PIX_FMT_YUV420P); + report("yuv420p"); + check_yuv2rgb(AV_PIX_FMT_YUV422P); + report("yuv422p"); + check_yuv2rgb(AV_PIX_FMT_YUVA420P); + report("yuva420p"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 0ed2ea5be6..49832b09bf 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -44,6 +44,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \ fate-checkasm-sw_range_convert \ fate-checkasm-sw_rgb \ fate-checkasm-sw_scale \ + fate-checkasm-sw_yuv2rgb \ fate-checkasm-takdsp \ fate-checkasm-utvideodsp \ fate-checkasm-v210dec \ From patchwork Sun Jun 16 22:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49957 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596826vqg; Sun, 16 Jun 2024 15:29:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdnorBxf1Ywmn5o4UdqduHKksGF8MCGGaIpTHwWdGO6CKywv6l6lrrd4s4Kol4kBw25VxBm3TJ4z8ypsRKvSeuQ+91Wpw7xP8KDw== X-Google-Smtp-Source: AGHT+IHowGsdVPIxfnt0n7S2rY6w1yC9bEhMB+GHrQpNh0e/QdNPy19V09qovNlvjW/egnJ3cPG9 X-Received: by 2002:a50:d759:0:b0:57c:5874:4f5c with SMTP id 4fb4d7f45d1cf-57cbd6c7561mr6610482a12.32.1718576993428; Sun, 16 Jun 2024 15:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576993; cv=none; d=google.com; s=arc-20160816; b=POG1iXxxPvBjnBZsehEjziBws1dUJnAdv7sqnHseOyltOOb9imVXHFK9vk5WljQ24w ffaKjXIK69PtngeXgyka8rGqUrrrHb4+PYTb8IP7o0MNclEygiwAA7uXTaLypY3sTbYS gCP9zGmpnpG020QXCJkLvdr33MknQP5QGUyfJrthb5/SF9Kw/pvhMCgj7oa2sH2L194c myxp6Zhnr8F0YgMUphS6cFYFSN9vBeGDuGtB3B2E3ouFaYpTUYToMy1NHR0xZE/9Ls6j X5LuQOiHSjZHBlkYGfcQJifjYglGfUJ/b429F9/8JnlIlncHw/bPxgN5qx8HR5mzrKbx TPVQ== 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=OlkK9mYLvMNyWNfq0OvMap4iGVuTFDYwBHZEQVIo6cE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=yy86pCa/3aTwjevG4WKfzbZDlZfSMbb9w5WTcJyR3iptQArtvviIe8/q0iPxgMBZ3X k+knLJ/2Yfcvmb1A6f87Z4Y9R7dUMBjuy35ynUvDTkifa7lndhqmvJmCWKDPs3WzWKfm D+4xzxkSZFkIhU9fPpuV/LbS89t9o8+Nw3NnSMQHNRJfHPwZa6s34OgI8cnacRJWrb0s /wGGoeFh3AfwJy5O/ZP/HzjLmp9AoyB5K/wNjY1JBkWkOEyTSMuNfYTbq821e/qxmrAl zawOOoj/jFlJH+Vn331qX3Tbibpq2GBGfCHTCFUDamDSWmipj0x+FHYQ6y/UV76MXvTP ZtRA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Li4Ryfbv; 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 4fb4d7f45d1cf-57cb72d60d3si3861834a12.100.2024.06.16.15.29.52; Sun, 16 Jun 2024 15:29:53 -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=20230601 header.b=Li4Ryfbv; 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 4035A68D767; Mon, 17 Jun 2024 01:29:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8CF9C68D742 for ; Mon, 17 Jun 2024 01:28:57 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-35f22d3abf1so3471212f8f.1 for ; Sun, 16 Jun 2024 15:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576936; x=1719181736; darn=ffmpeg.org; 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=uE1P5f0A7oGKEQ/3fewtVro4OXtTHymu9QEZzQ9e9cg=; b=Li4RyfbvbFU94ZkQD2jzs6n+n4VKzMdUju5gVFrGsNdTsnj2pNj84hbcxG9jFeMamQ M94C69Msyi8WdcFG4am5wi9wVsGlhv7zNrl8e9tZBWbVufKMgAIbab/43fEZPCyhNpu8 NQRVJlPB6EfXXdWyqYEohFKX+6LWFT+HV8CjOJZ98SBmFTP8t2UjL+hjBrz1SgnmlUdQ CUTjYIGFCIUrvH+CV2N+7fC08TimWxjGv/ZzfCrn8HjJARgR4f+DYIN13NLW0UrKNHUC XeS0H7qacUzfIvba42BhSqAwnUm94CEOIV1M54icZfYSFgXuxMEHZ4let8aplDJUef4m 1Ahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576936; x=1719181736; 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=uE1P5f0A7oGKEQ/3fewtVro4OXtTHymu9QEZzQ9e9cg=; b=KzwZB+OBKYUBNwtyt4fXhzniadQyXvwiTbhkhWhAotzxwM1cy7vZK/mLABraWlyEJO EOSlqLK+lSTngULX9stPQW2z2CNP94oyHFi2rVjYOtzg5C/EtgRSWgBrYAqbeuGWdpHa DsXXw6xuZXlNDzlZ0yrv8FzIVlSQFdtV2C3SgPR9HnDSLYNFvOrVb73MLVokpFKiHmrB XTIY85/CmWLcACnw2OCjAo8i616cSRfrh6D8P6mlXDs17WUkQ7CgkyyF7wtu976nWAfg Ftd4/JCSyDp3xISJASCyzDoynVEaJY/oHj9S23gyq5NGp7mGOta6LpHbU78BYhWHH4OB 7OdQ== X-Gm-Message-State: AOJu0Yw4FA5VHJdUuOOilXfVgEn/9jwXhgSYs5ggsngKZ+h/RNYZICEe M9hpXYu7V6bdLL+BQzCWSywQ568AI3/G/gpPMi04Y9kNIs8HvIvi33kbRA== X-Received: by 2002:adf:ed86:0:b0:360:79ed:6251 with SMTP id ffacd0b85a97d-3607a783347mr7194621f8f.52.1718576936361; Sun, 16 Jun 2024 15:28:56 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:55 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:49 +0200 Message-Id: <20240616222849.420361-6-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] swscale/yuv2rgb/x86: remove mmx/mmxext yuv2rgb functions 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: xGCpUiuvbXUH These functions are either slower or barely faster than the C LUT yuv2rgb code. --- libswscale/x86/yuv2rgb.c | 51 ----------------- libswscale/x86/yuv2rgb_template.c | 4 -- libswscale/x86/yuv_2_rgb.asm | 93 +------------------------------ 3 files changed, 3 insertions(+), 145 deletions(-) diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index 6754062245..41dfa80f33 100644 --- a/libswscale/x86/yuv2rgb.c +++ b/libswscale/x86/yuv2rgb.c @@ -41,25 +41,8 @@ #define DITHER1XBPP // only for MMX -//MMX versions -#if HAVE_MMX -#undef RENAME -#define COMPILE_TEMPLATE_MMX -#define RENAME(a) a ## _mmx -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMX -#endif /* HAVE_MMX */ - -// MMXEXT versions -#undef RENAME -#define COMPILE_TEMPLATE_MMXEXT -#define RENAME(a) a ## _mmxext -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMXEXT - //SSSE3 versions #undef RENAME -#define COMPILE_TEMPLATE_SSSE3 #define RENAME(a) a ## _ssse3 #include "yuv2rgb_template.c" @@ -99,40 +82,6 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) } } - if (EXTERNAL_MMXEXT(cpu_flags)) { - switch (c->dstFormat) { - case AV_PIX_FMT_RGB24: - return yuv420_rgb24_mmxext; - case AV_PIX_FMT_BGR24: - return yuv420_bgr24_mmxext; - } - } - - if (EXTERNAL_MMX(cpu_flags)) { - switch (c->dstFormat) { - case AV_PIX_FMT_RGB32: - if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA - return yuva420_rgb32_mmx; -#endif - break; - } else - return yuv420_rgb32_mmx; - case AV_PIX_FMT_BGR32: - if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA - return yuva420_bgr32_mmx; -#endif - break; - } else - return yuv420_bgr32_mmx; - case AV_PIX_FMT_RGB565: - return yuv420_rgb16_mmx; - case AV_PIX_FMT_RGB555: - return yuv420_rgb15_mmx; - } - } - #endif /* HAVE_X86ASM */ return NULL; } diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c index 596943bb73..a4741e6873 100644 --- a/libswscale/x86/yuv2rgb_template.c +++ b/libswscale/x86/yuv2rgb_template.c @@ -47,7 +47,6 @@ extern void RENAME(ff_yuv_420_bgr24)(x86_reg index, uint8_t *image, const uint8_ const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index); -#ifndef COMPILE_TEMPLATE_MMXEXT extern void RENAME(ff_yuv_420_rgb15)(x86_reg index, uint8_t *image, const uint8_t *pu_index, const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index); @@ -163,9 +162,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif -#if !defined(COMPILE_TEMPLATE_MMX) static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, @@ -193,4 +190,3 @@ static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm index a1f9134e08..b67ab162d2 100644 --- a/libswscale/x86/yuv_2_rgb.asm +++ b/libswscale/x86/yuv_2_rgb.asm @@ -38,12 +38,6 @@ pb_e0: times 16 db 224 pb_03: times 16 db 3 pb_07: times 16 db 7 -mask_1101: dw -1, -1, 0, -1 -mask_0010: dw 0, 0, -1, 0 -mask_0110: dw 0, -1, -1, 0 -mask_1001: dw -1, 0, 0, -1 -mask_0100: dw 0, -1, 0, 0 - SECTION .text ;----------------------------------------------------------------------------- @@ -55,14 +49,6 @@ SECTION .text ; ;----------------------------------------------------------------------------- -%macro MOV_H2L 1 -%if mmsize == 8 - psrlq %1, 32 -%else ; mmsize == 16 - psrldq %1, 8 -%endif -%endmacro - %macro yuv2rgb_fn 3 %if %3 == 32 @@ -91,18 +77,6 @@ SECTION .text %define m_blue m1 %endif -%if mmsize == 8 -%define time_num 1 -%define reg_num 8 -%define y_offset [pointer_c_ditherq + 8 * 8] -%define u_offset [pointer_c_ditherq + 9 * 8] -%define v_offset [pointer_c_ditherq + 10 * 8] -%define ug_coff [pointer_c_ditherq + 7 * 8] -%define vg_coff [pointer_c_ditherq + 6 * 8] -%define y_coff [pointer_c_ditherq + 3 * 8] -%define ub_coff [pointer_c_ditherq + 5 * 8] -%define vr_coff [pointer_c_ditherq + 4 * 8] -%elif mmsize == 16 %define time_num 2 %if ARCH_X86_32 %define reg_num 8 @@ -125,13 +99,11 @@ SECTION .text %define ub_coff m14 %define vr_coff m15 %endif ; ARCH_X86_32/64 -%endif ; coeff define mmsize == 8/16 cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters %if ARCH_X86_64 movsxd indexq, indexd -%if mmsize == 16 VBROADCASTSD y_offset, [pointer_c_ditherq + 8 * 8] VBROADCASTSD u_offset, [pointer_c_ditherq + 9 * 8] VBROADCASTSD v_offset, [pointer_c_ditherq + 10 * 8] @@ -141,7 +113,6 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters VBROADCASTSD ub_coff, [pointer_c_ditherq + 5 * 8] VBROADCASTSD vr_coff, [pointer_c_ditherq + 4 * 8] %endif -%endif .loop0: movu m_y, [py_2indexq + 2 * indexq] movh m_u, [pu_indexq + indexq] @@ -157,7 +128,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters psllw m1, 3 psllw m6, 3 psllw m7, 3 -%if (ARCH_X86_32 && mmsize == 16) +%if ARCH_X86_32 VBROADCASTSD m2, mu_offset VBROADCASTSD m3, mv_offset VBROADCASTSD m4, my_offset @@ -176,7 +147,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters pmulhw m0, m5 VBROADCASTSD m4, mvr_coff pmulhw m1, m4 -%else ; ARCH_X86_64 || mmsize == 8 +%else ; ARCH_X86_64 psubsw m0, u_offset ; U = U - 128 psubsw m1, v_offset ; V = V - 128 psubw m6, y_offset @@ -207,49 +178,10 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters packuswb m2, m7 ; G0 G2 G4 G6 ... G1 G3 G5 G7 ... mova m3, m_red mova m6, m_blue - MOV_H2L m_red + psrldq m_red, 8 punpcklbw m3, m2 ; R0 G0 R2 G2 R4 G4 R6 G6 R8 G8 ... punpcklbw m6, m_red ; B0 R1 B2 R3 B4 R5 B6 R7 B8 R9 ... - mova m5, m3 punpckhbw m2, m_blue ; G1 B1 G3 B3 G5 B5 G7 B7 G9 B9 ... -%if mmsize == 8 - punpcklwd m3 ,m6 ; R0 G0 B0 R1 R2 G2 B2 R3 - punpckhwd m5, m6 ; R4 G4 B4 R5 R6 G6 B6 R7 -%if cpuflag(mmxext) - pshufw m1, m2, 0xc6 - pshufw m6, m3, 0x84 - pshufw m7, m5, 0x38 - pand m6, [mask_1101] ; R0 G0 B0 R1 -- -- R2 G2 - movq m0, m1 - pand m7, [mask_0110] ; -- -- R6 G6 B6 R7 -- -- - movq m2, m1 - pand m1, [mask_0100] ; -- -- G3 B3 -- -- -- -- - psrlq m3, 48 ; B2 R3 -- -- -- -- -- -- - pand m0, [mask_0010] ; -- -- -- -- G1 B1 -- -- - psllq m5, 32 ; -- -- -- -- R4 G4 B4 R5 - pand m2, [mask_1001] ; G5 B5 -- -- -- -- G7 B7 - por m1, m3 - por m0, m6 - por m1, m5 - por m2, m7 - movntq [imageq], m0 - movntq [imageq + 8], m1 - movntq [imageq + 16], m2 -%else ; cpuflag(mmx) - movd [imageq], m3 ; R0 G0 R2 G2 - movd [imageq + 4], m2 ; G1 B1 - psrlq m3, 32 - psrlq m2, 16 - movd [imageq + 6], m3 ; R2 G2 B2 R3 - movd [imageq + 10], m2 ; G3 B3 - psrlq m2, 16 - movd [imageq + 12], m5 ; R4 G4 B4 R5 - movd [imageq + 16], m2 ; G5 B5 - psrlq m5, 32 - movd [imageq + 20], m2 ; -- -- G7 B7 - movd [imageq + 18], m5 ; R6 G6 B6 R7 -%endif ; cpuflag -%else ; mmsize == 16 pshufb m3, [rgb24_shuf1] ; r0 g0 r6 g6 r12 g12 r2 g2 r8 g8 r14 g14 r4 g4 r10 g10 pshufb m6, [rgb24_shuf2] ; b10 r11 b0 r1 b6 r7 b12 r13 b2 r3 b8 r9 b14 r15 b4 r5 pshufb m2, [rgb24_shuf3] ; g5 b5 g11 b11 g1 b1 g7 b7 g13 b13 g3 b3 g9 b9 g15 b15 @@ -274,7 +206,6 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters movu [imageq], m0 movu [imageq + 16], m1 movu [imageq + 32], m2 -%endif ; mmsize = 16 %else ; PACK RGB15/16/32 packuswb m0, m1 packuswb m3, m5 @@ -309,18 +240,12 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters movu [imageq + 24 * time_num], m_alpha %else ; PACK RGB15/16 %define depth 2 -%if cpuflag(ssse3) %define red_dither m3 %define green_dither m4 %define blue_dither m5 VBROADCASTSD red_dither, [pointer_c_ditherq + 0 * 8] VBROADCASTSD green_dither, [pointer_c_ditherq + 1 * 8] VBROADCASTSD blue_dither, [pointer_c_ditherq + 2 * 8] -%else ; cpuflag(mmx/mmxext) -%define blue_dither [pointer_c_ditherq + 2 * 8] -%define green_dither [pointer_c_ditherq + 1 * 8] -%define red_dither [pointer_c_ditherq + 0 * 8] -%endif %if %3 == 15 %define gmask pb_03 %define isRGB15 1 @@ -358,18 +283,6 @@ RET %endmacro -INIT_MMX mmx -yuv2rgb_fn yuv, rgb, 32 -yuv2rgb_fn yuv, bgr, 32 -yuv2rgb_fn yuva, rgb, 32 -yuv2rgb_fn yuva, bgr, 32 -yuv2rgb_fn yuv, rgb, 15 -yuv2rgb_fn yuv, rgb, 16 - -INIT_MMX mmxext -yuv2rgb_fn yuv, rgb, 24 -yuv2rgb_fn yuv, bgr, 24 - INIT_XMM ssse3 yuv2rgb_fn yuv, rgb, 24 yuv2rgb_fn yuv, bgr, 24