From patchwork Wed Mar 30 20:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35085 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011090pzb; Wed, 30 Mar 2022 13:32:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVBWVZ8kZaHvuwTP//jpmoBT/WTnqLfkThV8KhRFgW4ZbNItNiRS2Rm3i2Dq+1PIZjmZrL X-Received: by 2002:a17:907:2d2a:b0:6df:c027:a3ac with SMTP id gs42-20020a1709072d2a00b006dfc027a3acmr1458944ejc.179.1648672363883; Wed, 30 Mar 2022 13:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672363; cv=none; d=google.com; s=arc-20160816; b=LbwvvMnhT+qjukKztj1ahvm+YFSYb/lBu2z9OUPIyAZdEuTJiY6OMGuS3QTWzqb9QK TOQbwdg3chWiVKHZ+KO0kd9dmx6qC51Cl0WTbneYZzwu8L3d9AXxoqt1CMNhj3KmEKxV ZdhFL5Pj8HYiyW6PF3bOCmOoFlqNVCJiaePC6mkW9DEwp0fyoh83/vWSwp57niE9Ujc/ wpLUyHbw8gtm0SXR64qijyOTZ+bkywHyWMC1ZVjDLKh4AhnfTGxiOVUoE6PO9KPNbl8q vCWe0bTx1ww7suJSY79W2jpq3CikIG+Ji5Jm6lSX06LVmVKqDvDHaTidF//zL8BcPtIV IAAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=3AcGt/MhcllpFtkDJApxa4mO3JFPl1AQg0ZGqeEai2U=; b=S7jwheUO9PKfqV13e87GnLlP6LI5CO+75E0iBiqGam2hwcrvSMMnX4pFK3IWt9M3yE 9HQGjW1daHthjXihuQyd8EtIhyqa32bHzBqhL7YHk1E8pPIDl9+7dqcaTdNxwEJDqrx6 iBhrHNYk61w3k3U4HOs4fVp53vUnLlb4Ukz6cDs6JLOs4mq2nlSGAPhn1XqG7WHBqUIY eFetdodyyCTRnJexJr1MYiIwCYS7SYZueSjOq1507xgyk3sj2kHMNw+Xtm2qgcRGXLLc 9wXKntTWCafSs4NisPOHPfFcULWdBkaezlk5CDP18aCA+xFx88bzeNih6O7GE0V3VKQ0 CoZw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bp16-20020a170907919000b006df76385bc3si17851244ejb.99.2022.03.30.13.32.22; Wed, 30 Mar 2022 13:32:43 -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; 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 0D0A968B240; Wed, 30 Mar 2022 23:32:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03B4968B18C for ; Wed, 30 Mar 2022 23:32:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8BF45E67D7; Wed, 30 Mar 2022 22:32:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T5f5CnfqpoHH; Wed, 30 Mar 2022 22:32:11 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8BC26E67A2; Wed, 30 Mar 2022 22:32:10 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:31:58 +0200 Message-Id: <20220330203205.25937-1-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] fate/filter-refcmp-*: make refcmp_metadata fail on empty input 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DbLOHjbSPGQ0 On empty input the awk script was always successful which caused the filter-refcmp tests to always succeed. Also fix the command lines for refcmp_metadata compare function because it needs auto conversion filters, and update reference of test filter-refcmp-psnr-rgb because it was missed in a7fc78c1a638a32c3695c06f727774c740d675c2 but was never noticed due to the original issue... Signed-off-by: Marton Balint --- tests/fate-run.sh | 2 +- tests/ref/fate/filter-refcmp-psnr-rgb | 80 +++++++++++++-------------- tests/refcmp-metadata.awk | 3 + 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index fbfc0a925d..5e8d607d88 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -377,7 +377,7 @@ refcmp_metadata(){ refcmp=$1 pixfmt=$2 fuzz=${3:-0.001} - ffmpeg $FLAGS $ENC_OPTS \ + ffmpeg -auto_conversion_filters $FLAGS $ENC_OPTS \ -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \ -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk - } diff --git a/tests/ref/fate/filter-refcmp-psnr-rgb b/tests/ref/fate/filter-refcmp-psnr-rgb index f06db575ac..20abd3dc5a 100644 --- a/tests/ref/fate/filter-refcmp-psnr-rgb +++ b/tests/ref/fate/filter-refcmp-psnr-rgb @@ -1,45 +1,45 @@ frame:0 pts:0 pts_time:0 -lavfi.psnr.mse.r=1381.80 -lavfi.psnr.psnr.r=16.73 -lavfi.psnr.mse.g=896.00 -lavfi.psnr.psnr.g=18.61 -lavfi.psnr.mse.b=277.38 -lavfi.psnr.psnr.b=23.70 -lavfi.psnr.mse_avg=851.73 -lavfi.psnr.psnr_avg=18.83 +lavfi.psnr.mse.r=1367.642090 +lavfi.psnr.psnr.r=16.771078 +lavfi.psnr.mse.g=885.804382 +lavfi.psnr.psnr.g=18.657425 +lavfi.psnr.mse.b=274.825073 +lavfi.psnr.psnr.b=23.740240 +lavfi.psnr.mse_avg=842.757202 +lavfi.psnr.psnr_avg=18.873779 frame:1 pts:1 pts_time:1 -lavfi.psnr.mse.r=1380.37 -lavfi.psnr.psnr.r=16.73 -lavfi.psnr.mse.g=975.91 -lavfi.psnr.psnr.g=18.24 -lavfi.psnr.mse.b=435.72 -lavfi.psnr.psnr.b=21.74 -lavfi.psnr.mse_avg=930.67 -lavfi.psnr.psnr_avg=18.44 +lavfi.psnr.mse.r=1356.681152 +lavfi.psnr.psnr.r=16.806026 +lavfi.psnr.mse.g=958.161560 +lavfi.psnr.psnr.g=18.316416 +lavfi.psnr.mse.b=428.238312 +lavfi.psnr.psnr.b=21.813948 +lavfi.psnr.mse_avg=914.360352 +lavfi.psnr.psnr_avg=18.519630 frame:2 pts:2 pts_time:2 -lavfi.psnr.mse.r=1403.20 -lavfi.psnr.psnr.r=16.66 -lavfi.psnr.mse.g=954.05 -lavfi.psnr.psnr.g=18.34 -lavfi.psnr.mse.b=494.22 -lavfi.psnr.psnr.b=21.19 -lavfi.psnr.mse_avg=950.49 -lavfi.psnr.psnr_avg=18.35 +lavfi.psnr.mse.r=1387.254883 +lavfi.psnr.psnr.r=16.709242 +lavfi.psnr.mse.g=939.230957 +lavfi.psnr.psnr.g=18.403080 +lavfi.psnr.mse.b=493.913757 +lavfi.psnr.psnr.b=21.194292 +lavfi.psnr.mse_avg=940.133179 +lavfi.psnr.psnr_avg=18.398911 frame:3 pts:3 pts_time:3 -lavfi.psnr.mse.r=1452.80 -lavfi.psnr.psnr.r=16.51 -lavfi.psnr.mse.g=1001.02 -lavfi.psnr.psnr.g=18.13 -lavfi.psnr.mse.b=557.39 -lavfi.psnr.psnr.b=20.67 -lavfi.psnr.mse_avg=1003.74 -lavfi.psnr.psnr_avg=18.11 +lavfi.psnr.mse.r=1433.291260 +lavfi.psnr.psnr.r=16.567459 +lavfi.psnr.mse.g=990.005859 +lavfi.psnr.psnr.g=18.174425 +lavfi.psnr.mse.b=550.512329 +lavfi.psnr.psnr.b=20.723133 +lavfi.psnr.mse_avg=991.269836 +lavfi.psnr.psnr_avg=18.168884 frame:4 pts:4 pts_time:4 -lavfi.psnr.mse.r=1401.25 -lavfi.psnr.psnr.r=16.67 -lavfi.psnr.mse.g=1009.80 -lavfi.psnr.psnr.g=18.09 -lavfi.psnr.mse.b=602.42 -lavfi.psnr.psnr.b=20.33 -lavfi.psnr.mse_avg=1004.49 -lavfi.psnr.psnr_avg=18.11 +lavfi.psnr.mse.r=1385.949341 +lavfi.psnr.psnr.r=16.713329 +lavfi.psnr.mse.g=997.065796 +lavfi.psnr.psnr.g=18.143566 +lavfi.psnr.mse.b=601.962952 +lavfi.psnr.psnr.b=20.335106 +lavfi.psnr.mse_avg=994.992676 +lavfi.psnr.psnr_avg=18.152605 diff --git a/tests/refcmp-metadata.awk b/tests/refcmp-metadata.awk index fa21aad0e0..e7ed5ae809 100644 --- a/tests/refcmp-metadata.awk +++ b/tests/refcmp-metadata.awk @@ -50,12 +50,15 @@ BEGIN { } END { + result = result && (NR != 0); if (result) { for (i = 1; i <= ref_nr; i++) print ref_lines[i]; } else { for (i = 1; i <= NR; i++) print cmp_lines[i]; + if (NR == 0) + print "[refcmp] no input"; if (NR != ref_nr) print "[refcmp] lines: " NR " != " ref_nr > "/dev/stderr"; if (delta_max >= fuzz) From patchwork Wed Mar 30 20:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35087 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011303pzb; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD3HU12vuXL5gdfTBIbDuPbHEV7QBV9fSL3saeqU6aiQbP3FLD+gM3UuNujdR3rS2QgF26 X-Received: by 2002:a05:6402:4315:b0:419:2e38:ab8f with SMTP id m21-20020a056402431500b004192e38ab8fmr13109796edc.250.1648672395666; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672395; cv=none; d=google.com; s=arc-20160816; b=ario17SF9xPfDzNKTkWAb95XTx+PlcRk8AfsYWiv7qHmT58LnUko1oRhsh8CXI/GRr j8d/WUDNQsWCFf1zKb59tf4KdWgx7GiKO5HVkYsPMgjc3USYSxGBrPo8rObzBxNSO53i DG5+8JwdXP8iYsRREeqQUcDdzHb6m8ce3fv012g2yE9TIYw9eq0zYO2U6ZktBdEqDCPV cwszs4Rf8lD4jIA/aYE/p0hWhg2OQdoDMb811VU2EJhlL4lvFAYnYR06MEzH+FCLl0yR 20ccpY/Wuxxwhu5wsic9DNdBx/h5ONAFy1ii5FW1rCxpXMURfSheN1Gabmzf1ptcnQ8O 7VHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=deGamJuN/t46Q4x5HYvQiZSPVAUp1QGLFfSTR1aQSXs=; b=UoS/C42BwjKjNMIg/ucP0pOswslrvS1q88jfkxxMFtZVAFDZLe8B9m7zGh2q8RHhHz UKW8ngG2/FWYjNqS+r1/JxyMvBZ7agmyotRyhTJ2zn3zm8ingqlfUzjhlQbv2Jhn0qbT f/49r30OB64q98XCe4EbMLVZRDGol3CAuVzZdnmv/Lpi46h8tfW6GFpH84ow/vniBwk6 z8HfGgDs8WDM6tEd7fae2TFFHRat6QdtPq3hv8XeEUaYQHWlD8FuHrF6uQ+BQulVAody lm8B1HOs39LGeVNpx+2XxYANQEHPJSV/F5kq9EojmM9JtTz86qqbz6cWgGCi0M7nVqa4 EF2A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s15-20020a170906bc4f00b006dfe6119763si21769345ejv.325.2022.03.30.13.33.11; Wed, 30 Mar 2022 13:33:15 -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; 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 18E4868B256; Wed, 30 Mar 2022 23:32:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B93BE68B093 for ; Wed, 30 Mar 2022 23:32:14 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4598BE67E5; Wed, 30 Mar 2022 22:32:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id otFIDeMl-vNj; Wed, 30 Mar 2022 22:32:13 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 94595E6BB6; Wed, 30 Mar 2022 22:32:13 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:31:59 +0200 Message-Id: <20220330203205.25937-2-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] avcodec/texturedsp: add TextureDSPThreadContext for common decode/encode function 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: LdyTkw8nXvds This will allow using a common threaded decode or encode function from most codecs using texture DSP functions. Signed-off-by: Marton Balint --- libavcodec/texturedsp.c | 4 +++ libavcodec/texturedsp.h | 23 +++++++++++++ libavcodec/texturedsp_template.c | 57 ++++++++++++++++++++++++++++++++ libavcodec/texturedspenc.c | 4 +++ 4 files changed, 88 insertions(+) create mode 100644 libavcodec/texturedsp_template.c diff --git a/libavcodec/texturedsp.c b/libavcodec/texturedsp.c index b7dd8baa12..b8938213ef 100644 --- a/libavcodec/texturedsp.c +++ b/libavcodec/texturedsp.c @@ -652,3 +652,7 @@ av_cold void ff_texturedsp_init(TextureDSPContext *c) c->rgtc2u_block = rgtc2u_block; c->dxn3dc_block = dxn3dc_block; } + +#define TEXTUREDSP_FUNC_NAME ff_texturedsp_decompress_thread +#define TEXTUREDSP_TEX_FUNC(a, b, c) tex_funct(a, b, c) +#include "texturedsp_template.c" diff --git a/libavcodec/texturedsp.h b/libavcodec/texturedsp.h index 90ceb2b6aa..e15d3c2b02 100644 --- a/libavcodec/texturedsp.h +++ b/libavcodec/texturedsp.h @@ -39,6 +39,8 @@ #include #include +#include "avcodec.h" + #define TEXTURE_BLOCK_W 4 #define TEXTURE_BLOCK_H 4 @@ -60,7 +62,28 @@ typedef struct TextureDSPContext { int (*dxn3dc_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); } TextureDSPContext; +typedef struct TextureDSPThreadContext { + union { + const uint8_t *in; // Input frame data + uint8_t *out; // Output frame data + } frame_data; + ptrdiff_t stride; // Frame linesize + union { + const uint8_t *in; // Compressed texture for decompression + uint8_t *out; // Compressed texture of compression + } tex_data; + int tex_ratio; // Number of compressed bytes in a texture block + int raw_ratio; // Number bytes in a line of a raw block + int slice_count; // Number of slices for threaded operations + + /* Pointer to the selected compress or decompress function. */ + int (*tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); +} TextureDSPThreadContext; + void ff_texturedsp_init(TextureDSPContext *c); void ff_texturedspenc_init(TextureDSPContext *c); +int ff_texturedsp_decompress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb); +int ff_texturedsp_compress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb); + #endif /* AVCODEC_TEXTUREDSP_H */ diff --git a/libavcodec/texturedsp_template.c b/libavcodec/texturedsp_template.c new file mode 100644 index 0000000000..bd193aa97c --- /dev/null +++ b/libavcodec/texturedsp_template.c @@ -0,0 +1,57 @@ +/* + * Texture block compression and decompression + * Copyright (C) 2015 Vittorio Giovara + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, void *arg, + int slice, int thread_nb) +{ + TextureDSPThreadContext *ctx = arg; + uint8_t *d = ctx->tex_data.out; + int w_block = avctx->coded_width / TEXTURE_BLOCK_W; + int h_block = avctx->coded_height / TEXTURE_BLOCK_H; + int x, y; + int start_slice, end_slice; + int base_blocks_per_slice = h_block / ctx->slice_count; + int remainder_blocks = h_block % ctx->slice_count; + + /* When the frame height (in blocks) doesn't divide evenly between the + * number of slices, spread the remaining blocks evenly between the first + * operations */ + start_slice = slice * base_blocks_per_slice; + /* Add any extra blocks (one per slice) that have been added before this slice */ + start_slice += FFMIN(slice, remainder_blocks); + + end_slice = start_slice + base_blocks_per_slice; + /* Add an extra block if there are still remainder blocks to be accounted for */ + if (slice < remainder_blocks) + end_slice++; + + for (y = start_slice; y < end_slice; y++) { + uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H; + int off = y * w_block; + for (x = 0; x < w_block; x++) { + ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride, + d + (off + x) * ctx->tex_ratio); + } + } + + return 0; +} diff --git a/libavcodec/texturedspenc.c b/libavcodec/texturedspenc.c index 3d68e0cf39..381be16f75 100644 --- a/libavcodec/texturedspenc.c +++ b/libavcodec/texturedspenc.c @@ -670,3 +670,7 @@ av_cold void ff_texturedspenc_init(TextureDSPContext *c) c->dxt5ys_block = dxt5ys_block; c->rgtc1u_alpha_block = rgtc1u_alpha_block; } + +#define TEXTUREDSP_FUNC_NAME ff_texturedsp_compress_thread +#define TEXTUREDSP_TEX_FUNC(a, b, c) tex_funct(c, b, a) +#include "texturedsp_template.c" From patchwork Wed Mar 30 20:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35086 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011106pzb; Wed, 30 Mar 2022 13:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4tkE90rhVjZ+pK1Cg9jbZrsZrFpsCssV6iHNEpQGKFic/Bw+AhSwNIAFZefdPRRfy6s0H X-Received: by 2002:a05:6402:198:b0:410:83e3:21d7 with SMTP id r24-20020a056402019800b0041083e321d7mr12856508edv.159.1648672366559; Wed, 30 Mar 2022 13:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672366; cv=none; d=google.com; s=arc-20160816; b=m24rUXa2Vtgmtk7oS0V0dQ4trz6PEVf2oF+QFYZ+mDU8U7CkgXqOGSu4NM3g6bY2bY oFZYC4pHrhf6CFZTSBVNQIae5s39wzvIH7POwdNyQep56khLfWKkMdrXsgDCnqufFXpl QBKt2yPAY9vlXjq92UqNvAr3PlT5vEdJp+xCo7kPym8UhDWu+R845k4XMeE7ZbH3xDw4 6ZG+K+IDGByJ+zX4EDu6dOatI9yZDYm/nwA82i1bDherV1wGTeyMd2H+gRHCt8hMJADh PPg57gEc4QCc5hG993mdlFZ9OtBRsBQWM5cJRJeRE8yt+aoj+lWehXPxaXQGATmGjDR2 8B9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=1cikTzV2rX4HphR7B7NloJDG5PJ9gc6JwVVIMPeMzpU=; b=gN7jy5q+d245T5Ibgbf1+eE0n95vQ/nEaJKmlbBPtClU5Y1YkCJFdEhLclTuD9MxUb cDX8/JepaGGd84HnGg/pbCknNkcOvghpErGOhJWkIQhS3l1jlfeOwees3XvgDHpPiZ6f VfLta5igrsgBARfIkWiJIZ5vnDKSPMhalhTPJynvHqmuOKny/dKlYu71myp07nPQMq9n tGIsyFVCsI8SOcC8Ffgx5MUGaFu2Cpx1oitFY++a5QYDLaaq/aD7dSsS1NhXTWLZ0qe7 sdM0eQGzysplCGvbJxBg/3xwuB9mjX3uRppp6CHrsjzicU/EozHzoXIbbwGOJ0IMVsFU rs3A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a26-20020a1709066d5a00b006df9363ea5asi21652043ejt.483.2022.03.30.13.32.46; Wed, 30 Mar 2022 13:32:46 -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; 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 0FAD368B267; Wed, 30 Mar 2022 23:32:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F36368B20B for ; Wed, 30 Mar 2022 23:32:17 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B83F1E67D7; Wed, 30 Mar 2022 22:32:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h8kjRDUS7njJ; Wed, 30 Mar 2022 22:32:15 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 709ACE6CFC; Wed, 30 Mar 2022 22:32:15 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:00 +0200 Message-Id: <20220330203205.25937-3-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avcodec/dds: use the common texture dsp decode function 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1ke6z+T+JjMD Signed-off-by: Marton Balint --- libavcodec/dds.c | 135 +++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 87 deletions(-) diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 32690e1fd7..2254d18df8 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -106,12 +106,7 @@ typedef struct DDSContext { int bpp; enum DDSPostProc postproc; - const uint8_t *tex_data; // Compressed texture - int tex_ratio; // Compression ratio - int slice_count; // Number of slices for threaded operations - - /* Pointer to the selected compress or decompress function. */ - int (*tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + TextureDSPThreadContext dec; } DDSContext; static int parse_pixel_format(AVCodecContext *avctx) @@ -170,35 +165,36 @@ static int parse_pixel_format(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_RGBA; if (ctx->compressed) { + ctx->dec.raw_ratio = 16; switch (fourcc) { case MKTAG('D', 'X', 'T', '1'): - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.dxt1a_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.dxt1a_block; break; case MKTAG('D', 'X', 'T', '2'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt2_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt2_block; break; case MKTAG('D', 'X', 'T', '3'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt3_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt3_block; break; case MKTAG('D', 'X', 'T', '4'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt4_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt4_block; break; case MKTAG('D', 'X', 'T', '5'): - ctx->tex_ratio = 16; + ctx->dec.tex_ratio = 16; if (ycocg_scaled) - ctx->tex_funct = ctx->texdsp.dxt5ys_block; + ctx->dec.tex_funct = ctx->texdsp.dxt5ys_block; else if (ycocg_classic) - ctx->tex_funct = ctx->texdsp.dxt5y_block; + ctx->dec.tex_funct = ctx->texdsp.dxt5y_block; else - ctx->tex_funct = ctx->texdsp.dxt5_block; + ctx->dec.tex_funct = ctx->texdsp.dxt5_block; break; case MKTAG('R', 'X', 'G', 'B'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt5_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt5_block; /* This format may be considered as a normal map, * but it is handled differently in a separate postproc. */ ctx->postproc = DDS_SWIZZLE_RXGB; @@ -206,25 +202,25 @@ static int parse_pixel_format(AVCodecContext *avctx) break; case MKTAG('A', 'T', 'I', '1'): case MKTAG('B', 'C', '4', 'U'): - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.rgtc1u_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.rgtc1u_block; break; case MKTAG('B', 'C', '4', 'S'): - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.rgtc1s_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.rgtc1s_block; break; case MKTAG('A', 'T', 'I', '2'): /* RGT2 variant with swapped R and G (3Dc)*/ - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxn3dc_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxn3dc_block; break; case MKTAG('B', 'C', '5', 'U'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.rgtc2u_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.rgtc2u_block; break; case MKTAG('B', 'C', '5', 'S'): - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.rgtc2s_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.rgtc2s_block; break; case MKTAG('U', 'Y', 'V', 'Y'): ctx->compressed = 0; @@ -299,40 +295,40 @@ static int parse_pixel_format(AVCodecContext *avctx) avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC1_TYPELESS: case DXGI_FORMAT_BC1_UNORM: - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.dxt1a_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.dxt1a_block; break; case DXGI_FORMAT_BC2_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC2_TYPELESS: case DXGI_FORMAT_BC2_UNORM: - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt3_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt3_block; break; case DXGI_FORMAT_BC3_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC3_TYPELESS: case DXGI_FORMAT_BC3_UNORM: - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.dxt5_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.dxt5_block; break; case DXGI_FORMAT_BC4_TYPELESS: case DXGI_FORMAT_BC4_UNORM: - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.rgtc1u_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.rgtc1u_block; break; case DXGI_FORMAT_BC4_SNORM: - ctx->tex_ratio = 8; - ctx->tex_funct = ctx->texdsp.rgtc1s_block; + ctx->dec.tex_ratio = 8; + ctx->dec.tex_funct = ctx->texdsp.rgtc1s_block; break; case DXGI_FORMAT_BC5_TYPELESS: case DXGI_FORMAT_BC5_UNORM: - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.rgtc2u_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.rgtc2u_block; break; case DXGI_FORMAT_BC5_SNORM: - ctx->tex_ratio = 16; - ctx->tex_funct = ctx->texdsp.rgtc2s_block; + ctx->dec.tex_ratio = 16; + ctx->dec.tex_funct = ctx->texdsp.rgtc2s_block; break; default: av_log(avctx, AV_LOG_ERROR, @@ -434,43 +430,6 @@ static int parse_pixel_format(AVCodecContext *avctx) return 0; } -static int decompress_texture_thread(AVCodecContext *avctx, void *arg, - int slice, int thread_nb) -{ - DDSContext *ctx = avctx->priv_data; - AVFrame *frame = arg; - const uint8_t *d = ctx->tex_data; - int w_block = avctx->coded_width / TEXTURE_BLOCK_W; - int h_block = avctx->coded_height / TEXTURE_BLOCK_H; - int x, y; - int start_slice, end_slice; - int base_blocks_per_slice = h_block / ctx->slice_count; - int remainder_blocks = h_block % ctx->slice_count; - - /* When the frame height (in blocks) doesn't divide evenly between the - * number of slices, spread the remaining blocks evenly between the first - * operations */ - start_slice = slice * base_blocks_per_slice; - /* Add any extra blocks (one per slice) that have been added before this slice */ - start_slice += FFMIN(slice, remainder_blocks); - - end_slice = start_slice + base_blocks_per_slice; - /* Add an extra block if there are still remainder blocks to be accounted for */ - if (slice < remainder_blocks) - end_slice++; - - for (y = start_slice; y < end_slice; y++) { - uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H; - int off = y * w_block; - for (x = 0; x < w_block; x++) { - ctx->tex_funct(p + x * 16, frame->linesize[0], - d + (off + x) * ctx->tex_ratio); - } - } - - return 0; -} - static void do_swizzle(AVFrame *frame, int x, int y) { int i; @@ -513,7 +472,7 @@ static void run_postproc(AVCodecContext *avctx, AVFrame *frame) * http://www.realtimecollisiondetection.net/blog/?p=28 */ av_log(avctx, AV_LOG_DEBUG, "Post-processing normal map.\n"); - x_off = ctx->tex_ratio == 8 ? 0 : 3; + x_off = ctx->dec.tex_ratio == 8 ? 0 : 3; for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int x = src[x_off]; @@ -664,9 +623,9 @@ static int dds_decode(AVCodecContext *avctx, void *data, if (ctx->compressed) { int size = (avctx->coded_height / TEXTURE_BLOCK_H) * - (avctx->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio; - ctx->slice_count = av_clip(avctx->thread_count, 1, - avctx->coded_height / TEXTURE_BLOCK_H); + (avctx->coded_width / TEXTURE_BLOCK_W) * ctx->dec.tex_ratio; + ctx->dec.slice_count = av_clip(avctx->thread_count, 1, + avctx->coded_height / TEXTURE_BLOCK_H); if (bytestream2_get_bytes_left(gbc) < size) { av_log(avctx, AV_LOG_ERROR, @@ -676,8 +635,10 @@ static int dds_decode(AVCodecContext *avctx, void *data, } /* Use the decompress function on the texture, one block per thread. */ - ctx->tex_data = gbc->buffer; - avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); + ctx->dec.tex_data.in = gbc->buffer; + ctx->dec.frame_data.out = frame->data[0]; + ctx->dec.stride = frame->linesize[0]; + avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec, NULL, ctx->dec.slice_count); } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->data[0]; int x, y, i; From patchwork Wed Mar 30 20:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35088 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011305pzb; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxfrsW9ctFDAa5FfMQdhvd8l7CmNi5Nzzl8RBUVYcS4u244ITHiKHx/eoGhRIRjnqCDXQf X-Received: by 2002:a05:6402:430c:b0:419:4660:e261 with SMTP id m12-20020a056402430c00b004194660e261mr12851280edc.324.1648672395758; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672395; cv=none; d=google.com; s=arc-20160816; b=WxiRgd+NqvOWxhPLoPPRS5aSiPDin38fNaBF9zjWCQdrYsALWYLic7ywWSEin+phKX 1pFoekZTdE5mIhc+v3ouKTXrcrvTZxRZDJGI0jXCoOEcZDnu4phiHS5Eu8pSvMIlwoNq XBcB54yZK/OJUVY7ZD7TarcKCyIG3Ujo+sTm+hB8tY5SLgIEkOQqx8MFCwjwZDhiGC3j wcxEDrqOelojJHL0qmV6aC4zKmMs6jgHPxXw+/QPE7i81aY5G9wN0Z6y5EmI4nswNgco zHVgfnqQvzsPztXQucYJt85CMWNKZhRgHbEGA2dI8GQVa4aW0bNki0ZCHnXAPs1+APAC 1jBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=sC+pmvLSn9GwcMVijW/BgqXcSd62HE1+4wAwXVdZYGw=; b=FE2uzh4aWQHsiIAXM9vSZtcj4yODdbDXfOQqItR32kI09NDQ+KWtjqSNRNzBmO494Z QXka/l/2RDY6Qrssk3Qrvhnpy6ojddjjfKvc0Afc7Y+86dTwvW+VMmYW6LhxRlyQ+FmZ gKdTmq5+hv7k448AHbzskVda2vXu+wgtVrIQvKGlWx3aqueL9PWCKfotB6g498RFPoNd pX6iYrYjQLrLKG53pjUydj7oSzo0KdGdHj4Uy9RwHvBIuNgCjeqq3UnpvX70Z0qbd0il v+1EmNq0sLuSxbdK6uAu+2HqEe64QJwULFJ5QNnE8w8YKbbN+Ljgo45O2GbqLrezkAOM N08Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id os24-20020a170906af7800b006dfe7ec38f4si20981139ejb.770.2022.03.30.13.33.09; Wed, 30 Mar 2022 13:33:15 -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; 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 EDB7568B279; Wed, 30 Mar 2022 23:32:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F00C068B266 for ; Wed, 30 Mar 2022 23:32:17 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 89CF9E6CFC; Wed, 30 Mar 2022 22:32:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QdjH1xc-n-Ao; Wed, 30 Mar 2022 22:32:17 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A9085E6BB6; Wed, 30 Mar 2022 22:32:16 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:01 +0200 Message-Id: <20220330203205.25937-4-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] avcodec/hapdec: use the common texturedsp decode function 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /t2xRPUGaTqA Signed-off-by: Marton Balint --- libavcodec/hap.h | 11 ++--- libavcodec/hapdec.c | 110 ++++++++++---------------------------------- 2 files changed, 28 insertions(+), 93 deletions(-) diff --git a/libavcodec/hap.h b/libavcodec/hap.h index 00c3dbb32d..7e065e4838 100644 --- a/libavcodec/hap.h +++ b/libavcodec/hap.h @@ -72,23 +72,18 @@ typedef struct HapContext { HapChunk *chunks; int *chunk_results; /* Results from threaded operations */ - int tex_rat; /* Compression ratio */ - int tex_rat2; /* Compression ratio of the second texture */ - const uint8_t *tex_data; /* Compressed texture */ uint8_t *tex_buf; /* Buffer for compressed texture */ size_t tex_size; /* Size of the compressed texture */ size_t max_snappy; /* Maximum compressed size for snappy buffer */ - int slice_count; /* Number of slices for threaded operations */ - int texture_count; /* 2 for HAQA, 1 for other version */ int texture_section_size; /* size of the part of the texture section (for HAPQA) */ - int uncompress_pix_size; /* nb of byte / pixel for the target picture */ - /* Pointer to the selected compress or decompress function */ + /* Pointer to the selected compress function (encoder only) */ int (*tex_fun)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); - int (*tex_fun2)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + + TextureDSPThreadContext dec[2]; } HapContext; /* diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index 4a7ac15a8e..685d65d8b8 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -247,60 +247,6 @@ static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, return 0; } -static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg, - int slice, int thread_nb, int texture_num) -{ - HapContext *ctx = avctx->priv_data; - AVFrame *frame = arg; - const uint8_t *d = ctx->tex_data; - int w_block = avctx->coded_width / TEXTURE_BLOCK_W; - int h_block = avctx->coded_height / TEXTURE_BLOCK_H; - int x, y; - int start_slice, end_slice; - int base_blocks_per_slice = h_block / ctx->slice_count; - int remainder_blocks = h_block % ctx->slice_count; - - /* When the frame height (in blocks) doesn't divide evenly between the - * number of slices, spread the remaining blocks evenly between the first - * operations */ - start_slice = slice * base_blocks_per_slice; - /* Add any extra blocks (one per slice) that have been added before this slice */ - start_slice += FFMIN(slice, remainder_blocks); - - end_slice = start_slice + base_blocks_per_slice; - /* Add an extra block if there are still remainder blocks to be accounted for */ - if (slice < remainder_blocks) - end_slice++; - - for (y = start_slice; y < end_slice; y++) { - uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H; - int off = y * w_block; - for (x = 0; x < w_block; x++) { - if (texture_num == 0) { - ctx->tex_fun(p + x * 4 * ctx->uncompress_pix_size, frame->linesize[0], - d + (off + x) * ctx->tex_rat); - } else { - ctx->tex_fun2(p + x * 4 * ctx->uncompress_pix_size, frame->linesize[0], - d + (off + x) * ctx->tex_rat2); - } - } - } - - return 0; -} - -static int decompress_texture_thread(AVCodecContext *avctx, void *arg, - int slice, int thread_nb) -{ - return decompress_texture_thread_internal(avctx, arg, slice, thread_nb, 0); -} - -static int decompress_texture2_thread(AVCodecContext *avctx, void *arg, - int slice, int thread_nb) -{ - return decompress_texture_thread_internal(avctx, arg, slice, thread_nb, 1); -} - static int hap_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { @@ -310,12 +256,9 @@ static int hap_decode(AVCodecContext *avctx, void *data, int section_size; enum HapSectionType section_type; int start_texture_section = 0; - int tex_rat[2] = {0, 0}; bytestream2_init(&ctx->gbc, avpkt->data, avpkt->size); - tex_rat[0] = ctx->tex_rat; - /* check for multi texture header */ if (ctx->texture_count == 2) { ret = ff_hap_parse_section_header(&ctx->gbc, §ion_size, §ion_type); @@ -326,7 +269,6 @@ static int hap_decode(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } start_texture_section = 4; - tex_rat[1] = ctx->tex_rat2; } /* Get the output frame ready to receive data */ @@ -344,7 +286,7 @@ static int hap_decode(AVCodecContext *avctx, void *data, if (ctx->tex_size != (avctx->coded_width / TEXTURE_BLOCK_W) *(avctx->coded_height / TEXTURE_BLOCK_H) - *tex_rat[t]) { + *ctx->dec[t].tex_ratio) { av_log(avctx, AV_LOG_ERROR, "uncompressed size mismatches\n"); return AVERROR_INVALIDDATA; } @@ -355,11 +297,11 @@ static int hap_decode(AVCodecContext *avctx, void *data, if (hap_can_use_tex_in_place(ctx)) { int tex_size; /* Only DXTC texture compression in a contiguous block */ - ctx->tex_data = ctx->gbc.buffer; + ctx->dec[t].tex_data.in = ctx->gbc.buffer; tex_size = FFMIN(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc)); if (tex_size < (avctx->coded_width / TEXTURE_BLOCK_W) *(avctx->coded_height / TEXTURE_BLOCK_H) - *tex_rat[t]) { + *ctx->dec[t].tex_ratio) { av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); return AVERROR_INVALIDDATA; } @@ -377,15 +319,12 @@ static int hap_decode(AVCodecContext *avctx, void *data, return ctx->chunk_results[i]; } - ctx->tex_data = ctx->tex_buf; + ctx->dec[t].tex_data.in = ctx->tex_buf; } - /* Use the decompress function on the texture, one block per thread */ - if (t == 0){ - avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); - } else{ - avctx->execute2(avctx, decompress_texture2_thread, frame, NULL, ctx->slice_count); - } + ctx->dec[t].frame_data.out = frame->data[0]; + ctx->dec[t].stride = frame->linesize[0]; + avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec[t], NULL, ctx->dec[t].slice_count); } /* Frame is ready to be output */ @@ -415,40 +354,44 @@ static av_cold int hap_init(AVCodecContext *avctx) ff_texturedsp_init(&ctx->dxtc); ctx->texture_count = 1; - ctx->uncompress_pix_size = 4; + ctx->dec[0].raw_ratio = 16; + ctx->dec[0].slice_count = av_clip(avctx->thread_count, 1, + avctx->coded_height / TEXTURE_BLOCK_H); switch (avctx->codec_tag) { case MKTAG('H','a','p','1'): texture_name = "DXT1"; - ctx->tex_rat = 8; - ctx->tex_fun = ctx->dxtc.dxt1_block; + ctx->dec[0].tex_ratio = 8; + ctx->dec[0].tex_funct = ctx->dxtc.dxt1_block; avctx->pix_fmt = AV_PIX_FMT_RGB0; break; case MKTAG('H','a','p','5'): texture_name = "DXT5"; - ctx->tex_rat = 16; - ctx->tex_fun = ctx->dxtc.dxt5_block; + ctx->dec[0].tex_ratio = 16; + ctx->dec[0].tex_funct = ctx->dxtc.dxt5_block; avctx->pix_fmt = AV_PIX_FMT_RGBA; break; case MKTAG('H','a','p','Y'): texture_name = "DXT5-YCoCg-scaled"; - ctx->tex_rat = 16; - ctx->tex_fun = ctx->dxtc.dxt5ys_block; + ctx->dec[0].tex_ratio = 16; + ctx->dec[0].tex_funct = ctx->dxtc.dxt5ys_block; avctx->pix_fmt = AV_PIX_FMT_RGB0; break; case MKTAG('H','a','p','A'): texture_name = "RGTC1"; - ctx->tex_rat = 8; - ctx->tex_fun = ctx->dxtc.rgtc1u_gray_block; + ctx->dec[0].tex_ratio = 8; + ctx->dec[0].tex_funct = ctx->dxtc.rgtc1u_gray_block; + ctx->dec[0].raw_ratio = 4; avctx->pix_fmt = AV_PIX_FMT_GRAY8; - ctx->uncompress_pix_size = 1; break; case MKTAG('H','a','p','M'): texture_name = "DXT5-YCoCg-scaled / RGTC1"; - ctx->tex_rat = 16; - ctx->tex_rat2 = 8; - ctx->tex_fun = ctx->dxtc.dxt5ys_block; - ctx->tex_fun2 = ctx->dxtc.rgtc1u_alpha_block; + ctx->dec[0].tex_ratio = 16; + ctx->dec[1].tex_ratio = 8; + ctx->dec[0].tex_funct = ctx->dxtc.dxt5ys_block; + ctx->dec[1].tex_funct = ctx->dxtc.rgtc1u_alpha_block; + ctx->dec[1].raw_ratio = 16; + ctx->dec[1].slice_count = ctx->dec[0].slice_count; avctx->pix_fmt = AV_PIX_FMT_RGBA; ctx->texture_count = 2; break; @@ -458,9 +401,6 @@ static av_cold int hap_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "%s texture\n", texture_name); - ctx->slice_count = av_clip(avctx->thread_count, 1, - avctx->coded_height / TEXTURE_BLOCK_H); - return 0; } From patchwork Wed Mar 30 20:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35090 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011353pzb; Wed, 30 Mar 2022 13:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzG/WQCXn587cGPiyAiF4nW19HUz5tDNoejRlaO5be0Ke0DjDv81HKBO7fMJ+ou7T99VxA X-Received: by 2002:a17:907:7f04:b0:6e1:39b8:d1a5 with SMTP id qf4-20020a1709077f0400b006e139b8d1a5mr1529029ejc.83.1648672400325; Wed, 30 Mar 2022 13:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672400; cv=none; d=google.com; s=arc-20160816; b=o9vt5ahrHzJwbn7/q0FWfBrjXzXLb8RJs7f9pJxt4RSrRMBagQ793KQg+wNeUeLXKu /PCrc/PjNLjJFfuzbq1kfskqWSNd86mfvOW3LJjbv3fBjCg2RKW3OAquqY7N6z4OUU7f SCMqfLmej0xInqvYrAP3GztNSUUhicsE8YlpowAamQtomjvysG8HaSViGKRj6pZSa68M zqonfEOD+OJPQwvDPageIc1S+O86QDOkDP31wyxlIIO2B92niOCp1fTbk+6O5+GDPcQ0 G1BkM9Wq9V9yKhCNN7inn92Pgd+o6oBH/mHYZRBYTSrFKcNSZHmOD0QaKeo70YKdAz5L GtJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=lll/B82ScRUant/YplStZhhe8b0NgiuYNBVU+2xRrHg=; b=cjZ0GZp8HZeBexZK/hiOr63VlZvl9+TsUKCKHsA4MU87SqdZTPiEzswIceL80y672j z20nrYLx6Lwrb57TDKFYMIoNisRHO/9i569XE3SMzu/3be4QtjLufNer4OWe6x7AMMZI xhY3OhLkJkxiMdFAGdNj0lzZKoXoU1l3NBJVFqT4I1PnIvqncIy0OxDPSf49kbzPwHTI IEdeNCbkRF0Jqz4Cy1BfNrFrNvvJpFKxWDXfodqYQNcP//5Q5k0wv0rP233vyanprEbd 22uZQIKF72VF0QLkGq3FjI9BLUIhUA5ix4EVzIAU6dEHzkH9prQf+wAFWGlDEwZ/wVxi PWEw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t20-20020a056402525400b0041b539e9ceesi7014609edd.491.2022.03.30.13.33.19; Wed, 30 Mar 2022 13:33:20 -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; 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 1232768B285; Wed, 30 Mar 2022 23:32:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFEA568B284 for ; Wed, 30 Mar 2022 23:32:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5F161E67E5; Wed, 30 Mar 2022 22:32:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kG9OI8Jp5tsb; Wed, 30 Mar 2022 22:32:19 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F1048E6BB6; Wed, 30 Mar 2022 22:32:18 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:02 +0200 Message-Id: <20220330203205.25937-5-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] avcodec/hapenc: use the common texturedsp encode function 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OUbeMw2lI9+/ And add slice thread capabilities. Signed-off-by: Marton Balint --- libavcodec/hap.h | 4 +--- libavcodec/hapenc.c | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/libavcodec/hap.h b/libavcodec/hap.h index 7e065e4838..fb5a4c4123 100644 --- a/libavcodec/hap.h +++ b/libavcodec/hap.h @@ -80,9 +80,7 @@ typedef struct HapContext { int texture_count; /* 2 for HAQA, 1 for other version */ int texture_section_size; /* size of the part of the texture section (for HAPQA) */ - /* Pointer to the selected compress function (encoder only) */ - int (*tex_fun)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); - + TextureDSPThreadContext enc; TextureDSPThreadContext dec[2]; } HapContext; diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c index ee03fef449..148331a3dd 100644 --- a/libavcodec/hapenc.c +++ b/libavcodec/hapenc.c @@ -56,18 +56,14 @@ enum HapHeaderLength { static int compress_texture(AVCodecContext *avctx, uint8_t *out, int out_length, const AVFrame *f) { HapContext *ctx = avctx->priv_data; - int i, j; if (ctx->tex_size > out_length) return AVERROR_BUFFER_TOO_SMALL; - for (j = 0; j < avctx->height; j += 4) { - for (i = 0; i < avctx->width; i += 4) { - uint8_t *p = f->data[0] + i * 4 + j * f->linesize[0]; - const int step = ctx->tex_fun(out, f->linesize[0], p); - out += step; - } - } + ctx->enc.tex_data.out = out; + ctx->enc.frame_data.in = f->data[0]; + ctx->enc.stride = f->linesize[0]; + avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count); return 0; } @@ -236,7 +232,6 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt, static av_cold int hap_init(AVCodecContext *avctx) { HapContext *ctx = avctx->priv_data; - int ratio; int corrected_chunk_count; int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); @@ -256,32 +251,34 @@ static av_cold int hap_init(AVCodecContext *avctx) switch (ctx->opt_tex_fmt) { case HAP_FMT_RGBDXT1: - ratio = 8; + ctx->enc.tex_ratio = 8; avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); avctx->bits_per_coded_sample = 24; - ctx->tex_fun = ctx->dxtc.dxt1_block; + ctx->enc.tex_funct = ctx->dxtc.dxt1_block; break; case HAP_FMT_RGBADXT5: - ratio = 4; + ctx->enc.tex_ratio = 16; avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); avctx->bits_per_coded_sample = 32; - ctx->tex_fun = ctx->dxtc.dxt5_block; + ctx->enc.tex_funct = ctx->dxtc.dxt5_block; break; case HAP_FMT_YCOCGDXT5: - ratio = 4; + ctx->enc.tex_ratio = 16; avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); avctx->bits_per_coded_sample = 24; - ctx->tex_fun = ctx->dxtc.dxt5ys_block; + ctx->enc.tex_funct = ctx->dxtc.dxt5ys_block; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); return AVERROR_INVALIDDATA; } + ctx->enc.raw_ratio = 16; + ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / TEXTURE_BLOCK_H); /* Texture compression ratio is constant, so can we computer * beforehand the final size of the uncompressed buffer. */ - ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * - FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio; + ctx->tex_size = avctx->width / TEXTURE_BLOCK_W * + avctx->height / TEXTURE_BLOCK_H * ctx->enc.tex_ratio; switch (ctx->opt_compressor) { case HAP_COMP_NONE: @@ -294,7 +291,7 @@ static av_cold int hap_init(AVCodecContext *avctx) case HAP_COMP_SNAPPY: /* Round the chunk count to divide evenly on DXT block edges */ corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); - while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) { + while ((ctx->tex_size / ctx->enc.tex_ratio) % corrected_chunk_count != 0) { corrected_chunk_count--; } @@ -356,6 +353,7 @@ const FFCodec ff_hap_encoder = { .p.id = AV_CODEC_ID_HAP, .priv_data_size = sizeof(HapContext), .p.priv_class = &hapenc_class, + .p.capabilities = AV_CODEC_CAP_SLICE_THREADS, .init = hap_init, .encode2 = hap_encode, .close = hap_close, From patchwork Wed Mar 30 20:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35089 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011304pzb; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr9H0vkYW9FsSKXPqdO8EWfRUzqKPv54zxVhuogHLL0QXoF+rhG+oDeLotIibd38jH6WQT X-Received: by 2002:a17:907:c16:b0:6da:7d72:1357 with SMTP id ga22-20020a1709070c1600b006da7d721357mr1485428ejc.251.1648672395698; Wed, 30 Mar 2022 13:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672395; cv=none; d=google.com; s=arc-20160816; b=kRBBgH9eUWadMpp2Sk7Dw+ESG9zkN4FGYuqOP5EGGAbgkvISQ8b/bLK9xaszu65OgU fG/NuXlF9PpEel7Fdn/9TOiCK0qROHfxK0RTxvK3Pzck8XdoW+yCF3pJGgIjTGuUMneu 7W4VTUznGnf9/KbFvdOH7UpMsfiHiArCVQcMy7FkIpaCSDeFJvzyMATBKO9aPKnh7m4h VVFBAhJY5yiU2ZzyFVIlryHau4HZiTZ0lhM6O3CxTUfKGaDS7G1D3ZaGQ9Emau6hx0J7 BO/kDHOMJJKN0cRKDlhHYP7lKCHBHKyIUhmhUkYgCkMWp390r6R+d6BenYzLRd/wsrCB GVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=rwe/X7VTIi8EZN9DmN9InMr5KOA2cU8Pw5rYFiAX84U=; b=HGmxKpNITO/mE5TybuL/iIbtVQwx8WZiJkuIdt1FLOOAEb5JzOfEIz0Mrps0cwAImK w8/QLe4DxfcdTLXEMlutvZ/YH9/6FqGzMSUt5PFVy57Px7sCGpPNNrGnylXEjiiMfcg5 FbsmZ5RKa9SSTJ5ExmaLoeqp96w4TWJIIANY7BoeFwEFibBMQ2dpYVX+Mnnyc5U1SW9y bWyJvuhYzjptB3arhqZzbdmjfdZtEy/hY1bvMXbLoBUkkUZNbRnx93xzOv/Pt5pdrG0R yYMBVZZ1knmi/KRlpSaBLbfl43qyp3WQN5ohlKSeiAUAtXBcaRVpp04tUpav8ebLf6YL i6pA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e22-20020a1709067e1600b006df76385c4dsi20589032ejr.237.2022.03.30.13.33.07; Wed, 30 Mar 2022 13:33:15 -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; 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 EEC5768B284; Wed, 30 Mar 2022 23:32:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 62C7168B26B for ; Wed, 30 Mar 2022 23:32:24 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E7250E67D7; Wed, 30 Mar 2022 22:32:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gJYZSATvYV9i; Wed, 30 Mar 2022 22:32:21 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 70A46E6D0D; Wed, 30 Mar 2022 22:32:20 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:03 +0200 Message-Id: <20220330203205.25937-6-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] avcodec/vbndec: add VBN decoder 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: klfY3o5kxZDJ Add support for decoding Vizrt Binary Image (VBN) files. LZW-compressed data is not supported yet. Signed-off-by: Marton Balint --- Changelog | 1 + configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/vbn.h | 50 ++++++++++ libavcodec/vbndec.c | 196 +++++++++++++++++++++++++++++++++++++++ libavformat/allformats.c | 1 + libavformat/img2.c | 1 + libavformat/img2dec.c | 12 +++ 11 files changed, 272 insertions(+) create mode 100644 libavcodec/vbn.h create mode 100644 libavcodec/vbndec.c diff --git a/Changelog b/Changelog index ac614f8f05..7bad88dabc 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ version 5.1: - dropped obsolete XvMC hwaccel - pcm-bluray encoder - DFPWM audio encoder/decoder and raw muxer/demuxer +- Vizrt Binary Image decoder version 5.0: diff --git a/configure b/configure index e4d36aa639..90c99ff85e 100755 --- a/configure +++ b/configure @@ -2959,6 +2959,7 @@ txd_decoder_select="texturedsp" utvideo_decoder_select="bswapdsp llviddsp" utvideo_encoder_select="bswapdsp huffman llvidencdsp" vble_decoder_select="llviddsp" +vbn_decoder_select="texturedsp" vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp" vc1image_decoder_select="vc1_decoder" vorbis_decoder_select="mdct" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fb8b0e824b..90700085b8 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -708,6 +708,7 @@ OBJS-$(CONFIG_V408_ENCODER) += v408enc.o OBJS-$(CONFIG_V410_DECODER) += v410dec.o OBJS-$(CONFIG_V410_ENCODER) += v410enc.o OBJS-$(CONFIG_VB_DECODER) += vb.o +OBJS-$(CONFIG_VBN_DECODER) += vbndec.o OBJS-$(CONFIG_VBLE_DECODER) += vble.o OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o \ vc1_mc.o vc1_pred.o vc1.o vc1data.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 22d56760ec..f0a7ea7fd4 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -347,6 +347,7 @@ extern const FFCodec ff_v408_decoder; extern const FFCodec ff_v410_encoder; extern const FFCodec ff_v410_decoder; extern const FFCodec ff_vb_decoder; +extern const FFCodec ff_vbn_decoder; extern const FFCodec ff_vble_decoder; extern const FFCodec ff_vc1_decoder; extern const FFCodec ff_vc1_crystalhd_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 81f3b3c640..c08854cc93 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1863,6 +1863,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("GEM Raster image"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_VBN, + .type = AVMEDIA_TYPE_VIDEO, + .name = "vbn", + .long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 3ffb9bd22e..43c72ce8e4 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -308,6 +308,7 @@ enum AVCodecID { AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SGA_VIDEO, AV_CODEC_ID_GEM, + AV_CODEC_ID_VBN, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/vbn.h b/libavcodec/vbn.h new file mode 100644 index 0000000000..8660786de8 --- /dev/null +++ b/libavcodec/vbn.h @@ -0,0 +1,50 @@ +/* + * VBN format definitions + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * VBN format definitions. + */ + +#ifndef AVCODEC_VBN_H +#define AVCODEC_VBN_H + +#define VBN_MAGIC 0x900df11e +#define VBN_MAJOR 3 +#define VBN_MINOR 4 + +#define VBN_HEADER_SIZE 192 + +#define VBN_FORMAT_RAW 0 +#define VBN_FORMAT_LZ 1 +#define VBN_FORMAT_DXT1 2 +#define VBN_FORMAT_DXT5 3 + +#define VBN_COMPRESSION_NONE 0 +#define VBN_COMPRESSION_LZW 0x100 + +#define VBN_PIX_ALPHA 0 +#define VBN_PIX_LUMINANCE 1 +#define VBN_PIX_LUMINANCE_ALPHA 2 +#define VBN_PIX_RGB 3 +#define VBN_PIX_RGBA 5 +#define VBN_PIX_INDEX 6 + +#endif /* AVCODEC_VBN_H */ diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c new file mode 100644 index 0000000000..1119059c55 --- /dev/null +++ b/libavcodec/vbndec.c @@ -0,0 +1,196 @@ +/* + * Vizrt Binary Image decoder + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Vizrt Binary Image decoder + */ + +#include "avcodec.h" +#include "bytestream.h" +#include "codec_internal.h" +#include "internal.h" +#include "texturedsp.h" +#include "vbn.h" +#include "libavutil/imgutils.h" + +typedef struct VBNContext { + TextureDSPContext texdsp; + TextureDSPThreadContext dec; + GetByteContext gb; +} VBNContext; + +static av_cold int vbn_init(AVCodecContext *avctx) +{ + VBNContext *ctx = avctx->priv_data; + ff_texturedsp_init(&ctx->texdsp); + return 0; +} + +static int decompress(AVCodecContext *avctx, int compression, uint8_t **outbuf) +{ + VBNContext *ctx = avctx->priv_data; + GetByteContext *gb = &ctx->gb; + + if (compression == VBN_COMPRESSION_NONE) // outbuf is left NULL because gb->buf can be used directly + return bytestream2_get_bytes_left(gb); + + av_log(avctx, AV_LOG_ERROR, "Unsupported VBN compression: 0x%08x\n", compression); + return AVERROR_PATCHWELCOME; +} + +static int vbn_decode_frame(AVCodecContext *avctx, + void *data, int *got_frame, + AVPacket *avpkt) +{ + VBNContext *ctx = avctx->priv_data; + GetByteContext *gb = &ctx->gb; + AVFrame *frame = data; + uint8_t *image_buf = NULL; + int image_len; + int width, height, components, format, compression, pix_fmt, linesize, data_size; + int ret; + + bytestream2_init(gb, avpkt->data, avpkt->size); + + if (bytestream2_get_bytes_left(gb) < VBN_HEADER_SIZE) { + av_log(avctx, AV_LOG_ERROR, "VBN header truncated\n"); + return AVERROR_INVALIDDATA; + } + + if (bytestream2_get_le32(gb) != VBN_MAGIC || + bytestream2_get_le32(gb) != VBN_MAJOR || + bytestream2_get_le32(gb) != VBN_MINOR) { + av_log(avctx, AV_LOG_ERROR, "Invalid VBN header\n"); + return AVERROR_INVALIDDATA; + } + + width = bytestream2_get_le32(gb); + height = bytestream2_get_le32(gb); + components = bytestream2_get_le32(gb); + format = bytestream2_get_le32(gb); + pix_fmt = bytestream2_get_le32(gb); + bytestream2_get_le32(gb); // mipmaps + data_size = bytestream2_get_le32(gb); + bytestream2_seek(gb, VBN_HEADER_SIZE, SEEK_SET); + + compression = format & 0xffffff00; + format = format & 0xff; + + if (data_size != bytestream2_get_bytes_left(gb)) { + av_log(avctx, AV_LOG_ERROR, "Truncated packet\n"); + return AVERROR_INVALIDDATA; + } + + if (pix_fmt != VBN_PIX_RGBA && pix_fmt != VBN_PIX_RGB) { + av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: 0x%08x\n", pix_fmt); + return AVERROR_PATCHWELCOME; + } + + ret = ff_set_dimensions(avctx, width, height); + if (ret < 0) + return ret; + + if (format == VBN_FORMAT_RAW) { + if (pix_fmt == VBN_PIX_RGB && components == 3) { + avctx->pix_fmt = AV_PIX_FMT_RGB24; + linesize = avctx->width * 3; + } else if (pix_fmt == VBN_PIX_RGBA && components == 4) { + avctx->pix_fmt = AV_PIX_FMT_RGBA; + linesize = avctx->width * 4; + } else { + av_log(avctx, AV_LOG_ERROR, "Unsupported number of components: %d\n", components); + return AVERROR_PATCHWELCOME; + } + } else if (format == VBN_FORMAT_DXT1 || format == VBN_FORMAT_DXT5) { + if (avctx->width % TEXTURE_BLOCK_W || avctx->height % TEXTURE_BLOCK_H) { + av_log(avctx, AV_LOG_ERROR, "DXTx compression only supports 4 pixel aligned resolutions\n"); + return AVERROR_INVALIDDATA; + } + + avctx->pix_fmt = AV_PIX_FMT_RGBA; + if (format == VBN_FORMAT_DXT1) { + ctx->dec.tex_funct = ctx->texdsp.dxt1_block; + ctx->dec.tex_ratio = 8; + linesize = avctx->coded_width / 2; + } else { + ctx->dec.tex_funct = ctx->texdsp.dxt5_block; + ctx->dec.tex_ratio = 16; + linesize = avctx->coded_width; + } + } else { + av_log(avctx, AV_LOG_ERROR, "Unsupported VBN format: 0x%02x\n", format); + return AVERROR_PATCHWELCOME; + } + + image_len = decompress(avctx, compression, &image_buf); + if (image_len < 0) + return image_len; + + if (image_len < linesize * avctx->coded_height) { + av_log(avctx, AV_LOG_ERROR, "Insufficent data\n"); + ret = AVERROR_INVALIDDATA; + goto out; + } + + ret = ff_get_buffer(avctx, frame, 0); + if (ret < 0) + goto out; + + frame->pict_type = AV_PICTURE_TYPE_I; + frame->key_frame = 1; + + if (format == VBN_FORMAT_RAW) { + uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); + av_image_copy_plane(flipped, -frame->linesize[0], image_buf ? image_buf : gb->buffer, linesize, linesize, frame->height); + } else { + ctx->dec.slice_count = av_clip(avctx->thread_count, 1, avctx->coded_height / TEXTURE_BLOCK_H); + ctx->dec.tex_data.in = image_buf ? image_buf : gb->buffer; + ctx->dec.raw_ratio = 16; + ctx->dec.frame_data.out = frame->data[0] + frame->linesize[0] * (frame->height - 1); + ctx->dec.stride = -frame->linesize[0]; + avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec, NULL, ctx->dec.slice_count); + } + + *got_frame = 1; + ret = avpkt->size; + +out: + av_freep(&image_buf); + return ret; +} + +static av_cold int vbn_close(AVCodecContext *avctx) +{ + return 0; +} + +const FFCodec ff_vbn_decoder = { + .p.name = "vbn", + .p.long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VBN, + .init = vbn_init, + .decode = vbn_decode_frame, + .close = vbn_close, + .priv_data_size = sizeof(VBNContext), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE +}; diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 587ad59b3c..7c1d0ac38f 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -526,6 +526,7 @@ extern const AVInputFormat ff_image_sgi_pipe_demuxer; extern const AVInputFormat ff_image_svg_pipe_demuxer; extern const AVInputFormat ff_image_sunrast_pipe_demuxer; extern const AVInputFormat ff_image_tiff_pipe_demuxer; +extern const AVInputFormat ff_image_vbn_pipe_demuxer; extern const AVInputFormat ff_image_webp_pipe_demuxer; extern const AVInputFormat ff_image_xbm_pipe_demuxer; extern const AVInputFormat ff_image_xpm_pipe_demuxer; diff --git a/libavformat/img2.c b/libavformat/img2.c index 4153102c92..fe2ca7bfff 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -87,6 +87,7 @@ const IdStrMap ff_img_tags[] = { { AV_CODEC_ID_GEM, "img" }, { AV_CODEC_ID_GEM, "ximg" }, { AV_CODEC_ID_GEM, "timg" }, + { AV_CODEC_ID_VBN, "vbn" }, { AV_CODEC_ID_NONE, NULL } }; diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b9c06c5b54..551b9d508e 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -37,6 +37,7 @@ #include "internal.h" #include "img2.h" #include "libavcodec/mjpeg.h" +#include "libavcodec/vbn.h" #include "libavcodec/xwd.h" #include "subtitles.h" @@ -1131,6 +1132,16 @@ static int gem_probe(const AVProbeData *p) return 0; } +static int vbn_probe(const AVProbeData *p) +{ + const uint8_t *b = p->buf; + if (AV_RL32(b ) == VBN_MAGIC && + AV_RL32(b + 4) == VBN_MAJOR && + AV_RL32(b + 8) == VBN_MINOR) + return AVPROBE_SCORE_MAX - 1; + return 0; +} + #define IMAGEAUTO_DEMUXER_0(imgname, codecid) #define IMAGEAUTO_DEMUXER_1(imgname, codecid)\ const AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\ @@ -1181,6 +1192,7 @@ IMAGEAUTO_DEMUXER(sgi, SGI) IMAGEAUTO_DEMUXER(sunrast, SUNRAST) IMAGEAUTO_DEMUXER(svg, SVG) IMAGEAUTO_DEMUXER(tiff, TIFF) +IMAGEAUTO_DEMUXER(vbn, VBN) IMAGEAUTO_DEMUXER(webp, WEBP) IMAGEAUTO_DEMUXER(xbm, XBM) IMAGEAUTO_DEMUXER(xpm, XPM) From patchwork Wed Mar 30 20:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35092 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011523pzb; Wed, 30 Mar 2022 13:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyaGYtb/CKBe1NNsRR5vmBrtRKmagUAuk2saUtPIEb7K2fDz1iCC8SmV27oDcGFNy8ilH8 X-Received: by 2002:a05:6402:270f:b0:419:5b71:3493 with SMTP id y15-20020a056402270f00b004195b713493mr12877850edd.72.1648672419703; Wed, 30 Mar 2022 13:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672419; cv=none; d=google.com; s=arc-20160816; b=ioUxReQS5uYTguWEdPvQgGmxoDzoBkzUV98dzTKiFmjLBT3hkC2NO5QQ1BZNFCEGju xJuuB2YA+Bjc6Vradfs/y7QR7f3SpqTidf6qdNIFWHh/NBuXDqbpKx6tudwq891dIZm0 MVzMTCMWDe34tmMf7SboD0JVGw8R/iu+Jd/0ToqpOCOD1CJcHVwmLqGpFoSjmI2RIs2G j0tx+XaKFec5BzKru0uIeOITmkRqBnQX9skuF2nWCLKg50xhK62O7sjZNayEDVf/c6mV IEYaVJfuG1ABsaB/Q2cbWjnsEWoybqv4mXVNHYyJwxyRxzg9NJgIjezZ6nUh90SMBwNV XRew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=aV5T8vdIaG6PUQOXndzUXQTqlxu4tuwGh2afTXsb3dQ=; b=hpf6Zaioy9iq/TVQw64gOgvw+UNgyWYwJ1FxYD22QPxbty/mHAQEvoxHCOm2aglH2Z v5P36GLXCUmPcR1ITJSqVUG6nsjGmIy0R1Atc93+16VIvSVHQC2wi8ef1Wg2WUE67MOZ a5R5k/++M2B/uq2HX3fpXCThg2MC22Af8bORJ52vb5kqkL3KeM+yHinjvTjGdvMWtajc 2tmU+Ffu5R74cYm+QMY8KEUonKFkyvEVgStMveCCd+PDb10/s70Sa04B3NRXscskDJoY 7tYshkxE5TQ5vMGLg1tzc05ECMuDmDTWDOsZcE2hHMHI+s0ZHsfwrVaxUCU6NVS8oXLv +iVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t1-20020aa7d4c1000000b0041958583258si21768254edr.500.2022.03.30.13.33.38; Wed, 30 Mar 2022 13:33:39 -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; 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 11B3668B28C; Wed, 30 Mar 2022 23:32:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F30868B2A1 for ; Wed, 30 Mar 2022 23:32:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EC62EE6BB6; Wed, 30 Mar 2022 22:32:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kxVfUvUFhBS7; Wed, 30 Mar 2022 22:32:23 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2FB39E6DDE; Wed, 30 Mar 2022 22:32:22 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:04 +0200 Message-Id: <20220330203205.25937-7-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] avcodec/vbnenc: add VBN encoder 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VInhGJUT9T7j Signed-off-by: Marton Balint --- Changelog | 2 +- configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/vbnenc.c | 173 +++++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- libavformat/img2enc.c | 2 +- libavformat/version.h | 4 +- 8 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 libavcodec/vbnenc.c diff --git a/Changelog b/Changelog index 7bad88dabc..c3fbba5221 100644 --- a/Changelog +++ b/Changelog @@ -6,7 +6,7 @@ version 5.1: - dropped obsolete XvMC hwaccel - pcm-bluray encoder - DFPWM audio encoder/decoder and raw muxer/demuxer -- Vizrt Binary Image decoder +- Vizrt Binary Image encoder/decoder version 5.0: diff --git a/configure b/configure index 90c99ff85e..9c8965852b 100755 --- a/configure +++ b/configure @@ -2960,6 +2960,7 @@ utvideo_decoder_select="bswapdsp llviddsp" utvideo_encoder_select="bswapdsp huffman llvidencdsp" vble_decoder_select="llviddsp" vbn_decoder_select="texturedsp" +vbn_encoder_select="texturedspenc" vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp" vc1image_decoder_select="vc1_decoder" vorbis_decoder_select="mdct" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 90700085b8..90f46035d9 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -709,6 +709,7 @@ OBJS-$(CONFIG_V410_DECODER) += v410dec.o OBJS-$(CONFIG_V410_ENCODER) += v410enc.o OBJS-$(CONFIG_VB_DECODER) += vb.o OBJS-$(CONFIG_VBN_DECODER) += vbndec.o +OBJS-$(CONFIG_VBN_ENCODER) += vbnenc.o OBJS-$(CONFIG_VBLE_DECODER) += vble.o OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o \ vc1_mc.o vc1_pred.o vc1.o vc1data.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f0a7ea7fd4..585918da93 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -347,6 +347,7 @@ extern const FFCodec ff_v408_decoder; extern const FFCodec ff_v410_encoder; extern const FFCodec ff_v410_decoder; extern const FFCodec ff_vb_decoder; +extern const FFCodec ff_vbn_encoder; extern const FFCodec ff_vbn_decoder; extern const FFCodec ff_vble_decoder; extern const FFCodec ff_vc1_decoder; diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c new file mode 100644 index 0000000000..51f618c7d9 --- /dev/null +++ b/libavcodec/vbnenc.c @@ -0,0 +1,173 @@ +/* + * Vizrt Binary Image encoder + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Vizrt Binary Image encoder + */ + +#include "avcodec.h" +#include "bytestream.h" +#include "codec_internal.h" +#include "encode.h" +#include "texturedsp.h" +#include "vbn.h" + +#include "libavutil/imgutils.h" +#include "libavutil/frame.h" +#include "libavutil/opt.h" + +typedef struct VBNContext { + AVClass *class; + TextureDSPContext dxtc; + PutByteContext pb; + int format; + TextureDSPThreadContext enc; +} VBNContext; + +static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + VBNContext *ctx = avctx->priv_data; + PutByteContext *pb = &ctx->pb; + int ret; + ptrdiff_t linesize; + int64_t pkt_size; + + ret = av_image_check_size2(frame->width, frame->height, INT_MAX, frame->format, 0, avctx); + if (ret < 0) + return ret; + + if (ctx->format == VBN_FORMAT_DXT1 || ctx->format == VBN_FORMAT_DXT5) { + if (frame->width % TEXTURE_BLOCK_W || frame->height % TEXTURE_BLOCK_H) { + av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4\n", frame->width, frame->height); + return AVERROR(EINVAL); + } + if (frame->format != AV_PIX_FMT_RGBA) { + av_log(avctx, AV_LOG_ERROR, "DXT formats only support RGBA pixel format\n"); + return AVERROR(EINVAL); + } + ctx->enc.raw_ratio = 16; + ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / TEXTURE_BLOCK_H); + } + + switch (ctx->format) { + case VBN_FORMAT_DXT1: + linesize = frame->width / 2; + ctx->enc.tex_funct = ctx->dxtc.dxt1_block; + ctx->enc.tex_ratio = 8; + break; + case VBN_FORMAT_DXT5: + linesize = frame->width; + ctx->enc.tex_funct = ctx->dxtc.dxt5_block; + ctx->enc.tex_ratio = 16; + break; + case VBN_FORMAT_RAW: + linesize = av_image_get_linesize(frame->format, frame->width, 0); + if (linesize < 0) + return linesize; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->format); + return AVERROR(EINVAL); + } + + pkt_size = VBN_HEADER_SIZE + linesize * frame->height; + if (pkt_size > INT_MAX) + return AVERROR(EINVAL); + + if ((ret = ff_get_encode_buffer(avctx, pkt, pkt_size, 0)) < 0) + return ret; + + memset(pkt->data, 0, VBN_HEADER_SIZE); + bytestream2_init_writer(pb, pkt->data, pkt_size); + bytestream2_put_le32(pb, VBN_MAGIC); + bytestream2_put_le32(pb, VBN_MAJOR); + bytestream2_put_le32(pb, VBN_MINOR); + bytestream2_put_le32(pb, frame->width); + bytestream2_put_le32(pb, frame->height); + bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? 4 : 3); + bytestream2_put_le32(pb, ctx->format); + bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? VBN_PIX_RGBA : VBN_PIX_RGB); + bytestream2_put_le32(pb, 0); // mipmaps + bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); + bytestream2_seek_p(pb, 64, SEEK_SET); + bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); + + if (ctx->format == VBN_FORMAT_DXT1 || ctx->format == VBN_FORMAT_DXT5) { + ctx->enc.frame_data.in = (frame->height - 1) * frame->linesize[0] + frame->data[0]; + ctx->enc.stride = -frame->linesize[0]; + ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE; + avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count); + } else { + uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); + av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height); + } + + *got_packet = 1; + return 0; +} + +static av_cold int vbn_init(AVCodecContext *avctx) +{ + VBNContext *ctx = avctx->priv_data; + ff_texturedspenc_init(&ctx->dxtc); + return 0; +} + +static av_cold int vbn_close(AVCodecContext *avctx) +{ + return 0; +} + +#define OFFSET(x) offsetof(VBNContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "format", "Texture format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = VBN_FORMAT_DXT5 }, VBN_FORMAT_RAW, VBN_FORMAT_DXT5, FLAGS, "format" }, + { "raw", "RAW texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_RAW }, 0, 0, FLAGS, "format" }, + { "dxt1", "DXT1 texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_DXT1 }, 0, 0, FLAGS, "format" }, + { "dxt5", "DXT5 texture", 0, AV_OPT_TYPE_CONST, { .i64 = VBN_FORMAT_DXT5 }, 0, 0, FLAGS, "format" }, + { NULL }, +}; + +static const AVClass vbnenc_class = { + .class_name = "VBN encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +const FFCodec ff_vbn_encoder = { + .p.name = "vbn", + .p.long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VBN, + .p.capabilities = AV_CODEC_CAP_SLICE_THREADS, + .p.priv_class = &vbnenc_class, + .init = vbn_init, + .encode2 = vbn_encode, + .close = vbn_close, + .priv_data_size = sizeof(VBNContext), + .p.pix_fmts = (const enum AVPixelFormat[]) { + AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE, + }, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index a744e7469f..26ee41eb1f 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 25 +#define LIBAVCODEC_VERSION_MINOR 26 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 9b3b8741c8..ae351963d9 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -265,7 +265,7 @@ const AVOutputFormat ff_image2_muxer = { .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), .extensions = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png," "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24," - "sunras,xbm,xface,pix,y", + "sunras,vbn,xbm,xface,pix,y", .priv_data_size = sizeof(VideoMuxData), .video_codec = AV_CODEC_ID_MJPEG, .write_header = write_header, diff --git a/libavformat/version.h b/libavformat/version.h index f4a26c2870..683184d5da 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 20 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 21 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From patchwork Wed Mar 30 20:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35091 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1011438pzb; Wed, 30 Mar 2022 13:33:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMFq7ygdyXbBBUq0hcYhVwDIzZpi8iMeHduaksHxTei6egDYIq93DbjPpsVFzcPQjlLj00 X-Received: by 2002:a50:d711:0:b0:410:a51a:77c5 with SMTP id t17-20020a50d711000000b00410a51a77c5mr12944818edi.154.1648672409685; Wed, 30 Mar 2022 13:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648672409; cv=none; d=google.com; s=arc-20160816; b=d/nK9O19XwZ1sUJovEfiDxYxt6gY4VgBTi7j7LDNfBsvzCe5aJujfdML0SQ7TXvLPg gPiP6Rlwf+7awiiadvpRZ2l+b3cvFDpTOMXf0ND4Wz5K7srC3zC3gtEEP7IzTiAWUkKd vsYrn3CATaEV+loLMIwx/xjeeO2L4gwRZWIcLp9Luwe0ZfwNfNkDyOTQdYI15eN0P3L9 quw22po4bB135SkliZS6J07QC/0QX5/X2eiqvAwjldNmNwTatZqkYoHqgVqtceizzLj3 MMlv4oUecGlxhW1u8xH4UlQtzNa0NA/CUQSSNNWAhyYOjLcFhT6gS8YDs4bDW3Fgwlsx 3OBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=FH/mdmqjsSeG/gb0zfrRmbC1qCbwnx7UvfsGVabAShQ=; b=x6CG9kMZY84M/MAgs/kJeUm7PVNut/1gniaDQSi59yqtYb3v3DsippESpE7aXghZc3 ndHszh/rZBeTlgorOsdqXV5Y94hqXGaSn9sW9Ap80D3SSKbvTu7FJzZWMaAAQoEhpIHP aT6wNTN4Poo5t5ixYDsjT8bnHy6GgZ7hrNoLvJd291GiyWmge7a7ah3pWuzFyBNENx2z kRevH+VaXv50g/HK7M2LJ+uDBNh+gNUuvHidJ97jeuxI1JRwo3vrcssZ4E05Eqmgnchl UmkSIgdsdxWRhcItlftzExqJJFEplh3x5pgnHucNeYtHJm5QcUzLjwNNnGVX/aITS2zH INJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x17-20020a1709060ef100b006dfb5687a24si21139560eji.499.2022.03.30.13.33.29; Wed, 30 Mar 2022 13:33:29 -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; 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 017F868B294; Wed, 30 Mar 2022 23:32:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0B1B68B27B for ; Wed, 30 Mar 2022 23:32:27 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1FFF5E67E5; Wed, 30 Mar 2022 22:32:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4-G3DuGA8Hre; Wed, 30 Mar 2022 22:32:26 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2223CE67D7; Wed, 30 Mar 2022 22:32:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 22:32:05 +0200 Message-Id: <20220330203205.25937-8-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330203205.25937-1-cus@passwd.hu> References: <20220330203205.25937-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] fate: add fate tests for VBN encoder and decoder 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FskUi65EcIjY Signed-off-by: Marton Balint --- tests/Makefile | 1 + tests/fate-run.sh | 11 +++++++++++ tests/fate/vbn.mak | 36 ++++++++++++++++++++++++++++++++++++ tests/ref/fate/vbn-dxt1 | 11 +++++++++++ tests/ref/fate/vbn-dxt5 | 11 +++++++++++ tests/ref/fate/vbn-raw-rgb24 | 9 +++++++++ tests/ref/fate/vbn-raw-rgba | 11 +++++++++++ 7 files changed, 90 insertions(+) create mode 100644 tests/fate/vbn.mak create mode 100644 tests/ref/fate/vbn-dxt1 create mode 100644 tests/ref/fate/vbn-dxt5 create mode 100644 tests/ref/fate/vbn-raw-rgb24 create mode 100644 tests/ref/fate/vbn-raw-rgba diff --git a/tests/Makefile b/tests/Makefile index 9f33394856..e3b41a4f7b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -191,6 +191,7 @@ include $(SRC_PATH)/tests/fate/speedhq.mak include $(SRC_PATH)/tests/fate/subtitles.mak include $(SRC_PATH)/tests/fate/truehd.mak include $(SRC_PATH)/tests/fate/utvideo.mak +include $(SRC_PATH)/tests/fate/vbn.mak include $(SRC_PATH)/tests/fate/video.mak include $(SRC_PATH)/tests/fate/voice.mak include $(SRC_PATH)/tests/fate/vorbis.mak diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 5e8d607d88..3022aa44a6 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -382,6 +382,17 @@ refcmp_metadata(){ -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk - } +refcmp_metadata_files(){ + refcmp=$1 + pixfmt=$2 + file1=$3 + file2=$4 + fuzz=${5:-0.001} + ffmpeg -auto_conversion_filters $FLAGS -i $file1 $FLAGS -i $file2 $ENC_OPTS \ + -lavfi "[0:v]format=${pixfmt}[v0];[1:v]format=${pixfmt}[v1];[v0][v1]${refcmp},metadata=print:file=-" \ + -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk - +} + pixfmt_conversion(){ conversion="${test#pixfmt-}" outdir="tests/data/pixfmt" diff --git a/tests/fate/vbn.mak b/tests/fate/vbn.mak new file mode 100644 index 0000000000..044b110ac1 --- /dev/null +++ b/tests/fate/vbn.mak @@ -0,0 +1,36 @@ +fate-vbn-%: VBN_FILE = tests/data/$(subst fate-vbn-,,$(@)).vbn +fate-vbn-%: PIX_FMT = rgba +fate-vbn-raw-rgb24: PIX_FMT = rgb24 +fate-vbn-%: SRC = $(TARGET_SAMPLES)/png1/lena-$(PIX_FMT).png +fate-vbn-%: CMD = refcmp_metadata_files psnr $(PIX_FMT) $(VBN_FILE) $(SRC) + +fate-vbn-dxt1: tests/data/dxt1.vbn +fate-vbn-dxt5: tests/data/dxt5.vbn +fate-vbn-raw-rgba: tests/data/raw-rgba.vbn +fate-vbn-raw-rgb24: tests/data/raw-rgb24.vbn + +FATE_VBN += fate-vbn-dxt1 +FATE_VBN += fate-vbn-dxt5 +FATE_VBN += fate-vbn-raw-rgba +FATE_VBN += fate-vbn-raw-rgb24 + +tests/data/dxt1.vbn: TAG = GEN +tests/data/dxt1.vbn: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin -i $(TARGET_SAMPLES)/png1/lena-rgba.png -nostdin -c:v vbn -format dxt1 $(TARGET_PATH)/$@ -y 2>/dev/null + +tests/data/dxt5.vbn: TAG = GEN +tests/data/dxt5.vbn: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin -i $(TARGET_SAMPLES)/png1/lena-rgba.png -nostdin -c:v vbn -format dxt5 $(TARGET_PATH)/$@ -y 2>/dev/null + +tests/data/raw-rgba.vbn: TAG = GEN +tests/data/raw-rgba.vbn: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin -i $(TARGET_SAMPLES)/png1/lena-rgba.png -nostdin -c:v vbn -format raw $(TARGET_PATH)/$@ -y 2>/dev/null + +tests/data/raw-rgb24.vbn: TAG = GEN +tests/data/raw-rgb24.vbn: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin -i $(TARGET_SAMPLES)/png1/lena-rgb24.png -nostdin -c:v vbn -format raw $(TARGET_PATH)/$@ -y 2>/dev/null + +VBN_REFCMP_DEPS = PSNR_FILTER METADATA_FILTER VBN_ENCODER VBN_DECODER IMAGE2_MUXER IMAGE2_DEMUXER PNG_DECODER + +FATE_SAMPLES_FFMPEG-$(call ALLYES, $(VBN_REFCMP_DEPS)) += $(FATE_VBN) +fate-vbn: $(FATE_VBN) diff --git a/tests/ref/fate/vbn-dxt1 b/tests/ref/fate/vbn-dxt1 new file mode 100644 index 0000000000..0af4444d94 --- /dev/null +++ b/tests/ref/fate/vbn-dxt1 @@ -0,0 +1,11 @@ +frame:0 pts:0 pts_time:0 +lavfi.psnr.mse.r=36.794250 +lavfi.psnr.psnr.r=32.473003 +lavfi.psnr.mse.g=33.350525 +lavfi.psnr.psnr.g=32.899776 +lavfi.psnr.mse.b=28.317383 +lavfi.psnr.psnr.b=33.610271 +lavfi.psnr.mse.a=21186.988281 +lavfi.psnr.psnr.a=4.870111 +lavfi.psnr.mse_avg=5321.362793 +lavfi.psnr.psnr_avg=10.870575 diff --git a/tests/ref/fate/vbn-dxt5 b/tests/ref/fate/vbn-dxt5 new file mode 100644 index 0000000000..dbec0bd13d --- /dev/null +++ b/tests/ref/fate/vbn-dxt5 @@ -0,0 +1,11 @@ +frame:0 pts:0 pts_time:0 +lavfi.psnr.mse.r=36.794250 +lavfi.psnr.psnr.r=32.473003 +lavfi.psnr.mse.g=33.350525 +lavfi.psnr.psnr.g=32.899776 +lavfi.psnr.mse.b=28.317383 +lavfi.psnr.psnr.b=33.610271 +lavfi.psnr.mse.a=0.000183 +lavfi.psnr.psnr.a=85.503792 +lavfi.psnr.mse_avg=24.615585 +lavfi.psnr.psnr_avg=34.218700 diff --git a/tests/ref/fate/vbn-raw-rgb24 b/tests/ref/fate/vbn-raw-rgb24 new file mode 100644 index 0000000000..06143c27b6 --- /dev/null +++ b/tests/ref/fate/vbn-raw-rgb24 @@ -0,0 +1,9 @@ +frame:0 pts:0 pts_time:0 +lavfi.psnr.mse.r=0.000000 +lavfi.psnr.psnr.r=inf +lavfi.psnr.mse.g=0.000000 +lavfi.psnr.psnr.g=inf +lavfi.psnr.mse.b=0.000000 +lavfi.psnr.psnr.b=inf +lavfi.psnr.mse_avg=0.000000 +lavfi.psnr.psnr_avg=inf diff --git a/tests/ref/fate/vbn-raw-rgba b/tests/ref/fate/vbn-raw-rgba new file mode 100644 index 0000000000..4614ab5c25 --- /dev/null +++ b/tests/ref/fate/vbn-raw-rgba @@ -0,0 +1,11 @@ +frame:0 pts:0 pts_time:0 +lavfi.psnr.mse.r=0.000000 +lavfi.psnr.psnr.r=inf +lavfi.psnr.mse.g=0.000000 +lavfi.psnr.psnr.g=inf +lavfi.psnr.mse.b=0.000000 +lavfi.psnr.psnr.b=inf +lavfi.psnr.mse.a=0.000000 +lavfi.psnr.psnr.a=inf +lavfi.psnr.mse_avg=0.000000 +lavfi.psnr.psnr_avg=inf