patch-xa_acodec_c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. $OpenBSD: patch-xa_acodec_c,v 1.2 2015/06/29 23:07:07 ratchov Exp $
  2. --- xa_acodec.c.orig Sun Mar 21 23:36:25 1999
  3. +++ xa_acodec.c Fri Jun 26 12:27:44 2015
  4. @@ -198,7 +198,17 @@ xaULONG ocnt,buff_size;
  5. {
  6. if (inc_cnt < (1<<24))
  7. { /*** Decode Sample ***/
  8. - dataL = (spec & 4)?(ibuf[1]):(*ibuf);
  9. + if (snd_hdr->volume_boost)
  10. + {
  11. + unsigned c = snd_hdr->volume_boost;
  12. + unsigned d = 8 - c;
  13. + if (spec & 4)
  14. + dataL = (ibuf[1]<<c) | (ibuf[0]>>d);
  15. + else
  16. + dataL = (ibuf[0]<<c) | (ibuf[1]>>d);
  17. + }
  18. + else
  19. + dataL = (spec & 4)?(ibuf[1]):(*ibuf);
  20. ibuf += bps; byte_cnt += bps; samp_cnt--;
  21. inc_cnt += inc;
  22. }
  23. @@ -1884,6 +1894,19 @@ DEBUG_LEVEL1
  24. new_snd->inc = inc = (xaULONG)( finc * (double)(1<<24) );
  25. new_snd->inc_cnt = 0;
  26. + if (vaudiof->amp_scale < 2.0)
  27. + new_snd->volume_boost = 0;
  28. + else if (vaudiof->amp_scale < 4.0)
  29. + new_snd->volume_boost = 1;
  30. + else if (vaudiof->amp_scale < 8.0)
  31. + new_snd->volume_boost = 2;
  32. + else if (vaudiof->amp_scale < 16.0)
  33. + new_snd->volume_boost = 3;
  34. + else if (vaudiof->amp_scale < 32.0)
  35. + new_snd->volume_boost = 4;
  36. + else
  37. + new_snd->volume_boost = 5;
  38. +
  39. /* Determine Chunk Time */
  40. ftime = ((double)(xa_vaudio_hard_buff) * 1000.0) / (double)(hfreq);
  41. new_snd->ch_time = (xaLONG)ftime;
  42. @@ -2167,6 +2190,7 @@ fprintf(stderr,"XA_IPC_Sound itype %x\n",itype);
  43. break;
  44. case XA_AUDIO_LINEAR_1M:
  45. + case XA_AUDIO_SIGNED_1M:
  46. {
  47. switch(itype)
  48. {
  49. @@ -2183,7 +2207,8 @@ fprintf(stderr,"XA_IPC_Sound itype %x\n",itype);
  50. case XA_AUDIO_LINEAR_2SL:
  51. case XA_AUDIO_LINEAR_2SB:
  52. new_snd->spec =
  53. - ((itype & XA_AUDIO_TYPE_MASK)==XA_AUDIO_LINEAR)?(0):(1);
  54. + ((itype & XA_AUDIO_TYPE_MASK)==
  55. + (xa_audio_hard_type & XA_AUDIO_TYPE_MASK))?(0):(1);
  56. if (itype & XA_AUDIO_BPS_2_MSK)
  57. new_snd->spec |= (itype & XA_AUDIO_BIGEND_MSK)?(2):(4);
  58. if (itype & XA_AUDIO_STEREO_MSK)
  59. @@ -2195,12 +2220,16 @@ fprintf(stderr,"XA_IPC_Sound itype %x\n",itype);
  60. if (xa_audio_hard_type & XA_AUDIO_BIGEND_MSK)
  61. new_snd->spec = 0 | 4 | 8;
  62. else new_snd->spec = 1 | 4 | 8;
  63. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  64. + new_snd->spec |= 2;
  65. new_snd->delta = XA_ADecode_ULAWx_PCMxM;
  66. break;
  67. case XA_AUDIO_ULAW:
  68. if (xa_audio_hard_type & XA_AUDIO_BIGEND_MSK)
  69. new_snd->spec = 0 | 4;
  70. else new_snd->spec = 1 | 4;
  71. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  72. + new_snd->spec |= 2;
  73. new_snd->delta = XA_ADecode_ULAWx_PCMxM;
  74. break;
  75. case XA_AUDIO_ALAWS:
  76. @@ -2218,6 +2247,8 @@ fprintf(stderr,"XA_IPC_Sound itype %x\n",itype);
  77. case XA_AUDIO_ARMLAWS:
  78. if (xa_audio_hard_type & XA_AUDIO_BIGEND_MSK)
  79. new_snd->spec = 0 | 4 | 8;
  80. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  81. + new_snd->spec |= 2;
  82. else new_snd->spec = 1 | 4 | 8;
  83. new_snd->delta = XA_ADecode_ARMLAWx_PCMxM;
  84. break;
  85. @@ -2226,41 +2257,59 @@ fprintf(stderr,"XA_IPC_Sound itype %x\n",itype);
  86. new_snd->spec = 0 | 4;
  87. else new_snd->spec = 1 | 4;
  88. new_snd->delta = XA_ADecode_ARMLAWx_PCMxM;
  89. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  90. + new_snd->spec |= 2;
  91. break;
  92. case XA_AUDIO_ADPCM_M:
  93. - new_snd->spec = 2 | 4; /* 1 byte output */
  94. + new_snd->spec = 4; /* 1 byte output */
  95. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  96. + new_snd->spec |= 2;
  97. new_snd->delta = XA_ADecode_ADPCMM_PCM2M;
  98. break;
  99. case XA_AUDIO_ADPCM_S:
  100. - new_snd->spec = 2 | 4; /* 1 byte output */
  101. + new_snd->spec = 4; /* 1 byte output */
  102. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  103. + new_snd->spec |= 2;
  104. new_snd->delta = XA_ADecode_ADPCMS_PCM2M;
  105. break;
  106. case XA_AUDIO_DVI_M:
  107. - new_snd->spec = 2 | 4; /* 1 byte output */
  108. + new_snd->spec = 4; /* 1 byte output */
  109. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  110. + new_snd->spec |= 2;
  111. new_snd->delta = XA_ADecode_DVIM_PCMxM;
  112. break;
  113. case XA_AUDIO_DVI_S:
  114. - new_snd->spec = 2 | 4; /* 1 byte output */
  115. + new_snd->spec = 4; /* 1 byte output */
  116. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  117. + new_snd->spec |= 2;
  118. new_snd->delta = XA_ADecode_DVIS_PCMxM;
  119. break;
  120. case XA_AUDIO_IMA4_M:
  121. - new_snd->spec = 2 | 4; /* 1 byte output */
  122. + new_snd->spec = 4; /* 1 byte output */
  123. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  124. + new_snd->spec |= 2;
  125. new_snd->delta = XA_ADecode_IMA4M_PCMxM;
  126. break;
  127. case XA_AUDIO_IMA4_S:
  128. - new_snd->spec = 2 | 4; /* 1 byte output */
  129. + new_snd->spec = 4; /* 1 byte output */
  130. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  131. + new_snd->spec |= 2;
  132. new_snd->delta = XA_ADecode_IMA4S_PCMxM;
  133. break;
  134. #ifdef XA_GSM
  135. case XA_AUDIO_GSM:
  136. case XA_AUDIO_MSGSM:
  137. - new_snd->spec = 2 | 4; /* 1 byte output */
  138. + new_snd->spec = 4; /* 1 byte output */
  139. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  140. + new_snd->spec |= 2;
  141. if (itype == XA_AUDIO_MSGSM_M) new_snd->spec |= 0x80;
  142. new_snd->delta = XA_ADecode_GSMM_PCMxM;
  143. break;
  144. #endif
  145. case XA_AUDIO_NOP:
  146. - new_snd->spec = 2 | 4; /* 1 byte output */
  147. + new_snd->spec = 4; /* 1 byte output */
  148. + if (xa_audio_hard_type == XA_AUDIO_LINEAR_1M)
  149. + new_snd->spec |= 2;
  150. new_snd->delta = XA_ADecode_NOP_PCMXM;
  151. break;
  152. default: