Question

I have the below, snippet of code which puts an .amr file into a byte array.

I know how to get the bit rate from the header as shown below. So Assuming the bit rate is 7.95, what is the formula to use to calculate the frame size? Thanks.

public void getFrames() {
        File inputFile = new File(getmFileName());
        try {
            FileInputStream fis = new FileInputStream(inputFile);

            byte fileContent[]= new byte[(int) inputFile.length()];

            fis.read(fileContent); // Reads the file content as byte.
            fis.close();

            int count = 0;
            for (int i = 0; i < 8; i++) {

               Log.i(LOG_TAG, "byte"+ fileContent[i]);
               count++;
               Log.i(LOG_TAG, "7thbyte_of_1stHeader:" + ((fileContent[7]>>3)& 0x0F) );
            }} catch (Exception ex) {
            // TODO Auto-generated catch block
            ex.printStackTrace();

        }   }
Was it helpful?

Solution

Nokia offers the following table for the relation between codec mode (CMR), bit rate and frame size:

CMR     MODE        FRAME SIZE( in bytes )
0      AMR 4.75        13
1      AMR 5.15        14 
2      AMR 5.9         16
3      AMR 6.7         18
4      AMR 7.4         20
5      AMR 7.95        21
6      AMR 10.2        27
7      AMR 12.2        32
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top