Skip to content

Corrupted decoded audio data on dsPIC33FJ128GP802 #1

@mdanh2002

Description

@mdanh2002

Hi,

I successfully compiled your code on the dsPIC33FJ128GP802. By using snippets from the file mp3lib_test_package/main.c, I was able to get the code to successfully parse my MP3 files. The file header with MPEG layer and sampling rate information can be read properly and returns the correct value. By using the state machine functions to play a test file, the mp3_sm_output function is called correctly for the entire duration of the file, and duration_us also contains the correct value. Although the number of PCM samples returned is correct, the decoded PCM data is corrupted and can't be played back normally.

I sent the resulting PCM data via UART to my PC and noticed the following:

  1. If the original MP3 file contains only silence (generated using Goldwave silence function), the decoded PCM data will also contain only zeroes (and therefore silence). This indicates that the MP3 decoder functions must be at least partially working.
  2. However, for a normal MP3 file with audio, the decoded PCM data is corrupted. It contains silence (all zeroes) every few milliseconds, although some audio patterns resembling the original MP3 audio data can be discerned. On my sample file, for example, I can tell that the waveform for first few milliseconds of the decoded PCM data resembles that of the original data, and that there is an audio volume shift (change in amplitude) in the middle of the file. Other than that, the decoded audio is corrupted and unusable.

You can download sample data for point (2) here https://drive.google.com/file/d/14Qj36CQhfFA8uOvArntFRi0b4ux0iNQZ/view?usp=sharing
with the original MP3 file, decoded WAV file on my PC, and the decoded PCM data from the library.

If it helps, I have little difficulty compiling your code. The only challenge I have is with the mp3__cs and mp3_ca constant declaration in file mpeg_2__3_tbl.cs. The original code declares both constants to be in MP3_SECTION_CA_CS (.mp3_ca_cs), which causes a compiler error saying that the same section cannot appear at both addresses (0xD000 and 0xD012). I fixed it by declaring different names for each constant. The other thing is the "reserved" section declaration in your sample code at address 0x7FFA, which causes my PIC to crash immediately at main(), and has to be commented out. Otherwise, I did not make any change to the code.

One thing I noticed is that for certain files, the function mp3_sm_error is called more frequently compared with other files. On these files, the sum of duration_us in the mp3_header returned in mp3_sm_output will be significantly less than the actual duration of the file. For the MP3 in the above link, mp3_sm_error is never called and the decoding appears to process smoothly, with mp3_sm_finished called at the end. I also verified that the total number of decoded PCM bytes matches the expected value and observed the decode function in mp3_layer3_decode.c works normally and did not return error.

I am decoding in mono (NCHANNELS =1) due to limited memory. I am using MPLAB 8.92 on C30, using large code model, large data model, constants in code space and large scalar model. Tweaking various compiler/linker options yields no differences.

Thanks in advance for any advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions