Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
5.6 KiB

  1. #include <windows.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include "fv_x8.h" // for DLL entry points
  5. #include "variable.h"
  6. # define SAMPLING_FREQUENCY F_ECH
  7. # define DLL_MAJOR 1
  8. # define DLL_MINOR 0
  9. # define PCM_BUFFER_SIZE_4800_8000 2*NBSPF_4800_8000
  10. # define PCM_BUFFER_SIZE_12000_16000 2*NBSPF_12000_16000
  11. # define CODED_BUFFER_SIZE_4800 MAX_OUTPUT_BYTES_4800
  12. # define CODED_BUFFER_SIZE_8000_12000 MAX_OUTPUT_BYTES_8000_12000
  13. # define CODED_BUFFER_SIZE_16000 MAX_OUTPUT_BYTES_16000
  14. # define PCM_BITS_PER_SAMPLE 16
  15. # define CODEC_SUB_TAG_4800 800
  16. # define CODEC_SUB_TAG_8000 801
  17. # define CODEC_SUB_TAG_12000 802
  18. # define CODEC_SUB_TAG_16000 803
  19. # define CODEC_SUB_TAG_NAME_4800 "L&H SBCELP Codec 4.8 kbps"
  20. # define CODEC_SUB_TAG_NAME_8000 "L&H SBC var.bitrate, 8 kbps 8 kHz" // !!! lenght<40
  21. # define CODEC_SUB_TAG_NAME_12000 "L&H SBC var.bitrate, 12 kbps 8 kHz" // !!! lenght<40
  22. # define CODEC_SUB_TAG_NAME_16000 "L&H SBC var.bitrate, 16 kbps 8 kHz" // !!! lenght<40
  23. # define MakeVersion(a,b) ((DWORD)a<<16)|(DWORD)b
  24. # define LONG_CODEC_SUB_TAG_NAME_4800 "L&H SBCELP Codec, 4.8 kbps 8 kHz"
  25. # define LONG_CODEC_SUB_TAG_NAME_8000 "L&H SBC var.bitrate, 8 kbps 8 kHz"
  26. # define LONG_CODEC_SUB_TAG_NAME_12000 "L&H SBC var.bitrate, 12 kbps 8 kHz"
  27. # define LONG_CODEC_SUB_TAG_NAME_16000 "L&H SBC var.bitrate, 16 kbps 8 kHz"
  28. # define IS_VAR_BIT_RATE_4800 0
  29. # define IS_VAR_BIT_RATE_8000_12000_16000 1
  30. # define MIN_CODED_BUFFER_SIZE_4800 12
  31. # define MIN_CODED_BUFFER_SIZE_8000_12000_16000 1
  32. # define MEAN_BIT_RATE_4800 4800
  33. # define MEAN_BIT_RATE_8000 8000
  34. # define MEAN_BIT_RATE_12000 12000
  35. # define MEAN_BIT_RATE_16000 16000
  36. # define IS_RT_CODING_4800 FALSE
  37. # define IS_RT_CODING_8000_12000_16000 TRUE
  38. # define IS_RT_DECODING TRUE
  39. # define IS_FLOATING_POINT FALSE
  40. # define INPUT_PCM_ONLY 0x0001
  41. # define EXTRA_CODEC_INFO_SIZE 0
  42. LH_PREFIX LH_ERRCODE LH_SUFFIX MSLHSB_GetCodecInfo(LPCODECINFO CodecInfo, DWORD dwMaxBitRate)
  43. // Returns the input and output buffer sizes.
  44. {
  45. if ((!CodecInfo) || ((dwMaxBitRate != 4800) && (dwMaxBitRate != 8000) && (dwMaxBitRate != 12000) && (dwMaxBitRate != 16000)))
  46. return LH_EBADARG;
  47. CodecInfo->wBitsPerSamplePCM=PCM_BITS_PER_SAMPLE;
  48. CodecInfo->dwSampleRate=SAMPLING_FREQUENCY;
  49. CodecInfo->dwDLLVersion=MakeVersion(DLL_MAJOR,DLL_MINOR);
  50. switch (dwMaxBitRate)
  51. {
  52. case 4800:
  53. CodecInfo->wPCMBufferSize=PCM_BUFFER_SIZE_4800_8000;
  54. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_4800;
  55. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_4800;
  56. strcpy(CodecInfo->wFormatSubTagName,CODEC_SUB_TAG_NAME_4800);
  57. break;
  58. case 8000:
  59. CodecInfo->wPCMBufferSize=PCM_BUFFER_SIZE_4800_8000;
  60. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_8000_12000;
  61. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_8000;
  62. strcpy(CodecInfo->wFormatSubTagName,CODEC_SUB_TAG_NAME_8000);
  63. break;
  64. case 12000:
  65. CodecInfo->wPCMBufferSize=PCM_BUFFER_SIZE_12000_16000;
  66. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_8000_12000;
  67. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_12000;
  68. strcpy(CodecInfo->wFormatSubTagName,CODEC_SUB_TAG_NAME_12000);
  69. break;
  70. case 16000:
  71. CodecInfo->wPCMBufferSize=PCM_BUFFER_SIZE_12000_16000;
  72. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_16000;
  73. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_16000;
  74. strcpy(CodecInfo->wFormatSubTagName,CODEC_SUB_TAG_NAME_16000);
  75. break;
  76. }
  77. return LH_SUCCESS;
  78. }
  79. // PhilF: We don't call this guy from the wrapper, so no need to implement it
  80. #if 0
  81. LH_PREFIX LH_ERRCODE LH_SUFFIX MSLHSB_GetCodecInfoEx(LPCODECINFOEX CodecInfo,DWORD cbSize, DWORD dwMaxBitRate)
  82. {
  83. if ((!CodecInfo) || (cbSize!=(DWORD)sizeof(CODECINFOEX)) || ((dwMaxBitRate != 8000) && (dwMaxBitRate != 12000) && (dwMaxBitRate != 16000)))
  84. return LH_EBADARG;
  85. if (cbSize==(DWORD)sizeof(CODECINFOEX))
  86. {
  87. // Information on implemented codec
  88. switch (dwMaxBitRate)
  89. {
  90. case 8000:
  91. CodecInfo->wInputBufferSize=PCM_BUFFER_SIZE_8000;
  92. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_8000_12000;
  93. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_8000;
  94. strcpy(CodecInfo->szFormatSubTagName,LONG_CODEC_SUB_TAG_NAME_8000);
  95. CodecInfo->nAvgBytesPerSec=MEAN_BIT_RATE_8000/8;
  96. break;
  97. case 12000:
  98. CodecInfo->wInputBufferSize=PCM_BUFFER_SIZE_12000_16000;
  99. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_8000_12000;
  100. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_12000;
  101. strcpy(CodecInfo->szFormatSubTagName,LONG_CODEC_SUB_TAG_NAME_12000);
  102. CodecInfo->nAvgBytesPerSec=MEAN_BIT_RATE_12000/8;
  103. break;
  104. case 16000:
  105. CodecInfo->wInputBufferSize=PCM_BUFFER_SIZE_12000_16000;
  106. CodecInfo->wCodedBufferSize=CODED_BUFFER_SIZE_16000;
  107. CodecInfo->wFormatSubTag=CODEC_SUB_TAG_16000;
  108. strcpy(CodecInfo->szFormatSubTagName,LONG_CODEC_SUB_TAG_NAME_16000);
  109. CodecInfo->nAvgBytesPerSec=MEAN_BIT_RATE_16000/8;
  110. break;
  111. }
  112. CodecInfo->bIsVariableBitRate=IS_VAR_BIT_RATE;
  113. CodecInfo->bIsRealTimeEncoding=IS_RT_CODING;
  114. CodecInfo->bIsRealTimeDecoding=IS_RT_DECODING;
  115. CodecInfo->bIsFloatingPoint=IS_FLOATING_POINT;
  116. // Information on supported input format
  117. CodecInfo->wInputDataFormat=INPUT_PCM_ONLY;
  118. CodecInfo->dwInputSampleRate=SAMPLING_FREQUENCY;
  119. CodecInfo->wInputBitsPerSample=PCM_BITS_PER_SAMPLE;
  120. // Information on buffer sizes
  121. CodecInfo->wMinimumCodedBufferSize=MIN_CODED_BUFFER_SIZE;
  122. CodecInfo->dwDLLVersion=MakeVersion(DLL_MAJOR,DLL_MINOR);
  123. CodecInfo->cbSize=EXTRA_CODEC_INFO_SIZE;
  124. }
  125. }
  126. #endif