From patchwork Wed Aug 31 09:33:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 351 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp281089vsd; Wed, 31 Aug 2016 02:34:25 -0700 (PDT) X-Received: by 10.194.240.39 with SMTP id vx7mr8268100wjc.38.1472636065807; Wed, 31 Aug 2016 02:34:25 -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 gt6si2833934wjd.204.2016.08.31.02.34.24; Wed, 31 Aug 2016 02:34:25 -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 D40DD689D9C; Wed, 31 Aug 2016 12:33:58 +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 CB69F689D19 for ; Wed, 31 Aug 2016 12:33:51 +0300 (EEST) Received: from localhost.localdomain (ip4d1666ad.dynamic.kabel-deutschland.de [77.22.102.173]) by btbn.de (Postfix) with ESMTPSA id 5C400778F9; Wed, 31 Aug 2016 11:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1472636038; bh=5OhZkbTsh3K/qgHDsKKRMLg8qGBxNnm96PrG0SoK8fQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WFkpjxhUhHOFgJhoJ8XrufK2Uw311hcywHUOXBSV/vTuBV88DBhFlm2Q2a+SxfHyB cF0ULKhD8/XG3HlPzKnk2PI5zHpDQrfPI20Qxh+9d5Uv+K9n4Y8jTq0Lr0x2XRFBZ5 aa4OtoXs1bDEKgAxQ19l6yJ7Yxk5zdEHd1xbI/rs= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Aug 2016 11:33:49 +0200 Message-Id: <20160831093349.11140-3-timo@rothenpieler.org> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160831093349.11140-1-timo@rothenpieler.org> References: <20160829212300.7695-1-timo@rothenpieler.org> <20160831093349.11140-1-timo@rothenpieler.org> Subject: [FFmpeg-devel] [PATCH 3/3] swscale: add support for P010LE/BE output 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/output.c | 98 +++++++++++++++++++++++++++++++++++- libswscale/utils.c | 4 +- libswscale/x86/swscale.c | 4 +- tests/ref/fate/filter-pixdesc-p010be | 1 + tests/ref/fate/filter-pixdesc-p010le | 1 + 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 + 13 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-p010be create mode 100644 tests/ref/fate/filter-pixdesc-p010le diff --git a/libswscale/output.c b/libswscale/output.c index f340c53..62cbe2f 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -311,6 +311,98 @@ static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterS } } + +#define output_pixel(pos, val) \ + if (big_endian) { \ + AV_WB16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + } else { \ + AV_WL16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + } + +static void yuv2p010l1_c(const int16_t *src, + uint16_t *dest, int dstW, + int big_endian) +{ + int i; + int shift = 5; + + for (i = 0; i < dstW; i++) { + int val = src[i] + (1 << (shift - 1)); + output_pixel(&dest[i], val); + } +} + +static void yuv2p010lX_c(const int16_t *filter, int filterSize, + const int16_t **src, uint16_t *dest, int dstW, + int big_endian) +{ + int i, j; + int shift = 17; + + for (i = 0; i < dstW; i++) { + int val = 1 << (shift - 1); + + for (j = 0; j < filterSize; j++) + val += src[j][i] * filter[j]; + + output_pixel(&dest[i], val); + } +} + +static void yuv2p010cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize, + const int16_t **chrUSrc, const int16_t **chrVSrc, + uint8_t *dest8, int chrDstW) +{ + uint16_t *dest = (uint16_t*)dest8; + int shift = 17; + int big_endian = c->dstFormat == AV_PIX_FMT_P010BE; + int i, j; + + for (i = 0; i < chrDstW; i++) { + int u = 1 << (shift - 1); + int v = 1 << (shift - 1); + + for (j = 0; j < chrFilterSize; j++) { + u += chrUSrc[j][i] * chrFilter[j]; + v += chrVSrc[j][i] * chrFilter[j]; + } + + output_pixel(&dest[2*i] , u); + output_pixel(&dest[2*i+1], v); + } +} + +static void yuv2p010l1_LE_c(const int16_t *src, + uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010l1_c(src, (uint16_t*)dest, dstW, 0); +} + +static void yuv2p010l1_BE_c(const int16_t *src, + uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010l1_c(src, (uint16_t*)dest, dstW, 1); +} + +static void yuv2p010lX_LE_c(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0); +} + +static void yuv2p010lX_BE_c(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1); +} + +#undef output_pixel + + #define accumulate_bit(acc, val) \ acc <<= 1; \ acc |= (val) >= 234 @@ -2085,7 +2177,11 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, enum AVPixelFormat dstFormat = c->dstFormat; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); - if (is16BPS(dstFormat)) { + if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE) { + *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c; + *yuv2nv12cX = yuv2p010cX_c; + } else if (is16BPS(dstFormat)) { *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; } else if (is9_OR_10BPS(dstFormat)) { diff --git a/libswscale/utils.c b/libswscale/utils.c index 576d8f0..0aef672 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -246,8 +246,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_XYZ12BE] = { 1, 1, 1 }, [AV_PIX_FMT_XYZ12LE] = { 1, 1, 1 }, [AV_PIX_FMT_AYUV64LE] = { 1, 1}, - [AV_PIX_FMT_P010LE] = { 1, 0 }, - [AV_PIX_FMT_P010BE] = { 1, 0 }, + [AV_PIX_FMT_P010LE] = { 1, 1 }, + [AV_PIX_FMT_P010BE] = { 1, 1 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index d68e46b..869e7fb 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -429,14 +429,14 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c) #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \ switch(c->dstBpc){ \ case 16: do_16_case; break; \ - case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ + case 10: if (!isBE(c->dstFormat) && c->dstFormat != AV_PIX_FMT_P010LE) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ case 8: if ((condition_8bit) && !c->use_mmx_vfilter) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ } #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ switch(c->dstBpc){ \ case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ - case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ + case 10: if (!isBE(c->dstFormat) && c->dstFormat != AV_PIX_FMT_P010LE && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ default: av_assert0(c->dstBpc>8); \ diff --git a/tests/ref/fate/filter-pixdesc-p010be b/tests/ref/fate/filter-pixdesc-p010be new file mode 100644 index 0000000..4d9dd22 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-p010be @@ -0,0 +1 @@ +pixdesc-p010be 784a49bf554861da9d0809a615bcf813 diff --git a/tests/ref/fate/filter-pixdesc-p010le b/tests/ref/fate/filter-pixdesc-p010le new file mode 100644 index 0000000..cac2635 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-p010le @@ -0,0 +1 @@ +pixdesc-p010le 0268fd44f63022e21ada69704534fc85 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 5890d4d..ce957f7 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -35,6 +35,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv21 335d85c9af6110f26ae9e187a82ed2cf +p010be 7f9842d6015026136bad60d03c035cc3 +p010le 1929db89609c4b8c6d9c9030a9e7843d pal8 ff5929f5b42075793b2c34cb441bede5 rgb0 0de71e5a1f97f81fb51397a0435bfa72 rgb24 f4438057d046e6d98ade4e45294b21be diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 9b0b36f..e2c77a8 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -33,6 +33,8 @@ gray16be 38f599da990224de86e3dc7a543121a9 gray16le 9ff7c866bd98def4e6c91542c1c45f80 nv12 92cda427f794374731ec0321ee00caac nv21 1bcfc197f4fb95de85ba58182d8d2f69 +p010be 8b2de2eb6b099bbf355bfc55a0694ddc +p010le a1e4f713e145dfc465bfe0cc77096a03 pal8 1f2cdc8e718f95c875dbc1034a688bfb rgb0 736646b70dd9a0be22b8da8041e35035 rgb24 c5fbbf816bb2000f4d2914e335698ef5 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 135814a..20c76a1 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -35,6 +35,8 @@ monob 2129cc72a484d7e10a44de9117aa9f80 monow 03d783611d265cae78293f88ea126ea1 nv12 16f7a46708ef25ebd0b72e47920cc11e nv21 7294574037cc7f9373ef5695d8ebe809 +p010be a0311a09bba7383553267d2b3b9c075e +p010le f1cc90d292046109a626db2da9f0f9b6 pal8 0658c18dcd8d052d59dfbe23f5b368d9 rgb0 ca3fa6e865b91b3511c7f2bf62830059 rgb24 25ab271e26a5785be169578d99da5dd0 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 561aa9f..8e902fb 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -33,6 +33,8 @@ gray16be cf7294d9aa23e1b838692ec01ade587b gray16le d91ce41e304419bcf32ac792f01bd64f nv12 801e58f1be5fd0b5bc4bf007c604b0b4 nv21 9f10dfff8963dc327d3395af21f0554f +p010be 744b13e44d39e1ff7588983fa03e0101 +p010le aeb31f50c66f376b0530c7bb6287212b pal8 5b7c77d99817b4f52339742a47de7797 rgb0 0092452f37d73da20193265ace0b7d57 rgb24 21571104e6091a689feabb7867e513dd diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 7795c9b..e568843 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -35,6 +35,8 @@ monob faba75df28033ba7ce3d82ff2a99ee68 monow 6e9cfb8d3a344c5f0c3e1d5e1297e580 nv12 3c3ba9b1b4c4dfff09c26f71b51dd146 nv21 ab586d8781246b5a32d8760a61db9797 +p010be 3df51286ef66b53e3e283dbbab582263 +p010le 38945445b360fa737e9e37257393e823 rgb0 cfaf68671e43248267d8cd50cae8c13f rgb24 88894f608cf33ba310f21996748d77a7 rgb444be 99d36d814988fb388aacdef575dacfcf diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 5890d4d..ce957f7 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -35,6 +35,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv21 335d85c9af6110f26ae9e187a82ed2cf +p010be 7f9842d6015026136bad60d03c035cc3 +p010le 1929db89609c4b8c6d9c9030a9e7843d pal8 ff5929f5b42075793b2c34cb441bede5 rgb0 0de71e5a1f97f81fb51397a0435bfa72 rgb24 f4438057d046e6d98ade4e45294b21be diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index e082de8..62ea6fa 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -35,6 +35,8 @@ monob f01cb0b623357387827902d9d0963435 monow 35c68b86c226d6990b2dcb573a05ff6b nv12 b118d24a3653fe66e5d9e079033aef79 nv21 c74bb1c10dbbdee8a1f682b194486c4d +p010be 1d6726d94bf1385996a9a9840dd0e878 +p010le 5d436e6b35292a0e356d81f37f989b66 pal8 29e10892009b2cfe431815ec3052ed3b rgb0 fbd27e98154efb7535826afed41e9bb0 rgb24 e022e741451e81f2ecce1c7240b93e87 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 94429b6..9651724 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -35,6 +35,8 @@ monob 7810c4857822ccfc844d78f5e803269a monow 90a947bfcd5f2261e83b577f48ec57b1 nv12 261ebe585ae2aa4e70d39a10c1679294 nv21 2909feacd27bebb080c8e0fa41795269 +p010be 06e9354b6e0e38ba41736352cedc0bd5 +p010le cdf6a3c38d9d4e3f079fa369e1dda662 pal8 450b0155d0f2d5628bf95a442db5f817 rgb0 56a7ea69541bcd27bef6a5615784722b rgb24 195e6dae1c3a488b9d3ceb7560d25d85