From patchwork Wed Feb 28 12:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 46613 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:aea4:b0:19e:cdac:8cce with SMTP id do36csp348545pzb; Wed, 28 Feb 2024 04:56:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXIIqDQqOrPPIJGm3Vy1zd0oQlhKLnKOltuLi591qOE/K8qLp9I2SV6C1CDrKCPUjD4hDf8fYAKWgZPzcqJXOZSrs55mH4JznfjwA== X-Google-Smtp-Source: AGHT+IGgpRaXzitVBJvVIhUFKst5zrkngD6C6e3FKHiYe1bXUqXu5drr+mrT3ZBbNVjRsl+qoNep X-Received: by 2002:a17:906:134f:b0:a44:1cb4:2e7f with SMTP id x15-20020a170906134f00b00a441cb42e7fmr330854ejb.20.1709124992655; Wed, 28 Feb 2024 04:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709124992; cv=none; d=google.com; s=arc-20160816; b=q6iD6YbGCeIfe1qfMzGYQ4wlv4zEokW+6j7QJ5B3Yp2SsPdxdDlLn63Fni2busQ338 1dcqEHg15G5OolHFhCpcuEMIWqyCtMlvsFjXIVlwixYXEnC4Q6/x3Br/RY4/tD3T9yV2 vSn5a/VtPkiOgUkvZVjeeFzglqL63EZJ2U98rBszXJ/qs5/jfC21hT1xrZDm2bh/tVCQ Adq/QhYStjj7BOSJjitF6Wr0LyrO5mA+LhBIxT7B3u/LhPX3NMsjZIpCVOEXYPqcb35c Op6Nm8KpGteLCZAo1XwIFWjzlaKwcWNjj5olAV4TWXGks5sYxMDeFApWaQCyu/KoxRxE mFlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from:feedback-id :dkim-signature:dkim-signature:delivered-to; bh=8dDUzGsBHlOlCIcZndQkxLJL7+XR36CkXSiVss/n74U=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=HQAQQZuF3j2XosEXhGHmR7RrVrl7XpS82V23cYdTnOw0/Fs3WdGjC8pWw26FWMLISh BJafWtXq1mEDovk5KlE1tispYwRk+N41J70sFcxOrYWNsCgyqkp5bpIZQWggB8h1mLt0 V9NikZytxaTDiZwz+9DeGJOwu0DeFQ5FEkHPuHgo7yadsLzOOBsYeTW5Xi/0Qj0tCwqP 6/d0jie/dcviAAMHp58SSaxD0NnHdDjR6pBF4c7oixmKFqSN0sefeTAIbbFVzEg7eEeE UvAw+fYWPgWo2WMXiCwYXWOR/QPywCsTRHSel4QAEdhD4dGL764zpD0qgAAxavga3UWg OGEw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm2 header.b=OZUnpBy+; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=fgGXsNfy; 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 gt1-20020a170906f20100b00a43195a854esi1732277ejb.45.2024.02.28.04.56.31; Wed, 28 Feb 2024 04:56:32 -0800 (PST) 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=@itanimul.li header.s=fm2 header.b=OZUnpBy+; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=fgGXsNfy; 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 AC41B68C891; Wed, 28 Feb 2024 14:56:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1DD068C704 for ; Wed, 28 Feb 2024 14:56:20 +0200 (EET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1D92B5C0318 for ; Wed, 28 Feb 2024 07:56:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Feb 2024 07:56:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1709124979; x=1709211379; bh=n18fcKEZOt TMqIyasD9lfwZCUojoqHkMbUpigKmLqzY=; b=OZUnpBy+UVmVSXEx7oHaTwXwAt DPLHm3m9nfXCg7FZehHvq7SuXCQb7jgztKpOEUOb9Ky/qtv2vtVp4xDlMKOzi8xI uxfaFtqxIzpQzRSjOvAaiKUS5SFx2XF7g0Rh0JOkM9bwHjbHZexBfhzu8gV/FrLS tqSyS6dgNqv0ClYh6WSg0gVf2WLqyZcYfi2WPKrx0HZV18onmrw6jjs8zfrMzsmc cvBtt5orDmvK0oo15EfMYv3Do3Dbw7Yp0KVnPaDdyra3vanp1CGCdmvy4z9P+xKm u98lCjSV3LtuY/rror/EJOTEsuyZUSM//MFoyr0qlLYngDJynIvjv3DETUxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1709124979; x=1709211379; bh=n18fcKEZOtTMqIyasD9lfwZCUojo qHkMbUpigKmLqzY=; b=fgGXsNfyFMsEAMOIcei3p2MVlNcYBLSCnBem5tHqIct/ Lmk3sDFiC/Z4WT7L7+3PyvC7w6vAtvokI0xgLn6/CF6jWBSFse0gHtoMtj2xF0WC FnOI/yzoaGhGWVcEqUGgkqzv7ykr82gb93Nynxzeluoz2hwej6u18gEpf5LWxiAJ 2dMXDbgQRRcOGl91Hqqxo5+pb9+gWZ28seshV5QUBJ7rM8dxstFMUCWwi6d/3Tq9 TC1Pgx0D9gNIvuqFsq1LslKHqYxO4+xNYPbCqHmaJKyCPtmZjtBOyHAkIB9qzP23 DrwCZoUahPa5GQL9o2BQH1Af5UWx3eCw1OIIc2Bv5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrgeejgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffogggtgfesthekredtre dtjeenucfhrhhomhepfdflrdcuffgvkhhkvghrfdcuoehjuggvkhesihhtrghnihhmuhhl rdhliheqnecuggftrfgrthhtvghrnhepleefgeetheekvddvgedviedvudeltefhvdfhle etkeehkeeludejteeikeefleevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepjhguvghksehithgrnhhimhhulhdrlhhi X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 28 Feb 2024 07:56:18 -0500 (EST) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Feb 2024 13:56:09 +0100 Message-ID: <20240228125616.458327-1-jdek@itanimul.li> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] MAINTAINERS: remove inactive developer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5688KR4spRC3 Inactive since 2007. Signed-off-by: J. Dekker --- MAINTAINERS | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index cc7f564f48..ace58f02a1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -148,7 +148,6 @@ Codecs: cinepak.c Roberto Togni cinepakenc.c Rl / Aetey G.T. AB ccaption_dec.c Anshul Maheshwari, Aman Gupta - cljr Alex Beregszaszi cpia.c Stephan Hilb cscd.c Reimar Doeffinger cuviddec.c Timo Rothenpieler @@ -230,13 +229,12 @@ Codecs: rv10.c Michael Niedermayer smc.c Mike Melanson snow* Michael Niedermayer, Loren Merritt - sonic.c Alex Beregszaszi speedhq.c Steinar H. Gunderson srt* Aurelien Jacobs sunrast.c Ivo van Poorten svq3.c Michael Niedermayer truemotion1* Mike Melanson - tta.c Alex Beregszaszi, Jaikrishnan Menon + tta.c Jaikrishnan Menon txd.c Ivo van Poorten v4l2_* Jorge Ramirez-Ortiz vc2* Rostislav Pehlivanov @@ -446,7 +444,6 @@ Muxers/Demuxers: spdif* Anssi Hannula srtdec.c Aurelien Jacobs swf.c Baptiste Coudurier - tta.c Alex Beregszaszi txd.c Ivo van Poorten voc.c Aurelien Jacobs wav.c Michael Niedermayer @@ -493,7 +490,7 @@ Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier Amiga / PowerPC Colin Ward Linux / PowerPC Lauri Kasanen RISC-V RĂ©mi Denis-Courmont -Windows MinGW Alex Beregszaszi, Ramiro Polla +Windows MinGW Ramiro Polla Windows Cygwin Victor Paesa Windows MSVC Hendrik Leppkes ADI/Blackfin DSP Marc Hoffman From patchwork Wed Feb 28 12:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 46614 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:aea4:b0:19e:cdac:8cce with SMTP id do36csp348605pzb; Wed, 28 Feb 2024 04:56:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX+t/NkP9kGpVOhqFa1OAnHPgN9Sn2FWNlrtUObYb7Tpy23tPTuhzLJmri1zifz9bv/4r3XYdXtMiuF++Rt1RddRPGqOp6oYRixFA== X-Google-Smtp-Source: AGHT+IH/t9jp3QuZvxwb25SXW1u5QQ1J1mUw1Llx6Bks2OzrQB1KVYHyFaqrNmCwnrTuhacCKUu2 X-Received: by 2002:a17:906:6805:b0:a44:12b9:3762 with SMTP id k5-20020a170906680500b00a4412b93762mr740692ejr.10.1709125004164; Wed, 28 Feb 2024 04:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709125004; cv=none; d=google.com; s=arc-20160816; b=qWeV9m8+M3VhFhdY3ilNYUk83mW4AKST2SZx+6nuWnwEaO08JSV0QGcNBO/X3iEhZa 4dumGWY6wcFMer5/o7q/ZjwLlTRADqC6VaFKyXo1LUms9bi0In8gfk8yon0/K6fondSo sl2HvUfmpxJSRGV436Wlb8vlqHPRYEcx/jTdAAh8gliIqKxSkFwtZHe9+K8vOkJEhK7u mst5VgLMAl7iTYziTLk0/WmZP2G5AHAiIHeFKSNrtjkUishZApwEL25IkHjAchVxZ/fl gKGNUF+Xz/N9rTLQi2Vb94ugKWQsL2YduzenjG7DvESk8R4jn1X4jshtk57//KvbwpOx BmPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:feedback-id:dkim-signature:dkim-signature:delivered-to; bh=nC0cBedyOLAn2QWKsH29GrZ/leKtp7DYhGHXBFIhlLA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=JRr4FA4WIPi/eeo6Ck1btwHiLvwQVPR/pgp7vXovvBumOCKlkmglsTPSvwRvtof4i/ APIl+YdMEVhAt14PoFgVPqDsmJozIeuDBA7P/mxXf2vZRLH20Q1hvV/GtpHAsW5iSNlS 01osxQQDegS0SG+rjAFZacy9Emkhg0UlIqcI32HM2AY0/H+o2RcUQDXXu/d4USTd5RdH OQMGUL1FNHsMcy1GGBamM6InsBuoibXz4grZ2U+1zkPkcmlHY7u7F+n6IeVQMN5zO+0C lPJfWvpQmbc3V5lhtRW1njQWe8cGQbLj7oJ55wpz5CzgjComq1k1Yg38rm5LEjf47XPp fpvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm2 header.b=Hfon3Xu1; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=RnBGH7Ye; 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 q15-20020a170906388f00b00a43f9486487si609846ejd.423.2024.02.28.04.56.43; Wed, 28 Feb 2024 04:56:44 -0800 (PST) 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=@itanimul.li header.s=fm2 header.b=Hfon3Xu1; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=RnBGH7Ye; 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 EABD568CA4D; Wed, 28 Feb 2024 14:56:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33E6D68C891 for ; Wed, 28 Feb 2024 14:56:22 +0200 (EET) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F1BAA1140162 for ; Wed, 28 Feb 2024 07:56:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 28 Feb 2024 07:56:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1709124980; x= 1709211380; bh=rZ7O3uCgmQBIhjV1jYXya40GBN8ku3JuQqTa5UXxaWU=; b=H fon3Xu1kXZcqo2uRv/TdgOq/WFkjk/QncLN2xSbSbX+o4yZCtR/z0NRWYfEv6Akc kYceSIjfk3kd8hx4f81FwLsgcK6shu8BDJMp+sld4CIi2ROR6CHh5iJIWRKdZ4S7 qmHEL1ICC7KjJUy4CFqedhBPN4B4xpKSlDPs/AhxtkIgBGt1SH110D4qCEzjlAem mBscOnFXuDffuDU7f9nwOOg9h/57GJWHEekWX65XJ5Nngux42N7+DuyTMOyKpy8J 0Ox6EH9F3MYfiRvi5BNS8hvut+HFvFgQE6OE9fuYlkJJYKzDYFyRjNWUsI6xyG8f 9EVWL99Y+OavOa6lP80Iw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1709124980; x=1709211380; bh=rZ7O3uCgmQBIh jV1jYXya40GBN8ku3JuQqTa5UXxaWU=; b=RnBGH7Ye1gV9X8QsuaOj1JgAlxsHu p3VkFMmZp6likrexbSm/Xv31O9vVhAzx9XBL1RzRDhhCX+prgknllpxGJ457FQs2 10w329rfPSApsAMKw07ybXPERBX1parMQySkRDhYhm8yt1QNGdky9mWZhd6IDm/l XuZSmoJ8QLdvFohC+BnHR8ZUMOJzkB5DMzW/JBFKL1cR6EVHg2uoHT8s748NOZlj iRpZonnZVdiQqUmCS+qYIi1/gLpk7oAepQaF2gZ2ph4o+mG80eXYeagz2v1SHm9e T0CzaX0RA6I/MQm5t49906vxyaPNMJZDY5AS5f84x7OX6289D9sWX0++Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrgeejgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhimhhu lhdrlhhiqeenucggtffrrghtthgvrhhnpeevieekuedvudfhhfetheeujeeftdetteehle ethfegvedvgedukeeuuedvgffgveenucffohhmrghinheplhhoghgrrhhithhhmhhitgdr nhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hjuggvkhesihhtrghnihhmuhhlrdhlih X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 28 Feb 2024 07:56:20 -0500 (EST) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Feb 2024 13:56:10 +0100 Message-ID: <20240228125616.458327-2-jdek@itanimul.li> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228125616.458327-1-jdek@itanimul.li> References: <20240228125616.458327-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec: remove sonic lossy/lossless audio X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nTQzKAVlKgUd This was an experimental/research codec of which ffmpeg is the only encoder and decoder, development has stalled and these files don't exist in the wild. Signed-off-by: J. Dekker --- Changelog | 1 + configure | 3 - libavcodec/Makefile | 3 - libavcodec/allcodecs.c | 3 - libavcodec/codec_desc.c | 14 - libavcodec/sonic.c | 1125 --------------------------------------- 6 files changed, 1 insertion(+), 1148 deletions(-) delete mode 100644 libavcodec/sonic.c diff --git a/Changelog b/Changelog index 610ee61dd6..e2096f249a 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ version : - a C11-compliant compiler is now required; note that this requirement will be bumped to C17 in the near future, so consider updating your build environment if it lacks C17 support +- sonic lossy/lossless audio codec removed version 6.1: - libaribcaption decoder diff --git a/configure b/configure index bb5e630bad..e639a5e2b7 100755 --- a/configure +++ b/configure @@ -2991,9 +2991,6 @@ sipr_decoder_select="lsp" smvjpeg_decoder_select="mjpeg_decoder" snow_decoder_select="dwt h264qpel rangecoder videodsp" snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder videodsp" -sonic_decoder_select="golomb rangecoder" -sonic_encoder_select="golomb rangecoder" -sonic_ls_encoder_select="golomb rangecoder" sp5x_decoder_select="mjpeg_decoder" speedhq_decoder_select="blockdsp idctdsp" speedhq_encoder_select="mpegvideoenc" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 09ae5270b3..3fc716ee68 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -687,9 +687,6 @@ OBJS-$(CONFIG_SNOW_DECODER) += snowdec.o snow.o snow_dwt.o OBJS-$(CONFIG_SNOW_ENCODER) += snowenc.o snow.o snow_dwt.o \ h263.o h263data.o ituh263enc.o OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o -OBJS-$(CONFIG_SONIC_DECODER) += sonic.o -OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o -OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhqdec.o speedhq.o mpeg12.o \ mpeg12data.o OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o mpeg12enc.o speedhqenc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ef8c3a6d7d..e0a4a5421d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -535,9 +535,6 @@ extern const FFCodec ff_shorten_decoder; extern const FFCodec ff_sipr_decoder; extern const FFCodec ff_siren_decoder; extern const FFCodec ff_smackaud_decoder; -extern const FFCodec ff_sonic_encoder; -extern const FFCodec ff_sonic_decoder; -extern const FFCodec ff_sonic_ls_encoder; extern const FFCodec ff_tak_decoder; extern const FFCodec ff_truehd_encoder; extern const FFCodec ff_truehd_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 033344304c..9b456616be 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3175,20 +3175,6 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Wave synthesis pseudo-codec"), .props = AV_CODEC_PROP_INTRA_ONLY, }, - { - .id = AV_CODEC_ID_SONIC, - .type = AVMEDIA_TYPE_AUDIO, - .name = "sonic", - .long_name = NULL_IF_CONFIG_SMALL("Sonic"), - .props = AV_CODEC_PROP_INTRA_ONLY, - }, - { - .id = AV_CODEC_ID_SONIC_LS, - .type = AVMEDIA_TYPE_AUDIO, - .name = "sonicls", - .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"), - .props = AV_CODEC_PROP_INTRA_ONLY, - }, { .id = AV_CODEC_ID_EVRC, .type = AVMEDIA_TYPE_AUDIO, diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c deleted file mode 100644 index 0544fecf46..0000000000 --- a/libavcodec/sonic.c +++ /dev/null @@ -1,1125 +0,0 @@ -/* - * Simple free lossless/lossy audio codec - * Copyright (c) 2004 Alex Beregszaszi - * - * 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 - */ - -#include "config_components.h" - -#include "avcodec.h" -#include "codec_internal.h" -#include "decode.h" -#include "encode.h" -#include "get_bits.h" -#include "golomb.h" -#include "put_golomb.h" -#include "rangecoder.h" - - -/** - * @file - * Simple free lossless/lossy audio codec - * Based on Paul Francis Harrison's Bonk (http://www.logarithmic.net/pfh/bonk) - * Written and designed by Alex Beregszaszi - * - * TODO: - * - CABAC put/get_symbol - * - independent quantizer for channels - * - >2 channels support - * - more decorrelation types - * - more tap_quant tests - * - selectable intlist writers/readers (bonk-style, golomb, cabac) - */ - -#define MAX_CHANNELS 2 - -#define MID_SIDE 0 -#define LEFT_SIDE 1 -#define RIGHT_SIDE 2 - -typedef struct SonicContext { - int version; - int minor_version; - int lossless, decorrelation; - - int num_taps, downsampling; - double quantization; - - int channels, samplerate, block_align, frame_size; - - int *tap_quant; - int *int_samples; - int *coded_samples[MAX_CHANNELS]; - - // for encoding - int *tail; - int tail_size; - int *window; - int window_size; - - // for decoding - int *predictor_k; - int *predictor_state[MAX_CHANNELS]; -} SonicContext; - -#define LATTICE_SHIFT 10 -#define SAMPLE_SHIFT 4 -#define LATTICE_FACTOR (1 << LATTICE_SHIFT) -#define SAMPLE_FACTOR (1 << SAMPLE_SHIFT) - -#define BASE_QUANT 0.6 -#define RATE_VARIATION 3.0 - -static inline int shift(int a,int b) -{ - return (a+(1<<(b-1))) >> b; -} - -static inline int shift_down(int a,int b) -{ - return (a>>b)+(a<0); -} - -static av_always_inline av_flatten void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed, uint64_t rc_stat[256][2], uint64_t rc_stat2[32][2]){ - int i; - -#define put_rac(C,S,B) \ -do{\ - if(rc_stat){\ - rc_stat[*(S)][B]++;\ - rc_stat2[(S)-state][B]++;\ - }\ - put_rac(C,S,B);\ -}while(0) - - if(v){ - const int a= FFABS(v); - const int e= av_log2(a); - put_rac(c, state+0, 0); - if(e<=9){ - for(i=0; i=0; i--){ - put_rac(c, state+22+i, (a>>i)&1); //22..31 - } - - if(is_signed) - put_rac(c, state+11 + e, v < 0); //11..21 - }else{ - for(i=0; i=0; i--){ - put_rac(c, state+22+FFMIN(i,9), (a>>i)&1); //22..31 - } - - if(is_signed) - put_rac(c, state+11 + 10, v < 0); //11..21 - } - }else{ - put_rac(c, state+0, 1); - } -#undef put_rac -} - -static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ - if(get_rac(c, state+0)) - return 0; - else{ - int i, e; - unsigned a; - e= 0; - while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10 - e++; - if (e > 31) - return AVERROR_INVALIDDATA; - } - - a= 1; - for(i=e-1; i>=0; i--){ - a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31 - } - - e= -(is_signed && get_rac(c, state+11 + FFMIN(e, 10))); //11..21 - return (a^e)-e; - } -} - -#if 1 -static inline int intlist_write(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - put_symbol(c, state, buf[i], 1, NULL, NULL); - - return 1; -} - -static inline int intlist_read(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - buf[i] = get_symbol(c, state, 1); - - return 1; -} -#elif 1 -static inline int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - set_se_golomb(pb, buf[i]); - - return 1; -} - -static inline int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - buf[i] = get_se_golomb(gb); - - return 1; -} - -#else - -#define ADAPT_LEVEL 8 - -static int bits_to_store(uint64_t x) -{ - int res = 0; - - while(x) - { - res++; - x >>= 1; - } - return res; -} - -static void write_uint_max(PutBitContext *pb, unsigned int value, unsigned int max) -{ - int i, bits; - - if (!max) - return; - - bits = bits_to_store(max); - - for (i = 0; i < bits-1; i++) - put_bits(pb, 1, value & (1 << i)); - - if ( (value | (1 << (bits-1))) <= max) - put_bits(pb, 1, value & (1 << (bits-1))); -} - -static unsigned int read_uint_max(GetBitContext *gb, int max) -{ - int i, bits, value = 0; - - if (!max) - return 0; - - bits = bits_to_store(max); - - for (i = 0; i < bits-1; i++) - if (get_bits1(gb)) - value += 1 << i; - - if ( (value | (1<<(bits-1))) <= max) - if (get_bits1(gb)) - value += 1 << (bits-1); - - return value; -} - -static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) -{ - int i, j, x = 0, low_bits = 0, max = 0; - int step = 256, pos = 0, dominant = 0, any = 0; - int *copy, *bits; - - copy = av_calloc(entries, sizeof(*copy)); - if (!copy) - return AVERROR(ENOMEM); - - if (base_2_part) - { - int energy = 0; - - for (i = 0; i < entries; i++) - energy += abs(buf[i]); - - low_bits = bits_to_store(energy / (entries * 2)); - if (low_bits > 15) - low_bits = 15; - - put_bits(pb, 4, low_bits); - } - - for (i = 0; i < entries; i++) - { - put_bits(pb, low_bits, abs(buf[i])); - copy[i] = abs(buf[i]) >> low_bits; - if (copy[i] > max) - max = abs(copy[i]); - } - - bits = av_calloc(entries*max, sizeof(*bits)); - if (!bits) - { - av_free(copy); - return AVERROR(ENOMEM); - } - - for (i = 0; i <= max; i++) - { - for (j = 0; j < entries; j++) - if (copy[j] >= i) - bits[x++] = copy[j] > i; - } - - // store bitstream - while (pos < x) - { - int steplet = step >> 8; - - if (pos + steplet > x) - steplet = x - pos; - - for (i = 0; i < steplet; i++) - if (bits[i+pos] != dominant) - any = 1; - - put_bits(pb, 1, any); - - if (!any) - { - pos += steplet; - step += step / ADAPT_LEVEL; - } - else - { - int interloper = 0; - - while (((pos + interloper) < x) && (bits[pos + interloper] == dominant)) - interloper++; - - // note change - write_uint_max(pb, interloper, (step >> 8) - 1); - - pos += interloper + 1; - step -= step / ADAPT_LEVEL; - } - - if (step < 256) - { - step = 65536 / step; - dominant = !dominant; - } - } - - // store signs - for (i = 0; i < entries; i++) - if (buf[i]) - put_bits(pb, 1, buf[i] < 0); - - av_free(bits); - av_free(copy); - - return 0; -} - -static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) -{ - int i, low_bits = 0, x = 0; - int n_zeros = 0, step = 256, dominant = 0; - int pos = 0, level = 0; - int *bits = av_calloc(entries, sizeof(*bits)); - - if (!bits) - return AVERROR(ENOMEM); - - if (base_2_part) - { - low_bits = get_bits(gb, 4); - - if (low_bits) - for (i = 0; i < entries; i++) - buf[i] = get_bits(gb, low_bits); - } - -// av_log(NULL, AV_LOG_INFO, "entries: %d, low bits: %d\n", entries, low_bits); - - while (n_zeros < entries) - { - int steplet = step >> 8; - - if (!get_bits1(gb)) - { - for (i = 0; i < steplet; i++) - bits[x++] = dominant; - - if (!dominant) - n_zeros += steplet; - - step += step / ADAPT_LEVEL; - } - else - { - int actual_run = read_uint_max(gb, steplet-1); - -// av_log(NULL, AV_LOG_INFO, "actual run: %d\n", actual_run); - - for (i = 0; i < actual_run; i++) - bits[x++] = dominant; - - bits[x++] = !dominant; - - if (!dominant) - n_zeros += actual_run; - else - n_zeros++; - - step -= step / ADAPT_LEVEL; - } - - if (step < 256) - { - step = 65536 / step; - dominant = !dominant; - } - } - - // reconstruct unsigned values - n_zeros = 0; - for (i = 0; n_zeros < entries; i++) - { - while(1) - { - if (pos >= entries) - { - pos = 0; - level += 1 << low_bits; - } - - if (buf[pos] >= level) - break; - - pos++; - } - - if (bits[i]) - buf[pos] += 1 << low_bits; - else - n_zeros++; - - pos++; - } - av_free(bits); - - // read signs - for (i = 0; i < entries; i++) - if (buf[i] && get_bits1(gb)) - buf[i] = -buf[i]; - -// av_log(NULL, AV_LOG_INFO, "zeros: %d pos: %d\n", n_zeros, pos); - - return 0; -} -#endif - -static void predictor_init_state(int *k, int *state, int order) -{ - int i; - - for (i = order-2; i >= 0; i--) - { - int j, p, x = state[i]; - - for (j = 0, p = i+1; p < order; j++,p++) - { - int tmp = x + shift_down(k[j] * (unsigned)state[p], LATTICE_SHIFT); - state[p] += shift_down(k[j]* (unsigned)x, LATTICE_SHIFT); - x = tmp; - } - } -} - -static int predictor_calc_error(int *k, int *state, int order, int error) -{ - int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT); - -#if 1 - int *k_ptr = &(k[order-2]), - *state_ptr = &(state[order-2]); - for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) - { - int k_value = *k_ptr, state_value = *state_ptr; - x -= (unsigned)shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT); - state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT); - } -#else - for (i = order-2; i >= 0; i--) - { - x -= (unsigned)shift_down(k[i] * state[i], LATTICE_SHIFT); - state[i+1] = state[i] + shift_down(k[i] * x, LATTICE_SHIFT); - } -#endif - - // don't drift too far, to avoid overflows - if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16); - if (x < -(SAMPLE_FACTOR<<16)) x = -(SAMPLE_FACTOR<<16); - - state[0] = x; - - return x; -} - -#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER -// Heavily modified Levinson-Durbin algorithm which -// copes better with quantization, and calculates the -// actual whitened result as it goes. - -static void modified_levinson_durbin(int *window, int window_entries, - int *out, int out_entries, int channels, int *tap_quant) -{ - int i; - int *state = window + window_entries; - - memcpy(state, window, window_entries * sizeof(*state)); - - for (i = 0; i < out_entries; i++) - { - int step = (i+1)*channels, k, j; - double xx = 0.0, xy = 0.0; -#if 1 - int *x_ptr = &(window[step]); - int *state_ptr = &(state[0]); - j = window_entries - step; - for (;j>0;j--,x_ptr++,state_ptr++) - { - double x_value = *x_ptr; - double state_value = *state_ptr; - xx += state_value*state_value; - xy += x_value*state_value; - } -#else - for (j = 0; j <= (window_entries - step); j++); - { - double stepval = window[step+j]; - double stateval = window[j]; -// xx += (double)window[j]*(double)window[j]; -// xy += (double)window[step+j]*(double)window[j]; - xx += stateval*stateval; - xy += stepval*stateval; - } -#endif - if (xx == 0.0) - k = 0; - else - k = (int)(floor(-xy/xx * (double)LATTICE_FACTOR / (double)(tap_quant[i]) + 0.5)); - - if (k > (LATTICE_FACTOR/tap_quant[i])) - k = LATTICE_FACTOR/tap_quant[i]; - if (-k > (LATTICE_FACTOR/tap_quant[i])) - k = -(LATTICE_FACTOR/tap_quant[i]); - - out[i] = k; - k *= tap_quant[i]; - -#if 1 - x_ptr = &(window[step]); - state_ptr = &(state[0]); - j = window_entries - step; - for (;j>0;j--,x_ptr++,state_ptr++) - { - int x_value = *x_ptr; - int state_value = *state_ptr; - *x_ptr = x_value + shift_down(k*state_value,LATTICE_SHIFT); - *state_ptr = state_value + shift_down(k*x_value, LATTICE_SHIFT); - } -#else - for (j=0; j <= (window_entries - step); j++) - { - int stepval = window[step+j]; - int stateval=state[j]; - window[step+j] += shift_down(k * stateval, LATTICE_SHIFT); - state[j] += shift_down(k * stepval, LATTICE_SHIFT); - } -#endif - } -} - -static inline int code_samplerate(int samplerate) -{ - switch (samplerate) - { - case 44100: return 0; - case 22050: return 1; - case 11025: return 2; - case 96000: return 3; - case 48000: return 4; - case 32000: return 5; - case 24000: return 6; - case 16000: return 7; - case 8000: return 8; - } - return AVERROR(EINVAL); -} - -static av_cold int sonic_encode_init(AVCodecContext *avctx) -{ - SonicContext *s = avctx->priv_data; - int *coded_samples; - PutBitContext pb; - int i; - - s->version = 2; - - if (avctx->ch_layout.nb_channels > MAX_CHANNELS) - { - av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); - return AVERROR(EINVAL); /* only stereo or mono for now */ - } - - if (avctx->ch_layout.nb_channels == 2) - s->decorrelation = MID_SIDE; - else - s->decorrelation = 3; - - if (avctx->codec->id == AV_CODEC_ID_SONIC_LS) - { - s->lossless = 1; - s->num_taps = 32; - s->downsampling = 1; - s->quantization = 0.0; - } - else - { - s->num_taps = 128; - s->downsampling = 2; - s->quantization = 1.0; - } - - // max tap 2048 - if (s->num_taps < 32 || s->num_taps > 1024 || s->num_taps % 32) { - av_log(avctx, AV_LOG_ERROR, "Invalid number of taps\n"); - return AVERROR_INVALIDDATA; - } - - // generate taps - s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant)); - if (!s->tap_quant) - return AVERROR(ENOMEM); - - for (i = 0; i < s->num_taps; i++) - s->tap_quant[i] = ff_sqrt(i+1); - - s->channels = avctx->ch_layout.nb_channels; - s->samplerate = avctx->sample_rate; - - s->block_align = 2048LL*s->samplerate/(44100*s->downsampling); - s->frame_size = s->channels*s->block_align*s->downsampling; - - s->tail_size = s->num_taps*s->channels; - s->tail = av_calloc(s->tail_size, sizeof(*s->tail)); - if (!s->tail) - return AVERROR(ENOMEM); - - s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k) ); - if (!s->predictor_k) - return AVERROR(ENOMEM); - - coded_samples = av_calloc(s->block_align, s->channels * sizeof(**s->coded_samples)); - if (!coded_samples) - return AVERROR(ENOMEM); - for (i = 0; i < s->channels; i++, coded_samples += s->block_align) - s->coded_samples[i] = coded_samples; - - s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples)); - - s->window_size = ((2*s->tail_size)+s->frame_size); - s->window = av_calloc(s->window_size, 2 * sizeof(*s->window)); - if (!s->window || !s->int_samples) - return AVERROR(ENOMEM); - - avctx->extradata = av_mallocz(16); - if (!avctx->extradata) - return AVERROR(ENOMEM); - init_put_bits(&pb, avctx->extradata, 16*8); - - put_bits(&pb, 2, s->version); // version - if (s->version >= 1) - { - if (s->version >= 2) { - put_bits(&pb, 8, s->version); - put_bits(&pb, 8, s->minor_version); - } - put_bits(&pb, 2, s->channels); - put_bits(&pb, 4, code_samplerate(s->samplerate)); - } - put_bits(&pb, 1, s->lossless); - if (!s->lossless) - put_bits(&pb, 3, SAMPLE_SHIFT); // XXX FIXME: sample precision - put_bits(&pb, 2, s->decorrelation); - put_bits(&pb, 2, s->downsampling); - put_bits(&pb, 5, (s->num_taps >> 5)-1); // 32..1024 - put_bits(&pb, 1, 0); // XXX FIXME: no custom tap quant table - - flush_put_bits(&pb); - avctx->extradata_size = put_bytes_output(&pb); - - av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n", - s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling); - - avctx->frame_size = s->block_align*s->downsampling; - - return 0; -} - -static av_cold int sonic_encode_close(AVCodecContext *avctx) -{ - SonicContext *s = avctx->priv_data; - - av_freep(&s->coded_samples[0]); - av_freep(&s->predictor_k); - av_freep(&s->tail); - av_freep(&s->tap_quant); - av_freep(&s->window); - av_freep(&s->int_samples); - - return 0; -} - -static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet_ptr) -{ - SonicContext *s = avctx->priv_data; - RangeCoder c; - int i, j, ch, quant = 0, x = 0; - int ret; - const short *samples = (const int16_t*)frame->data[0]; - uint8_t state[32]; - - if ((ret = ff_alloc_packet(avctx, avpkt, s->frame_size * 5 + 1000)) < 0) - return ret; - - ff_init_range_encoder(&c, avpkt->data, avpkt->size); - ff_build_rac_states(&c, 0.05*(1LL<<32), 256-8); - memset(state, 128, sizeof(state)); - - // short -> internal - for (i = 0; i < s->frame_size; i++) - s->int_samples[i] = samples[i]; - - if (!s->lossless) - for (i = 0; i < s->frame_size; i++) - s->int_samples[i] = s->int_samples[i] << SAMPLE_SHIFT; - - switch(s->decorrelation) - { - case MID_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - { - s->int_samples[i] += s->int_samples[i+1]; - s->int_samples[i+1] -= shift(s->int_samples[i], 1); - } - break; - case LEFT_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - s->int_samples[i+1] -= s->int_samples[i]; - break; - case RIGHT_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - s->int_samples[i] -= s->int_samples[i+1]; - break; - } - - memset(s->window, 0, s->window_size * sizeof(*s->window)); - - for (i = 0; i < s->tail_size; i++) - s->window[x++] = s->tail[i]; - - for (i = 0; i < s->frame_size; i++) - s->window[x++] = s->int_samples[i]; - - for (i = 0; i < s->tail_size; i++) - s->window[x++] = 0; - - for (i = 0; i < s->tail_size; i++) - s->tail[i] = s->int_samples[s->frame_size - s->tail_size + i]; - - // generate taps - modified_levinson_durbin(s->window, s->window_size, - s->predictor_k, s->num_taps, s->channels, s->tap_quant); - - if ((ret = intlist_write(&c, state, s->predictor_k, s->num_taps, 0)) < 0) - return ret; - - for (ch = 0; ch < s->channels; ch++) - { - x = s->tail_size+ch; - for (i = 0; i < s->block_align; i++) - { - int sum = 0; - for (j = 0; j < s->downsampling; j++, x += s->channels) - sum += s->window[x]; - s->coded_samples[ch][i] = sum; - } - } - - // simple rate control code - if (!s->lossless) - { - double energy1 = 0.0, energy2 = 0.0; - for (ch = 0; ch < s->channels; ch++) - { - for (i = 0; i < s->block_align; i++) - { - double sample = s->coded_samples[ch][i]; - energy2 += sample*sample; - energy1 += fabs(sample); - } - } - - energy2 = sqrt(energy2/(s->channels*s->block_align)); - energy1 = M_SQRT2*energy1/(s->channels*s->block_align); - - // increase bitrate when samples are like a gaussian distribution - // reduce bitrate when samples are like a two-tailed exponential distribution - - if (energy2 > energy1) - energy2 += (energy2-energy1)*RATE_VARIATION; - - quant = (int)(BASE_QUANT*s->quantization*energy2/SAMPLE_FACTOR); -// av_log(avctx, AV_LOG_DEBUG, "quant: %d energy: %f / %f\n", quant, energy1, energy2); - - quant = av_clip(quant, 1, 65534); - - put_symbol(&c, state, quant, 0, NULL, NULL); - - quant *= SAMPLE_FACTOR; - } - - // write out coded samples - for (ch = 0; ch < s->channels; ch++) - { - if (!s->lossless) - for (i = 0; i < s->block_align; i++) - s->coded_samples[ch][i] = ROUNDED_DIV(s->coded_samples[ch][i], quant); - - if ((ret = intlist_write(&c, state, s->coded_samples[ch], s->block_align, 1)) < 0) - return ret; - } - - avpkt->size = ff_rac_terminate(&c, 0); - *got_packet_ptr = 1; - return 0; - -} -#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */ - -#if CONFIG_SONIC_DECODER -static const int samplerate_table[] = - { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 }; - -static av_cold int sonic_decode_init(AVCodecContext *avctx) -{ - SonicContext *s = avctx->priv_data; - int *tmp; - GetBitContext gb; - int i; - int ret; - - s->channels = avctx->ch_layout.nb_channels; - s->samplerate = avctx->sample_rate; - - if (!avctx->extradata) - { - av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n"); - return AVERROR_INVALIDDATA; - } - - ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size); - if (ret < 0) - return ret; - - s->version = get_bits(&gb, 2); - if (s->version >= 2) { - s->version = get_bits(&gb, 8); - s->minor_version = get_bits(&gb, 8); - } - if (s->version != 2) - { - av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n"); - return AVERROR_INVALIDDATA; - } - - if (s->version >= 1) - { - int sample_rate_index; - s->channels = get_bits(&gb, 2); - sample_rate_index = get_bits(&gb, 4); - if (sample_rate_index >= FF_ARRAY_ELEMS(samplerate_table)) { - av_log(avctx, AV_LOG_ERROR, "Invalid sample_rate_index %d\n", sample_rate_index); - return AVERROR_INVALIDDATA; - } - s->samplerate = samplerate_table[sample_rate_index]; - av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n", - s->channels, s->samplerate); - } - - if (s->channels > MAX_CHANNELS || s->channels < 1) - { - av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); - return AVERROR_INVALIDDATA; - } - av_channel_layout_uninit(&avctx->ch_layout); - avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; - avctx->ch_layout.nb_channels = s->channels; - - s->lossless = get_bits1(&gb); - if (!s->lossless) - skip_bits(&gb, 3); // XXX FIXME - s->decorrelation = get_bits(&gb, 2); - if (s->decorrelation != 3 && s->channels != 2) { - av_log(avctx, AV_LOG_ERROR, "invalid decorrelation %d\n", s->decorrelation); - return AVERROR_INVALIDDATA; - } - - s->downsampling = get_bits(&gb, 2); - if (!s->downsampling) { - av_log(avctx, AV_LOG_ERROR, "invalid downsampling value\n"); - return AVERROR_INVALIDDATA; - } - - s->num_taps = (get_bits(&gb, 5)+1)<<5; - if (get_bits1(&gb)) // XXX FIXME - av_log(avctx, AV_LOG_INFO, "Custom quant table\n"); - - s->block_align = 2048LL*s->samplerate/(44100*s->downsampling); - s->frame_size = s->channels*s->block_align*s->downsampling; -// avctx->frame_size = s->block_align; - - if (s->num_taps * s->channels > s->frame_size) { - av_log(avctx, AV_LOG_ERROR, - "number of taps times channels (%d * %d) larger than frame size %d\n", - s->num_taps, s->channels, s->frame_size); - return AVERROR_INVALIDDATA; - } - - av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n", - s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling); - - // generate taps - s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant)); - if (!s->tap_quant) - return AVERROR(ENOMEM); - - for (i = 0; i < s->num_taps; i++) - s->tap_quant[i] = ff_sqrt(i+1); - - s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k)); - - tmp = av_calloc(s->num_taps, s->channels * sizeof(**s->predictor_state)); - if (!tmp) - return AVERROR(ENOMEM); - for (i = 0; i < s->channels; i++, tmp += s->num_taps) - s->predictor_state[i] = tmp; - - tmp = av_calloc(s->block_align, s->channels * sizeof(**s->coded_samples)); - if (!tmp) - return AVERROR(ENOMEM); - for (i = 0; i < s->channels; i++, tmp += s->block_align) - s->coded_samples[i] = tmp; - - s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples)); - if (!s->int_samples) - return AVERROR(ENOMEM); - - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - return 0; -} - -static av_cold int sonic_decode_close(AVCodecContext *avctx) -{ - SonicContext *s = avctx->priv_data; - - av_freep(&s->int_samples); - av_freep(&s->tap_quant); - av_freep(&s->predictor_k); - av_freep(&s->predictor_state[0]); - av_freep(&s->coded_samples[0]); - - return 0; -} - -static int sonic_decode_frame(AVCodecContext *avctx, AVFrame *frame, - int *got_frame_ptr, AVPacket *avpkt) -{ - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - SonicContext *s = avctx->priv_data; - RangeCoder c; - uint8_t state[32]; - int i, quant, ch, j, ret; - int16_t *samples; - - if (buf_size == 0) return 0; - - frame->nb_samples = s->frame_size / avctx->ch_layout.nb_channels; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) - return ret; - samples = (int16_t *)frame->data[0]; - -// av_log(NULL, AV_LOG_INFO, "buf_size: %d\n", buf_size); - - memset(state, 128, sizeof(state)); - ff_init_range_decoder(&c, buf, buf_size); - ff_build_rac_states(&c, 0.05*(1LL<<32), 256-8); - - intlist_read(&c, state, s->predictor_k, s->num_taps, 0); - - // dequantize - for (i = 0; i < s->num_taps; i++) - s->predictor_k[i] *= (unsigned) s->tap_quant[i]; - - if (s->lossless) - quant = 1; - else - quant = get_symbol(&c, state, 0) * (unsigned)SAMPLE_FACTOR; - -// av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant); - - for (ch = 0; ch < s->channels; ch++) - { - int x = ch; - - if (c.overread > MAX_OVERREAD) - return AVERROR_INVALIDDATA; - - predictor_init_state(s->predictor_k, s->predictor_state[ch], s->num_taps); - - intlist_read(&c, state, s->coded_samples[ch], s->block_align, 1); - - for (i = 0; i < s->block_align; i++) - { - for (j = 0; j < s->downsampling - 1; j++) - { - s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, 0); - x += s->channels; - } - - s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * (unsigned)quant); - x += s->channels; - } - - for (i = 0; i < s->num_taps; i++) - s->predictor_state[ch][i] = s->int_samples[s->frame_size - s->channels + ch - i*s->channels]; - } - - switch(s->decorrelation) - { - case MID_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - { - s->int_samples[i+1] += shift(s->int_samples[i], 1); - s->int_samples[i] -= s->int_samples[i+1]; - } - break; - case LEFT_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - s->int_samples[i+1] += s->int_samples[i]; - break; - case RIGHT_SIDE: - for (i = 0; i < s->frame_size; i += s->channels) - s->int_samples[i] += s->int_samples[i+1]; - break; - } - - if (!s->lossless) - for (i = 0; i < s->frame_size; i++) - s->int_samples[i] = shift(s->int_samples[i], SAMPLE_SHIFT); - - // internal -> short - for (i = 0; i < s->frame_size; i++) - samples[i] = av_clip_int16(s->int_samples[i]); - - *got_frame_ptr = 1; - - return buf_size; -} - -const FFCodec ff_sonic_decoder = { - .p.name = "sonic", - CODEC_LONG_NAME("Sonic"), - .p.type = AVMEDIA_TYPE_AUDIO, - .p.id = AV_CODEC_ID_SONIC, - .priv_data_size = sizeof(SonicContext), - .init = sonic_decode_init, - .close = sonic_decode_close, - FF_CODEC_DECODE_CB(sonic_decode_frame), - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | AV_CODEC_CAP_CHANNEL_CONF, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -}; -#endif /* CONFIG_SONIC_DECODER */ - -#if CONFIG_SONIC_ENCODER -const FFCodec ff_sonic_encoder = { - .p.name = "sonic", - CODEC_LONG_NAME("Sonic"), - .p.type = AVMEDIA_TYPE_AUDIO, - .p.id = AV_CODEC_ID_SONIC, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | - AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, - .priv_data_size = sizeof(SonicContext), - .init = sonic_encode_init, - FF_CODEC_ENCODE_CB(sonic_encode_frame), - .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, - .close = sonic_encode_close, -}; -#endif - -#if CONFIG_SONIC_LS_ENCODER -const FFCodec ff_sonic_ls_encoder = { - .p.name = "sonicls", - CODEC_LONG_NAME("Sonic lossless"), - .p.type = AVMEDIA_TYPE_AUDIO, - .p.id = AV_CODEC_ID_SONIC_LS, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | - AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, - .priv_data_size = sizeof(SonicContext), - .init = sonic_encode_init, - FF_CODEC_ENCODE_CB(sonic_encode_frame), - .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, - .close = sonic_encode_close, -}; -#endif