Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  one question for bps openning audio
« previous next »
  • Print
Pages: [1]

Author Topic: one question for bps openning audio  (Read 2918 times)

Offline powerpan

  • Member
  • *
  • Posts: 52
one question for bps openning audio
« on: April 23, 2011, 05:24:47 AM »
check the code, did not pass the right bits per sample parameters out to hardware, like FLAC, output 28 bit to DSP, how to know the song bps while hardware only supports 8,10,12,14,16,28,20,24,32 bits for samples?

id3 has no bps field and this parameter might be got via codec_main. anybody knows?
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: one question for bps openning audio
« Reply #1 on: April 23, 2011, 06:21:19 AM »
You might want to rework your question. I have no idea what you are talking about.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline powerpan

  • Member
  • *
  • Posts: 52
Re: one question for bps openning audio
« Reply #2 on: April 23, 2011, 09:22:45 AM »
for example, every codec will have its own sample depth

    /* Generic codec initialisation */
    ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1);

above is from flac.c in codecs dir. and the real SAMPLE_DEPTH is 16 or 24bit instead of the defined value(29bit). and, any sound card needs this to set to work properly, my questions is why Rockbox did not set this value in DSP?

or, I think it must be some place to set the sample depth, just could not find it out.

« Last Edit: April 23, 2011, 10:56:06 AM by powerpan »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: one question for bps openning audio
« Reply #3 on: April 23, 2011, 02:17:29 PM »
Quote from: powerpan on April 23, 2011, 09:22:45 AM
for example, every codec will have its own sample depth

    /* Generic codec initialisation */
    ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1);

above is from flac.c in codecs dir. and the real SAMPLE_DEPTH is 16 or 24bit instead of the defined value(29bit).

ARM and Coldfire processors are 32 bit, so they also return 32 bit samples.  The DSP_SET_SAMPLE_DEPTH value is the location of the decimal point in the 32 bit fixed point number.  Its used to ensure that the gain is correct during playback, since internally different codecs use different fixed point representations. 

Quote from: powerpan on April 23, 2011, 09:22:45 AM
and, any sound card needs this to set to work properly, my questions is why Rockbox did not set this value in DSP?

The DAC doesn't know or care how many bits the source material was, nor how many bits the decoder uses internally.  Internally some codecs like flac do have a header that states the bits used in the source material, but many do not (mp3, wma, vorbis, aac, etc). 
Logged

Offline powerpan

  • Member
  • *
  • Posts: 52
Re: one question for bps openning audio
« Reply #4 on: April 24, 2011, 06:13:49 AM »
so, it means the program assume to use 32bit output by default. in the CPU specification for audio part, you must set the right bit rates before the DMA and the I2S FIFO could work properly, that's my question, where dose rockbox set this value to hardware? s3c2440 only has 16bit audio output, so, how the programm deal with 16 bit output ? or just right shift 16 bits to fit it?

DAC does not care how many bits but AIC in the CPU cares. don't know if my question is clear or not.

explain in another way, say saving the decoded stream to a wav file, a field is bits per sample, in main.c under libffmpeg dir, there is a simple output wav function, it needs fc->bps to write to a wav file, so, it must be a place to output the bps field to DSP  so that CPU AIC(hardward) could work properly.
« Last Edit: April 25, 2011, 08:51:14 AM by powerpan »
Logged

Offline powerpan

  • Member
  • *
  • Posts: 52
Re: one question for bps openning audio
« Reply #5 on: May 15, 2011, 07:46:25 AM »
found that the BPS was no need for rockbox because all output is clipped to 16bit output.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: one question for bps openning audio
« Reply #6 on: May 15, 2011, 04:48:51 PM »
Quote from: powerpan on May 15, 2011, 07:46:25 AM
found that the BPS was no need for rockbox because all output is clipped to 16bit output.


Correct.   Like you said a couple weeks ago, we have 16 bit DACs. 
Logged

Offline powerpan

  • Member
  • *
  • Posts: 52
Re: one question for bps openning audio
« Reply #7 on: May 18, 2011, 12:09:17 PM »
I was confusing while reading rockbox's codes, why shift up and down....
memcpy in system causes much CPU time because CPU always waits the memory ready..

the API design is good and I found a way to get the real BPS from codec already without rewriting the CODECs.

and metadata got mp4 filesize wrong, and don't know why in rockbox space, ci->filesize has 2 copies.. one is right and one is wrong by get_mp4_metadata function..

Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: one question for bps openning audio
« Reply #8 on: May 18, 2011, 12:20:12 PM »
Quote from: powerpan on May 18, 2011, 12:09:17 PM
the API design is good and I found a way to get the real BPS from codec already without rewriting the CODECs.

Let me guess:  its always 32 bits ;)
Logged

Offline powerpan

  • Member
  • *
  • Posts: 52
Re: one question for bps openning audio
« Reply #9 on: May 18, 2011, 11:37:53 PM »
my output always set to 24bit, how to upload a picture?

        if (snd_card.bps_tested<BPS_TEST_TIME)      // test real bps from the decoder
        {
           temp |= data0;
         if (snd_card.stereo_mode == STEREO_NONINTERLEAVED)
            temp |= data1;
        }


........

   if (snd_card.bps_tested<BPS_TEST_TIME)
   {
      if (temp)         // there is valid sound data
      {
         snd_card.dataLR |= temp;
         //printf("dataLR:%x, iTimecnt:%d\n", snd_card.dataLR, snd_card.bps_tested);
         snd_card.bps_tested ++;
      }
      
      if (snd_card.bps_tested==BPS_TEST_TIME)
      {
         //printf("\nsound output bps:%d\n", snd_card.bps);
         temp = 0xfffffffe;
         for (i=23;i>8;i--)      // test to 8 bit is enough
         {
            //printf("temp=:%lx, dataLR:%lx, data0:%lx\n", (unsigned int)temp, (unsigned int)snd_card.dataLR, (unsigned int)data0);
            data0 = snd_card.dataLR & temp;
            if (data0==snd_card.dataLR)
               snd_card.bps = i;

            temp <<= 1;         // for the next test
         }
         printf("\nreal bps detected:%d\n", snd_card.bps);
         
         //exit(1);   ////debug
      }
   }
« Last Edit: May 18, 2011, 11:45:19 PM by powerpan »
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  one question for bps openning audio
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.076 seconds with 15 queries.