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 8BEC248AA0 for ; Fri, 29 Dec 2023 17:33:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3FB4F68CC0B; Fri, 29 Dec 2023 19:33:38 +0200 (EET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A7F768C85B for ; Fri, 29 Dec 2023 19:33:32 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 263351C0003 for ; Fri, 29 Dec 2023 17:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1703871211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=av7VXD5mGCiGWxe73TlQaORG7nSBSJ12l8+OvKv7BKQ=; b=c6jTH7Dy2INHj117bnyT0yEZIelnYGfTMzXeowQx0vlR9zbzVTwiCVGK+lGuvprGZkqERf msbTThphC6uzrNLTzb/ZMeWW9Nx/0BDpmsDY+/nkZsnIAeXz5SLl2MHQFLbKoTINT7JGDI dTNZ8nkn1/YDzRMV78+jWT3e2o/g21x8MrRrzalkuiar0SbX64GldZQDW4WqXy7fpN6JCk 2atrQS5HnIn0mRYz6obT31w3Q3icrLthR0gEhmgYKs2wn83bpPFdl3Q0K2cnlVmVHLL3xQ S+7MqduJMrkJcsmryZWzlPniDI6+SKzze9BrTFGT9Y39ljcVV7X0qT1Cvhx1ow== Date: Fri, 29 Dec 2023 18:33:30 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20231229173330.GI6420@pb2> References: <20231226223049.GU6420@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 3/6] Add CRYO APC 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="===============1865563796308892359==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1865563796308892359== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="h3Z7hgQQ7qPTU8Su" Content-Disposition: inline --h3Z7hgQQ7qPTU8Su Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 28, 2023 at 11:31:05AM +0100, Tomas H=E4rdin wrote: > tis 2023-12-26 klockan 23:30 +0100 skrev Michael Niedermayer: > > Hi > >=20 > > On Tue, Dec 26, 2023 at 04:52:47PM +0100, Tomas H=E4rdin wrote: > > >=20 > >=20 > > [...] > > > + > > > +static int apc_write_header(AVFormatContext *s) > > > +{ > > > +=A0=A0=A0 AVIOContext *pb =3D s->pb; > > > +=A0=A0=A0 AVCodecParameters *par; > > > +=A0=A0=A0 AVStream *st; > > > + > > > +=A0=A0=A0 if (s->nb_streams !=3D 1) { > > > +=A0=A0=A0=A0=A0=A0=A0 av_log(s, AV_LOG_ERROR, "Must have exactly one= stream\n"); > > > +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); > > > +=A0=A0=A0 } > > > + > > > +=A0=A0=A0 st =3D s->streams[0]; > > > +=A0=A0=A0 par =3D st->codecpar; > > > + > > > +=A0=A0=A0 if (par->ch_layout.nb_channels <=3D 0 || par- > > > >ch_layout.nb_channels > 2) { > > > +=A0=A0=A0=A0=A0=A0=A0 av_log(s, AV_LOG_ERROR, "Must be mono or stere= o\n"); > > > +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); > > > +=A0=A0=A0 } > > > + > > > +=A0=A0=A0 if (par->extradata_size !=3D 0 && par->extradata_size !=3D= 8) { > > > +=A0=A0=A0=A0=A0=A0=A0 av_log(s, AV_LOG_ERROR, > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "Must have exactly 0 or 8 bytes of= extradata, got > > > %i\n", > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 par->extradata_size); > > > +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); > > > +=A0=A0=A0 } > > > + > > > +=A0=A0=A0 ffio_wfourcc(pb, "CRYO"); > > > +=A0=A0=A0 ffio_wfourcc(pb, "_APC"); > > > +=A0=A0=A0 ffio_wfourcc(pb, "1.20"); > >=20 > > > +=A0=A0=A0 avio_wl32(pb, 0); // number or samples > >=20 > > please add to the comment "updated in apc_write_trailer()" >=20 > Sure >=20 >=20 > > > +static int apc_write_packet(AVFormatContext *s, AVPacket *pkt) > > > +{ > > > +=A0=A0=A0 size_t extradata_size =3D 0; > >=20 > > > +=A0=A0=A0 const uint8_t *extradata =3D av_packet_get_side_data( > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 pkt, AV_PKT_DATA_NEW_EXTRADATA, &e= xtradata_size); > > > + > > > +=A0=A0=A0 if (extradata_size =3D=3D 8) { > > > +=A0=A0=A0=A0=A0=A0=A0 // we got predictors from encoder > > > +=A0=A0=A0=A0=A0=A0=A0 // try to seek back end write them > > > +=A0=A0=A0=A0=A0=A0=A0 int64_t pos =3D avio_tell(s->pb), err; > > > +=A0=A0=A0=A0=A0=A0=A0 if ((err =3D avio_seek(s->pb, 20, SEEK_SET)) >= =3D 0) { > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 avio_write(s->pb, extradata, extra= data_size); > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 avio_seek(s->pb, pos, SEEK_SET); > > > +=A0=A0=A0=A0=A0=A0=A0 } else { > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 av_log(s, AV_LOG_ERROR, "Got predi= ctors from encoder > > > but couldn't seek back to write them\n"); > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // fail since we should always be = able to do this > > > within the avio cache > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // unless the encoder gave us pred= ictors way too late > > > for some reason > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return err; > > > +=A0=A0=A0=A0=A0=A0=A0 } > > > +=A0=A0=A0 } > >=20 > > I think the encoder should buffer data or use 2 passes > > if it needs future data. seeking back in the muxer is a bit odd. > >=20 > > if it becomes available always in teh first packet then maybe the > > whole header could be written in the first packet >=20 > Good idea. IIRC the issue was that extradata is either given > immediately (remuxing) or after a single-packet delay (encoding), hence > the check for *new* metadata >=20 > > I would suggest, you add APC support to nut. > > Thats a good test to ensure the packet and extradata is set at the > > right time > > for a generic muxer >=20 > How would I go about doing that? nut mainly needs to be able to map the ffmpeg API CODEC_ID to some external= id so the codec id needs to be in one of the table nut scans for it thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable --h3Z7hgQQ7qPTU8Su Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZY8C4gAKCRBhHseHBAsP q40iAJ9TlKiGpMUh6q+X/64vlu2jvKAIZgCeInPaKeFxV68DCuh3JoBRLQRrM04= =nfwv -----END PGP SIGNATURE----- --h3Z7hgQQ7qPTU8Su-- --===============1865563796308892359== 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". --===============1865563796308892359==--