From patchwork Fri Sep 2 14:36:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 397 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp1492200vsd; Fri, 2 Sep 2016 07:36:59 -0700 (PDT) X-Received: by 10.28.142.148 with SMTP id q142mr3471749wmd.92.1472827018571; Fri, 02 Sep 2016 07:36:58 -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 kz8si11922202wjc.261.2016.09.02.07.36.51; Fri, 02 Sep 2016 07:36:58 -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 14A1F689C48; Fri, 2 Sep 2016 17:36:41 +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 A7675689C4D for ; Fri, 2 Sep 2016 17:36:34 +0300 (EEST) Received: from localhost.localdomain (ip4d1666ad.dynamic.kabel-deutschland.de [77.22.102.173]) by btbn.de (Postfix) with ESMTPSA id F044B77A99; Fri, 2 Sep 2016 16:36:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1472827002; bh=B2c1VoJnG70BSjw3f/CnjRlXsnHVXWELB4uNwAyIqGA=; h=From:To:Cc:Subject:Date; b=UCjwSPLWr0uWVcQaJvas5OWKYZxW5UqpUmZ714Tv/hAKsOxXo/VkyRwuJXzJG4Zpe bfeW/KIxkhEPGgDx14bkWBAefZ47MqpkxwW5sB1EaAr67alCzcRtc8n8XQ/54725Np Q9pHCB/Lv7YC6dh5kN8/SdZ5EL6py4PE7yX51PHA= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Sep 2016 16:36:34 +0200 Message-Id: <20160902143635.31585-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH v2 1/2] swscale: add unscaled copy from yuv420p10 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 | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index b231abe..f0b2fbf 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -197,6 +197,45 @@ static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[], return srcSliceH; } +static int planarToP010Wrapper(SwsContext *c, const uint8_t *src8[], + int srcStride[], int srcSliceY, + int srcSliceH, uint8_t *dstParam8[], + int dstStride[]) +{ + const uint16_t **src = (const uint16_t**)src8; + uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY); + uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2); + int x, y; + + av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 || + dstStride[0] % 2 || dstStride[1] % 2)); + + for (y = 0; y < srcSliceH; y++) { + uint16_t *tdstY = dstY; + const uint16_t *tsrc0 = src[0]; + for (x = c->srcW; x > 0; x--) { + *tdstY++ = *tsrc0++ << 6; + } + src[0] += srcStride[0] / 2; + dstY += dstStride[0] / 2; + + if (!(y & 1)) { + uint16_t *tdstUV = dstUV; + const uint16_t *tsrc1 = src[1]; + const uint16_t *tsrc2 = src[2]; + for (x = c->srcW / 2; x > 0; x--) { + *tdstUV++ = *tsrc1++ << 6; + *tdstUV++ = *tsrc2++ << 6; + } + src[1] += srcStride[1] / 2; + src[2] += srcStride[2] / 2; + dstUV += dstStride[1] / 2; + } + } + + return srcSliceH; +} + static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[]) @@ -1600,6 +1639,11 @@ void ff_get_unscaled_swscale(SwsContext *c) !(flags & SWS_ACCURATE_RND) && (c->dither == SWS_DITHER_BAYER || c->dither == SWS_DITHER_AUTO) && !(dstH & 1)) { c->swscale = ff_yuv2rgb_get_func_ptr(c); } + /* yuv420p10_to_p010 */ + if ((srcFormat == AV_PIX_FMT_YUV420P10 || srcFormat == AV_PIX_FMT_YUVA420P10) && + dstFormat == AV_PIX_FMT_P010) { + c->swscale = planarToP010Wrapper; + } if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) && (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&