From patchwork Sun Sep 8 13:12:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 14974 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DB338447989 for ; Sun, 8 Sep 2019 16:12:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C5D12687F55; Sun, 8 Sep 2019 16:12:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 83D17687F1B for ; Sun, 8 Sep 2019 16:12:27 +0300 (EEST) Received: by mail-pf1-f193.google.com with SMTP id y72so7438458pfb.12 for ; Sun, 08 Sep 2019 06:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vRNV/GlA5FC/l5bwTDf0J+ecERaNZDpNij1BatC1GDk=; b=iRHfo76i/KxDK3sUkJCd1aSzTmaXJxnPM0i7BEADkt5TDsRXGNPP9NcqHcrGkGR3dB 6UlSyahKlX051HKI/+0YbuFmG5b9jnyUy5Q33KMxlG9Tdayt4iwhyJCmSV0+ReNds5tW +TlWSbsMw1GPu0cFQAkYurIhKHBLB3KVGR+x9UMTLp9oqap4sWwfOU8Z7NnUQfgnOUD5 wziUACm1MAO05HBuAO+9TLdpTazJOIz0sPiwrGQAtEvs5jDDDmfmylt6iHPnxrOT4Phn iK0+vEkEICsBF2fdQgtO+d9NoMgCE2IXbNMitkGTulWVtO3oaPz5u3zpn84nIsZce68R 3gKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vRNV/GlA5FC/l5bwTDf0J+ecERaNZDpNij1BatC1GDk=; b=Stt5YcvunBHGE+zjj5Aeq+WzfhIYDAUmR8+D+xGN4/b7VMBhDL1ZEMk9OPsS/+pgEo xcE5+QDSRGtvgqleOSu70wCc5DdCSLLW9MK1gldeTjjxVVyso6jKzlUVyPcJk0bOTjbP i4tvzbe0D5J/qF5a0zur5Q3mvHNm8VDd7k/usCRlklqDF9G/yay6n0qJw8kjto3KGlDY vsdh3DRq00NCvwQvT3xvIWU5tZVRbvpJym7YXQlVF6XnBlHgSyVLhjkj8ueVhNLlVgwC vlffMHLw+T9+Z8C97Fkm8ulmxsH8dXiZ+2DpXURLbKxvz/FdzwP4ni9oC1bx7XDfwQdv YVGg== X-Gm-Message-State: APjAAAU66xIUcroCYBZ8/u1Hwb9A0cj0aDGHHHw2q43EEkvSrjSe76bu TkD9zZH1xrAVgfUA2MvobLt0IEJl X-Google-Smtp-Source: APXvYqxn7gc/YEvXngMNc1rib3tXvjNKgT2OKCheq+DGlGELSwMlkQ8T8HpCgnuVtWUpLqCowak3Pw== X-Received: by 2002:a63:3ec7:: with SMTP id l190mr17332037pga.334.1567948345504; Sun, 08 Sep 2019 06:12:25 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id c64sm15675156pfc.19.2019.09.08.06.12.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Sep 2019 06:12:25 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 8 Sep 2019 21:12:15 +0800 Message-Id: <20190908131215.27715-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190908131215.27715-1-lance.lmwang@gmail.com> References: <20190907155020.2283-1-lance.lmwang@gmail.com> <20190908131215.27715-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 2/2] swscale/swscale: various cosmetics for the code style 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libswscale/swscale.c | 66 +++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index b4f958a..5212317 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -242,12 +242,10 @@ static int swscale(SwsContext *c, const uint8_t *src[], * and faster */ const int dstW = c->dstW; const int dstH = c->dstH; - const enum AVPixelFormat dstFormat = c->dstFormat; const int flags = c->flags; int32_t *vLumFilterPos = c->vLumFilterPos; int32_t *vChrFilterPos = c->vChrFilterPos; - const int vLumFilterSize = c->vLumFilterSize; const int vChrFilterSize = c->vChrFilterSize; @@ -271,7 +269,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], int lastInLumBuf = c->lastInLumBuf; int lastInChrBuf = c->lastInChrBuf; - int lumStart = 0; int lumEnd = c->descIndex[0]; int chrStart = lumEnd; @@ -283,20 +280,16 @@ static int swscale(SwsContext *c, const uint8_t *src[], SwsSlice *vout_slice = &c->slice[c->numSlice-1]; SwsFilterDescriptor *desc = c->desc; - int needAlpha = c->needAlpha; int hasLumHoles = 1; int hasChrHoles = 1; - if (isPacked(c->srcFormat)) { - src[1] = - src[2] = - src[3] = src[0]; - srcStride[1] = - srcStride[2] = - srcStride[3] = srcStride[0]; + for (int i = 1; i < 4; i++) { + src[i] = src[0]; + srcStride[i] = srcStride[0]; + } } srcStride[1] <<= c->vChrDrop; srcStride[2] <<= c->vChrDrop; @@ -322,11 +315,10 @@ static int swscale(SwsContext *c, const uint8_t *src[], } } - if ( (uintptr_t)dst[0]&15 || (uintptr_t)dst[1]&15 || (uintptr_t)dst[2]&15 - || (uintptr_t)src[0]&15 || (uintptr_t)src[1]&15 || (uintptr_t)src[2]&15 - || dstStride[0]&15 || dstStride[1]&15 || dstStride[2]&15 || dstStride[3]&15 - || srcStride[0]&15 || srcStride[1]&15 || srcStride[2]&15 || srcStride[3]&15 - ) { + if ((uintptr_t)dst[0]&15 || (uintptr_t)dst[1]&15 || (uintptr_t)dst[2]&15 || + (uintptr_t)src[0]&15 || (uintptr_t)src[1]&15 || (uintptr_t)src[2]&15 || + dstStride[0]&15 || dstStride[1]&15 || dstStride[2]&15 || dstStride[3]&15 || + srcStride[0]&15 || srcStride[1]&15 || srcStride[2]&15 || srcStride[3]&15) { static int warnedAlready=0; int cpu_flags = av_get_cpu_flags(); if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){ @@ -339,11 +331,9 @@ static int swscale(SwsContext *c, const uint8_t *src[], * will not get executed. This is not really intended but works * currently, so people might do it. */ if (srcSliceY == 0) { - lumBufIndex = -1; - chrBufIndex = -1; + lumBufIndex = chrBufIndex = -1; dstY = 0; - lastInLumBuf = -1; - lastInChrBuf = -1; + lastInLumBuf = lastInChrBuf = -1; } if (!should_dither) { @@ -366,16 +356,14 @@ static int swscale(SwsContext *c, const uint8_t *src[], hout_slice->plane[2].sliceY = lastInChrBuf + 1; hout_slice->plane[3].sliceY = lastInLumBuf + 1; - hout_slice->plane[0].sliceH = - hout_slice->plane[1].sliceH = - hout_slice->plane[2].sliceH = - hout_slice->plane[3].sliceH = 0; + for (int i = 0; i < 4; i++) + hout_slice->plane[i].sliceH = 0; hout_slice->width = dstW; } for (; dstY < dstH; dstY++) { const int chrDstY = dstY >> c->chrDstVSubSample; - int use_mmx_vfilter= c->use_mmx_vfilter; + int use_mmx_vfilter = c->use_mmx_vfilter; // First line needed as input const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]); @@ -394,7 +382,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], // handle holes (FAST_BILINEAR & weird filters) if (firstLumSrcY > lastInLumBuf) { - hasLumHoles = lastInLumBuf != firstLumSrcY - 1; if (hasLumHoles) { hout_slice->plane[0].sliceY = firstLumSrcY; @@ -406,7 +393,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], lastInLumBuf = firstLumSrcY - 1; } if (firstChrSrcY > lastInChrBuf) { - hasChrHoles = lastInChrBuf != firstChrSrcY - 1; if (hasChrHoles) { hout_slice->plane[1].sliceY = firstChrSrcY; @@ -438,7 +424,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], av_assert0((lastLumSrcY - firstLumSrcY + 1) <= hout_slice->plane[0].available_lines); av_assert0((lastChrSrcY - firstChrSrcY + 1) <= hout_slice->plane[1].available_lines); - posY = hout_slice->plane[0].sliceY + hout_slice->plane[0].sliceH; if (posY <= lastLumSrcY && !hasLumHoles) { firstPosY = FFMAX(firstLumSrcY, posY); @@ -501,10 +486,8 @@ static int swscale(SwsContext *c, const uint8_t *src[], yuv2packed1, yuv2packed2, yuv2packedX, yuv2anyX, use_mmx_vfilter); } - { - for (i = vStart; i < vEnd; ++i) - desc[i].process(c, &desc[i], dstY, 1); - } + for (i = vStart; i < vEnd; i++) + desc[i].process(c, &desc[i], dstY, 1); } if (isPlanar(dstFormat) && isALPHA(dstFormat) && !needAlpha) { int length = dstW; @@ -570,7 +553,6 @@ static av_cold void sws_init_swscale(SwsContext *c) ff_sws_init_input_funcs(c); - if (c->srcBpc == 8) { if (c->dstBpc <= 14) { c->hyScale = c->hcScale = hScale8To15_c; @@ -628,7 +610,6 @@ static int check_image_pointers(const uint8_t * const data[4], enum AVPixelForma int i; av_assert2(desc); - for (i = 0; i < 4; i++) { int plane = desc->comp[i].plane; if (!data[plane] || !linesizes[plane]) @@ -788,8 +769,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, } if (c->gamma_flag && c->cascaded_context[0]) { - - ret = sws_scale(c->cascaded_context[0], srcSlice, srcStride, srcSliceY, srcSliceH, c->cascaded_tmp, c->cascaded_tmpStride); @@ -798,16 +777,20 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return ret; if (c->cascaded_context[2]) - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride); + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, + c->cascaded1_tmpStride); else - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); if (ret < 0) return ret; if (c->cascaded_context[2]) { ret = sws_scale(c->cascaded_context[2], - (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY, + (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, + c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY, dst, dstStride); } return ret; @@ -820,8 +803,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (ret < 0) return ret; ret = sws_scale(c->cascaded_context[1], - (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH, - dst, dstStride); + (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, + c->cascaded_context[0]->dstH, dst, dstStride); return ret; } @@ -983,7 +966,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, c->sliceDir = 0; ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); - if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) { int dstY = c->dstY ? c->dstY : srcSliceY + srcSliceH; uint16_t *dst16 = (uint16_t*)(dst2[0] + (dstY - ret) * dstStride2[0]);