AnsweredAssumed Answered

MP3 Decoder Module

Question asked by MartyP on Apr 11, 2012
Latest reply on Apr 19, 2012 by MartyP

Hello all,

 

I'm trying to set up the MP3 Decoder Module on a BF512.  I've set up my test like the BF527 example, but only decoding the mpeg2 file, clip_48khz.mp2.  I'm emulating the code, so I've actually hard coded a raw data array of about the first 2MB of this clip into the code to eliminate the slow file I/O on the input.  I'm still outputting over an ICE-100B to a WAV file.  The first run through the adi_mp3_decoder function returns an ADI_MP3_DEC_NEED_MORE_DATA, as expected, and each following run returns ADI_MP3_DEC_SUCCESS, again as expected, until the end of the file.  The actual PCM data however does not seem to be valid.  I decoded the example mp2 file using a commercial product and I can see the PCM data from the BlackFin is not close to the output from the commercial decoder.  The BF WAV file is garbled and seems only about half decoded.  I've verified the output WAV file header, the MPEG audio frame headers just before each audio frame gets decoded and the writing of PCM data to file.  The decoder module doesn't complain, it just seems to put out the wrong data.  I initialize the memory pools and create the decoder like the BF527 example and MP3 Developer's Guide,

 

     /* state memory */

          state_dec1.onchip_block0 = (int *)OnchipBlock0_Dec1;

          state_dec1.onchip_block1 = (int *)OnchipBlock1_Dec1;

          state_dec1.onchip        = Onchip;

          state_dec1.offchip       = AnyWhere;

 

          /* scratch memory */

          scratch_dec1.onchip_block0 = (int *)OnchipBlock0Scratch_Dec1;

          scratch_dec1.onchip_block1 = (int *)OnchipBlock1Scratch_Dec1;

          scratch_dec1.onchip        = OnchipScratch;

     scratch_dec1.offchip       = AnyWhereScratch;

 

          dec1_handle = adi_mp3_dec_create(&state_dec1, &scratch_dec1);

 

 

And I configure the decoder like the example,

 

        requested_config_dec1.noMoreDataWithApp   = 0;

        requested_config_dec1.enable_mp3   = 1;

        requested_config_dec1.input_buffer_length    = ADI_MP3_DEC_MIN_BITSTREAM_BUFSIZE;

        requested_config_dec1.input_buffer_base_addr = input_buffer_dec1;

        requested_config_dec1.frame_properties = &frame_properties_dec1;

        requested_config_dec1.max_bytes_to_search_for_sync = ADI_MP3_DEC_MAX_BYTES_TO_SEARCH_FOR_SYNC;

 

        requested_config_dec1.use_circular_output_buffer = USE_CIRCULAR_OUTPUT_BUFFER;

        requested_config_dec1.output_buffer_base_addr = output_pcm_channels[0];

        requested_config_dec1.output_buffer_length_int16 = OUTPUT_BUFFER_LENGTH;

 

        dec1_output_status.num_input_bytes_consumed = 0;

        dec1_output_status.frame_properties_ptr = &frame_properties_dec1;

        dec1_output_status.anc_data_ptr = adi_ans_data_dec1;

        dec1_output_status.anc_data_size = 0;

 

        current_read_ptr = input_buffer_dec1;

        current_write_ptr = output_buffer_dec1;

 

        // must be "1"

        requested_config_dec1.use_circular_buffer = 1;

 

        end_of_stream_reached = 0;

       

        dec_return = adi_mp3_dec_init(dec1_handle,

                                    (const adi_mp3_dec_config_t*)&requested_config_dec1,

                                    &actual_decoder_config_dec1);

 

 

If anyone has any tips or advice I would be very grateful.  This module doesn't say it supports the BF512, but I'm hoping it isn't too tough to adapt it to the BF512.  Thanks for any info.  

Outcomes