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 ESMTPS id 818AF4D12C for ; Mon, 17 Feb 2025 16:19:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3ECB268BF97; Mon, 17 Feb 2025 18:19:38 +0200 (EET) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3187368B379 for ; Mon, 17 Feb 2025 18:19:31 +0200 (EET) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6ef7c9e9592so34318927b3.1 for ; Mon, 17 Feb 2025 08:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739809169; x=1740413969; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZrW340/wzcAbc93xUrMlhoBgfXKptvdM7LsePw0AgRw=; b=Z5Q0QFwVIFhluaQ4fom5Y3rqsMei99Bg/mSOw6p1TtxMSKZNQNgyaz01Nz6VbvxHJ1 1zSM5XSgKz3MFZFaXjiM+daAAvnCR2l4pyASVqe3JoSPxK9WsRTCVKAMyyiTM2ar/O/e NoQtl7g6K/7YB2D8b/XzHYpBFhDY1qtuK3lAnVOhiRa5T0iv7vmlKm/RBEkAnL95Yydv jaNPgSNQkLjzV/R0dbx09HG+ApycO1FH7bZn2l59goXxMYkWMqoYi6zgI4FoCF3/Of39 7NnAqxCEUpYHUiH4BM7CP5jYfuHz3d1WrOr2SmnIUwyT//w95fzIhAHdHtD0vW9azp8k cK4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739809169; x=1740413969; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZrW340/wzcAbc93xUrMlhoBgfXKptvdM7LsePw0AgRw=; b=UBXF1tQDCiL7zEh9DN3ht7Ey+urnCKKrctyB+xty3d23WX4leeAy7oIsW+jsYdIJfQ /6aP5DQqAUgjbvup3tajnMN0uGTURlbbvvBMLohOp0YJ0SI7h5eutyTvpOgZp4TCGXyR FA2b4qBOmlSPSViG1rmWGEDlY/5LEMmB7mWDXCky37lBJj3xMmWpw6CJclbFGnalPVz4 Dx6Dh1DuWaq9FSSm9fV7L9Cu+op+zf/nCKq3/At8k0W9ZEjjDKUa3Fc82gqMrd/W7Pdl t2Eo50mIb6/fG/pfNNhjJNBydcyNPzbp59l/hj7Ak5aHIznsREAQpSbg8xjHYHVN+jM5 J81A== X-Gm-Message-State: AOJu0Yw++8OWMv9t1ZFWvpbDzUXaxqly+Kdb6504VwdVQuq/At8y4adF ugHpmtdgNq29YYRLs/nNBfbJpLQd3G0WvJqR+ZG/0ppCErhn5tFTkdEXpA== X-Gm-Gg: ASbGncuT8IFnc5uZifCVjzqG8kV/Me3183mr8G+r2MSvWMsgQQafHX0bRfzln5gTDNA iyf1hcf7cAuSyxl0iEiYPE2wJeRNhhYsN3GKX4LpUoh8CZK3cI/s5CP/BKwLSv5hBAjcjarKLVL DoylY/IOQ7FWxmTGHxK1QMZ/X3qNkljLXEydnkjd0qYCXwSwgFtShQQWxsNJqIVGrYD5OYmERHr fvNhCYmyWX6svdAPTTbYfNlc2Irf/BCcV19myXqx6q65HJNJNTIyrF+BrtCcGnnNYR+u11/OCqK Ir16Gf04fBc+bkX1ZBpbxIEn47sdU+iZYtxmC6nFzdepWu+N0oyYEQ== X-Google-Smtp-Source: AGHT+IGi6FaZUtKX78dzVW+f2zVIbBaVagp6p5BUg1HF+E8C8s8lMozphlf7RZjqVuJ2RaUAg+4MXA== X-Received: by 2002:a05:690c:6287:b0:6f9:7d7d:a725 with SMTP id 00721157ae682-6fb58390b21mr84410467b3.33.1739809168926; Mon, 17 Feb 2025 08:19:28 -0800 (PST) Received: from localhost.localdomain ([2607:fb91:fef:2a0c:58ec:790:2715:af11]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6fb3605b553sm21488177b3.30.2025.02.17.08.19.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 17 Feb 2025 08:19:28 -0800 (PST) From: Romain Beauxis To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2025 10:19:15 -0600 Message-Id: <20250217161921.76121-1-romain.beauxis@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 0/6] Properly decode ogg metadata in ogg/flac and ogg/opus chained bitstreams 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: Romain Beauxis 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: This is a series of patches to allow proper decoding of ogg metadata in chained `ogg/flac` and `ogg/opus` streams. ## Changes since last version: - Opus processing moved back to `opus_header` to make sure that opus demuxing is not impacted by those changes. - Generic decoding method implemented directly in `libavcodec/decode.c` to avoid having each decoded handle the metadata injection. ### Summary of code changes: The changes in this patch series allow proper decoding of metadata associated with subsequent streams in chained ogg/flac and ogg/opus bitstream. This is done by intercepting ogg packets with comments in the ogg demuxer, parsing the comment block and attaching it as packed `AV_PKT_DATA_METADATA_UPDATE` side-data. The new metadata can then be unpacked in `libavcodec/decode.c` and attached to the next decoded frame. It is worth noting that is using a mechanism specific to ogg stream that seemed to only have been used for vorbis streams so far. Along with the changes are new FATE tests validating the implementation. ### Discussion and context: `ogg/opus` is a pretty popular combination of codec and encapsulation. In particular, it is widely used in Icecast streams, where chained streams are the norm because of the ogg specs requirement for inserting in-band metadata. `ogg/flac` streams are pretty important because there are perhaps the only combination of lossless audio codec and open-source container that allows for proper transmittion of lossless audio data accross systems such as Icecast, browser media tags and more. In the context of long-running audio streams, the ogg bitstream specs[1] have historically been very badly implemented. For each new track and each new metadata, the specs require the logical bitstream to come to a full `EOF` and then start with a full new logical stream. These specs have often been confused with a gobal EOF by most implementations. Furtunately, FFmpeg is a little better at that in that it is able to parse chained logical ogg bitstreams and properly output either encoded ogg packets or decoded audio. Current limitations with chained ogg streams in FFmpeg include: 1. Metadata from secondary chained `ogg/flac` and `ogg/opus` bitstreams are ignored by the demuxer/decoder. 2. Secondary chained streams packet headers are silently removed by the demuxer when decoding ogg/opus streams. 3. No adjustment underlying PTS or DTS: PTS and DTS of secondary chained streams reset from their own logical stream initia value causing timestamp discontinuity. 4. Chained bitstreams with more than one underlying type of content (audio+video, etc) is not yet supported though this is a much less needed feature. The changes in this patch series address issue #1. Future work could address the remaining issues. -- Romain [1]: https://xiph.org/ogg/doc/framing.html Romain Beauxis (6): libavcodec/decode.c: intercept `AV_PKT_DATA_METADATA_UPDATE` packet extra data, attach them to the next decoded frame. tests: Add stream dump test API util. libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add them to ogg stream new_metadata. tests: Add chained ogg/flac stream dump test. libavformat/oggparseopus.c: Parse comments from secondary chained streams header packet. tests: Add chained ogg/opus stream dump test. libavcodec/decode.c | 20 +++ libavformat/oggparseflac.c | 28 +++++ libavformat/oggparseopus.c | 21 +++- tests/Makefile | 3 + tests/api/Makefile | 2 +- tests/api/api-dump-stream-meta-test.c | 169 ++++++++++++++++++++++++++ tests/fate/ogg-flac.mak | 11 ++ tests/fate/ogg-opus.mak | 11 ++ 8 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 tests/api/api-dump-stream-meta-test.c create mode 100644 tests/fate/ogg-flac.mak create mode 100644 tests/fate/ogg-opus.mak -- 2.39.5 (Apple Git-154) _______________________________________________ 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".