Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] ogg/vorbis: implement header packet skip in chained ogg bitstreams.
Date: Tue, 3 Jun 2025 21:20:15 +0200
Message-ID: <GV1P250MB07379AE39B3DB0213CBCE77A8F6DA@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CABWZ6OQvtb12EpohBH_eJQcWU5=hQ4tAn2v+tYW6qkNTDB4E9g@mail.gmail.com>

Romain Beauxis:
> Le mar. 3 juin 2025 à 12:12, Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com> a écrit :
>>
>> Romain Beauxis:
>>> This is a redo of 574f634e49847e2225ee50013afebf0de03ef013 using a flat
>>> memory storage for the extradata.
>>>
>>> PR review comments addressed:
>>> * Use flat memory array
>>> * Rename structure to follow convention
>>> * Add stddef.h header
>>>
>>> Bonus: libavcodec/vorbisdec.c diff is greatly improved!
>>>
>>> ---
>>>  libavcodec/vorbis_parser.h                 |  7 +++
>>>  libavcodec/vorbisdec.c                     | 45 ++++++++++++-----
>>>  libavformat/oggparsevorbis.c               | 56 ++++++++++++++++++++--
>>>  tests/ref/fate/ogg-vorbis-chained-meta.txt |  3 --
>>>  4 files changed, 94 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/libavcodec/vorbis_parser.h b/libavcodec/vorbis_parser.h
>>> index 789932ac49..9010723590 100644
>>> --- a/libavcodec/vorbis_parser.h
>>> +++ b/libavcodec/vorbis_parser.h
>>> @@ -27,6 +27,7 @@
>>>  #define AVCODEC_VORBIS_PARSER_H
>>>
>>>  #include <stdint.h>
>>> +#include <stddef.h>
>>>
>>>  typedef struct AVVorbisParseContext AVVorbisParseContext;
>>>
>>> @@ -45,6 +46,12 @@ void av_vorbis_parse_free(AVVorbisParseContext **s);
>>>  #define VORBIS_FLAG_COMMENT 0x00000002
>>>  #define VORBIS_FLAG_SETUP   0x00000004
>>>
>>> +typedef struct AVVorbisHeaderExtradata {
>>> +    unsigned int header_type;
>>> +    size_t   header_size;
>>> +    uint8_t header[];
>>> +} AVVorbisHeaderExtradata;
>>> +
>>
>> It seems you started this work before my latest mail
>> https://ffmpeg.org/pipermail/ffmpeg-devel/2025-May/344422.html:
>> AV_PKT_DATA_NEW_EXTRADATA should use the same format as ordinary
>> extradata. (A user may e.g. use this new extradata for muxing, where the
>> ordinary extradata is expected.) This generally allows to reuse
>> extradata parsing functions (potentially after having factored them out
>> of the init function).
> 
> I'm not sure what you mean. Could you elaborate?
> 
> If you look at https://ffmpeg.org/pipermail/ffmpeg-devel/2025-June/344446.html
> you will see that the format seems like ordinary extradata to me. In
> fact, as soon as the key is changed, vorbis metadata update finally
> starts to flow as expected without changing the decoder side of
> things, as exemplified by the test diff in the changeset.

I do not get what your link to the patch exchanging
AV_PKT_DATA_METADATA_UPDATE for AV_PKT_DATA_STRINGS_METADATA is supposed
to mean. The format of these two types of metadata is the same, but this
has nothing to do with AV_PKT_DATA_NEW_EXTRADATA or with extradata in
general.

> 
>> Besides that, there are some problems with your approach: You are simply
>> casting a pointer into the new extradata to AVVorbisHeaderExtradata*,
>> although the address may not be properly aligned. You are also not
>> checking that the extradata contains as much data as header_size claims
>> it does. The layout of your new extradata also depends on the system
>> (due to sizeof(header_size) and due to endianness), which makes it hard
>> to checksum it. And you forgot the APIchanges entry/version bump for
>> this struct (this point will become moot in a future version of this
>> patch, when no new struct is added).
> 
> Ok this makes sense, I can work on it.
> 
> Let me recap the needs:
> * extradata needs to be a flat memory array
> * extradata needs to be platform-independent and constantly checksum-able.
> * What's the exact requirement for alignment?
> Considering that the array contains 2 or more sequentially stored
> header chunks, do you require the start of each header chunk to have
> to be aligned? Is there a technical reason for that?

a) Reading or writing anything is undefined behavior unless the memory
is suitably aligned for the type used to access it; failure to do so
causes crashes (bus errors) on some systems.
b) As I said: Don't add a new structure for extradata, use the already
established format for vorbis.

- Andreas

_______________________________________________
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".

  reply	other threads:[~2025-06-03 19:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-01 16:21 Romain Beauxis
2025-06-03 17:12 ` Andreas Rheinhardt
2025-06-03 18:50   ` Romain Beauxis
2025-06-03 19:20     ` Andreas Rheinhardt [this message]
2025-06-03 19:53       ` Romain Beauxis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1P250MB07379AE39B3DB0213CBCE77A8F6DA@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git