0

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();

        }   }
cube
  • 1,774
  • 4
  • 23
  • 33

1 Answers1

0

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
Michael
  • 57,169
  • 9
  • 80
  • 125
  • Thanks Michael. I'm little confused here, in that Nokia spec it says that the frame size in bits is 159. So the math doesn't add up. 159/8 doesn't equal 21. What am I missing? – cube Mar 27 '14 at 23:46
  • trunc((159+7)/8) + 1 = 21. You have to pad the bits to fill the byte and then add a further byte for the frame header. – kbro Aug 19 '20 at 14:33