From patchwork Fri Aug 25 15:13:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43317 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3a86:b0:149:dfde:5c0a with SMTP id d6csp24370pzh; Fri, 25 Aug 2023 08:14:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKgg28/o7SWD2nyUfPMHkTaoxNuqB6aTL7hT+YRoWzDtTbCkVSGu4hu+SeQN6KaNcKtLHO X-Received: by 2002:aa7:dcce:0:b0:522:586d:6f3a with SMTP id w14-20020aa7dcce000000b00522586d6f3amr13260581edu.6.1692976444043; Fri, 25 Aug 2023 08:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692976444; cv=none; d=google.com; s=arc-20160816; b=m/o7nM8jFViAsYtnwO/RFezc2T6SMopZfbh30b7cufQkK2o0UJPMiYa8mtNFANH21D W7IUkAIO4gWc1APZyS+O5iHvefb7stwdmXzs4ZpZ29B1HCHEB92eYWZeY8zjZJURqB/x 3GMGTHFDbpT0/yVyYjCayO9CFs8y3LgsH4be5wGYGcGeGbyGUlVRbqbVWgWfMuw7B59c 2o2uD+Ce1zIAMLizDRY0l3dsswn4zyhnov1MchkF4c1Dzcm+B0EFp4LNteMkLRDiIMEG aKkiTJUXw+MwMhGywkVsmZ5nCO475giWeyH6ZVsCLQcP9OD890Dajj0kbC3a1qGVo1Nj CF0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=7qzM9D1ocdWeyimVrSbnRryMbOw5kDC4eYS9NYJQYdE=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=h2IcyXIRxg7dUjl0bjdg/Dxbflrm0Z034uFCrWw+bCVj1DaTP2tkqi00cg+pkPs30T Y0qsdfHqQskfNQU+mMwq/Cg9GxoNQeGC8FDYWVFlNYNwAhuYOBjVaSJdwcLwYeNGIMuM xfvI8frr0OQyvklSWG2rlhEJxVy/aVbErHXHm1kZTwY5Pwe6hkbWj6ReZS3T9ZR432ug Hm54iHrEm+VQmcA9QHTzY5pRaLqk8Jxe71/AJWoSVGtvMsvW1a8/cS11Anyko9ugAoX9 LAByhBQMubusnhh7RX9L400kYuiIR0FOBwusIYp+ijuw2aAHdowjgXKr6GTlHKA5hHMX 2gwA== 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 x18-20020aa7d6d2000000b005232618b016si1182902edr.208.2023.08.25.08.13.40; Fri, 25 Aug 2023 08:14:04 -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 4D1E668C640; Fri, 25 Aug 2023 18:13:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E755368BD32 for ; Fri, 25 Aug 2023 18:13:29 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4C3D040006 for ; Fri, 25 Aug 2023 15:13:28 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Aug 2023 17:13:27 +0200 Message-Id: <20230825151328.25567-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/apedec: Fix CRC for 24bps and bigendian 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zSqsB4F2VFjm Fixes CRC for vlc.ape and APE_48K_24bit_2CH_02_01.ape Signed-off-by: Michael Niedermayer --- libavcodec/apedec.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 613c76df0b..7bad8500e1 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1625,13 +1625,24 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame, s->samples -= blockstodecode; if (avctx->err_recognition & AV_EF_CRCCHECK && - s->fileversion >= 3900 && s->bps < 24) { + s->fileversion >= 3900) { uint32_t crc = s->CRC_state; const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE); + int stride = s->bps == 24 ? 4 : (s->bps>>3); + int offset = s->bps == 24; + int bytes = s->bps >> 3; + for (i = 0; i < blockstodecode; i++) { for (ch = 0; ch < s->channels; ch++) { - uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3)); - crc = av_crc(crc_tab, crc, smp, s->bps >> 3); +#if HAVE_BIGENDIAN + uint8_t *smp_native = frame->data[ch] + i*stride; + uint8_t smp[4]; + for(int j = 0; jdata[ch] + i*stride; +#endif + crc = av_crc(crc_tab, crc, smp+offset, bytes); } } From patchwork Fri Aug 25 15:13:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43318 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3a86:b0:149:dfde:5c0a with SMTP id d6csp24488pzh; Fri, 25 Aug 2023 08:14:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbnUQFjG8WrcGywBWXSkRpQW7Gmc1ChFsmRGdjoLJuphnUe8WrulN9p6WO+DSqaCvi7ep6 X-Received: by 2002:a17:907:2718:b0:99c:55ac:3a61 with SMTP id w24-20020a170907271800b0099c55ac3a61mr13019989ejk.56.1692976454274; Fri, 25 Aug 2023 08:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692976454; cv=none; d=google.com; s=arc-20160816; b=she+S44nZK5LzqtrIEnIxRQUhnBJ1IzD+srnSBd/O8uOZIdvuzAl7G9/Wwg/AEdq+n EB4vKknUTV8Xu19gwYSpUK4VC9uq3XSszlA73aX+Tkff6QyHJN8h74jQnryri5So/WYm uepP7lmeMdvhZhzYlJK0IO2DMUFy2LT/UO9Go2K72TyNK2wSNozMPSYpT+o4TpAhIosg TE/egfutNQAkj1SR6eThS9RS70R5TJwF7LzWg2I0PYyEA6Z5jbKtl/xu7Yl2/1V6qFSl Lcq0uTBUGCQoXUVMJZ1gMkO3sPjkCEDELMj2y/VJWRylwdayrsjYXBJUp1VItJ5/rMdI Y5bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=oLIxU4gp3UphZEjNhCH9R51yxA7g3FqnZwXt9f2iFck=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=hxqiXv8ZeFSYY+ZYFpFjzHFbQgW5q0go6n5tzsC5NAyWNldZ4IGLXCspfwfVBf/vnR D3vpnNsqU+9HxgFTvqglCu5Gp0C2hXj5vVm+jtL75x1rO5fKgz6y0V693x96jQj6mrga Wsfnf6L3d0LOEi8iyCDpLbXFusyEDN9YPKx+AEwWlMeVyB87uQ3ywPi5T7gcgmwmNE67 vDk6FbUcufm77CyfWAliiJUqL+q8pLSd5ksmWDNz7Df4EKBMYGvBzLSh9d2atEdaOkmf bZMXOqjUCKtfY4de+Hjny3XpExnVFUyQZ8K7vy1ccBpnEy+JD4zZGB4lizRpF+2FHZu1 xXXg== 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 mb9-20020a170906eb0900b0099b4222f51fsi1101440ejb.266.2023.08.25.08.13.51; Fri, 25 Aug 2023 08:14:14 -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 36E2868C65B; Fri, 25 Aug 2023 18:13:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E151768BD32 for ; Fri, 25 Aug 2023 18:13:30 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4145FE0005 for ; Fri, 25 Aug 2023 15:13:29 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Aug 2023 17:13:28 +0200 Message-Id: <20230825151328.25567-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230825151328.25567-1-michael@niedermayer.cc> References: <20230825151328.25567-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: G+gDOev/XxGm Fixes: Ticket9816 Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5. Signed-off-by: Michael Niedermayer --- libavcodec/apedec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 7bad8500e1..b1cceb9395 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1184,7 +1184,9 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count) static av_always_inline int predictor_update_filter(APEPredictor64 *p, const int decoded, const int filter, const int delayA, const int delayB, - const int adaptA, const int adaptB) + const int adaptA, const int adaptB, + int compression_level + ) { int64_t predictionA, predictionB; int32_t sign; @@ -1212,7 +1214,12 @@ static av_always_inline int predictor_update_filter(APEPredictor64 *p, p->buf[delayB - 3] * p->coeffsB[filter][3] + p->buf[delayB - 4] * p->coeffsB[filter][4]; - p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10); + if (compression_level < COMPRESSION_LEVEL_INSANE) { + predictionA = (int32_t)predictionA; + predictionB = (int32_t)predictionB; + p->lastA[filter] = decoded + ((int32_t)(predictionA + (predictionB >> 1)) >> 10); + } else + p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10); p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5); sign = APESIGN(decoded); @@ -1240,10 +1247,10 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count) while (count--) { /* Predictor Y */ *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, - YADAPTCOEFFSA, YADAPTCOEFFSB); + YADAPTCOEFFSA, YADAPTCOEFFSB, ctx->compression_level); decoded0++; *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, - XADAPTCOEFFSA, XADAPTCOEFFSB); + XADAPTCOEFFSA, XADAPTCOEFFSB, ctx->compression_level); decoded1++; /* Combined */