amrFileCodec.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // amrFileCodec.h
  3. // amrDemoForiOS
  4. //
  5. // Created by Tang Xiaoping on 9/27/11.
  6. // Copyright 2011 test. All rights reserved.
  7. //
  8. #ifndef amrFileCodec_h
  9. #define amrFileCodec_h
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include "interf_dec.h"
  14. #include "interf_enc.h"
  15. #define AMR_MAGIC_NUMBER "#!AMR\n"
  16. #define MP3_MAGIC_NUMBER "ID3"
  17. #define PCM_FRAME_SIZE 160 // 8khz 8000*0.02=160
  18. #define MAX_AMR_FRAME_SIZE 32
  19. #define AMR_FRAME_COUNT_PER_SECOND 50
  20. typedef struct {
  21. char chChunkID[4];
  22. int nChunkSize;
  23. } EM_XCHUNKHEADER;
  24. typedef struct {
  25. short nFormatTag;
  26. short nChannels;
  27. int nSamplesPerSec;
  28. int nAvgBytesPerSec;
  29. short nBlockAlign;
  30. short nBitsPerSample;
  31. } EM_WAVEFORMAT;
  32. typedef struct {
  33. short nFormatTag;
  34. short nChannels;
  35. int nSamplesPerSec;
  36. int nAvgBytesPerSec;
  37. short nBlockAlign;
  38. short nBitsPerSample;
  39. short nExSize;
  40. } EM_WAVEFORMATX;
  41. typedef struct {
  42. char chRiffID[4];
  43. int nRiffSize;
  44. char chRiffFormat[4];
  45. } EM_RIFFHEADER;
  46. typedef struct {
  47. char chFmtID[4];
  48. int nFmtSize;
  49. EM_WAVEFORMAT wf;
  50. } EM_FMTBLOCK;
  51. // WAVE audio processing frequency is 8khz
  52. // audio processing unit = 8000*0.02 = 160 (decided by audio processing frequency)
  53. // audio channels 1 : 160
  54. // 2 : 160*2 = 320
  55. // bps decides the size of processing sample
  56. // bps = 8 --> 8 bits
  57. // 16 --> 16 bit
  58. int EM_EncodeWAVEFileToAMRFile(const char* pchWAVEFilename, const char* pchAMRFileName, int nChannels, int nBitsPerSample);
  59. int EM_DecodeAMRFileToWAVEFile(const char* pchAMRFileName, const char* pchWAVEFilename);
  60. int isMP3File(const char* filePath);
  61. int isAMRFile(const char* filePath);
  62. #endif