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 7F8B548F15 for ; Thu, 29 Feb 2024 17:41:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADB3F68D1FB; Thu, 29 Feb 2024 19:41:44 +0200 (EET) Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3210E68D1E5 for ; Thu, 29 Feb 2024 19:41:37 +0200 (EET) Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7bc332d3a8cso74162039f.2 for ; Thu, 29 Feb 2024 09:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709228494; x=1709833294; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8vEu09dL6pIq7DhVrIKdp+9qN0Vd0wizlSRQVyL6BMw=; b=ezSABV8+6D435+MVgvO1Fp7xyAIK6zymfvu0hntUnNDe8RwtYvwnHrgI10N3vD96Rx UWv5NYoGJoCot9Cca4pz1Bh5iCtBpJ+fRwzR9j5LxZAUQF2eADSztXRgGaaFRBm/Z6sX VtP6xbpnup9wM2vO64329mzpGQovdRstjeNCydhwtYY/xSvIKwz/Tz1VR9nMexd+75Wv xZPQiPxs8FwhK6h3a8yjMT2GXWBO6WMF+a588ficHHkR2GeIOVRC5cYRt9dod3cwCRSs zo7w7iwumYiKr12V/cMMKnWr5q0pZVIuUzKSkis+ozXFtlfjmgDB93ZaK+ozJ2TNYHGO F4AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709228494; x=1709833294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8vEu09dL6pIq7DhVrIKdp+9qN0Vd0wizlSRQVyL6BMw=; b=tOKNv2i0G4OtPYjqRamrlruu7o8KDW9lTDfEx3aDlGPay/Pv6ii5DtmRgQlk3dAlf8 zAXWWKZwgPINge1XCHR1fsdCyehVcTLQJw6CFZHBnOozaIf6S8dUm8ABIjTlyIGZzhK1 AtNBLw0HrM8fhulrytHuYjCIltLUvI2Br4ukjCg5bbVgB5cE4AIwTlgPNrTN4L4YHv7p FEETXEDmzp6N05HwbTXdQl6Hj/6Rn+ovZl71qaXEKCqEQWWo0v8/P8Fl0suFrGhoA1Vx l62DbdP6DKEr87tvg8K00zEY258oyjl2s7ShRDOf8ghrGuQicH53ifgHPlAvzOJ8Ipo7 wqPw== X-Gm-Message-State: AOJu0YwGhjajLWVDJJY/dWKdA8GadNyxgu37TLRhFZjHTWVxvL5U/JAE OaywMOJpj9IpI25ooWeavQb4n0qd0v0O1wxoPFGKjqyh62xHzhBHJ99i/wxL X-Google-Smtp-Source: AGHT+IHq4rusuWhipbf+48q9Cijuj0DBzsxLgHR2zuTvJGJxRh6lXjt3T5PPBfkKT9mhQgBuV2mGQg== X-Received: by 2002:a92:c80a:0:b0:365:a6d2:32a7 with SMTP id v10-20020a92c80a000000b00365a6d232a7mr3278256iln.18.1709228494049; Thu, 29 Feb 2024 09:41:34 -0800 (PST) Received: from localhost.localdomain ([190.194.169.124]) by smtp.gmail.com with ESMTPSA id jw40-20020a056a0092a800b006e563efb454sm1539060pfb.135.2024.02.29.09.41.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:41:33 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Feb 2024 14:41:22 -0300 Message-ID: <20240229174122.6696-2-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240229174122.6696-1-jamrial@gmail.com> References: <20240229174122.6696-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/iamfenc: ensure updated extradata is written 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: 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: Signed-off-by: James Almer --- libavformat/iamfenc.c | 30 +++++++++++++++++++++++++++++- tests/ref/fate/iamf-5_1_4 | 14 +++++++------- tests/ref/fate/iamf-7_1_4 | 16 ++++++++-------- tests/ref/fate/iamf-ambisonic_1 | 10 +++++----- tests/ref/fate/iamf-stereo | 4 ++-- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/libavformat/iamfenc.c b/libavformat/iamfenc.c index 72a7555c9a..ebf0c2fd67 100644 --- a/libavformat/iamfenc.c +++ b/libavformat/iamfenc.c @@ -35,6 +35,9 @@ typedef struct IAMFMuxContext { IAMFContext iamf; + int64_t descriptors_offset; + int update_extradata; + int first_stream_id; } IAMFMuxContext; @@ -124,6 +127,7 @@ static int iamf_write_header(AVFormatContext *s) IAMFContext *const iamf = &c->iamf; int ret; + c->descriptors_offset = avio_tell(s->pb); ret = ff_iamf_write_descriptors(iamf, s->pb, s); if (ret < 0) return ret; @@ -135,7 +139,7 @@ static int iamf_write_header(AVFormatContext *s) static int iamf_write_packet(AVFormatContext *s, AVPacket *pkt) { - const IAMFMuxContext *const c = s->priv_data; + IAMFMuxContext *const c = s->priv_data; AVStream *st = s->streams[pkt->stream_index]; int ret = 0; @@ -143,10 +147,33 @@ static int iamf_write_packet(AVFormatContext *s, AVPacket *pkt) ret = ff_iamf_write_parameter_blocks(&c->iamf, s->pb, pkt, s); if (!ret) ret = ff_iamf_write_audio_frame(&c->iamf, s->pb, st->id, pkt); + if (!ret && !pkt->size) + c->update_extradata = 1; return ret; } +static int iamf_write_trailer(AVFormatContext *s) +{ + const IAMFMuxContext *const c = s->priv_data; + const IAMFContext *const iamf = &c->iamf; + int64_t pos; + int ret; + + if (!c->update_extradata || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) + return 0; + + pos = avio_tell(s->pb); + avio_seek(s->pb, c->descriptors_offset, SEEK_SET); + ret = ff_iamf_write_descriptors(iamf, s->pb, s); + if (ret < 0) + return ret; + + avio_seek(s->pb, pos, SEEK_SET); + + return 0; +} + static void iamf_deinit(AVFormatContext *s) { IAMFMuxContext *const c = s->priv_data; @@ -178,6 +205,7 @@ const FFOutputFormat ff_iamf_muxer = { .deinit = iamf_deinit, .write_header = iamf_write_header, .write_packet = iamf_write_packet, + .write_trailer = iamf_write_trailer, .p.codec_tag = (const AVCodecTag* const []){ iamf_codec_tags, NULL }, .p.flags = AVFMT_GLOBALHEADER | AVFMT_NOTIMESTAMPS, }; diff --git a/tests/ref/fate/iamf-5_1_4 b/tests/ref/fate/iamf-5_1_4 index e6eb356ff0..030765ecee 100644 --- a/tests/ref/fate/iamf-5_1_4 +++ b/tests/ref/fate/iamf-5_1_4 @@ -1,11 +1,11 @@ -c447cbbc8943cfb751fdf1145a094250 *tests/data/fate/iamf-5_1_4.iamf +7749af0b8f37c91e4cc0dbc6f31d7f67 *tests/data/fate/iamf-5_1_4.iamf 85603 tests/data/fate/iamf-5_1_4.iamf -#extradata 0: 34, 0x40a802c6 -#extradata 1: 34, 0x40a802c6 -#extradata 2: 34, 0x407c02c4 -#extradata 3: 34, 0x407c02c4 -#extradata 4: 34, 0x40a802c6 -#extradata 5: 34, 0x40a802c6 +#extradata 0: 34, 0xafa70d5e +#extradata 1: 34, 0xafa70d5e +#extradata 2: 34, 0xaf7b0d5c +#extradata 3: 34, 0xaf7b0d5c +#extradata 4: 34, 0xafa70d5e +#extradata 5: 34, 0xafa70d5e #tb 0: 1/44100 #media_type 0: audio #codec_id 0: flac diff --git a/tests/ref/fate/iamf-7_1_4 b/tests/ref/fate/iamf-7_1_4 index c176f4a1cd..39cbd6d840 100644 --- a/tests/ref/fate/iamf-7_1_4 +++ b/tests/ref/fate/iamf-7_1_4 @@ -1,12 +1,12 @@ -157c3185684e12cc8385ee7c3ef2fb4c *tests/data/fate/iamf-7_1_4.iamf +5d9fcee2b9b2ad3c802c40bb1147016e *tests/data/fate/iamf-7_1_4.iamf 99851 tests/data/fate/iamf-7_1_4.iamf -#extradata 0: 34, 0x40a802c6 -#extradata 1: 34, 0x40a802c6 -#extradata 2: 34, 0x407c02c4 -#extradata 3: 34, 0x407c02c4 -#extradata 4: 34, 0x40a802c6 -#extradata 5: 34, 0x40a802c6 -#extradata 6: 34, 0x40a802c6 +#extradata 0: 34, 0xafa70d5e +#extradata 1: 34, 0xafa70d5e +#extradata 2: 34, 0xaf7b0d5c +#extradata 3: 34, 0xaf7b0d5c +#extradata 4: 34, 0xafa70d5e +#extradata 5: 34, 0xafa70d5e +#extradata 6: 34, 0xafa70d5e #tb 0: 1/44100 #media_type 0: audio #codec_id 0: flac diff --git a/tests/ref/fate/iamf-ambisonic_1 b/tests/ref/fate/iamf-ambisonic_1 index 928a9c6cf2..ed73dd4d09 100644 --- a/tests/ref/fate/iamf-ambisonic_1 +++ b/tests/ref/fate/iamf-ambisonic_1 @@ -1,9 +1,9 @@ -0b66877e65e3e5bae46887aced977593 *tests/data/fate/iamf-ambisonic_1.iamf +c3751e6a2d85bd6a8318fe93b5754309 *tests/data/fate/iamf-ambisonic_1.iamf 57006 tests/data/fate/iamf-ambisonic_1.iamf -#extradata 0: 34, 0x3615025b -#extradata 1: 34, 0x3615025b -#extradata 2: 34, 0x3615025b -#extradata 3: 34, 0x3615025b +#extradata 0: 34, 0xad120cfe +#extradata 1: 34, 0xad120cfe +#extradata 2: 34, 0xad120cfe +#extradata 3: 34, 0xad120cfe #tb 0: 1/44100 #media_type 0: audio #codec_id 0: flac diff --git a/tests/ref/fate/iamf-stereo b/tests/ref/fate/iamf-stereo index 65d6b506d4..82206f84bf 100644 --- a/tests/ref/fate/iamf-stereo +++ b/tests/ref/fate/iamf-stereo @@ -1,6 +1,6 @@ -ace731a4fbc302e24498d6b64daa16e7 *tests/data/fate/iamf-stereo.iamf +4000d96f7363212c5a75c6f7fa5756f5 *tests/data/fate/iamf-stereo.iamf 14426 tests/data/fate/iamf-stereo.iamf -#extradata 0: 34, 0x40a802c6 +#extradata 0: 34, 0xafa70d5e #tb 0: 1/44100 #media_type 0: audio #codec_id 0: flac -- 2.44.0 _______________________________________________ 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".