On Fri, Mar 22, 2024 at 05:01:00PM +0000, Antoine Soulier via ffmpeg-devel wrote: > The LC3 audio codec is the default codec of Bluetooth LE audio. > This is a wrapper over the liblc3 library (https://github.com/google/liblc3). > > Signed-off-by: Antoine Soulier > Signed-off-by: Antoine SOULIER > --- > libavcodec/Makefile | 3 + > libavcodec/allcodecs.c | 3 + > libavcodec/codec_desc.c | 14 +++ > libavcodec/codec_id.h | 2 + > libavcodec/liblc3dec.c | 146 ++++++++++++++++++++++++++++++ > libavcodec/liblc3enc.c | 191 ++++++++++++++++++++++++++++++++++++++++ > 6 files changed, 359 insertions(+) > create mode 100644 libavcodec/liblc3dec.c > create mode 100644 libavcodec/liblc3enc.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 708434ac76..7d2cf3076d 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1123,6 +1123,9 @@ OBJS-$(CONFIG_LIBILBC_ENCODER) += libilbc.o > OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o > OBJS-$(CONFIG_LIBJXL_ENCODER) += libjxlenc.o libjxl.o > OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o > +OBJS-$(CONFIG_LIBLC3_ENCODER) += liblc3enc.o > +OBJS-$(CONFIG_LIBLC3_LC3_DECODER) += liblc3dec.o > +OBJS-$(CONFIG_LIBLC3_LC3PLUS_DECODER) += liblc3dec.o > OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o > OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o > OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index 2386b450a6..29aedaeac6 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -776,6 +776,9 @@ extern const FFCodec ff_libilbc_encoder; > extern const FFCodec ff_libilbc_decoder; > extern const FFCodec ff_libjxl_decoder; > extern const FFCodec ff_libjxl_encoder; > +extern const FFCodec ff_liblc3_encoder; > +extern const FFCodec ff_liblc3_lc3_decoder; > +extern const FFCodec ff_liblc3_lc3plus_decoder; > extern const FFCodec ff_libmp3lame_encoder; > extern const FFCodec ff_libopencore_amrnb_encoder; > extern const FFCodec ff_libopencore_amrnb_decoder; > diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c > index 3bab86db62..230bba2a09 100644 > --- a/libavcodec/codec_desc.c > +++ b/libavcodec/codec_desc.c > @@ -3425,6 +3425,20 @@ static const AVCodecDescriptor codec_descriptors[] = { > .long_name = NULL_IF_CONFIG_SMALL("QOA (Quite OK Audio)"), > .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, > }, > + { > + .id = AV_CODEC_ID_LC3, > + .type = AVMEDIA_TYPE_AUDIO, > + .name = "lc3", > + .long_name = NULL_IF_CONFIG_SMALL("LC3 (Low Complexity Communication Codec)"), > + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, > + }, > + { > + .id = AV_CODEC_ID_LC3_PLUS, > + .type = AVMEDIA_TYPE_AUDIO, > + .name = "lc3_plus", > + .long_name = NULL_IF_CONFIG_SMALL("LC3plus (Low Complexity Communication Codec plus)"), > + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, > + }, > > /* subtitle codecs */ > { > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h > index c8dc21da74..7e4cb39049 100644 > --- a/libavcodec/codec_id.h > +++ b/libavcodec/codec_id.h > @@ -543,6 +543,8 @@ enum AVCodecID { > AV_CODEC_ID_AC4, > AV_CODEC_ID_OSQ, > AV_CODEC_ID_QOA, > + AV_CODEC_ID_LC3, > + AV_CODEC_ID_LC3_PLUS, > > /* subtitle codecs */ > AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. > diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c > new file mode 100644 > index 0000000000..e97cecc68f > --- /dev/null > +++ b/libavcodec/liblc3dec.c > @@ -0,0 +1,146 @@ > +/* > + * LC3 decoder wrapper > + * Copyright (C) 2024 Antoine Soulier > + * > + * This file is part of FFmpeg. > + * > + * Permission to use, copy, modify, and/or distribute this software for any > + * purpose with or without fee is hereby granted, provided that the above > + * copyright notice and this permission notice appear in all copies. > + * > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include this breaks build libavcodec/liblc3enc.c:20:10: fatal error: lc3.h: No such file or directory #include ^~~~~~~ configure enables this even before the configure patch thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire