From patchwork Mon Sep 5 10:04:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 423 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp21932vsd; Mon, 5 Sep 2016 03:04:37 -0700 (PDT) X-Received: by 10.194.114.130 with SMTP id jg2mr30504747wjb.44.1473069876726; Mon, 05 Sep 2016 03:04:36 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t129si16651599wme.25.2016.09.05.03.04.29; Mon, 05 Sep 2016 03:04:36 -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=@rothenpieler.org; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A7A26689F6F; Mon, 5 Sep 2016 13:04:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B4C2C689E15 for ; Mon, 5 Sep 2016 13:04:12 +0300 (EEST) Received: from localhost (btbn.de [127.0.0.1]) by btbn.de (Postfix) with ESMTP id 614F3158C3 for ; Mon, 5 Sep 2016 12:04:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at btbn.de Received: from btbn.de ([127.0.0.1]) by localhost (mail.btbn.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z8sG5t5RP_h3; Mon, 5 Sep 2016 12:04:04 +0200 (CEST) Received: by btbn.de (Postfix, from userid 1000) id 5A370158BC; Mon, 5 Sep 2016 12:04:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1473069844; bh=CoNhHGRnHAuwIzO2LouhAexwconRO3XOhNzW6S/WV14=; h=From:To:Cc:Subject:Date; b=ysIKwKIYl+ULtzZ0xLyvPkWl+EutcQ8B/WQe0pTs8ytCbyAc8/q6bhhfR1vcpm3Hw jsIOkzJnK4EEDhKrJ4Y8CGU71w3KbQxnlbcxAoq5jcxU7avNsnLZ35HoioWS14vJcg hTdaiYonfKEfuay3pLc2HaA3GwEA9NdZeuaYS/vM= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Sep 2016 12:04:02 +0200 Message-Id: <20160905100402.27329-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH v3] swscale: add unscaled conversion from yuv420p to p010 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libswscale/swscale_unscaled.c | 57 ++++++++++++++++++++++++++++++++++++ tests/ref/fate/filter-pixdesc-p010le | 2 +- tests/ref/fate/filter-pixfmts-copy | 2 +- tests/ref/fate/filter-pixfmts-crop | 2 +- tests/ref/fate/filter-pixfmts-field | 2 +- tests/ref/fate/filter-pixfmts-hflip | 2 +- tests/ref/fate/filter-pixfmts-il | 2 +- tests/ref/fate/filter-pixfmts-null | 2 +- tests/ref/fate/filter-pixfmts-scale | 2 +- tests/ref/fate/filter-pixfmts-vflip | 2 +- 10 files changed, 66 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 716c386..e46763c 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -33,6 +33,7 @@ #include "libavutil/bswap.h" #include "libavutil/pixdesc.h" #include "libavutil/avassert.h" +#include "libavutil/avconfig.h" DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={ { @@ -236,6 +237,57 @@ static int planarToP010Wrapper(SwsContext *c, const uint8_t *src8[], return srcSliceH; } +#if AV_HAVE_BIGENDIAN +#define output_pixel(p, v) do { \ + uint16_t *pp = (p); \ + AV_WL16(pp, (v)); \ + } while(0) +#else +#define output_pixel(p, v) (*p) = (v) +#endif + +static int planar8ToP01xleWrapper(SwsContext *c, const uint8_t *src[], + int srcStride[], int srcSliceY, + int srcSliceH, uint8_t *dstParam8[], + int dstStride[]) +{ + uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY); + uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2); + int x, y, t; + + av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2)); + + for (y = 0; y < srcSliceH; y++) { + uint16_t *tdstY = dstY; + const uint8_t *tsrc0 = src[0]; + for (x = c->srcW; x > 0; x--) { + t = *tsrc0++; + output_pixel(tdstY++, t | (t << 8)); + } + src[0] += srcStride[0]; + dstY += dstStride[0] / 2; + + if (!(y & 1)) { + uint16_t *tdstUV = dstUV; + const uint8_t *tsrc1 = src[1]; + const uint8_t *tsrc2 = src[2]; + for (x = c->srcW / 2; x > 0; x--) { + t = *tsrc1++; + output_pixel(tdstUV++, t | (t << 8)); + t = *tsrc2++; + output_pixel(tdstUV++, t | (t << 8)); + } + src[1] += srcStride[1]; + src[2] += srcStride[2]; + dstUV += dstStride[1] / 2; + } + } + + return srcSliceH; +} + +#undef output_pixel + static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[]) @@ -1653,6 +1705,11 @@ void ff_get_unscaled_swscale(SwsContext *c) dstFormat == AV_PIX_FMT_P010) { c->swscale = planarToP010Wrapper; } + /* yuv420p_to_p010le */ + if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) && + dstFormat == AV_PIX_FMT_P010LE) { + c->swscale = planar8ToP01xleWrapper; + } if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) && (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) && diff --git a/tests/ref/fate/filter-pixdesc-p010le b/tests/ref/fate/filter-pixdesc-p010le index cac2635..2500604 100644 --- a/tests/ref/fate/filter-pixdesc-p010le +++ b/tests/ref/fate/filter-pixdesc-p010le @@ -1 +1 @@ -pixdesc-p010le 0268fd44f63022e21ada69704534fc85 +pixdesc-p010le 7b4a503997eb4e14cba80ee52db85e39 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index ce957f7..f19dcb0 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -36,7 +36,7 @@ monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv21 335d85c9af6110f26ae9e187a82ed2cf p010be 7f9842d6015026136bad60d03c035cc3 -p010le 1929db89609c4b8c6d9c9030a9e7843d +p010le c453421b9f726bdaf2bacf59a492c43b pal8 ff5929f5b42075793b2c34cb441bede5 rgb0 0de71e5a1f97f81fb51397a0435bfa72 rgb24 f4438057d046e6d98ade4e45294b21be diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index e2c77a8..86b3f02 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -34,7 +34,7 @@ gray16le 9ff7c866bd98def4e6c91542c1c45f80 nv12 92cda427f794374731ec0321ee00caac nv21 1bcfc197f4fb95de85ba58182d8d2f69 p010be 8b2de2eb6b099bbf355bfc55a0694ddc -p010le a1e4f713e145dfc465bfe0cc77096a03 +p010le 373b50c766dfd0a8e79c9a73246d803a pal8 1f2cdc8e718f95c875dbc1034a688bfb rgb0 736646b70dd9a0be22b8da8041e35035 rgb24 c5fbbf816bb2000f4d2914e335698ef5 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 20c76a1..7f3abf6 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -36,7 +36,7 @@ monow 03d783611d265cae78293f88ea126ea1 nv12 16f7a46708ef25ebd0b72e47920cc11e nv21 7294574037cc7f9373ef5695d8ebe809 p010be a0311a09bba7383553267d2b3b9c075e -p010le f1cc90d292046109a626db2da9f0f9b6 +p010le ee09a18aefa3ebe97715b3a7312cb8ff pal8 0658c18dcd8d052d59dfbe23f5b368d9 rgb0 ca3fa6e865b91b3511c7f2bf62830059 rgb24 25ab271e26a5785be169578d99da5dd0 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 8e902fb..f069fc6 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -34,7 +34,7 @@ gray16le d91ce41e304419bcf32ac792f01bd64f nv12 801e58f1be5fd0b5bc4bf007c604b0b4 nv21 9f10dfff8963dc327d3395af21f0554f p010be 744b13e44d39e1ff7588983fa03e0101 -p010le aeb31f50c66f376b0530c7bb6287212b +p010le a50b160346ab94f55a425065b57006f0 pal8 5b7c77d99817b4f52339742a47de7797 rgb0 0092452f37d73da20193265ace0b7d57 rgb24 21571104e6091a689feabb7867e513dd diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index e568843..640a75a 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -36,7 +36,7 @@ monow 6e9cfb8d3a344c5f0c3e1d5e1297e580 nv12 3c3ba9b1b4c4dfff09c26f71b51dd146 nv21 ab586d8781246b5a32d8760a61db9797 p010be 3df51286ef66b53e3e283dbbab582263 -p010le 38945445b360fa737e9e37257393e823 +p010le eadcd8241e97e35b2b47d5eb2eaea6cd rgb0 cfaf68671e43248267d8cd50cae8c13f rgb24 88894f608cf33ba310f21996748d77a7 rgb444be 99d36d814988fb388aacdef575dacfcf diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index ce957f7..f19dcb0 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -36,7 +36,7 @@ monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv21 335d85c9af6110f26ae9e187a82ed2cf p010be 7f9842d6015026136bad60d03c035cc3 -p010le 1929db89609c4b8c6d9c9030a9e7843d +p010le c453421b9f726bdaf2bacf59a492c43b pal8 ff5929f5b42075793b2c34cb441bede5 rgb0 0de71e5a1f97f81fb51397a0435bfa72 rgb24 f4438057d046e6d98ade4e45294b21be diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 62ea6fa..6320557 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -36,7 +36,7 @@ monow 35c68b86c226d6990b2dcb573a05ff6b nv12 b118d24a3653fe66e5d9e079033aef79 nv21 c74bb1c10dbbdee8a1f682b194486c4d p010be 1d6726d94bf1385996a9a9840dd0e878 -p010le 5d436e6b35292a0e356d81f37f989b66 +p010le 4b316f2b9e18972299beb73511278fa8 pal8 29e10892009b2cfe431815ec3052ed3b rgb0 fbd27e98154efb7535826afed41e9bb0 rgb24 e022e741451e81f2ecce1c7240b93e87 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 9651724..57dbca8 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -36,7 +36,7 @@ monow 90a947bfcd5f2261e83b577f48ec57b1 nv12 261ebe585ae2aa4e70d39a10c1679294 nv21 2909feacd27bebb080c8e0fa41795269 p010be 06e9354b6e0e38ba41736352cedc0bd5 -p010le cdf6a3c38d9d4e3f079fa369e1dda662 +p010le fd18d322bffbf5816902c13102872e22 pal8 450b0155d0f2d5628bf95a442db5f817 rgb0 56a7ea69541bcd27bef6a5615784722b rgb24 195e6dae1c3a488b9d3ceb7560d25d85