From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EF33C405D3 for ; Tue, 21 Dec 2021 18:43:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C33268AEBC; Tue, 21 Dec 2021 20:43:50 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A150768A800 for ; Tue, 21 Dec 2021 20:43:44 +0200 (EET) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 463B9106014E for ; Tue, 21 Dec 2021 18:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1640112224; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=VHnFfjRIgiA3Zd6QXKeHku+wUwrECoStikEe0dwEjaU=; b=T6sEf6LtoarUqviD9ofpvGBwcRiWrS0YGybXauFr3EF+6HoqtQGYx9A/Nhm69vEu Hks48CpWxKOd4Q4jZU6Ka6DQmPwLF7Q9AmpsRxBHujeLENqBrMZS5OVhSAesrvTe29d pS5gF7V5v3a+ZcOPGsrmciNmoJt9JVKcTCRqCdOpGYPqbsroJH//CNCkXpEmPRkI4fO oqp/ZDoUDuZGXskOzkkMaEkuLja/UxYXt1YoZV7tsEIgAA9TQDN0vKw5+61n9vvN+uA gB2hg9pkfbWH+eEQCsRTeloZ8vaWCHIdfL/DulwnpJQTvaKnaMppv4jOmFuk7hzCVnY c7JOu1q5Jg== Date: Tue, 21 Dec 2021 19:43:44 +0100 (CET) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_241781_212657732.1640112224062" Subject: [FFmpeg-devel] swscale: fix style issues and check malloc in ff_shuffle_filter_coefficients 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" Archived-At: List-Archive: List-Post: ------=_Part_241781_212657732.1640112224062 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Google's net worth for 2021:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 1 000 000 000 000 USD. Google's revenue for 2021:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 204 000 000 000 USD. Average annual salary for a Google engineer:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 135 000 = USD. The greatest, most powerful beacon of capitalism on the planet sends a patch to an open-source project ran by volunteers. Said monument of wealth's revenue is dependent upon said project ran by volunteers. Issues per line of code: ~2.4. Guess which project's ran by volunteers who receive nothing from Google yet have to fix issues in patches meant to fix issues? Patch attached without snarky commit message. But I hope my point gets acro= ss. ------=_Part_241781_212657732.1640112224062 Content-Type: text/x-patch; charset=us-ascii; name=0001-swscale-fix-style-issues-and-check-malloc-in-ff_shuf.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-swscale-fix-style-issues-and-check-malloc-in-ff_shuf.patch >From 306cbe3204deb0314265adda226acea224329849 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 21 Dec 2021 19:14:56 +0100 Subject: [PATCH] swscale: fix style issues and check malloc in ff_shuffle_filter_coefficients --- libswscale/swscale_internal.h | 2 +- libswscale/utils.c | 65 +++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 64aa0b9804..e834f2aa91 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -1106,5 +1106,5 @@ void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, #define MAX_LINES_AHEAD 4 //shuffle filter and filterPos for hyScale and hcScale filters in avx2 -void ff_shuffle_filter_coefficients(SwsContext *c, int* filterPos, int filterSize, int16_t *filter, int dstW); +int ff_shuffle_filter_coefficients(SwsContext *c, int* filterPos, int filterSize, int16_t *filter, int dstW); #endif /* SWSCALE_SWSCALE_INTERNAL_H */ diff --git a/libswscale/utils.c b/libswscale/utils.c index d4a72d3ce1..fbc1dc98ff 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -278,36 +278,40 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_P416LE] = { 1, 0 }, }; -void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int filterSize, int16_t *filter, int dstW){ +int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, + int filterSize, int16_t *filter, int dstW) +{ #if ARCH_X86_64 - int i, j, k, l; int cpu_flags = av_get_cpu_flags(); - if (EXTERNAL_AVX2_FAST(cpu_flags)){ - if ((c->srcBpc == 8) && (c->dstBpc <= 14)){ - if (dstW % 16 == 0){ - if (filter != NULL){ - for (i = 0; i < dstW; i += 8){ - FFSWAP(int, filterPos[i + 2], filterPos[i+4]); - FFSWAP(int, filterPos[i + 3], filterPos[i+5]); - } - if (filterSize > 4){ - int16_t *tmp2 = av_malloc(dstW * filterSize * 2); - memcpy(tmp2, filter, dstW * filterSize * 2); - for (i = 0; i < dstW; i += 16){//pixel - for (k = 0; k < filterSize / 4; ++k){//fcoeff - for (j = 0; j < 16; ++j){//inner pixel - for (l = 0; l < 4; ++l){//coeff - int from = i * filterSize + j * filterSize + k * 4 + l; - int to = (i) * filterSize + j * 4 + l + k * 64; - filter[to] = tmp2[from]; - } - } - } + + if (!EXTERNAL_AVX2_FAST(cpu_flags)) + return 0; + + if ((c->srcBpc == 8) && (c->dstBpc <= 14) && !(dstW % 16) && filter) { + for (int i = 0; i < dstW; i += 8) { + FFSWAP(int, filterPos[i + 2], filterPos[i+4]); + FFSWAP(int, filterPos[i + 3], filterPos[i+5]); + } + + if (filterSize > 4) { + int16_t *tmp2 = av_malloc(dstW * filterSize * 2); + if (!tmp2) + return AVERROR(ENOMEM); + + memcpy(tmp2, filter, dstW * filterSize * 2); + + for (int i = 0; i < dstW; i += 16) { //pixel + for (int k = 0; k < filterSize / 4; k++) { //fcoeff + for (int j = 0; j < 16; j++) { //inner pixel + for (int l = 0; l < 4; l++) { //coeff + int from = i * filterSize + j * filterSize + k * 4 + l; + int to = (i) * filterSize + j * 4 + l + k * 64; + filter[to] = tmp2[from]; } - av_free(tmp2); } } } + av_free(tmp2); } } #endif @@ -1836,7 +1840,12 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, get_local_pos(c, 0, 0, 0), get_local_pos(c, 0, 0, 0))) < 0) goto fail; - ff_shuffle_filter_coefficients(c, c->hLumFilterPos, c->hLumFilterSize, c->hLumFilter, dstW); + + if ((ret = ff_shuffle_filter_coefficients(c, c->hLumFilterPos, + c->hLumFilterSize, + c->hLumFilter, dstW))) + goto fail; + if ((ret = initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc, c->chrSrcW, c->chrDstW, filterAlign, 1 << 14, @@ -1846,7 +1855,11 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, get_local_pos(c, c->chrSrcHSubSample, c->src_h_chr_pos, 0), get_local_pos(c, c->chrDstHSubSample, c->dst_h_chr_pos, 0))) < 0) goto fail; - ff_shuffle_filter_coefficients(c, c->hChrFilterPos, c->hChrFilterSize, c->hChrFilter, c->chrDstW); + + if ((ret = ff_shuffle_filter_coefficients(c, c->hChrFilterPos, + c->hChrFilterSize, + c->hChrFilter, c->chrDstW))) + goto fail; } } // initialize horizontal stuff -- 2.34.1 ------=_Part_241781_212657732.1640112224062 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ------=_Part_241781_212657732.1640112224062--