avcodec: remove CELT decoder

libcelt, which it depends on, was not updated in a very long time and is
considered deprecated, as Opus exists which has a CELT mode. Therefore
remove standalone CELT decoding support.

It was already broken since b8604a9761,
11 years ago, and no one noticed and complained.
This commit is contained in:
Marvin Scholz
2026-05-22 09:33:52 +00:00
committed by Lynne
co-authored by Lynne
parent f17c8db820
commit 61a0b8fb41
8 changed files with 2 additions and 161 deletions
+1
View File
@@ -14,6 +14,7 @@ version <next>:
- APV Vulkan hwaccel
- Animated WebP decoder
- Animated WebP demuxer
- Remove CELT decoding support (doesn't affect Opus CELT)
version 8.1:
Vendored
-6
View File
@@ -222,7 +222,6 @@ External library support:
--enable-libbluray enable BluRay reading using libbluray [no]
--enable-libbs2b enable bs2b DSP library [no]
--enable-libcaca enable textual display using libcaca [no]
--enable-libcelt enable CELT decoding via libcelt [no]
--enable-libcdio enable audio CD grabbing with libcdio [no]
--enable-libcodec2 enable codec2 en/decoding using libcodec2 [no]
--enable-libdav1d enable AV1 decoding via libdav1d [no]
@@ -2085,7 +2084,6 @@ EXTERNAL_LIBRARY_LIST="
libbluray
libbs2b
libcaca
libcelt
libcodec2
libdav1d
libdc1394
@@ -3825,7 +3823,6 @@ libaom_av1_encoder_deps="libaom"
libaom_av1_encoder_select="extract_extradata_bsf dovi_rpuenc"
libaribb24_decoder_deps="libaribb24"
libaribcaption_decoder_deps="libaribcaption"
libcelt_decoder_deps="libcelt"
libcodec2_decoder_deps="libcodec2"
libcodec2_encoder_deps="libcodec2"
libdav1d_decoder_deps="libdav1d"
@@ -7322,9 +7319,6 @@ enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883
enabled libass && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init
enabled libbluray && require_pkg_config libbluray libbluray libbluray/bluray.h bd_open
enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
{ check_lib libcelt celt/celt.h celt_decoder_create_custom -lcelt0 ||
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas
enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2
enabled libdav1d && require_pkg_config libdav1d "dav1d >= 1.0.0" "dav1d/dav1d.h" dav1d_version
-8
View File
@@ -307,14 +307,6 @@ This decoder generates wave patterns according to predefined sequences. Its
use is purely internal and the format of the data it accepts is not publicly
documented.
@section libcelt
libcelt decoder wrapper.
libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec.
Requires the presence of the libcelt headers and library during configuration.
You need to explicitly configure the build with @code{--enable-libcelt}.
@section libgsm
libgsm decoder wrapper.
-2
View File
@@ -1295,8 +1295,6 @@ following image formats are supported:
@item Bink Audio @tab @tab X
@tab Used in Bink and Smacker files in many games.
@item Bonk audio @tab @tab X
@item CELT @tab @tab E
@tab decoding supported through external library libcelt
@item codec2 @tab E @tab E
@tab en/decoding supported through external library libcodec2
@item CRI HCA @tab @tab X
-1
View File
@@ -1174,7 +1174,6 @@ OBJS-$(CONFIG_LIBAOM_AV1_DECODER) += libaomdec.o libaom.o
OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += libaomenc.o libaom.o
OBJS-$(CONFIG_LIBARIBB24_DECODER) += libaribb24.o ass.o
OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o
OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o
OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o
-1
View File
@@ -786,7 +786,6 @@ extern FFCodec ff_libaom_av1_encoder;
/* preferred over libaribb24 */
extern const FFCodec ff_libaribcaption_decoder;
extern const FFCodec ff_libaribb24_decoder;
extern const FFCodec ff_libcelt_decoder;
extern const FFCodec ff_libcodec2_encoder;
extern const FFCodec ff_libcodec2_decoder;
extern const FFCodec ff_libdav1d_decoder;
-142
View File
@@ -1,142 +0,0 @@
/*
* Xiph CELT decoder using libcelt
* Copyright (c) 2011 Nicolas George
*
* 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 <celt/celt.h>
#include <celt/celt_header.h>
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "libavutil/intreadwrite.h"
struct libcelt_context {
CELTMode *mode;
CELTDecoder *dec;
int discard;
};
static int ff_celt_error_to_averror(int err)
{
switch (err) {
case CELT_BAD_ARG: return AVERROR(EINVAL);
#ifdef CELT_BUFFER_TOO_SMALL
case CELT_BUFFER_TOO_SMALL: return AVERROR(ENOBUFS);
#endif
case CELT_INTERNAL_ERROR: return AVERROR(EFAULT);
case CELT_CORRUPTED_DATA: return AVERROR_INVALIDDATA;
case CELT_UNIMPLEMENTED: return AVERROR(ENOSYS);
#ifdef ENOTRECOVERABLE
case CELT_INVALID_STATE: return AVERROR(ENOTRECOVERABLE);
#endif
case CELT_ALLOC_FAIL: return AVERROR(ENOMEM);
default: return AVERROR(EINVAL);
}
}
static int ff_celt_bitstream_version_hack(CELTMode *mode)
{
CELTHeader header = { .version_id = 0 };
celt_header_init(&header, mode, 960, 2);
return header.version_id;
}
static av_cold int libcelt_dec_init(AVCodecContext *c)
{
struct libcelt_context *celt = c->priv_data;
int err;
if (!c->ch_layout.nb_channels || !c->frame_size ||
c->frame_size > INT_MAX / sizeof(int16_t) / c->ch_layout.nb_channels)
return AVERROR(EINVAL);
celt->mode = celt_mode_create(c->sample_rate, c->frame_size, &err);
if (!celt->mode)
return ff_celt_error_to_averror(err);
celt->dec = celt_decoder_create_custom(celt->mode, c->ch_layout.nb_channels, &err);
if (!celt->dec) {
celt_mode_destroy(celt->mode);
return ff_celt_error_to_averror(err);
}
if (c->extradata_size >= 4) {
celt->discard = AV_RL32(c->extradata);
if (celt->discard < 0 || celt->discard >= c->frame_size) {
av_log(c, AV_LOG_WARNING,
"Invalid overlap (%d), ignored.\n", celt->discard);
celt->discard = 0;
}
}
if (c->extradata_size >= 8) {
unsigned version = AV_RL32(c->extradata + 4);
unsigned lib_version = ff_celt_bitstream_version_hack(celt->mode);
if (version != lib_version)
av_log(c, AV_LOG_WARNING,
"CELT bitstream version 0x%x may be "
"improperly decoded by libcelt for version 0x%x.\n",
version, lib_version);
}
c->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
static av_cold int libcelt_dec_close(AVCodecContext *c)
{
struct libcelt_context *celt = c->priv_data;
celt_decoder_destroy(celt->dec);
celt_mode_destroy(celt->mode);
return 0;
}
static int libcelt_dec_decode(AVCodecContext *c, AVFrame *frame,
int *got_frame_ptr, AVPacket *pkt)
{
struct libcelt_context *celt = c->priv_data;
int err;
int16_t *pcm;
frame->nb_samples = c->frame_size;
if ((err = ff_get_buffer(c, frame, 0)) < 0)
return err;
pcm = (int16_t *)frame->data[0];
err = celt_decode(celt->dec, pkt->data, pkt->size, pcm, c->frame_size);
if (err < 0)
return ff_celt_error_to_averror(err);
if (celt->discard) {
frame->nb_samples -= celt->discard;
memmove(pcm, pcm + celt->discard * c->ch_layout.nb_channels,
frame->nb_samples * c->ch_layout.nb_channels * sizeof(int16_t));
celt->discard = 0;
}
*got_frame_ptr = 1;
return pkt->size;
}
const FFCodec ff_libcelt_decoder = {
.p.name = "libcelt",
CODEC_LONG_NAME("Xiph CELT decoder using libcelt"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_CELT,
.p.capabilities = AV_CODEC_CAP_DR1,
.p.wrapper_name = "libcelt",
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
.priv_data_size = sizeof(struct libcelt_context),
.init = libcelt_dec_init,
.close = libcelt_dec_close,
FF_CODEC_DECODE_CB(libcelt_dec_decode),
};
+1 -1
View File
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 34
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \