amrFileCodec.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <stdlib.h>
  11. #include <string.h>
  12. #include <stdio.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. {
  22. char chChunkID[4];
  23. int nChunkSize;
  24. }EM_XCHUNKHEADER;
  25. typedef struct
  26. {
  27. short nFormatTag;
  28. short nChannels;
  29. int nSamplesPerSec;
  30. int nAvgBytesPerSec;
  31. short nBlockAlign;
  32. short nBitsPerSample;
  33. }EM_WAVEFORMAT;
  34. typedef struct
  35. {
  36. short nFormatTag;
  37. short nChannels;
  38. int nSamplesPerSec;
  39. int nAvgBytesPerSec;
  40. short nBlockAlign;
  41. short nBitsPerSample;
  42. short nExSize;
  43. }EM_WAVEFORMATX;
  44. typedef struct
  45. {
  46. char chRiffID[4];
  47. int nRiffSize;
  48. char chRiffFormat[4];
  49. }EM_RIFFHEADER;
  50. typedef struct
  51. {
  52. char chFmtID[4];
  53. int nFmtSize;
  54. EM_WAVEFORMAT wf;
  55. }EM_FMTBLOCK;
  56. // WAVE audio processing frequency is 8khz
  57. // audio processing unit = 8000*0.02 = 160 (decided by audio processing frequency)
  58. // audio channels 1 : 160
  59. // 2 : 160*2 = 320
  60. // bps decides the size of processing sample
  61. // bps = 8 --> 8 bits
  62. // 16 --> 16 bit
  63. int EM_EncodeWAVEFileToAMRFile(const char* pchWAVEFilename, const char* pchAMRFileName, int nChannels, int nBitsPerSample);
  64. int EM_DecodeAMRFileToWAVEFile(const char* pchAMRFileName, const char* pchWAVEFilename);
  65. int isMP3File(const char *filePath);
  66. int isAMRFile(const char *filePath);
  67. #endif