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 A7B944B792 for ; Thu, 13 Jun 2024 07:28:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F0FE68D965; Thu, 13 Jun 2024 10:28:16 +0300 (EEST) Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 106EB68D800 for ; Thu, 13 Jun 2024 10:28:10 +0300 (EEST) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-579e00ee47fso98414a12.0 for ; Thu, 13 Jun 2024 00:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718263689; x=1718868489; darn=ffmpeg.org; h=thread-index:content-language:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:to:from :from:to:cc:subject:date:message-id:reply-to; bh=3Hpqy0UEISi38PghFSdEtdJd8n96AtOJiXdnWhz5cmU=; b=SqNG3Jge+p9F3TFG5NBpfsjU7QYFI2KDsb2+RGG7a4zrF36pFyaMeSv1C1L+C/UNeH YBoy3um4ei0jojbp5DGftEG68/0Bn/O0XAQEL0j4fBpSjV8lAiQShWyaFoXHHpEDkZSx EToKVh2gewWxZghd6w28edb8IC1gLu/c4nI2WGlnRvZgnV1jpL2TsOzsMOje8SgVdPkl auM9r3tFW0B2WixyGcWkLlpMhApV0Nah7At/P/6ZEmOcSDgLwn8ow/s72YvXBez9DFhp 7LkHXUW8wZcUX0x4HYtCJ8h33yxkvvs/sZPsea395lQt5cKxtEX1e4Byz62CewL8PQ5I 8YTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718263689; x=1718868489; h=thread-index:content-language:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3Hpqy0UEISi38PghFSdEtdJd8n96AtOJiXdnWhz5cmU=; b=CYs7fddRGUByDAMMJ57TN1ezSElPo/rr4OxE/LE26/zD5zRZqLu+f9ad9GbgLUgKTI dCZbVjnUuiC3bCGPu7o8QDNkYtXA+MLYKbcgVU6v924F+5moqEkcHGPaJdqWy0Ic1z1K 3H+J6SR8FKXG+1dRSVf2ilw1/ruIW46R4L8Cv6LLHA2QzvNzlUjtyPVgZi87CXcuseW0 ssD3cf+DrHBHGIbVSgrYoTdjXKVcrX16HEluIinf4rK+ODjcac2v3RHGx3qxoQbiOmum QGxHP8+kBc/aX7NKPHcOgpRGFyFIXWU9j1vUaJvSDtkeGgtnePebOaCnjCoD9Ouat3aV ZrrA== X-Gm-Message-State: AOJu0YzyQ07R4QM9b/oDjsjvpXDJ3V6+NH2dhpLJuer+JlPzT6GgZJwu 9zfqA3r9DRWk0QDMWAUsgVRL90i/wprRzVtMgq2YS3JKatj6cBaeOrxFCA== X-Google-Smtp-Source: AGHT+IFn5Xk79oDIaIdWw7Z+c2oiVoALNT64ruzBOuWI8zwKktJrj0wvlFWtvtbgtrHuMBPXoawSkg== X-Received: by 2002:a50:9b15:0:b0:57c:a703:c597 with SMTP id 4fb4d7f45d1cf-57ca8dfdae7mr2424595a12.0.1718263689186; Thu, 13 Jun 2024 00:28:09 -0700 (PDT) Received: from Mishu ([2a02:2f0f:830c:c700:a4f7:3c24:5d9d:9f1e]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb741e884sm540367a12.63.2024.06.13.00.28.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2024 00:28:08 -0700 (PDT) From: To: "'FFmpeg development discussions and patches'" References: <000c01daa54d$8a0eedf0$9e2cc9d0$@gmail.com> <20240530213132.GE2821752@pb2> <008e01dab529$e5510630$aff31290$@gmail.com> <20240603224202.GD2821752@pb2> <001001dabbce$083f3c70$18bdb550$@gmail.com> <20240611171808.GP2821752@pb2> <005401dabd01$f66608f0$e3321ad0$@gmail.com> <20240612235217.GX2821752@pb2> In-Reply-To: <20240612235217.GX2821752@pb2> Date: Thu, 13 Jun 2024 10:28:07 +0300 Message-ID: <004901dabd63$3cf4a950$b6ddfbf0$@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Content-Language: ro Thread-Index: AQF53sdsVM9iibY6Rm6BSu+PKGSxTgKF963BAWal2xYCbz23lQJMz4PFAttEFQACFSpRXQGZpUfisg1nxkA= Subject: Re: [FFmpeg-devel] [PATCH v3] area changed: scdet filter 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: > -----Original Message----- > From: ffmpeg-devel On Behalf Of > Michael Niedermayer > Sent: joi, 13 iunie 2024 02:52 > To: FFmpeg development discussions and patches > Subject: Re: [FFmpeg-devel] [PATCH v3] area changed: scdet filter > > > I honestly dont see the value of refcounting the global cbrt tables > > either they can be static and initialized by a single AV_ONCE_INIT or just > allocate and reinint for each filter. > There is one cbrt_table for each bitdepth. Initializing all of them before knowing which one is used, would be a waste. To allocate and initialize one table for each filter/client would be a waste too in a multiple clients scenario. > > + > > +void ff_scene_scrd_c(SCENE_SAD_PARAMS) { > > + uint64_t scrdPlus = 0; > > + uint64_t scrdMinus = 0; > > + int x, y; > > + double mean; > > + uint8_t *table = cbrt_table[8]; > > + > > + if (!table) { > > + *sum = 0; > > + return; > > + } > > + > > + for (y = 0; y < height; y++) { > > + for (x = 0; x < width; x++) > > + if (src1[x] > src2[x]) > > + scrdMinus += table[src1[x] - src2[x]]; > > + else > > + scrdPlus += table[src2[x] - src1[x]]; > > + src1 += stride1; > > + src2 += stride2; > > + } > > + > > > + mean = (sqrt(scrdPlus) + sqrt(scrdMinus)) / 2.0; > > + *sum = 2.0 * mean * mean; > > one sqrt less: > 0.5*(scrdPlus + scrdMinus) + sqrt(scrdPlus * (double)scrdMinus) > OK, will do in the next version. > > +} > > + > > +void ff_scene_scrd2B_c(SCENE_SAD_PARAMS, int bitdepth) { > > + uint64_t scrdPlus = 0; > > + uint64_t scrdMinus = 0; > > + const uint16_t *src1w = (const uint16_t*)src1; > > + const uint16_t *src2w = (const uint16_t*)src2; > > + int x, y; > > + double mean; > > + uint16_t *table = (uint16_t*)cbrt_table[bitdepth]; > > + > > + if (!table) { > > + *sum = 0; > > + return; > > + } > > + > > + stride1 /= 2; > > + stride2 /= 2; > > + > > + for (y = 0; y < height; y++) { > > + for (x = 0; x < width; x++) > > + if (src1w[x] > src2w[x]) > > + scrdMinus += table[src1w[x] - src2w[x]]; > > + else > > + scrdPlus += table[src2w[x] - src1w[x]]; > > + src1w += stride1; > > + src2w += stride2; > > + } > > + > > + mean = (sqrt(scrdPlus) + sqrt(scrdMinus)) / 2.0; > > + *sum = 2.0 * mean * mean; > > +} > > + > > +void ff_scene_scrd9_c(SCENE_SAD_PARAMS) > > +{ > > + ff_scene_scrd2B_c(src1, stride1, src2, stride2, width, height, > > +sum, 9); } > > + > > +void ff_scene_scrd10_c(SCENE_SAD_PARAMS) > > +{ > > + ff_scene_scrd2B_c(src1, stride1, src2, stride2, width, height, > > +sum, 10); } > > + > > +void ff_scene_scrd12_c(SCENE_SAD_PARAMS) > > +{ > > + ff_scene_scrd2B_c(src1, stride1, src2, stride2, width, height, > > +sum, 12); } > > + > > +void ff_scene_scrd14_c(SCENE_SAD_PARAMS) > > +{ > > + ff_scene_scrd2B_c(src1, stride1, src2, stride2, width, height, > > +sum, 14); } > > + > > +void ff_scene_scrd16_c(SCENE_SAD_PARAMS) > > +{ > > + ff_scene_scrd2B_c(src1, stride1, src2, stride2, width, height, > > +sum, 16); } > > duplicating this 5 times just for a different LUT pointer is ugly > > It's not pretty, but I did it to preserve the existing interface and keep logic together. Any suggestion how else to do it? _______________________________________________ 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".