From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 668E04E374 for ; Mon, 9 Jun 2025 10:08:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 2D4D268C9C5; Mon, 9 Jun 2025 13:07:59 +0300 (EEST) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 65BBC68C9C5 for ; Mon, 9 Jun 2025 13:07:52 +0300 (EEST) Received: from 9cc26bf9dd0d78128d17c1cbbc1b2daf ([1.145.244.154]) (authenticated (0 bits)) by mx.sdf.org (8.18.1/8.14.3) with ESMTPSA id 559A7hQp022980 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Mon, 9 Jun 2025 10:07:49 GMT Date: Mon, 9 Jun 2025 20:07:42 +1000 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: <229f66d18527e833365012589f6d2e0acc484b18.1749463495.git.pross@xvid.org> References: MIME-Version: 1.0 In-Reply-To: Subject: [FFmpeg-devel] [PATCHv3 5/8] avformat/g728dec: raw G.728 demuxer 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 Content-Type: multipart/mixed; boundary="===============8976334301983672211==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8976334301983672211== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r+bbOeuLcTa7FBJM" Content-Disposition: inline --r+bbOeuLcTa7FBJM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/g728dec.c | 58 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 libavformat/g728dec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 9884b4a4cb..2e73f1325e 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -247,6 +247,7 @@ OBJS-$(CONFIG_G726_DEMUXER) +=3D g726.o OBJS-$(CONFIG_G726_MUXER) +=3D rawenc.o OBJS-$(CONFIG_G726LE_DEMUXER) +=3D g726.o OBJS-$(CONFIG_G726LE_MUXER) +=3D rawenc.o +OBJS-$(CONFIG_G728_DEMUXER) +=3D g728dec.o OBJS-$(CONFIG_G729_DEMUXER) +=3D g729dec.o OBJS-$(CONFIG_GDV_DEMUXER) +=3D gdv.o OBJS-$(CONFIG_GENH_DEMUXER) +=3D genh.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 17215d733d..4e9958bd18 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -191,6 +191,7 @@ extern const FFInputFormat ff_g726_demuxer; extern const FFOutputFormat ff_g726_muxer; extern const FFInputFormat ff_g726le_demuxer; extern const FFOutputFormat ff_g726le_muxer; +extern const FFInputFormat ff_g728_demuxer; extern const FFInputFormat ff_g729_demuxer; extern const FFInputFormat ff_gdv_demuxer; extern const FFInputFormat ff_genh_demuxer; diff --git a/libavformat/g728dec.c b/libavformat/g728dec.c new file mode 100644 index 0000000000..dbf5e64d05 --- /dev/null +++ b/libavformat/g728dec.c @@ -0,0 +1,58 @@ +/* + * G.728 raw demuxer + * + * 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-130= 1 USA + */ + +#include "avformat.h" +#include "demux.h" +#include "internal.h" + +static int g728_read_header(AVFormatContext *s) +{ + AVStream *st =3D avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codecpar->codec_type =3D AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id =3D ffifmt(s->iformat)->raw_codec_id; + st->codecpar->sample_rate =3D 8000; + st->codecpar->bit_rate =3D 16000; + st->codecpar->block_align =3D 5; + st->codecpar->ch_layout =3D (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + + return 0; +} + +static int g728_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + int ret =3D av_get_packet(s->pb, pkt, 1020); // a size similar to RAW_= PACKET_SIZE divisible by 5 + pkt->flags &=3D ~AV_PKT_FLAG_CORRUPT; + pkt->duration =3D (pkt->size / 5) * 20; + return ret; +} + +const FFInputFormat ff_g728_demuxer =3D { + .p.name =3D "g728", + .p.long_name =3D NULL_IF_CONFIG_SMALL("raw G.728"), + .p.extensions =3D "g728", + .p.flags =3D AVFMT_GENERIC_INDEX, + .read_header =3D g728_read_header, + .read_packet =3D g728_read_packet, + .raw_codec_id =3D AV_CODEC_ID_G728, +}; --=20 2.47.2 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --r+bbOeuLcTa7FBJM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCaEaybgAKCRBnYHnFrEDd awtIAJ4k8R4kgwZqrYBvQ1T7l+mgVbuJnwCaAiMGBv12okY/A0A1C2FmasLkW9w= =qDz8 -----END PGP SIGNATURE----- --r+bbOeuLcTa7FBJM-- --===============8976334301983672211== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============8976334301983672211==--