iphone - Decoding ima4 audio format -


I am compressing some audio files to reduce the download size of an iPhone application. In particular I command I'm using FFF on line .waf format CAF format w / ima4 compression.

I've read horrible posts about this exact topic (wooji-juice.com). I'm having trouble / w "decoding IMA 4 packet" phase. I have seen their sample code and I am trapped. Please

Additional information : Here's what I got done and I'm having trouble ... I'm a simulator and phone Can run .wav files in both. I can compress the .wav files to the compression by using afconvert on the command line .caf w / ima4 compression. I'm using SoundEngine which came w / CrashLanding (I have fixed a memory leak). I have modified the soundEngine code to search for amformatid 'IMA 4'.

I do not understand the blog written above by starting a blog post / "Calculate the size of unpacked data" Why do I need to do this? Besides, what does the word "packet" mean? I'm new to any type of audio programming. After collecting all the data from

and, here's my proposal (some experiments may be required)

File structure

  • The Apple IMA 4 file is composed of 34 bytes of packet. This is the packet unit used to create the file.
  • Each of the 34 bytes packets has two parts:
    • The precedence in the first 2 bytes is: An initial divisor and a step index
    • There were sound nibbles in 32 bytes (A hunchback of 4 beats is used to obtain a 16-bit sample)
  • Compressed data of 32 bytes in each packet, which is one of 64 samples of 16 bits Represent.
  • If the sound file is stereo, the packets are interleaved (one on the left, one for the right);

Decoding

Each pack of 34 bytes will be prompted by the decompression of 16 to 64 specimens. Therefore, the size of uncompressed data is 128 bytes per packet.

The decoding pseudo code looks like this:

  int [] ima_index_table = ... // index table [multimedia wiki] [2] int [] step_table = .. [[Multimedia wiki] [2] byte [] Step table with packet [...] Packet = 34 pack a pack of bytes [] Output =. Output buffer of 128 bytes int prime = (packet [0] & lt; & lt; 8) Packet [1]; Intel Prophecy = Introduction & amp; Amp; 0xFF80; See [multimedia wiki] [2] int step_index = preface & amp; Amp; 0x007F; See [multimedia wiki] [2] int i; Int j = 0; For (i = 2; i <34; i ++) {byte data = packet [i]; Int low_nbble = data & amp; Amp; 0x0F; Integer upper_enbubble = (data & amp; 0xF0) & gt; & Gt; 4; // Lower Encrypt Decode step_index + + ima_index_table [lower_nibble]; Diff = ((signed) nibble + 0.5 f) * step / 4; Predictor + = diff; Step = ima_step_table [step indices]; // Click the predictive value to stay in the category if the (prediction> 65535) output [j ++] = 65535; Else if (predictor & lt; -65536) Output [j ++] = -65536; And output [j ++] = (short) scripter; // decoded apple nab step_index + = ima_index_table [upper_nibble]; Diff = ((signed) nibble + 0.5 f) * step / 4; Predictor + = diff; Step = ima_step_table [step indices]; //Click the predictive value to stay in the category if the (prediction> 65535) output [j ++] = 65535; Else if (predictor & lt; -65536) Output [j ++] = -65536; And output [j ++] = (short) scripter; }  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -