Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Padding (Read 2989 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Padding

I have a question about padding in MPEG audio streams.

In this ISO-IEC 11172-3 9041091 document I read:
(1)
Quote
".. Padding should be applied to the bitstream such that the accumulated length of coded frames, after a certain number of them, does not deviate more than (+0, -1 slot) from the computed value..";

(2)
Quote
".. Padding is only necessary with a sampling frequency of 44.1kHz..";

(3)
Quote
".. If this calculation does not give an integer number the result is truncated and 'padding' is required.."


(With this 'calculation' being a 'number of slots' (N) (= 12 * bitrate / samplefreq for L.I, = 144 * bitrate / samplefreq. for L.II / L.III)).

Now, I guess it should be obvious, but can someone point out how to use this to verify padding in an existing MPEG audio file?

Thanks in advance :-)

Padding

Reply #1
I was hoping someone would care to shed some light on this, anyone?

Let's see whether I can elaborate on this myself a bit (I'm just writing this off the top of my head):
[blockquote]say Nc is this 'certain number of frames',
say Np is the number of frames which are padded, as a part of this 'certain number of frames' (with Np <= Nc ),
and Ns is the 'number-of-slots' from the suggested calculation, then

Nc x Ns + Np x 1 = something, with something ~ (1 / sample-frequency)..[/blockquote]
Any ideas about 'something' ?
;-)

Padding

Reply #2
example: 128 kbps CBR mp3
  • slots (i.e. bytes) per frame = 144*128/44.1 = 417.95918367
  • unpadded frame: 417 bytes
  • padded frame: 418 bytes
  • 95.9% of all frames in a file should be padded.
So you can verify padding in an existing file like this: add the sizes (number of slots) of all frames (padded and unpadded) and divide that sum by the number of frames. The result is the actual average frame size in that file. Compare this to the theoretical average frame size (144*bitrate/samplefreq).

For the strict ISO verification as described in your quote you have to check for every frame of the file the condition mentioned: that the actual accumulated frame sizes (from beginning of file up to the current frame) are never larger and never smaller by more than one slot than the theoretical accumulated frame sizes (which may be fractional).

 

Padding

Reply #3
Thanks smack (the obbvious clearly escaped me here :-)