From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E52334853E for ; Sat, 6 Apr 2024 07:54:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03B8568CFF2; Sat, 6 Apr 2024 10:54:16 +0300 (EEST) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5243B68C09C for ; Sat, 6 Apr 2024 10:54:09 +0300 (EEST) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-56e0c00e7fcso3215144a12.2 for ; Sat, 06 Apr 2024 00:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712390048; x=1712994848; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=W3SI9n+MTS+YD+cJNwMUc3VDIj9fi46Fjky2QTYNegE=; b=Z7NmSUx9t4UD7mEt6m8KQKjLVkqDhgYO6QSJ2QxTCZSg9xYK6nLJKApcDbEGF10xA4 QVLXX4EUjq3rq6YfiJ3CRSEUCqbK+Whh67Rv762VicKe0DRTNmD8LKuD1Txj4moGicXq VkidwsuLXJvQOv3D3ArFHRwK9DB+tETTWy1LfOWEI4x5trj2Psmt2+50313wHu74sbBB 1AqkdEEPzx0zO+rRVj2NpLcDdxybfLbkyhQ3JrDIwo4EXU/wZNkDEI7FdOxEgNbcMw5/ CNJtbm6KqcHAZISyJ9A4665PnJ8eLtILOGkUk7TiEcGmWtxan/dR7WrXuJZVbPTp/R49 pQ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712390048; x=1712994848; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W3SI9n+MTS+YD+cJNwMUc3VDIj9fi46Fjky2QTYNegE=; b=YaStiJ/dNYX0woMuxAAgiyTPXNM3tUDePyPuS9xgHfUFBHNoVxkNvrzDTNiEu68zKj 1ygT4aRWHsbeRcKQB7g/9AyG7+UIAgQIGUoicvt/CrmdTJUEchWnb1JQsJiAdzyjIKR1 psgdazNtLrIKguWuR06yoEflm0q9W/xV6M/oqt1DB7Lr5k4IAdLusEc6gwlGrfLXBLOx tMHqSM4+3N26L5vkI693TNADxCt2u3ri1L03QRckTS21kq6g2pnY3XUHWFZHtFt1/QaG lqNR4SBZVcQvSwnq2qifjs6yRcGvX58fTlhlfMMzYkYGPusFBiC+rUR1W/6Fag1O1c7q Xq9g== X-Gm-Message-State: AOJu0Yydodjwxk0QUH7GCmCK8FmFdSIiriNw1SKPeEPlm2b5DEEjftJI jMGKyIw6OllVA2lvQCo5wgPaZHpmEjKgArqA2r0ligMTdLxMHrBpzqMsH/H3 X-Google-Smtp-Source: AGHT+IEuXIxEdKh3ortGVqoZ90IRz2rFsoNgKmYNWWyxgcGPDQvJWwsfRNM8vS2PwNvG89/Hf6KEtg== X-Received: by 2002:a50:8d47:0:b0:56d:f9dc:c82f with SMTP id t7-20020a508d47000000b0056df9dcc82fmr2740707edt.14.1712390047504; Sat, 06 Apr 2024 00:54:07 -0700 (PDT) Received: from mariano (host-79-42-51-175.retail.telecomitalia.it. [79.42.51.175]) by smtp.gmail.com with ESMTPSA id x26-20020aa7d6da000000b0056e460eda12sm340896edr.55.2024.04.06.00.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 00:54:07 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id C7321BFCE8; Sat, 6 Apr 2024 09:54:06 +0200 (CEST) Date: Sat, 6 Apr 2024 09:54:06 +0200 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , Antoine Soulier References: <20240404225734.3036715-1-asoulier@google.com> <20240404225734.3036715-2-asoulier@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240404225734.3036715-2-asoulier@google.com> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/lc3: Add file format for LC3/LC3plus transport 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: Antoine Soulier Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Thursday 2024-04-04 22:57:34 +0000, ffmpeg-devel Mailing List wrote: > From: Antoine SOULIER > > A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for > test purpose. This is the format implemented here. > --- > Changelog | 1 + > doc/muxers.texi | 6 ++ > libavformat/Makefile | 2 + > libavformat/allformats.c | 2 + > libavformat/lc3dec.c | 160 +++++++++++++++++++++++++++++++++++++++ > libavformat/lc3enc.c | 100 ++++++++++++++++++++++++ > 6 files changed, 271 insertions(+) > create mode 100644 libavformat/lc3dec.c > create mode 100644 libavformat/lc3enc.c > > diff --git a/Changelog b/Changelog > index 18e83b99a1..92670f6a05 100644 > --- a/Changelog > +++ b/Changelog > @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, > releases are sorted from youngest to oldest. > > version : > +- LC3/LC3plus demuxer and muxer > - Raw Captions with Time (RCWT) closed caption demuxer > - LC3/LC3plus decoding/encoding using external library liblc3 nit: add new entry to the bottom > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index d8a1f83309..ed4144f6d1 100644 > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -2700,6 +2700,12 @@ computer-generated compositions. > > This muxer accepts a single audio stream containing PCM data. > > +@section lc3 > +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or > +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). > + > +This muxer accepts a single @code{lc3} audio stream. > + > @section matroska > > Matroska container muxer. > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 9981799cc9..027d0cdae5 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o > OBJS-$(CONFIG_KVAG_MUXER) += kvag.o rawenc.o > OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o > OBJS-$(CONFIG_LATM_MUXER) += latmenc.o rawenc.o > +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o > +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o > OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o > OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o > OBJS-$(CONFIG_LUODAT_DEMUXER) += luodatdec.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index ae925dcf60..305fa46532 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; > extern const FFOutputFormat ff_kvag_muxer; > extern const FFInputFormat ff_laf_demuxer; > extern const FFOutputFormat ff_latm_muxer; > +extern const FFInputFormat ff_lc3_demuxer; > +extern const FFOutputFormat ff_lc3_muxer; > extern const FFInputFormat ff_lmlm4_demuxer; > extern const FFInputFormat ff_loas_demuxer; > extern const FFInputFormat ff_luodat_demuxer; > diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c > new file mode 100644 > index 0000000000..1fcde8ca4e > --- /dev/null > +++ b/libavformat/lc3dec.c > @@ -0,0 +1,160 @@ > +/* > + * LC3 demuxer > + * Copyright (C) 2024 Antoine Soulier > + * > + * 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 > + */ > + > +/** > + * @file > + * Based on the file format specified by : > + * > + * - Bluetooth SIG - Low Complexity Communication Codec Test Suite > + * https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=502301 > + * 3.2.8.2 Reference LC3 Codec Bitstream Format > + * > + * - ETSI TI 103 634 V1.4.1 - Low Complexity Communication Codec plus > + * https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf > + * LC3plus conformance script package > + */ > + > +#include "libavcodec/packet.h" > +#include "libavutil/intreadwrite.h" > + > +#include "avformat.h" > +#include "avio.h" > +#include "demux.h" > +#include "internal.h" > + > +typedef struct LC3DemuxContext { > + int frame_samples; > + int64_t end_dts; > +} LC3DemuxContext; > + > +static int lc3_read_probe(const AVProbeData *p) > +{ > + uint16_t frame_10us, srate_100hz; > + > + if (p->buf_size < 12) > + return 0; > + > + if (AV_RB16(p->buf + 0) != 0x1ccc || > + AV_RL16(p->buf + 2) < 9 * sizeof(uint16_t)) > + return 0; > + > + srate_100hz = AV_RL16(p->buf + 4); > + if (srate_100hz != 8000/100 && srate_100hz != 16000/100 && > + srate_100hz != 24000/100 && srate_100hz != 32000/100 && > + srate_100hz != 48000/100 && srate_100hz != 96000/100) > + return 0; nit++: sligthly simpler if you multiply srate to avoid the dividend in the checks Also I'm a bit surprised by this logic, since here we are assuming only a subset of srate values, but on the other end there is no validation in the demuxer. Probably it's good to keep this logic for the probing, but in this case we should also add validation here and in the muxer? > + > + frame_10us = AV_RL16(p->buf + 10); > + if (frame_10us != 2500/10 && frame_10us != 5000/10 && > + frame_10us != 7500/10 && frame_10us != 10000/10) > + return 0; ditto mutatis mutandis [...] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".