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 01CD041148 for ; Mon, 14 Feb 2022 19:33:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7973C68B186; Mon, 14 Feb 2022 21:33:06 +0200 (EET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0AE468AF96 for ; Mon, 14 Feb 2022 21:33:00 +0200 (EET) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 51760100002 for ; Mon, 14 Feb 2022 19:32:58 +0000 (UTC) Date: Mon, 14 Feb 2022 20:32:56 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220214193256.GF2829255@pb2> References: <20210503113157.2215-1-zane@zanevaniperen.com> <20210503113157.2215-4-zane@zanevaniperen.com> MIME-Version: 1.0 In-Reply-To: <20210503113157.2215-4-zane@zanevaniperen.com> Subject: Re: [FFmpeg-devel] [PATCH 4/4] avformat: add Argonaut Games CVG muxer 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="===============0750514502835367543==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============0750514502835367543== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9qjSTXeRdg0lH6U0" Content-Disposition: inline --9qjSTXeRdg0lH6U0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 03, 2021 at 09:31:57PM +1000, Zane van Iperen wrote: > Signed-off-by: Zane van Iperen > --- > Changelog | 1 + > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/argo_cvg.c | 149 ++++++++++++++++++++++++++++++++++++++- > libavformat/version.h | 2 +- > 5 files changed, 152 insertions(+), 2 deletions(-) >=20 > diff --git a/Changelog b/Changelog > index 9567009d63..41b1690dfd 100644 > --- a/Changelog > +++ b/Changelog > @@ -5,6 +5,7 @@ version : > - ADPCM IMA Westwood encoder > - Westwood AUD muxer > - Argonaut Games CVG demuxer > +- Argonaut Games CVG muxer > =20 > =20 > version 4.4: > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 0dca1ffd77..c9ef564523 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -108,6 +108,7 @@ OBJS-$(CONFIG_ARGO_ASF_DEMUXER) +=3D argo_as= f.o > OBJS-$(CONFIG_ARGO_ASF_MUXER) +=3D argo_asf.o > OBJS-$(CONFIG_ARGO_BRP_DEMUXER) +=3D argo_brp.o argo_asf.o > OBJS-$(CONFIG_ARGO_CVG_DEMUXER) +=3D argo_cvg.o > +OBJS-$(CONFIG_ARGO_CVG_MUXER) +=3D argo_cvg.o > OBJS-$(CONFIG_ASF_DEMUXER) +=3D asfdec_f.o asf.o asfcrypt.= o \ > avlanguage.o > OBJS-$(CONFIG_ASF_O_DEMUXER) +=3D asfdec_o.o asf.o asfcrypt.= o \ > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 923af3f649..111ca3cbf0 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -67,6 +67,7 @@ extern const AVInputFormat ff_argo_asf_demuxer; > extern const AVOutputFormat ff_argo_asf_muxer; > extern const AVInputFormat ff_argo_brp_demuxer; > extern const AVInputFormat ff_argo_cvg_demuxer; > +extern const AVOutputFormat ff_argo_cvg_muxer; > extern const AVInputFormat ff_asf_demuxer; > extern const AVOutputFormat ff_asf_muxer; > extern const AVInputFormat ff_asf_o_demuxer; > diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c > index 2851c1649f..f0d9f3e076 100644 > --- a/libavformat/argo_cvg.c > +++ b/libavformat/argo_cvg.c > @@ -1,5 +1,5 @@ > /* > - * Argonaut Games CVG demuxer > + * Argonaut Games CVG (de)muxer > * > * Copyright (C) 2021 Zane van Iperen (zane@zanevaniperen.com) > * > @@ -21,6 +21,7 @@ > */ > #include "avformat.h" > #include "internal.h" > +#include "libavutil/opt.h" > #include "libavutil/intreadwrite.h" > =20 > /* > @@ -53,6 +54,14 @@ typedef struct ArgoCVGDemuxContext { > uint32_t blocks_read; > } ArgoCVGDemuxContext; > =20 > +typedef struct ArgoCVGMuxContext { > + const AVClass *class; > + int skip_rate_check; > + uint32_t checksum; > + size_t size; > +} ArgoCVGMuxContext; > + > +#if CONFIG_ARGO_CVG_DEMUXER > /* "Special" files that are played at a different rate. */ > static ArgoCVGOverride overrides[] =3D { > { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */ > @@ -243,3 +252,141 @@ const AVInputFormat ff_argo_cvg_demuxer =3D { > .read_packet =3D argo_cvg_read_packet, > .read_seek =3D argo_cvg_seek, > }; > +#endif > + > +#if CONFIG_ARGO_CVG_MUXER > +static int argo_cvg_write_init(AVFormatContext *s) > +{ > + ArgoCVGMuxContext *ctx =3D s->priv_data; > + const AVCodecParameters *par; > + > + if (s->nb_streams !=3D 1) { > + av_log(s, AV_LOG_ERROR, "CVG files have exactly one stream\n"); > + return AVERROR(EINVAL); > + } > + > + par =3D s->streams[0]->codecpar; > + > + if (par->codec_id !=3D AV_CODEC_ID_ADPCM_PSX) { > + av_log(s, AV_LOG_ERROR, "%s codec not supported\n", > + avcodec_get_name(par->codec_id)); > + return AVERROR(EINVAL); > + } > + > + if (par->channels !=3D 1) { > + av_log(s, AV_LOG_ERROR, "CVG files only support 1 channel\n"); > + return AVERROR(EINVAL); > + } > + > + if (par->block_align !=3D ARGO_CVG_BLOCK_ALIGN) > + return AVERROR(EINVAL); > + > + if (!ctx->skip_rate_check && par->sample_rate !=3D 22050) { > + av_log(s, AV_LOG_ERROR, "Sample rate must be 22050\n"); > + return AVERROR(EINVAL); > + } > + > + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { > + av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write ou= tput file\n"); > + return AVERROR(EINVAL); > + } > + > + return 0; > +} > + > +static int argo_cvg_write_header(AVFormatContext *s) > +{ > + ArgoCVGMuxContext *ctx =3D s->priv_data; > + > + avio_wl32(s->pb, 0); /* Size, fixed later. */ > + avio_wl32(s->pb, 0); > + avio_wl32(s->pb, 1); > + > + ctx->checksum =3D 1; > + ctx->size =3D 8; > + return 0; > +} > + > +static int argo_cvg_write_packet(AVFormatContext *s, AVPacket *pkt) > +{ > + ArgoCVGMuxContext *ctx =3D s->priv_data; > + AVCodecParameters *par =3D s->streams[0]->codecpar; > + > + if (pkt->size % par->block_align !=3D 0) > + return AVERROR_INVALIDDATA; > + > + avio_write(s->pb, pkt->data, pkt->size); > + > + ctx->size +=3D pkt->size; > + > + if (ctx->size > UINT32_MAX) > + return AVERROR_INVALIDDATA; > + > + for (int i =3D 0; i < pkt->size; i++) > + ctx->checksum +=3D pkt->data[i]; > + > + return 0; > +} > + > +static int argo_cvg_write_trailer(AVFormatContext *s) > +{ > + ArgoCVGMuxContext *ctx =3D s->priv_data; > + int64_t ret; > + > + av_log(s, AV_LOG_TRACE, "size =3D %zu\n", ctx->size); > + av_log(s, AV_LOG_TRACE, "checksum =3D %u\n", ctx->checksum); > + > + /* > + * NB: This is wrong. We're always slightly under the original. > + * Verified by remuxing. For reference (orig - remuxed): > + * - TCLD.CVG: 4706074 - 4705696 =3D 378 > + * - DANLOOP1.CVG: 5684641 - 5684212 =3D 429 > + * - CRYS.CVG: 2495499 - 2495367 =3D 132 > + * - PICKUP88.CVG: 1348091 - 1347937 =3D 154 > + * - SELECT1.CVG: 549987 - 549752 =3D 235 Are these files available somewhere ? thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates --9qjSTXeRdg0lH6U0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYgquZQAKCRBhHseHBAsP q4MKAKCQ5JG2I8PL6dxqPgG0Diexca8WlgCeOUqLYyM1xnOhM1ewEXiZstBI1r4= =EdVn -----END PGP SIGNATURE----- --9qjSTXeRdg0lH6U0-- --===============0750514502835367543== 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". --===============0750514502835367543==--