Skip to main content

Topic: combining main data in mp3 file (Read 1658 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • treemon
  • [*]
combining main data in mp3 file
This is my first post here, I am happy to find this forum where I can share specific problems, hopefully I will get some direction,

I am trying to decode mp3 file using my C code for informative purposes, I dont want to use any library etc. I have gone through previous threads and I can do following stuffs successfully

1. take an mp3 file and process as bitstream that gives me correct number of physical frames
2. decode frame header and side information and store main data in a array of struct.
2. Now I want to convert these physical frames into logical frames for making better sense of data.

I have learned that side info has pointer to begin_main_data and we can sum part_2_3len to get total size of main data


size of main data ( in bits) = part2_3_length (g1 + channel0) + part2_3_length (g1 +channel1) + part2_3_length (g2 + channel0) + part2_3_length (g2 + channel1)
so is it true ?

And below the frame by frame debug log for an mp3 file

fs -> frame size, (excluding header)

bmd -> begin main data pointer

smd -> size main data (in bytes)

======output =========

fs : 413, bmd : 0, smd : 1
fs : 414, bmd : 381, smd : 651
fs : 414, bmd : 62, smd : 470
fs : 414, bmd : 28, smd : 409
fs : 414, bmd : 79, smd : 430
fs : 414, bmd : 117, smd : 385
fs : 414, bmd : 173, smd : 333

From above log it seems that either my code is wrong or conceptually I am missing something first physical frame has no data of its own, second frame has 381 bytes in first frame and remaining (651-381 = 270) in its own frame, so in its own frame 414 -32 - 270 = 112 are left as byte reservoir which should be used by next frame, but the third frame is starting from -62 offset and not -112

can you pls make me understand what is wrong with my procedure

Thanks a lot