From patchwork Tue Oct 11 17:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn van Beurden X-Patchwork-Id: 34835 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp981206pzb; Tue, 11 Oct 2022 10:25:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6BAzV555EdNnI+PlMKiXXDJm3pp9EiKZsreGcsGy+FK6ATJe+gY5gtsJWVCmvOQDcLiyiu X-Received: by 2002:a17:907:2beb:b0:78d:9b56:12b4 with SMTP id gv43-20020a1709072beb00b0078d9b5612b4mr13537498ejc.237.1665509107362; Tue, 11 Oct 2022 10:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665509107; cv=none; d=google.com; s=arc-20160816; b=qg2yWohORauR1a17/Z8zwBIUZTzbbibL9LBxMETh2yfRWRjK/EjXPdp3vYMkXU0lo+ 79aHVM00+9EeVnKbjZFHjzJF/6lajtI8i6rWOAyKU550GjhnGVvvwFOi+rSgLld9DMqg t6BRbOEO6COqA8teohIzb+6B0tshSrD6D6xAvW/7BegnSCNgEX1pMnn/V2lLwXQZOEJX yRfwOj5ADwDVH4GCBDlexvsPH3jschO6aJ532TlAa8Gu3Gq0OVoilqEc604M8AGQirJz kYirSGytMVSsZJCVU7l7fLE9BYQ0r+SXI8ExjGMhoAGWDhif3IhWCtAZxNXECtUxWhjx t5wQ== 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 :dkim-signature:delivered-to; bh=etw4msrgdgJYD6yiRrAZ6rR0d+B0yQ7ZI+BAXLlV3AM=; b=VoBKb+QIfeyQ1WRoI1g1VVAalSyqF9nnXqgv13CVP2gSd22rE3wMjf9WXmYng5pBh9 35KcotDI7HTQCdsXZ+Owjcx1EcyHq0OUzHD82+4JJnx7AUshHZfyE/nNrCV3OTof3A1g Y5/35toTXUxLJxApOW7M2UfMhAvPSw5A9f1gPcMo3Due90OKTFpRwWWtkccWAKVWzlll QBh4iJYqhM1rfie8iuJUAxhlO5o0bT4vfgAms7rxYAhL6fWlm3q87ZpsiZ4rvAZhV6Q1 NRbFqd7FHbqZF1ZRvUIFHGb8KoLymkLXUFqln/qwo9kDP/oHocEm37GztDUkPPi7B0ej vZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YM3bLeqB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g12-20020a1709065d0c00b0078a4aad3141si14549893ejt.211.2022.10.11.10.25.06; Tue, 11 Oct 2022 10:25:07 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YM3bLeqB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1C7D68BCB0; Tue, 11 Oct 2022 20:25:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A7E5A68B9C6 for ; Tue, 11 Oct 2022 20:24:56 +0300 (EEST) Received: by mail-ed1-f41.google.com with SMTP id e18so21136698edj.3 for ; Tue, 11 Oct 2022 10:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JA1RsQ8ytvto56E0G0ZOKNfFbGLVJtOpyDgNy6wcz+k=; b=YM3bLeqBZfR9OuJ22z69/VU5HSdfS2D/JwxsjJJvnX1IbkF85vS0LwUrLP9z80aoUS NDosMhLQiGy1/LweEhMZDGO6sx3iSDiXPSL6lwRidHbwmpv+W2V4wXIf2MlVd31oT9uo GkkpfObRMV+6aPKnFxl9GZGbKvNE6ejhrnjdkrVup6ttU5q9DzaCmGBSzixJvzqXIwDC 6j1uPGC86gozT15gIvKkH0owln0HlsvHGIyCGXfyscIcZP21KRTTjJTIiezkbvjFpQPB 49QHgyfqQwyuqjN65a2tfGAeTeIl1xpY4OTCzAuI6AsRLbc1TUyEWjazvj7UeCcgrSGv G/Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JA1RsQ8ytvto56E0G0ZOKNfFbGLVJtOpyDgNy6wcz+k=; b=wIkU3ezidsk2BBP0mftFkBqJq7tdCKKdWCA556fD2tf6VsRCRQxnS1Aw0mKVGaIdA4 pPvQyFxGqVoVGOmUNFPiGNOYiLmo3jtFrVM9mSuBgC9mqxDQ8X6HuQMmFbF7OcEz69jm yiaOsQi8oZ21uQez1YF1yUMH8JwyjXuZ6AFMP+LYLQY2TRmtL137aX5wMC6jlk0OTnk8 gQR9JwyJsje+skLD8M483avykpI1Bn/rVSZYEakVkteWaAdrVCi+NEzNwIRtnuYtR+a0 OWXWsFQD3DX04fJMWJsnralfa+O8FlpcIWwdJOWx4FvXaVYObbTsOJNAcrf0gKeTDV2q 3cYw== X-Gm-Message-State: ACrzQf2qcMvwmBYavosLFNAXakZcU2JXNaIcuYOEv5J9wAUIoSHCcfqE IACyZ9eUqxQyo2cohPdFVrt9wIvzcVQ= X-Received: by 2002:a05:6402:4505:b0:451:1551:7b14 with SMTP id ez5-20020a056402450500b0045115517b14mr24248813edb.300.1665509095703; Tue, 11 Oct 2022 10:24:55 -0700 (PDT) Received: from localhost.localdomain (92-64-99-37.biz.kpn.net. [92.64.99.37]) by smtp.googlemail.com with ESMTPSA id jt11-20020a170906ca0b00b0078de26f66b9sm8532ejb.114.2022.10.11.10.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 10:24:54 -0700 (PDT) From: Martijn van Beurden To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Oct 2022 19:24:34 +0200 Message-Id: <20221011172437.36211-1-mvanb1@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 0/3] 32bps FLAC patches 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: Martijn van Beurden Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: X/0DbXNmgTy7 Recently libFLAC gained the ability (first released in FLAC 1.4.0) to create FLAC files containing 32-bit int PCM samples. To keep complexity reasonable, the choice was made to limit residuals to 32-bit integers, which the encoder must make sure of. In case the encoder cannot find any predictor of which the residuals fit this limit, it must default to using a verbatim subframe. Tests have shown that this does not happen often (<0.1% of subframes on a music corpus of various styles). See also discussion here: https://github.com/ietf-wg-cellar/flac-specification/pull/148 These two patches implement decoding and encoding following this format. Changes since v1: fix copy-paste error in encoder, several invocations of lpc_encode_choose_datapath used wrong parameters, making FATE fail as compression was less than it should be Changes since v2: Rebased decoder part as it didn't apply anymore Changes since v3: Moved put_golomb part to flacenc.c (as it is now quite specific to FLAC) and renamed put_sbits64 to put_sbits63 (and changed assert accordingly) Changes since v4: Fix check of decoded_buffer_33bps malloc. Fix reading of wasted bits for 33bps subframe. Add fate test Changes since v5: Slimmed down 32 bps fate flac test from 2 to 1 input file. Replaced -strict -2 with -strict experimental in fate and encoder warning. Changes since v6: Deduplicated function bodies with preprocessor macros in both encoder and decoder, declared variables in loop body where possible and changed ff_ctz to ff_ctzll where necessary Martijn van Beurden (3): libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM libavcodec/flacenc: Implement encoding of 32 bit-per-sample PCM fate/flac: Add test of 32 bps encoding/decoding libavcodec/flac.c | 4 +- libavcodec/flacdec.c | 218 ++++++++++++++++-- libavcodec/flacenc.c | 480 +++++++++++++++++++++++++++++++--------- libavcodec/get_bits.h | 12 + libavcodec/mathops.h | 9 + libavcodec/put_bits.h | 7 + libavcodec/put_golomb.h | 14 -- tests/fate/flac.mak | 4 + 8 files changed, 602 insertions(+), 146 deletions(-)