[ID3 Dev] Padding

Ben Bennett fiji at ayup.limey.net
Tue Aug 23 14:10:31 PDT 2005


On Tue, Aug 23, 2005 at 10:00:26PM +0100, Ion Todirel wrote:
> If i use padding to add a new frame: let's say that i have a tag with TIT1 and TIT2: 
>  
> <tag header>
> <TIT1 header><TIT1 contents>
> <TIT2 header><TIT2 contents>
> <end of the tag, no padding>
> <mp3 audio data>
> <tag footer>
> <ID3v1 tag>

Yes.
 
>  
> if i add a new frame (TALB) using padding tag will look like this?:
>  
> <tag header>
> <TALB header only>
> <TIT1 header><TIT1 contents>
> <TIT2 header><TIT2 contents>
> <end of the tag, start of the padding>
> <TALB contents (or TALB enlargement, if padding is used to enlarge a frame)>
> <mp3 audio data>
> <no footer>
> <ID3v1 tag>

No.

The TALB is a frame and MUST be inside the ID3 tag.  The padding also
falls inside the tag, (i.e. is included in the tag size) but MUST
follow all frames.  So it will look like:

<tag header>
<TALB header only>
<TIT1 header><TIT1 contents>
<TIT2 header><TIT2 contents>
<TALB contents (or TALB enlargement, if padding is used to enlarge a frame)>
<padding>
<end of the tag>
<mp3 audio data>
<no footer>
<ID3v1 tag>

> if frame TALB already exists in the tag:
>  
> <tag header>
> <TALB header><TALB contents>
> 
> <TIT1 header><TIT1 contents>
> <TIT2 header><TIT2 contents>
> <end of the tag, no padding>
> <mp3 audio data>
> <tag footer>
> <ID3v1 tag>

Okay.

> and i extend it using padding:
>  
> <tag header>
> <TALB header><TALB contents>
> 
> <TIT1 header><TIT1 contents>
> <TIT2 header><TIT2 contents>
> <end of the tag, start of the padding>
> <TALB aditional content (or TALB enlargement)>
> <mp3 audio data>
> <no footer>
> <ID3v1 tag>

Again, no.  You can not split the additional content from TALB.  There
can only be one TALB frame per tag.  So it will look like:

<tag header>
<TALB header><New TALB contents>
<TIT1 header><TIT1 contents>
<TIT2 header><TIT2 contents>
<padding>
<end of the tag>
<mp3 audio data>
<no footer>
<ID3v1 tag>

  
> But how to detect when padding starts? just before last frame, but how to detect when is last frame?

Padding falls after all frames.  It is the last thing in the tag.  So
if you expect to see a frame header but read all nuls then you are
into the padding.

The only point to padding is to prevent rewriting all of the content
in the file if a tag grows.  So if you have N bytes of padding at the
end of a frame and you grow the content by N bytes or less, you can
just rewrite the tag and shrink the padding.  But if you need to grow
something by more than N bytes then you need to fiddle with the
remainder of the file as well.

Does that help?

		      -ben

---------------------------------------------------------------------
To unsubscribe, e-mail: id3v2-unsubscribe at id3.org
For additional commands, e-mail: id3v2-help at id3.org



More information about the ID3v2 mailing list