Browse Source

Updated VGMStream to r1050-1964-g9346ae50

master
parent
commit
fecb53a55a
100 changed files with 8539 additions and 2175 deletions
  1. +100
    -28
      Frameworks/vgmstream/libvgmstream.xcodeproj/project.pbxproj
  2. +108
    -76
      Frameworks/vgmstream/vgmstream/ext_libs/clHCA.c
  3. +6
    -1
      Frameworks/vgmstream/vgmstream/ext_libs/clHCA.h
  4. +1
    -1
      Frameworks/vgmstream/vgmstream/src/coding/atrac9_decoder.c
  5. +0
    -259
      Frameworks/vgmstream/vgmstream/src/coding/atrac9_decoder.c.orig
  6. +1
    -1
      Frameworks/vgmstream/vgmstream/src/coding/celt_fsb_decoder.c
  7. +29
    -0
      Frameworks/vgmstream/vgmstream/src/coding/circus_decoder.c
  8. +23
    -4
      Frameworks/vgmstream/vgmstream/src/coding/coding.h
  9. +334
    -132
      Frameworks/vgmstream/vgmstream/src/coding/coding_utils.c
  10. +101
    -1
      Frameworks/vgmstream/vgmstream/src/coding/ea_xa_decoder.c
  11. +3
    -2
      Frameworks/vgmstream/vgmstream/src/coding/ea_xas_decoder.c
  12. +161
    -137
      Frameworks/vgmstream/vgmstream/src/coding/ffmpeg_decoder.c
  13. +134
    -17
      Frameworks/vgmstream/vgmstream/src/coding/ffmpeg_decoder_custom_opus.c
  14. +6
    -10
      Frameworks/vgmstream/vgmstream/src/coding/g719_decoder.c
  15. +44
    -19
      Frameworks/vgmstream/vgmstream/src/coding/hca_decoder.c
  16. +52
    -0
      Frameworks/vgmstream/vgmstream/src/coding/ima_decoder.c
  17. +1
    -1
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_custom_utils.c
  18. +1
    -1
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_custom_utils_awc.c
  19. +3
    -3
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_custom_utils_ealayer3.c
  20. +175
    -0
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_custom_utils_eamp3.c
  21. +30
    -15
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_decoder.c
  22. +2
    -0
      Frameworks/vgmstream/vgmstream/src/coding/mpeg_decoder.h
  23. +12
    -4
      Frameworks/vgmstream/vgmstream/src/coding/mta2_decoder.c
  24. +2
    -2
      Frameworks/vgmstream/vgmstream/src/coding/mtaf_decoder.c
  25. +1
    -1
      Frameworks/vgmstream/vgmstream/src/coding/ngc_dtk_decoder.c
  26. +92
    -0
      Frameworks/vgmstream/vgmstream/src/coding/pcfx_decoder.c
  27. +4
    -4
      Frameworks/vgmstream/vgmstream/src/coding/psx_decoder.c
  28. +3
    -3
      Frameworks/vgmstream/vgmstream/src/coding/vorbis_custom_decoder.c
  29. +2
    -2
      Frameworks/vgmstream/vgmstream/src/coding/xa_decoder.c
  30. +128
    -69
      Frameworks/vgmstream/vgmstream/src/formats.c
  31. +8
    -8
      Frameworks/vgmstream/vgmstream/src/layout/blocked.c
  32. +5
    -0
      Frameworks/vgmstream/vgmstream/src/layout/blocked_ea_schl.c
  33. +0
    -34
      Frameworks/vgmstream/vgmstream/src/layout/blocked_emff.c
  34. +1
    -1
      Frameworks/vgmstream/vgmstream/src/layout/blocked_h4m.c
  35. +50
    -0
      Frameworks/vgmstream/vgmstream/src/layout/blocked_mul.c
  36. +8
    -9
      Frameworks/vgmstream/vgmstream/src/layout/blocked_vs.c
  37. +17
    -0
      Frameworks/vgmstream/vgmstream/src/layout/blocked_vs_square.c
  38. +1
    -1
      Frameworks/vgmstream/vgmstream/src/layout/blocked_vs_str.c
  39. +2
    -2
      Frameworks/vgmstream/vgmstream/src/layout/blocked_xa.c
  40. +3
    -3
      Frameworks/vgmstream/vgmstream/src/layout/layout.h
  41. +1
    -26
      Frameworks/vgmstream/vgmstream/src/meta/aax.c
  42. +11
    -4
      Frameworks/vgmstream/vgmstream/src/meta/adx_keys.h
  43. +26
    -18
      Frameworks/vgmstream/vgmstream/src/meta/akb.c
  44. +28
    -41
      Frameworks/vgmstream/vgmstream/src/meta/atsl.c
  45. +5
    -1
      Frameworks/vgmstream/vgmstream/src/meta/awc.c
  46. +2
    -2
      Frameworks/vgmstream/vgmstream/src/meta/bik.c
  47. +28
    -6
      Frameworks/vgmstream/vgmstream/src/meta/bnk_sony.c
  48. +108
    -27
      Frameworks/vgmstream/vgmstream/src/meta/ea_1snh.c
  49. +170
    -25
      Frameworks/vgmstream/vgmstream/src/meta/ea_eaac.c
  50. +9
    -19
      Frameworks/vgmstream/vgmstream/src/meta/ea_eaac_streamfile.h
  51. +363
    -131
      Frameworks/vgmstream/vgmstream/src/meta/ea_schl.c
  52. +0
    -179
      Frameworks/vgmstream/vgmstream/src/meta/emff.c
  53. +52
    -0
      Frameworks/vgmstream/vgmstream/src/meta/fag.c
  54. +2
    -0
      Frameworks/vgmstream/vgmstream/src/meta/fsb.c
  55. +11
    -3
      Frameworks/vgmstream/vgmstream/src/meta/fsb5.c
  56. +71
    -43
      Frameworks/vgmstream/vgmstream/src/meta/genh.c
  57. +2
    -3
      Frameworks/vgmstream/vgmstream/src/meta/gsp_gsb.c
  58. +2
    -0
      Frameworks/vgmstream/vgmstream/src/meta/gtd.c
  59. +54
    -30
      Frameworks/vgmstream/vgmstream/src/meta/hca.c
  60. +20
    -2
      Frameworks/vgmstream/vgmstream/src/meta/hca_keys.h
  61. +4150
    -0
      Frameworks/vgmstream/vgmstream/src/meta/hca_keys_awb.h
  62. +121
    -0
      Frameworks/vgmstream/vgmstream/src/meta/imc.c
  63. +44
    -10
      Frameworks/vgmstream/vgmstream/src/meta/meta.h
  64. +62
    -0
      Frameworks/vgmstream/vgmstream/src/meta/msf_banpresto.c
  65. +74
    -0
      Frameworks/vgmstream/vgmstream/src/meta/msf_tamasoft.c
  66. +164
    -0
      Frameworks/vgmstream/vgmstream/src/meta/mul.c
  67. +4
    -3
      Frameworks/vgmstream/vgmstream/src/meta/naomi_spsd.c
  68. +6
    -4
      Frameworks/vgmstream/vgmstream/src/meta/nds_strm_ffta2.c
  69. +20
    -15
      Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_mpds.c
  70. +35
    -5
      Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_std.c
  71. +2
    -1
      Frameworks/vgmstream/vgmstream/src/meta/ngc_pdt.c
  72. +4
    -7
      Frameworks/vgmstream/vgmstream/src/meta/nub_xma.c
  73. +119
    -0
      Frameworks/vgmstream/vgmstream/src/meta/nus3audio.c
  74. +1
    -26
      Frameworks/vgmstream/vgmstream/src/meta/nus3bank.c
  75. +57
    -0
      Frameworks/vgmstream/vgmstream/src/meta/nwav.c
  76. +1
    -1
      Frameworks/vgmstream/vgmstream/src/meta/nxa.c
  77. +173
    -0
      Frameworks/vgmstream/vgmstream/src/meta/ogg_opus.c
  78. +79
    -44
      Frameworks/vgmstream/vgmstream/src/meta/ogg_vorbis.c
  79. +56
    -29
      Frameworks/vgmstream/vgmstream/src/meta/opus.c
  80. +5
    -30
      Frameworks/vgmstream/vgmstream/src/meta/opus_ppp.c
  81. +3
    -5
      Frameworks/vgmstream/vgmstream/src/meta/p3d.c
  82. +40
    -76
      Frameworks/vgmstream/vgmstream/src/meta/pona.c
  83. +5
    -1
      Frameworks/vgmstream/vgmstream/src/meta/pos.c
  84. +3
    -29
      Frameworks/vgmstream/vgmstream/src/meta/ps2_ads.c
  85. +80
    -0
      Frameworks/vgmstream/vgmstream/src/meta/ps2_va3.c
  86. +22
    -26
      Frameworks/vgmstream/vgmstream/src/meta/ps3_msf.c
  87. +0
    -66
      Frameworks/vgmstream/vgmstream/src/meta/psx_fag.c
  88. +2
    -2
      Frameworks/vgmstream/vgmstream/src/meta/redspark.c
  89. +23
    -12
      Frameworks/vgmstream/vgmstream/src/meta/riff.c
  90. +8
    -4
      Frameworks/vgmstream/vgmstream/src/meta/rsd.c
  91. +35
    -57
      Frameworks/vgmstream/vgmstream/src/meta/sdt.c
  92. +87
    -69
      Frameworks/vgmstream/vgmstream/src/meta/seg.c
  93. +0
    -5
      Frameworks/vgmstream/vgmstream/src/meta/sgxd.c
  94. +29
    -12
      Frameworks/vgmstream/vgmstream/src/meta/sli.c
  95. +5
    -30
      Frameworks/vgmstream/vgmstream/src/meta/sps_n1.c
  96. +17
    -17
      Frameworks/vgmstream/vgmstream/src/meta/sqex_scd.c
  97. +29
    -44
      Frameworks/vgmstream/vgmstream/src/meta/svs.c
  98. +30
    -27
      Frameworks/vgmstream/vgmstream/src/meta/sxd.c
  99. +6
    -2
      Frameworks/vgmstream/vgmstream/src/meta/ta_aac.c
  100. +319
    -105
      Frameworks/vgmstream/vgmstream/src/meta/txth.c

+ 100
- 28
Frameworks/vgmstream/libvgmstream.xcodeproj/project.pbxproj View File

@@ -28,12 +28,10 @@
8306B0AD20984552000302D4 /* blocked_caf.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0922098454E000302D4 /* blocked_caf.c */; };
8306B0AE20984552000302D4 /* blocked_filp.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0932098454F000302D4 /* blocked_filp.c */; };
8306B0AF20984552000302D4 /* blocked_rws.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0942098454F000302D4 /* blocked_rws.c */; };
8306B0B020984552000302D4 /* blocked_ps2_strlr.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0952098454F000302D4 /* blocked_ps2_strlr.c */; };
8306B0B120984552000302D4 /* blocked_halpst.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0962098454F000302D4 /* blocked_halpst.c */; };
8306B0B220984552000302D4 /* blocked_mxch.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B0972098454F000302D4 /* blocked_mxch.c */; };
8306B0B320984552000302D4 /* blocked_thp.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09820984550000302D4 /* blocked_thp.c */; };
8306B0B420984552000302D4 /* blocked_tra.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09920984550000302D4 /* blocked_tra.c */; };
8306B0B520984552000302D4 /* blocked_emff.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09A20984550000302D4 /* blocked_emff.c */; };
8306B0B620984552000302D4 /* blocked_hwas.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09B20984550000302D4 /* blocked_hwas.c */; };
8306B0B720984552000302D4 /* blocked_str_snds.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09C20984550000302D4 /* blocked_str_snds.c */; };
8306B0B820984552000302D4 /* blocked_ws_aud.c in Sources */ = {isa = PBXBuildFile; fileRef = 8306B09D20984551000302D4 /* blocked_ws_aud.c */; };
@@ -93,6 +91,31 @@
832389521D224C0800482226 /* hca_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 832389511D224C0800482226 /* hca_decoder.c */; };
83299FD01E7660C7003A3242 /* bik.c in Sources */ = {isa = PBXBuildFile; fileRef = 83299FCE1E7660C7003A3242 /* bik.c */; };
83299FD11E7660C7003A3242 /* dsp_adx.c in Sources */ = {isa = PBXBuildFile; fileRef = 83299FCF1E7660C7003A3242 /* dsp_adx.c */; };
832BF7FF21E050B7006F50F1 /* circus_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF7FC21E050B6006F50F1 /* circus_decoder.c */; };
832BF80021E050B7006F50F1 /* mpeg_custom_utils_eamp3.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF7FD21E050B7006F50F1 /* mpeg_custom_utils_eamp3.c */; };
832BF80121E050B7006F50F1 /* pcfx_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF7FE21E050B7006F50F1 /* pcfx_decoder.c */; };
832BF80521E050DC006F50F1 /* blocked_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80221E050DB006F50F1 /* blocked_mul.c */; };
832BF80621E050DC006F50F1 /* blocked_vs_square.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80321E050DC006F50F1 /* blocked_vs_square.c */; };
832BF80721E050DC006F50F1 /* blocked_vs_str.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80421E050DC006F50F1 /* blocked_vs_str.c */; };
832BF80921E05135006F50F1 /* fag.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80821E05135006F50F1 /* fag.c */; };
832BF81C21E0514B006F50F1 /* xpcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80A21E05148006F50F1 /* xpcm.c */; };
832BF81D21E0514B006F50F1 /* msf_tamasoft.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80B21E05148006F50F1 /* msf_tamasoft.c */; };
832BF81E21E0514B006F50F1 /* xps.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80C21E05148006F50F1 /* xps.c */; };
832BF81F21E0514B006F50F1 /* ps2_va3.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80D21E05148006F50F1 /* ps2_va3.c */; };
832BF82021E0514B006F50F1 /* zsnd_streamfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 832BF80E21E05149006F50F1 /* zsnd_streamfile.h */; };
832BF82121E0514B006F50F1 /* zsnd.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF80F21E05149006F50F1 /* zsnd.c */; };
832BF82221E0514B006F50F1 /* vs_str.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81021E05149006F50F1 /* vs_str.c */; };
832BF82321E0514B006F50F1 /* imc.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81121E05149006F50F1 /* imc.c */; };
832BF82421E0514B006F50F1 /* mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81221E05149006F50F1 /* mul.c */; };
832BF82521E0514B006F50F1 /* ogg_opus.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81321E05149006F50F1 /* ogg_opus.c */; };
832BF82621E0514B006F50F1 /* nwav.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81421E0514A006F50F1 /* nwav.c */; };
832BF82721E0514B006F50F1 /* xa.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81521E0514A006F50F1 /* xa.c */; };
832BF82821E0514B006F50F1 /* xwma.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81621E0514A006F50F1 /* xwma.c */; };
832BF82921E0514B006F50F1 /* msf_banpresto.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81721E0514A006F50F1 /* msf_banpresto.c */; };
832BF82A21E0514B006F50F1 /* vs_square.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81821E0514A006F50F1 /* vs_square.c */; };
832BF82B21E0514B006F50F1 /* xopus.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81921E0514A006F50F1 /* xopus.c */; };
832BF82C21E0514B006F50F1 /* hca_keys_awb.h in Headers */ = {isa = PBXBuildFile; fileRef = 832BF81A21E0514A006F50F1 /* hca_keys_awb.h */; };
832BF82D21E0514B006F50F1 /* nus3audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 832BF81B21E0514B006F50F1 /* nus3audio.c */; };
832C70BF1E9335E400BD7B4E /* Vorbis.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83F4128F1E932F9A002E37D0 /* Vorbis.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
83345A4F1F8AEB2800B2EAA4 /* nub_xma.c in Sources */ = {isa = PBXBuildFile; fileRef = 83345A4B1F8AEB2700B2EAA4 /* nub_xma.c */; };
83345A501F8AEB2800B2EAA4 /* pc_al2.c in Sources */ = {isa = PBXBuildFile; fileRef = 83345A4C1F8AEB2700B2EAA4 /* pc_al2.c */; };
@@ -138,7 +161,6 @@
834FE0B4215C798C000A5D3D /* ffmpeg_decoder_custom_opus.c in Sources */ = {isa = PBXBuildFile; fileRef = 834FE0AB215C798A000A5D3D /* ffmpeg_decoder_custom_opus.c */; };
834FE0B5215C798C000A5D3D /* acm_decoder_libacm.h in Headers */ = {isa = PBXBuildFile; fileRef = 834FE0AC215C798B000A5D3D /* acm_decoder_libacm.h */; };
834FE0B6215C798C000A5D3D /* derf_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 834FE0AD215C798B000A5D3D /* derf_decoder.c */; };
834FE0B7215C798C000A5D3D /* atrac9_decoder.c.orig in Resources */ = {isa = PBXBuildFile; fileRef = 834FE0AE215C798B000A5D3D /* atrac9_decoder.c.orig */; };
834FE0B8215C798C000A5D3D /* acm_decoder_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 834FE0AF215C798C000A5D3D /* acm_decoder_decode.c */; };
834FE0B9215C798C000A5D3D /* xmd_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 834FE0B0215C798C000A5D3D /* xmd_decoder.c */; };
834FE0BA215C798C000A5D3D /* ea_mt_decoder_utk.h in Headers */ = {isa = PBXBuildFile; fileRef = 834FE0B1215C798C000A5D3D /* ea_mt_decoder_utk.h */; };
@@ -247,7 +269,6 @@
836F6F7F18BDC2190095E648 /* dmsg_segh.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4318BDC2180095E648 /* dmsg_segh.c */; };
836F6F8018BDC2190095E648 /* dsp_bdsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4418BDC2180095E648 /* dsp_bdsp.c */; };
836F6F8218BDC2190095E648 /* ea_schl.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4618BDC2180095E648 /* ea_schl.c */; };
836F6F8418BDC2190095E648 /* emff.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4818BDC2180095E648 /* emff.c */; };
836F6F8518BDC2190095E648 /* exakt_sc.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4918BDC2180095E648 /* exakt_sc.c */; };
836F6F8618BDC2190095E648 /* excitebots.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4A18BDC2180095E648 /* excitebots.c */; };
836F6F8718BDC2190095E648 /* ffw.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6E4B18BDC2180095E648 /* ffw.c */; };
@@ -352,7 +373,6 @@
836F6FFA18BDC2190095E648 /* ps2_spm.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EBE18BDC2190095E648 /* ps2_spm.c */; };
836F6FFB18BDC2190095E648 /* ps2_sps.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EBF18BDC2190095E648 /* ps2_sps.c */; };
836F6FFC18BDC2190095E648 /* ps2_ster.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EC018BDC2190095E648 /* ps2_ster.c */; };
836F6FFF18BDC2190095E648 /* ps2_strlr.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EC318BDC2190095E648 /* ps2_strlr.c */; };
836F700018BDC2190095E648 /* ps2_svag.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EC418BDC2190095E648 /* ps2_svag.c */; };
836F700118BDC2190095E648 /* ps2_tec.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EC518BDC2190095E648 /* ps2_tec.c */; };
836F700218BDC2190095E648 /* ps2_tk5.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EC618BDC2190095E648 /* ps2_tk5.c */; };
@@ -371,8 +391,6 @@
836F701218BDC2190095E648 /* ps3_ivag.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6ED618BDC2190095E648 /* ps3_ivag.c */; };
836F701418BDC2190095E648 /* ps3_msf.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6ED818BDC2190095E648 /* ps3_msf.c */; };
836F701518BDC2190095E648 /* ps3_past.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6ED918BDC2190095E648 /* ps3_past.c */; };
836F701918BDC2190095E648 /* psx_cdxa.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EDD18BDC2190095E648 /* psx_cdxa.c */; };
836F701A18BDC2190095E648 /* psx_fag.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EDE18BDC2190095E648 /* psx_fag.c */; };
836F701B18BDC2190095E648 /* psx_gms.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EDF18BDC2190095E648 /* psx_gms.c */; };
836F701D18BDC2190095E648 /* raw.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EE118BDC2190095E648 /* raw.c */; };
836F701E18BDC2190095E648 /* redspark.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6EE218BDC2190095E648 /* redspark.c */; };
@@ -652,12 +670,10 @@
8306B0922098454E000302D4 /* blocked_caf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_caf.c; sourceTree = "<group>"; };
8306B0932098454F000302D4 /* blocked_filp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_filp.c; sourceTree = "<group>"; };
8306B0942098454F000302D4 /* blocked_rws.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_rws.c; sourceTree = "<group>"; };
8306B0952098454F000302D4 /* blocked_ps2_strlr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_ps2_strlr.c; sourceTree = "<group>"; };
8306B0962098454F000302D4 /* blocked_halpst.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_halpst.c; sourceTree = "<group>"; };
8306B0972098454F000302D4 /* blocked_mxch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_mxch.c; sourceTree = "<group>"; };
8306B09820984550000302D4 /* blocked_thp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_thp.c; sourceTree = "<group>"; };
8306B09920984550000302D4 /* blocked_tra.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_tra.c; sourceTree = "<group>"; };
8306B09A20984550000302D4 /* blocked_emff.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_emff.c; sourceTree = "<group>"; };
8306B09B20984550000302D4 /* blocked_hwas.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_hwas.c; sourceTree = "<group>"; };
8306B09C20984550000302D4 /* blocked_str_snds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_str_snds.c; sourceTree = "<group>"; };
8306B09D20984551000302D4 /* blocked_ws_aud.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_ws_aud.c; sourceTree = "<group>"; };
@@ -716,6 +732,31 @@
832389511D224C0800482226 /* hca_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hca_decoder.c; sourceTree = "<group>"; };
83299FCE1E7660C7003A3242 /* bik.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bik.c; sourceTree = "<group>"; };
83299FCF1E7660C7003A3242 /* dsp_adx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dsp_adx.c; sourceTree = "<group>"; };
832BF7FC21E050B6006F50F1 /* circus_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = circus_decoder.c; sourceTree = "<group>"; };
832BF7FD21E050B7006F50F1 /* mpeg_custom_utils_eamp3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mpeg_custom_utils_eamp3.c; sourceTree = "<group>"; };
832BF7FE21E050B7006F50F1 /* pcfx_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pcfx_decoder.c; sourceTree = "<group>"; };
832BF80221E050DB006F50F1 /* blocked_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_mul.c; sourceTree = "<group>"; };
832BF80321E050DC006F50F1 /* blocked_vs_square.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_vs_square.c; sourceTree = "<group>"; };
832BF80421E050DC006F50F1 /* blocked_vs_str.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blocked_vs_str.c; sourceTree = "<group>"; };
832BF80821E05135006F50F1 /* fag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fag.c; sourceTree = "<group>"; };
832BF80A21E05148006F50F1 /* xpcm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xpcm.c; sourceTree = "<group>"; };
832BF80B21E05148006F50F1 /* msf_tamasoft.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msf_tamasoft.c; sourceTree = "<group>"; };
832BF80C21E05148006F50F1 /* xps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xps.c; sourceTree = "<group>"; };
832BF80D21E05148006F50F1 /* ps2_va3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_va3.c; sourceTree = "<group>"; };
832BF80E21E05149006F50F1 /* zsnd_streamfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zsnd_streamfile.h; sourceTree = "<group>"; };
832BF80F21E05149006F50F1 /* zsnd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zsnd.c; sourceTree = "<group>"; };
832BF81021E05149006F50F1 /* vs_str.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vs_str.c; sourceTree = "<group>"; };
832BF81121E05149006F50F1 /* imc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = imc.c; sourceTree = "<group>"; };
832BF81221E05149006F50F1 /* mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mul.c; sourceTree = "<group>"; };
832BF81321E05149006F50F1 /* ogg_opus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ogg_opus.c; sourceTree = "<group>"; };
832BF81421E0514A006F50F1 /* nwav.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nwav.c; sourceTree = "<group>"; };
832BF81521E0514A006F50F1 /* xa.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xa.c; sourceTree = "<group>"; };
832BF81621E0514A006F50F1 /* xwma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xwma.c; sourceTree = "<group>"; };
832BF81721E0514A006F50F1 /* msf_banpresto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msf_banpresto.c; sourceTree = "<group>"; };
832BF81821E0514A006F50F1 /* vs_square.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vs_square.c; sourceTree = "<group>"; };
832BF81921E0514A006F50F1 /* xopus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xopus.c; sourceTree = "<group>"; };
832BF81A21E0514A006F50F1 /* hca_keys_awb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hca_keys_awb.h; sourceTree = "<group>"; };
832BF81B21E0514B006F50F1 /* nus3audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nus3audio.c; sourceTree = "<group>"; };
83345A4B1F8AEB2700B2EAA4 /* nub_xma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nub_xma.c; sourceTree = "<group>"; };
83345A4C1F8AEB2700B2EAA4 /* pc_al2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pc_al2.c; sourceTree = "<group>"; };
83345A4E1F8AEB2800B2EAA4 /* xvag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xvag.c; sourceTree = "<group>"; };
@@ -759,7 +800,6 @@
834FE0AB215C798A000A5D3D /* ffmpeg_decoder_custom_opus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffmpeg_decoder_custom_opus.c; sourceTree = "<group>"; };
834FE0AC215C798B000A5D3D /* acm_decoder_libacm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acm_decoder_libacm.h; sourceTree = "<group>"; };
834FE0AD215C798B000A5D3D /* derf_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = derf_decoder.c; sourceTree = "<group>"; };
834FE0AE215C798B000A5D3D /* atrac9_decoder.c.orig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = atrac9_decoder.c.orig; sourceTree = "<group>"; };
834FE0AF215C798C000A5D3D /* acm_decoder_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acm_decoder_decode.c; sourceTree = "<group>"; };
834FE0B0215C798C000A5D3D /* xmd_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xmd_decoder.c; sourceTree = "<group>"; };
834FE0B1215C798C000A5D3D /* ea_mt_decoder_utk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ea_mt_decoder_utk.h; sourceTree = "<group>"; };
@@ -870,7 +910,6 @@
836F6E4318BDC2180095E648 /* dmsg_segh.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dmsg_segh.c; sourceTree = "<group>"; };
836F6E4418BDC2180095E648 /* dsp_bdsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dsp_bdsp.c; sourceTree = "<group>"; };
836F6E4618BDC2180095E648 /* ea_schl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ea_schl.c; sourceTree = "<group>"; };
836F6E4818BDC2180095E648 /* emff.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = emff.c; sourceTree = "<group>"; };
836F6E4918BDC2180095E648 /* exakt_sc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = exakt_sc.c; sourceTree = "<group>"; };
836F6E4A18BDC2180095E648 /* excitebots.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = excitebots.c; sourceTree = "<group>"; };
836F6E4B18BDC2180095E648 /* ffw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffw.c; sourceTree = "<group>"; };
@@ -975,7 +1014,6 @@
836F6EBE18BDC2190095E648 /* ps2_spm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_spm.c; sourceTree = "<group>"; };
836F6EBF18BDC2190095E648 /* ps2_sps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_sps.c; sourceTree = "<group>"; };
836F6EC018BDC2190095E648 /* ps2_ster.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_ster.c; sourceTree = "<group>"; };
836F6EC318BDC2190095E648 /* ps2_strlr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_strlr.c; sourceTree = "<group>"; };
836F6EC418BDC2190095E648 /* ps2_svag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_svag.c; sourceTree = "<group>"; };
836F6EC518BDC2190095E648 /* ps2_tec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_tec.c; sourceTree = "<group>"; };
836F6EC618BDC2190095E648 /* ps2_tk5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_tk5.c; sourceTree = "<group>"; };
@@ -994,8 +1032,6 @@
836F6ED618BDC2190095E648 /* ps3_ivag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps3_ivag.c; sourceTree = "<group>"; };
836F6ED818BDC2190095E648 /* ps3_msf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps3_msf.c; sourceTree = "<group>"; };
836F6ED918BDC2190095E648 /* ps3_past.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps3_past.c; sourceTree = "<group>"; };
836F6EDD18BDC2190095E648 /* psx_cdxa.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psx_cdxa.c; sourceTree = "<group>"; };
836F6EDE18BDC2190095E648 /* psx_fag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psx_fag.c; sourceTree = "<group>"; };
836F6EDF18BDC2190095E648 /* psx_gms.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psx_gms.c; sourceTree = "<group>"; };
836F6EE118BDC2190095E648 /* raw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raw.c; sourceTree = "<group>"; };
836F6EE218BDC2190095E648 /* redspark.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = redspark.c; sourceTree = "<group>"; };
@@ -1284,8 +1320,8 @@
8315958320FEC831007002F0 /* asf_decoder.c */,
8306B08120984517000302D4 /* at3plus_decoder.c */,
830EBE0F2004655D0023AA10 /* atrac9_decoder.c */,
834FE0AE215C798B000A5D3D /* atrac9_decoder.c.orig */,
834FE0B2215C798C000A5D3D /* celt_fsb_decoder.c */,
832BF7FC21E050B6006F50F1 /* circus_decoder.c */,
831BA6221EAC61CB00CF89B0 /* coding_utils.c */,
836F6DE518BDC2180095E648 /* coding.h */,
834FE0AD215C798B000A5D3D /* derf_decoder.c */,
@@ -1309,6 +1345,7 @@
839E21D91F2EDAF000EE54D7 /* mpeg_custom_utils_ahx.c */,
83AA5D141F6E2F600020821C /* mpeg_custom_utils_awc.c */,
83AA5D131F6E2F5F0020821C /* mpeg_custom_utils_ealayer3.c */,
832BF7FD21E050B7006F50F1 /* mpeg_custom_utils_eamp3.c */,
839E21DD1F2EDAF000EE54D7 /* mpeg_custom_utils.c */,
836F6DEF18BDC2180095E648 /* mpeg_decoder.c */,
839E21DE1F2EDAF000EE54D7 /* mpeg_decoder.h */,
@@ -1322,6 +1359,7 @@
836F6DF618BDC2180095E648 /* nwa_decoder.c */,
836F6DF718BDC2180095E648 /* nwa_decoder.h */,
836F6DF818BDC2180095E648 /* ogg_vorbis_decoder.c */,
832BF7FE21E050B7006F50F1 /* pcfx_decoder.c */,
836F6DF918BDC2180095E648 /* pcm_decoder.c */,
83709E0C1ECBC1C3005C03D3 /* psv_decoder.c */,
836F6DFA18BDC2180095E648 /* psx_decoder.c */,
@@ -1360,7 +1398,6 @@
83EED5D5203A8BD7008BEB45 /* blocked_ea_swvr.c */,
8306B08B2098454D000302D4 /* blocked_ea_wve_ad10.c */,
8306B08A2098454D000302D4 /* blocked_ea_wve_au00.c */,
8306B09A20984550000302D4 /* blocked_emff.c */,
8306B0932098454F000302D4 /* blocked_filp.c */,
8306B0A020984551000302D4 /* blocked_gsb.c */,
8342469520C4D23D00926E48 /* blocked_h4m.c */,
@@ -1368,9 +1405,9 @@
8306B09B20984550000302D4 /* blocked_hwas.c */,
8349A8E51FE6253800E26435 /* blocked_ivaud.c */,
8306B09E20984551000302D4 /* blocked_matx.c */,
832BF80221E050DB006F50F1 /* blocked_mul.c */,
8306B0972098454F000302D4 /* blocked_mxch.c */,
8306B08D2098454D000302D4 /* blocked_ps2_iab.c */,
8306B0952098454F000302D4 /* blocked_ps2_strlr.c */,
8306B0942098454F000302D4 /* blocked_rws.c */,
8306B08F2098454E000302D4 /* blocked_sthd.c */,
8306B09C20984550000302D4 /* blocked_str_snds.c */,
@@ -1378,6 +1415,8 @@
8306B09920984550000302D4 /* blocked_tra.c */,
8349A8E61FE6253900E26435 /* blocked_vawx.c */,
83AA5D1A1F6E2F7F0020821C /* blocked_vgs.c */,
832BF80321E050DC006F50F1 /* blocked_vs_square.c */,
832BF80421E050DC006F50F1 /* blocked_vs_str.c */,
8306B0A120984551000302D4 /* blocked_vs.c */,
8306B09D20984551000302D4 /* blocked_ws_aud.c */,
8306B09F20984551000302D4 /* blocked_wsi.c */,
@@ -1462,10 +1501,10 @@
83EED5D1203A8BC7008BEB45 /* ea_swvr.c */,
8306B0C42098458D000302D4 /* ea_wve_ad10.c */,
8306B0BF2098458C000302D4 /* ea_wve_au00.c */,
836F6E4818BDC2180095E648 /* emff.c */,
836F6E4918BDC2180095E648 /* exakt_sc.c */,
836F6E4A18BDC2180095E648 /* excitebots.c */,
8349A8EF1FE6257C00E26435 /* ezw.c */,
832BF80821E05135006F50F1 /* fag.c */,
838BDB6D1D3B043C0022CA6F /* ffmpeg.c */,
836F6E4B18BDC2180095E648 /* ffw.c */,
8349A8FD1FE6257F00E26435 /* flx.c */,
@@ -1483,11 +1522,13 @@
83709DFF1ECBC1A4005C03D3 /* gtd.c */,
8342469020C4D22F00926E48 /* h4m.c */,
836F6E5218BDC2180095E648 /* halpst.c */,
832BF81A21E0514A006F50F1 /* hca_keys_awb.h */,
83AA5D211F6E2F9C0020821C /* hca_keys.h */,
8323894F1D2246C300482226 /* hca.c */,
834FE0DF215C79EB000A5D3D /* hd3_bd3.c */,
836F6E5318BDC2180095E648 /* his.c */,
834FE0E0215C79EB000A5D3D /* idsp_ie.c */,
832BF81121E05149006F50F1 /* imc.c */,
836F6E5518BDC2180095E648 /* ios_psnd.c */,
836F6E5618BDC2180095E648 /* ish_isd.c */,
836F6E5718BDC2180095E648 /* ivaud.c */,
@@ -1507,9 +1548,12 @@
8349A9031FE6258100E26435 /* mogg.c */,
836F6E6018BDC2180095E648 /* mp4.c */,
8306B0CB2098458E000302D4 /* msb_msh.c */,
832BF81721E0514A006F50F1 /* msf_banpresto.c */,
832BF80B21E05148006F50F1 /* msf_tamasoft.c */,
83709E011ECBC1A4005C03D3 /* mss.c */,
834FE0E7215C79EC000A5D3D /* msv.c */,
836F6E6118BDC2180095E648 /* msvp.c */,
832BF81221E05149006F50F1 /* mul.c */,
836F6E6218BDC2180095E648 /* mus_acm.c */,
836F6E6318BDC2180095E648 /* musc.c */,
836F6E6418BDC2180095E648 /* musx.c */,
@@ -1545,10 +1589,13 @@
834FE0E1215C79EB000A5D3D /* nub_idsp.c */,
83AB8C731E8072A100086084 /* nub_vag.c */,
83345A4B1F8AEB2700B2EAA4 /* nub_xma.c */,
832BF81B21E0514B006F50F1 /* nus3audio.c */,
834FE0D1215C79E9000A5D3D /* nus3bank.c */,
836F6E8118BDC2180095E648 /* nwa.c */,
832BF81421E0514A006F50F1 /* nwav.c */,
834FE0DB215C79EA000A5D3D /* nxa.c */,
8306B0C02098458C000302D4 /* nxap.c */,
832BF81321E05149006F50F1 /* ogg_opus.c */,
83A21F7F201D8980000F04B9 /* ogg_vorbis.c */,
831BA60F1EAC61A500CF89B0 /* ogl.c */,
8349A8FB1FE6257F00E26435 /* omu.c */,
@@ -1619,11 +1666,11 @@
836F6EBE18BDC2190095E648 /* ps2_spm.c */,
836F6EBF18BDC2190095E648 /* ps2_sps.c */,
836F6EC018BDC2190095E648 /* ps2_ster.c */,
836F6EC318BDC2190095E648 /* ps2_strlr.c */,
8350C0591E071990009E0A93 /* ps2_svag_snk.c */,
836F6EC418BDC2190095E648 /* ps2_svag.c */,
836F6EC518BDC2190095E648 /* ps2_tec.c */,
836F6EC618BDC2190095E648 /* ps2_tk5.c */,
832BF80D21E05148006F50F1 /* ps2_va3.c */,
836F6EC818BDC2190095E648 /* ps2_vas.c */,
836F6EC918BDC2190095E648 /* ps2_vbk.c */,
831BA6101EAC61A500CF89B0 /* ps2_vds_vdm.c */,
@@ -1642,8 +1689,6 @@
836F6ED818BDC2190095E648 /* ps3_msf.c */,
8350270C1ED119D200C25929 /* ps3_mta2.c */,
836F6ED918BDC2190095E648 /* ps3_past.c */,
836F6EDD18BDC2190095E648 /* psx_cdxa.c */,
836F6EDE18BDC2190095E648 /* psx_fag.c */,
836F6EDF18BDC2190095E648 /* psx_gms.c */,
836F6EE118BDC2190095E648 /* raw.c */,
836F6EE218BDC2190095E648 /* redspark.c */,
@@ -1707,6 +1752,8 @@
836F6EFD18BDC2190095E648 /* vgs.c */,
834FE0CE215C79E8000A5D3D /* vis.c */,
834FE0D4215C79E9000A5D3D /* vpk.c */,
832BF81821E0514A006F50F1 /* vs_square.c */,
832BF81021E05149006F50F1 /* vs_str.c */,
836F6EFE18BDC2190095E648 /* vs.c */,
8349A8F91FE6257E00E26435 /* vsf_tta.c */,
836F6EFF18BDC2190095E648 /* vsf.c */,
@@ -1733,6 +1780,7 @@
831BA6151EAC61A500CF89B0 /* x360_cxs.c */,
831BA6171EAC61A500CF89B0 /* x360_pasx.c */,
836F6F0A18BDC2190095E648 /* x360_tra.c */,
832BF81521E0514A006F50F1 /* xa.c */,
834FE0D2215C79E9000A5D3D /* xau_konami.c */,
833A7A2D1ED11961003EC53E /* xau.c */,
836F6F0B18BDC2190095E648 /* xbox_hlwav.c */,
@@ -1743,13 +1791,19 @@
8350C0541E071881009E0A93 /* xma.c */,
834FE0DC215C79EA000A5D3D /* xmd.c */,
830EBE112004656E0023AA10 /* xnb.c */,
832BF81921E0514A006F50F1 /* xopus.c */,
832BF80A21E05148006F50F1 /* xpcm.c */,
832BF80C21E05148006F50F1 /* xps.c */,
836F6F1218BDC2190095E648 /* xss.c */,
834FE0C6215C79E7000A5D3D /* xvag_streamfile.h */,
83345A4E1F8AEB2800B2EAA4 /* xvag.c */,
836F6F1318BDC2190095E648 /* xwb.c */,
83A21F7D201D8980000F04B9 /* xwc.c */,
832BF81621E0514A006F50F1 /* xwma.c */,
836F6F1418BDC2190095E648 /* ydsp.c */,
836F6F1518BDC2190095E648 /* zsd.c */,
832BF80E21E05149006F50F1 /* zsnd_streamfile.h */,
832BF80F21E05149006F50F1 /* zsnd.c */,
836F6F1618BDC2190095E648 /* zwdsp.c */,
);
path = meta;
@@ -1797,8 +1851,10 @@
834FE0ED215C79ED000A5D3D /* fsb_interleave_streamfile.h in Headers */,
8349A9111FE6258200E26435 /* bar_streamfile.h in Headers */,
836F6F2718BDC2190095E648 /* g72x_state.h in Headers */,
832BF82C21E0514B006F50F1 /* hca_keys_awb.h in Headers */,
8306B0E020984590000302D4 /* ppst_streamfile.h in Headers */,
834FE0BA215C798C000A5D3D /* ea_mt_decoder_utk.h in Headers */,
832BF82021E0514B006F50F1 /* zsnd_streamfile.h in Headers */,
839E21E01F2EDAF100EE54D7 /* vorbis_custom_data_fsb.h in Headers */,
836F705418BDC2190095E648 /* streamfile.h in Headers */,
83A3F0761E3AD8B900D6A794 /* stack_alloc.h in Headers */,
@@ -1974,7 +2030,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
834FE0B7215C798C000A5D3D /* atrac9_decoder.c.orig in Resources */,
836F6B4718BDB8880095E648 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1989,9 +2044,9 @@
839E21E21F2EDAF100EE54D7 /* vorbis_custom_utils_wwise.c in Sources */,
83E56BA51F2EE3520026BC60 /* vorbis_custom_utils_ogl.c in Sources */,
834FE104215C79ED000A5D3D /* nxa.c in Sources */,
8306B0B020984552000302D4 /* blocked_ps2_strlr.c in Sources */,
8349A9071FE6258200E26435 /* dec.c in Sources */,
839E21E91F2EDAF100EE54D7 /* vorbis_custom_utils_sk.c in Sources */,
832BF80721E050DC006F50F1 /* blocked_vs_str.c in Sources */,
839E21E41F2EDAF100EE54D7 /* vorbis_custom_utils_fsb.c in Sources */,
839E21E11F2EDAF100EE54D7 /* vorbis_custom_decoder.c in Sources */,
839E21E71F2EDAF100EE54D7 /* mpeg_custom_utils.c in Sources */,
@@ -2026,9 +2081,11 @@
836F703218BDC2190095E648 /* str_asr.c in Sources */,
836F6FB218BDC2190095E648 /* ngc_gcub.c in Sources */,
836F702818BDC2190095E648 /* sat_dvi.c in Sources */,
832BF82D21E0514B006F50F1 /* nus3audio.c in Sources */,
836F6F2F18BDC2190095E648 /* mtaf_decoder.c in Sources */,
83AA5D161F6E2F600020821C /* ea_xa_decoder.c in Sources */,
836F6F9B18BDC2190095E648 /* mn_str.c in Sources */,
832BF82821E0514B006F50F1 /* xwma.c in Sources */,
8306B0EB20984590000302D4 /* wave_segmented.c in Sources */,
836F6F9F18BDC2190095E648 /* musc.c in Sources */,
8349A9121FE6258200E26435 /* vsf_tta.c in Sources */,
@@ -2043,6 +2100,7 @@
836F6F2818BDC2190095E648 /* ima_decoder.c in Sources */,
8306B0DD20984590000302D4 /* waf.c in Sources */,
8306B0B320984552000302D4 /* blocked_thp.c in Sources */,
832BF80921E05135006F50F1 /* fag.c in Sources */,
834FE0B6215C798C000A5D3D /* derf_decoder.c in Sources */,
836F702318BDC2190095E648 /* rsf.c in Sources */,
834FE109215C79ED000A5D3D /* idsp_ie.c in Sources */,
@@ -2100,11 +2158,13 @@
831BA61A1EAC61A500CF89B0 /* ps2_vds_vdm.c in Sources */,
836F6FF218BDC2190095E648 /* ps2_rnd.c in Sources */,
83709E0D1ECBC1C3005C03D3 /* mc3_decoder.c in Sources */,
832BF80521E050DC006F50F1 /* blocked_mul.c in Sources */,
836F6FA818BDC2190095E648 /* nds_swav.c in Sources */,
8306B0D920984590000302D4 /* ngc_str_cauldron.c in Sources */,
834FE0FB215C79ED000A5D3D /* xau_konami.c in Sources */,
833A7A2E1ED11961003EC53E /* xau.c in Sources */,
836F6FB518BDC2190095E648 /* ngc_pdt.c in Sources */,
832BF81E21E0514B006F50F1 /* xps.c in Sources */,
836F6F6C18BDC2190095E648 /* ahx.c in Sources */,
83AB8C751E8072A100086084 /* nub_vag.c in Sources */,
836F702D18BDC2190095E648 /* sfl.c in Sources */,
@@ -2139,6 +2199,8 @@
8349A9181FE6258200E26435 /* ea_1snh.c in Sources */,
83EED5D4203A8BC7008BEB45 /* aus.c in Sources */,
836F6F7F18BDC2190095E648 /* dmsg_segh.c in Sources */,
832BF81D21E0514B006F50F1 /* msf_tamasoft.c in Sources */,
832BF7FF21E050B7006F50F1 /* circus_decoder.c in Sources */,
83709E071ECBC1A4005C03D3 /* mss.c in Sources */,
836F6F8F18BDC2190095E648 /* his.c in Sources */,
834FE0E9215C79ED000A5D3D /* ao.c in Sources */,
@@ -2161,7 +2223,6 @@
836F6FF318BDC2190095E648 /* ps2_rstm.c in Sources */,
836F6F7918BDC2190095E648 /* dc_asd.c in Sources */,
836F6FC118BDC2190095E648 /* pc_adp.c in Sources */,
836F701A18BDC2190095E648 /* psx_fag.c in Sources */,
836F703B18BDC2190095E648 /* vsf.c in Sources */,
836F6F8218BDC2190095E648 /* ea_schl.c in Sources */,
836F6F7318BDC2190095E648 /* bcstm.c in Sources */,
@@ -2181,14 +2242,17 @@
836F6F8518BDC2190095E648 /* exakt_sc.c in Sources */,
836F6FA618BDC2190095E648 /* nds_sad.c in Sources */,
8306B0F120984590000302D4 /* ppst.c in Sources */,
832BF81C21E0514B006F50F1 /* xpcm.c in Sources */,
836F702B18BDC2190095E648 /* sdt.c in Sources */,
836F6FDA18BDC2190095E648 /* ps2_hgc1.c in Sources */,
836F702C18BDC2190095E648 /* seg.c in Sources */,
836F700918BDC2190095E648 /* ps2_voi.c in Sources */,
836F6F3E18BDC2190095E648 /* aix_layout.c in Sources */,
836F6FE018BDC2190095E648 /* ps2_joe.c in Sources */,
832BF82721E0514B006F50F1 /* xa.c in Sources */,
8306B0A220984552000302D4 /* blocked_bdsp.c in Sources */,
836F700118BDC2190095E648 /* ps2_tec.c in Sources */,
832BF82121E0514B006F50F1 /* zsnd.c in Sources */,
836F703018BDC2190095E648 /* sqex_scd.c in Sources */,
8306B0A320984552000302D4 /* blocked_ast.c in Sources */,
836F6FD518BDC2190095E648 /* ps2_enth.c in Sources */,
@@ -2197,7 +2261,6 @@
8315958720FEC832007002F0 /* asf_decoder.c in Sources */,
836F705218BDC2190095E648 /* zwdsp.c in Sources */,
836F6FFB18BDC2190095E648 /* ps2_sps.c in Sources */,
836F6FFF18BDC2190095E648 /* ps2_strlr.c in Sources */,
836F6F2018BDC2190095E648 /* adx_decoder.c in Sources */,
8349A8EC1FE6253900E26435 /* blocked_vawx.c in Sources */,
834FE0EA215C79ED000A5D3D /* aif_asobo.c in Sources */,
@@ -2225,7 +2288,6 @@
836F6F3118BDC2190095E648 /* ngc_afc_decoder.c in Sources */,
836F6F9918BDC2190095E648 /* maxis_xa.c in Sources */,
836F702118BDC2190095E648 /* rs03.c in Sources */,
836F6F8418BDC2190095E648 /* emff.c in Sources */,
836F6F8818BDC2190095E648 /* fsb.c in Sources */,
836F6FE518BDC2190095E648 /* ps2_lpcm.c in Sources */,
836F6FB318BDC2190095E648 /* ngc_lps.c in Sources */,
@@ -2241,12 +2303,14 @@
834FE106215C79ED000A5D3D /* utk.c in Sources */,
831BA6281EAC61CB00CF89B0 /* coding_utils.c in Sources */,
836F700218BDC2190095E648 /* ps2_tk5.c in Sources */,
832BF80121E050B7006F50F1 /* pcfx_decoder.c in Sources */,
83AA5D271F6E2F9C0020821C /* stm.c in Sources */,
831BA61D1EAC61A500CF89B0 /* ubi_raki.c in Sources */,
836F703F18BDC2190095E648 /* wii_smp.c in Sources */,
8306B0A520984552000302D4 /* blocked_ea_wve_au00.c in Sources */,
836F6FB818BDC2190095E648 /* ngc_tydsp.c in Sources */,
836F701518BDC2190095E648 /* ps3_past.c in Sources */,
832BF80621E050DC006F50F1 /* blocked_vs_square.c in Sources */,
836F6F7C18BDC2190095E648 /* dc_kcey.c in Sources */,
836F6FED18BDC2190095E648 /* ps2_npsf.c in Sources */,
83A21F8B201D8982000F04B9 /* sps_n1.c in Sources */,
@@ -2269,12 +2333,13 @@
836F704618BDC2190095E648 /* x360_tra.c in Sources */,
834FE0F0215C79ED000A5D3D /* apc.c in Sources */,
836F6FFA18BDC2190095E648 /* ps2_spm.c in Sources */,
836F701918BDC2190095E648 /* psx_cdxa.c in Sources */,
834D3A6E19F47C98001C54F6 /* g1l.c in Sources */,
836F6FC318BDC2190095E648 /* pc_smp.c in Sources */,
836F6FCE18BDC2190095E648 /* ps2_ast.c in Sources */,
832BF82A21E0514B006F50F1 /* vs_square.c in Sources */,
834FE0B4215C798C000A5D3D /* ffmpeg_decoder_custom_opus.c in Sources */,
8349A9091FE6258200E26435 /* pc_ast.c in Sources */,
832BF81F21E0514B006F50F1 /* ps2_va3.c in Sources */,
8349A91C1FE6258200E26435 /* mogg.c in Sources */,
834FE0F5215C79ED000A5D3D /* wv2.c in Sources */,
836F703D18BDC2190095E648 /* wii_mus.c in Sources */,
@@ -2298,10 +2363,12 @@
836F6F7718BDC2190095E648 /* capdsp.c in Sources */,
836F6FB018BDC2190095E648 /* ngc_dsp_ygo.c in Sources */,
836F703318BDC2190095E648 /* str_snds.c in Sources */,
832BF82221E0514B006F50F1 /* vs_str.c in Sources */,
8349A9191FE6258200E26435 /* afc.c in Sources */,
836F703718BDC2190095E648 /* tun.c in Sources */,
836F700B18BDC2190095E648 /* ps2_wad.c in Sources */,
8349A9161FE6258200E26435 /* flx.c in Sources */,
832BF82921E0514B006F50F1 /* msf_banpresto.c in Sources */,
834FE0BE215C79A9000A5D3D /* blocked_xa_aiff.c in Sources */,
831BA61E1EAC61A500CF89B0 /* vawx.c in Sources */,
836F702A18BDC2190095E648 /* sd9.c in Sources */,
@@ -2315,6 +2382,7 @@
836F6F9518BDC2190095E648 /* kraw.c in Sources */,
836F6FB718BDC2190095E648 /* ngc_ssm.c in Sources */,
8306B0E920984590000302D4 /* opus.c in Sources */,
832BF80021E050B7006F50F1 /* mpeg_custom_utils_eamp3.c in Sources */,
83709E051ECBC1A4005C03D3 /* gtd.c in Sources */,
8306B0A420984552000302D4 /* segmented.c in Sources */,
83A21F86201D8981000F04B9 /* xwc.c in Sources */,
@@ -2330,6 +2398,7 @@
836F6F2518BDC2190095E648 /* g721_decoder.c in Sources */,
836F6FE818BDC2190095E648 /* ps2_mic.c in Sources */,
836F6F3C18BDC2190095E648 /* xa_decoder.c in Sources */,
832BF82521E0514B006F50F1 /* ogg_opus.c in Sources */,
834FE10A215C79ED000A5D3D /* nub_idsp.c in Sources */,
83709E091ECBC1A4005C03D3 /* ta_aac.c in Sources */,
836F6F9118BDC2190095E648 /* ios_psnd.c in Sources */,
@@ -2338,9 +2407,11 @@
834FE0FF215C79ED000A5D3D /* sqex_scd_sscf.c in Sources */,
836F6FAA18BDC2190095E648 /* ngc_bh2pcm.c in Sources */,
831BA6211EAC61A500CF89B0 /* x360_pasx.c in Sources */,
832BF82621E0514B006F50F1 /* nwav.c in Sources */,
836F6F3018BDC2190095E648 /* nds_procyon_decoder.c in Sources */,
8349A8E81FE6253900E26435 /* blocked_dec.c in Sources */,
831BA6181EAC61A500CF89B0 /* adx.c in Sources */,
832BF82321E0514B006F50F1 /* imc.c in Sources */,
836F6FB118BDC2190095E648 /* ngc_ffcc_str.c in Sources */,
8306B0B620984552000302D4 /* blocked_hwas.c in Sources */,
836F6FC218BDC2190095E648 /* pc_mxst.c in Sources */,
@@ -2387,7 +2458,6 @@
8306B0B420984552000302D4 /* blocked_tra.c in Sources */,
836F6FDD18BDC2190095E648 /* ps2_ikm.c in Sources */,
834FE0B8215C798C000A5D3D /* acm_decoder_decode.c in Sources */,
8306B0B520984552000302D4 /* blocked_emff.c in Sources */,
836F6FBD18BDC2190095E648 /* nwa.c in Sources */,
834FE0F7215C79ED000A5D3D /* vis.c in Sources */,
83A21F8C201D8982000F04B9 /* kma9.c in Sources */,
@@ -2399,6 +2469,7 @@
836F6F4118BDC2190095E648 /* blocked.c in Sources */,
836F6F3B18BDC2190095E648 /* ws_decoder.c in Sources */,
838BDB6E1D3B043C0022CA6F /* ffmpeg.c in Sources */,
832BF82B21E0514B006F50F1 /* xopus.c in Sources */,
836F6F3418BDC2190095E648 /* nwa_decoder.c in Sources */,
836F6F2E18BDC2190095E648 /* msadpcm_decoder.c in Sources */,
836F6F9218BDC2190095E648 /* ish_isd.c in Sources */,
@@ -2417,6 +2488,7 @@
832389501D2246C300482226 /* hca.c in Sources */,
836F701B18BDC2190095E648 /* psx_gms.c in Sources */,
8306B0F020984590000302D4 /* atsl.c in Sources */,
832BF82421E0514B006F50F1 /* mul.c in Sources */,
836F700518BDC2190095E648 /* ps2_vbk.c in Sources */,
836F6FDF18BDC2190095E648 /* ps2_int.c in Sources */,
8306B0AC20984552000302D4 /* blocked_xa.c in Sources */,


+ 108
- 76
Frameworks/vgmstream/vgmstream/ext_libs/clHCA.c View File

@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <memory.h>

#define HCA_MASK 0x7F7F7F7F /* chunk obfuscation when the HCA is encrypted (ciph type > 0) */
#define HCA_MASK 0x7F7F7F7F /* chunk obfuscation when the HCA is encrypted with key */
#define HCA_SUBFRAMES_PER_FRAME 8
#define HCA_SAMPLES_PER_SUBFRAME 128
#define HCA_SAMPLES_PER_FRAME (HCA_SUBFRAMES_PER_FRAME*HCA_SAMPLES_PER_SUBFRAME)
@@ -34,6 +34,13 @@

#define HCA_MAX_CHANNELS 16 /* internal max? in practice only 8 can be encoded */

#define HCA_ERROR_PARAMS -1
#define HCA_ERROR_HEADER -2
#define HCA_ERROR_CHECKSUM -3
#define HCA_ERROR_SYNC -4
#define HCA_ERROR_UNPACK -5
#define HCA_ERROR_BITREADER -6

//--------------------------------------------------
// Decoder config/state
//--------------------------------------------------
@@ -239,7 +246,7 @@ int clHCA_isOurFile(const void *data, unsigned int size) {
unsigned int header_size = 0;

if (!data || size < 0x08)
return -1;
return HCA_ERROR_PARAMS;

bitreader_init(&br, data, 8);
if ((bitreader_peek(&br, 32) & HCA_MASK) == 0x48434100) {/*'HCA\0'*/
@@ -248,13 +255,13 @@ int clHCA_isOurFile(const void *data, unsigned int size) {
}

if (header_size == 0)
return -1;
return HCA_ERROR_HEADER;
return header_size;
}

int clHCA_getInfo(clHCA *hca, clHCA_stInfo *info) {
if (!hca || !info || !hca->is_valid)
return -1;
return HCA_ERROR_PARAMS;

info->version = hca->version;
info->headerSize = hca->header_size;
@@ -286,10 +293,10 @@ void clHCA_ReadSamples16(clHCA *hca, signed short *samples) {
for (k = 0; k < hca->channels; k++) {
f = hca->channel[k].wave[i][j];
//f = f * hca->rva_volume; /* rare, won't apply for now */
if (f > 1) {
f = 1;
} else if (f < -1) {
f = -1;
if (f > 1.0f) {
f = 1.0f;
} else if (f < -1.0f) {
f = -1.0f;
}
s = (signed int) (f * scale);
if ((unsigned) (s + 0x8000) & 0xFFFF0000)
@@ -424,7 +431,7 @@ static int ath_init(unsigned char *ath_curve, int type, unsigned int sample_rate
ath_init1(ath_curve, sample_rate);
break;
default:
return -1;
return HCA_ERROR_HEADER;
}
return 0;
}
@@ -455,7 +462,7 @@ static void cipher_init1(unsigned char *cipher_table) {
const int add = 11;
unsigned int i, v = 0;

/* keyless encryption (unused?) */
/* keyless encryption (rare) */
for (i = 1; i < 256 - 1; i++) {
v = (v * mul + add) & 0xFF;
if (v == 0 || v == 0xFF)
@@ -542,7 +549,7 @@ static void cipher_init56(unsigned char *cipher_table, unsigned long long keycod
}

static int cipher_init(unsigned char *cipher_table, int type, unsigned long long keycode) {
if (!(keycode))
if (type == 56 && !(keycode))
type = 0;

switch (type) {
@@ -556,7 +563,7 @@ static int cipher_init(unsigned char *cipher_table, int type, unsigned long long
cipher_init56(cipher_table, keycode);
break;
default:
return -1;
return HCA_ERROR_HEADER;
}
return 0;
}
@@ -568,16 +575,17 @@ static unsigned int header_ceil2(unsigned int a, unsigned int b) {
return (b > 0) ? (a / b + ((a % b) ? 1 : 0)) : 0;
}

int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
int clHCA_DecodeHeader(clHCA *hca, const void *data, unsigned int size) {
clData br;
int res;

if (!hca || !data )
return -1;
if (!hca || !data)
return HCA_ERROR_PARAMS;

hca->is_valid = 0;

if (size < 0x08)
return -1;
return HCA_ERROR_PARAMS;

bitreader_init(&br, data, size);

@@ -594,18 +602,18 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->version != 0x0102 &&
hca->version != 0x0103 &&
hca->version != 0x0200)
return -1;
return HCA_ERROR_HEADER;
#endif
if (size < hca->header_size)
return -1;
return HCA_ERROR_PARAMS;

if (crc16_checksum(data,hca->header_size))
return -1;
return HCA_ERROR_CHECKSUM;

size -= 0x08;
}
else {
return -1;
return HCA_ERROR_HEADER;
}

/* format info */
@@ -618,18 +626,18 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->encoder_padding = bitreader_read(&br, 16);

if (!(hca->channels >= 1 && hca->channels <= HCA_MAX_CHANNELS))
return -1;
return HCA_ERROR_HEADER;

if (hca->frame_count == 0)
return -1;
return HCA_ERROR_HEADER;

if (!(hca->sample_rate >= 1 && hca->sample_rate <= 0x7FFFFF)) /* encoder max seems 48000 */
return -1;
return HCA_ERROR_HEADER;

size -= 0x10;
}
else {
return -1;
return HCA_ERROR_HEADER;
}

/* compression (v2.0) or decode (v1.x) info */
@@ -668,7 +676,7 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
size -= 0x0c;
}
else {
return -1;
return HCA_ERROR_HEADER;
}

/* VBR (variable bit rate) info */
@@ -678,7 +686,7 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->vbr_noise_Level = bitreader_read(&br, 16);

if (!(hca->frame_size == 0 && hca->vbr_max_frame_size > 8 && hca->vbr_max_frame_size <= 0x1FF))
return -1;
return HCA_ERROR_HEADER;

size -= 0x08;
}
@@ -710,7 +718,7 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {

if (!(hca->loop_start_frame >= 0 && hca->loop_start_frame <= hca->loop_end_frame
&& hca->loop_end_frame < hca->frame_count))
return -1;
return HCA_ERROR_HEADER;

size -= 0x10;
}
@@ -729,7 +737,7 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->ciph_type = bitreader_read(&br, 16);

if (!(hca->ciph_type == 0 || hca->ciph_type == 1 || hca->ciph_type == 56))
return -1;
return HCA_ERROR_HEADER;

size -= 0x06;
}
@@ -760,11 +768,11 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->comment_len = bitreader_read(&br, 8);

if (hca->comment_len > size)
return -1;
return HCA_ERROR_HEADER;

temp = realloc(hca->comment, hca->comment_len + 1);
if (!temp)
return -1;
return HCA_ERROR_HEADER;
hca->comment = temp;
for (i = 0; i < hca->comment_len; ++i)
hca->comment[i] = bitreader_read(&br, 8);
@@ -782,17 +790,17 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
size -= (size - 0x02); /* fills up to header_size, sans checksum */
}

/* should be fully read, but allow data buffer may be bigger than header_size */
/* should be fully read, but allow as data buffer may be bigger than header_size */
//if (size != 0x02)
// return -1;
// return HCA_ERROR_HEADER;


/* extra validations */
if (!(hca->frame_size >= 0x08 && hca->frame_size <= 0xFFFF)) /* actual max seems 0x155*channels */
return -1; /* theoretically can be 0 if VBR (not seen) */
return HCA_ERROR_HEADER; /* theoretically can be 0 if VBR (not seen) */

if (!(hca->min_resolution == 1 && hca->max_resolution == 15))
return -1;
return HCA_ERROR_HEADER;


/* inits state */
@@ -803,10 +811,12 @@ int clHCA_DecodeHeader(clHCA *hca, void *data, unsigned int size) {
hca->total_band_count - hca->base_band_count - hca->stereo_band_count,
hca->bands_per_hfr_group);

if (ath_init(hca->ath_curve, hca->ath_type, hca->sample_rate) < 0)
return -1;
if (cipher_init(hca->cipher_table, hca->ciph_type, hca->keycode) < 0)
return -1;
res = ath_init(hca->ath_curve, hca->ath_type, hca->sample_rate);
if (res < 0)
return res;
res = cipher_init(hca->cipher_table, hca->ciph_type, hca->keycode);
if (res < 0)
return res;


/* init channels */
@@ -919,43 +929,62 @@ int clHCA_TestBlock(clHCA *hca, void *data, unsigned int size) {
unsigned int ch, sf, s;
int status;
int clips = 0, blanks = 0;
float fsample;
signed int psample;

/* return if decode fails (happens sometimes with wrong keys) */

/* first blocks can be empty/silent, check all bytes but sync/crc */
{
int i;
int is_empty = 1;
const unsigned char *buf = data;

for (i = 2; i < size - 0x02; i++) {
if (buf[i] != 0) {
is_empty = 0;
break;
}
}

if (is_empty) {
return 0;
}
}

/* return if decode fails (happens often with wrong keys due to bad bitstream values) */
status = clHCA_DecodeBlock(hca, data, size);
if (status < 0)
return -1;

/* check decode results */
/* check decode results as bad keys may still get here */
for (ch = 0; ch < hca->channels; ch++) {
for (sf = 0; sf < HCA_SUBFRAMES_PER_FRAME; sf++) {
for (s = 0; s < HCA_SAMPLES_PER_SUBFRAME; s++) {
fsample = hca->channel[ch].wave[sf][s];
psample = (signed int) (fsample * scale);
if (fsample > 1.0f || fsample < -1.0f)
float fsample = hca->channel[ch].wave[sf][s];
if (fsample > 1.0f || fsample < -1.0f) { //improve?
clips++;
else if (psample == 0 || psample == -1)
blanks++;
}
else {
signed int psample = (signed int) (fsample * scale);
if (psample == 0 || psample == -1)
blanks++;
}
}
}
}

/* the more clips the less likely block was correctly decrypted */
if (clips > 0)
if (clips == 1)
clips++;
if (clips > 1)
return clips;
/* if block is silent result is not useful */
if (blanks == hca->channels * HCA_SUBFRAMES_PER_FRAME * HCA_SAMPLES_PER_SUBFRAME)
return 0;

/* block may be correct (but wrong keys can get this too) */
/* block may be correct (but wrong keys can get this too and should test more blocks) */
return 1;
}


#if 0
// it'd seem like resetting IMDCT (others get overwritten) would matter when restarting the
// stream from 0, but doesn't seem any different, maybe because the first frame acts as setup/empty
void clHCA_DecodeReset(clHCA * hca) {
unsigned int i;

@@ -965,18 +994,18 @@ void clHCA_DecodeReset(clHCA * hca) {
for (i = 0; i < hca->channels; i++) {
stChannel *ch = &hca->channel[i];

memset(ch->intensity, 0, sizeof(ch->intensity[0]) * HCA_SUBFRAMES_PER_FRAME);
memset(ch->scalefactors, 0, sizeof(ch->scalefactors[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->resolution, 0, sizeof(ch->resolution[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->gain, 0, sizeof(ch->gain[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->spectra, 0, sizeof(ch->spectra[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->temp, 0, sizeof(ch->temp[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->dct, 0, sizeof(ch->dct[0]) * HCA_SAMPLES_PER_SUBFRAME);
/* most values get overwritten during decode */
//memset(ch->intensity, 0, sizeof(ch->intensity[0]) * HCA_SUBFRAMES_PER_FRAME);
//memset(ch->scalefactors, 0, sizeof(ch->scalefactors[0]) * HCA_SAMPLES_PER_SUBFRAME);
//memset(ch->resolution, 0, sizeof(ch->resolution[0]) * HCA_SAMPLES_PER_SUBFRAME);
//memset(ch->gain, 0, sizeof(ch->gain[0]) * HCA_SAMPLES_PER_SUBFRAME);
//memset(ch->spectra, 0, sizeof(ch->spectra[0]) * HCA_SAMPLES_PER_SUBFRAME);
//memset(ch->temp, 0, sizeof(ch->temp[0]) * HCA_SAMPLES_PER_SUBFRAME);
//memset(ch->dct, 0, sizeof(ch->dct[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->imdct_previous, 0, sizeof(ch->imdct_previous[0]) * HCA_SAMPLES_PER_SUBFRAME);
memset(ch->wave, 0, sizeof(ch->wave[0][0]) * HCA_SUBFRAMES_PER_FRAME * HCA_SUBFRAMES_PER_FRAME);
//memset(ch->wave, 0, sizeof(ch->wave[0][0]) * HCA_SUBFRAMES_PER_FRAME * HCA_SUBFRAMES_PER_FRAME);
}
}
#endif

//--------------------------------------------------
// Decode
@@ -1002,19 +1031,19 @@ int clHCA_DecodeBlock(clHCA *hca, void *data, unsigned int size) {
unsigned int subframe, ch;

if (!data || !hca || !hca->is_valid)
return -1;
return HCA_ERROR_PARAMS;
if (size < hca->frame_size)
return -1;
return HCA_ERROR_PARAMS;

bitreader_init(&br, data, hca->frame_size);

/* test sync (not encrypted) */
sync = bitreader_read(&br, 16);
if (sync != 0xFFFF)
return -1;
return HCA_ERROR_SYNC;

if (crc16_checksum(data, hca->frame_size))
return -1;
return HCA_ERROR_CHECKSUM;

cipher_decrypt(hca->cipher_table, data, hca->frame_size);

@@ -1029,7 +1058,7 @@ int clHCA_DecodeBlock(clHCA *hca, void *data, unsigned int size) {
int unpack = decode1_unpack_channel(&hca->channel[ch], &br,
hca->hfr_group_count, packed_noise_level, hca->ath_curve);
if (unpack < 0)
return -1;
return unpack;
}
}

@@ -1059,9 +1088,12 @@ int clHCA_DecodeBlock(clHCA *hca, void *data, unsigned int size) {
}
}

/* should read all frame sans checksum at most */
if (br.bit > br.size - 16) {
return -1;
/* should read all frame sans checksum (16b) at most */
/* one frame was found to read up to 14b left (cross referenced with CRI's tools),
* perhaps some encoding hiccup [World of Final Fantasy Maxima (Switch) am_ev21_0170 video],
* though this validation makes more sense when testing keys and isn't normally done on decode */
if (br.bit + 14 > br.size) { /* relax validation a bit for that case */
return HCA_ERROR_BITREADER;
}

return 0;
@@ -1131,8 +1163,8 @@ static int decode1_unpack_channel(stChannel *ch, clData *br,
if (delta != expected_delta) {
/* may happen with bad keycodes, scalefactors must be 6b indexes */
int scalefactor_test = (int)scalefactor_prev + ((int)delta - (int)extra_delta);
if (scalefactor_test < 0 || scalefactor_test > 64) {
return -1;
if (scalefactor_test < 0 || scalefactor_test >= 64) {
return HCA_ERROR_UNPACK;
}

scalefactor_prev += delta - extra_delta;
@@ -1160,7 +1192,7 @@ static int decode1_unpack_channel(stChannel *ch, clData *br,
}
/* 15 may be an invalid value? */
//else {
// return -1;
// return HCA_ERROR_INSENSITY;
//}
}
else {
@@ -1519,9 +1551,9 @@ static const unsigned int decode5_imdct_window_int[128] = {
static const float *decode5_imdct_window = (const float *)decode5_imdct_window_int;

static void decoder5_run_imdct(stChannel *ch, int subframe) {
const static unsigned int size = HCA_SAMPLES_PER_SUBFRAME;
const static unsigned int half = HCA_SAMPLES_PER_SUBFRAME / 2;
const static unsigned int mdct_bits = HCA_MDCT_BITS;
static const unsigned int size = HCA_SAMPLES_PER_SUBFRAME;
static const unsigned int half = HCA_SAMPLES_PER_SUBFRAME / 2;
static const unsigned int mdct_bits = HCA_MDCT_BITS;


/* apply DCT-IV to dequantized spectra */


+ 6
- 1
Frameworks/vgmstream/vgmstream/ext_libs/clHCA.h View File

@@ -27,7 +27,7 @@ void clHCA_delete(clHCA *);
* the header length with clHCA_isOurFile, then read data and call this.
* May be called multiple times to reset decoder state.
* Returns 0 on success, <0 on failure. */
int clHCA_DecodeHeader(clHCA *, void *data, unsigned int size);
int clHCA_DecodeHeader(clHCA *, const void *data, unsigned int size);

typedef struct clHCA_stInfo {
unsigned int version;
@@ -61,6 +61,7 @@ int clHCA_getInfo(clHCA *, clHCA_stInfo *out);

/* Decodes a single frame, from data after headerSize. Should be called after
* clHCA_DecodeHeader and size must be at least blockSize long.
* Data may be modified if encrypted.
* Returns 0 on success, <0 on failure. */
int clHCA_DecodeBlock(clHCA *, void *data, unsigned int size);

@@ -81,6 +82,10 @@ void clHCA_SetKey(clHCA *, unsigned long long keycode);
* and select the key with scores closer to 1. */
int clHCA_TestBlock(clHCA *hca, void *data, unsigned int size);

/* Resets the internal decode state, used when restarting to decode the file from the beginning.
* Without it there are minor differences, mainly useful when testing a new key. */
void clHCA_DecodeReset(clHCA * hca);

#ifdef __cplusplus
}
#endif


+ 1
- 1
Frameworks/vgmstream/vgmstream/src/coding/atrac9_decoder.c View File

@@ -128,7 +128,7 @@ void decode_atrac9(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do,
decode_fail:
/* on error just put some 0 samples */
VGM_LOG("ATRAC9: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done));
VGM_LOG("ATRAC9: decode fail at %x, missing %i samples\n", (uint32_t)stream->offset, (samples_to_do - samples_done));
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels);
}


+ 0
- 259
Frameworks/vgmstream/vgmstream/src/coding/atrac9_decoder.c.orig View File

@@ -1,259 +0,0 @@
#include "coding.h"
#ifdef VGM_USE_ATRAC9
#include "libatrac9.h"
/* opaque struct */
struct atrac9_codec_data {
uint8_t *data_buffer;
size_t data_buffer_size;
sample *sample_buffer;
size_t samples_filled; /* number of samples in the buffer */
size_t samples_used; /* number of samples extracted from the buffer */
int samples_to_discard;
atrac9_config config;
void *handle; /* decoder handle */
Atrac9CodecInfo info; /* decoder info */
};
atrac9_codec_data *init_atrac9(atrac9_config *cfg) {
int status;
uint8_t config_data[4];
atrac9_codec_data *data = NULL;
data = calloc(1, sizeof(atrac9_codec_data));
if (!data) goto fail;
data->handle = Atrac9GetHandle();
if (!data->handle) goto fail;
put_32bitBE(config_data, cfg->config_data);
status = Atrac9InitDecoder(data->handle, config_data);
if (status < 0) goto fail;
status = Atrac9GetCodecInfo(data->handle, &data->info);
if (status < 0) goto fail;
//;VGM_LOG("ATRAC9: config=%x, sf-size=%x, sub-frames=%i x %i samples\n", cfg->config_data, info.superframeSize, info.framesInSuperframe, info.frameSamples);
if (cfg->channels && cfg->channels != data->info.channels) {
VGM_LOG("ATRAC9: channels in header %i vs config %i don't match\n", cfg->channels, data->info.channels);
goto fail; /* unknown multichannel layout */
}
/* must hold at least one superframe and its samples */
data->data_buffer_size = data->info.superframeSize;
data->data_buffer = calloc(sizeof(uint8_t), data->data_buffer_size);
data->sample_buffer = calloc(sizeof(sample), data->info.channels * data->info.frameSamples * data->info.framesInSuperframe);
data->samples_to_discard = cfg->encoder_delay;
memcpy(&data->config, cfg, sizeof(atrac9_config));
return data;
fail:
free_atrac9(data);
return NULL;
}
void decode_atrac9(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do, int channels) {
VGMSTREAMCHANNEL *stream = &vgmstream->ch[0];
atrac9_codec_data * data = vgmstream->codec_data;
int samples_done = 0;
while (samples_done < samples_to_do) {
if (data->samples_filled) { /* consume samples */
int samples_to_get = data->samples_filled;
if (data->samples_to_discard) {
/* discard samples for looping */
if (samples_to_get > data->samples_to_discard)
samples_to_get = data->samples_to_discard;
data->samples_to_discard -= samples_to_get;
}
else {
/* get max samples and copy */
if (samples_to_get > samples_to_do - samples_done)
samples_to_get = samples_to_do - samples_done;
memcpy(outbuf + samples_done*channels,
data->sample_buffer + data->samples_used*channels,
samples_to_get*channels * sizeof(sample));
samples_done += samples_to_get;
}
/* mark consumed samples */
data->samples_used += samples_to_get;
data->samples_filled -= samples_to_get;
}
else { /* decode data */
int iframe, status;
int bytes_used = 0;
uint8_t *buffer = data->data_buffer;
size_t bytes;
data->samples_used = 0;
/* ATRAC9 is made of decodable superframes with several sub-frames. AT9 config data gives
* superframe size, number of frames and samples (~100-200 bytes and ~256/1024 samples). */
/* read one raw block (superframe) and advance offsets */
bytes = read_streamfile(data->data_buffer,stream->offset, data->info.superframeSize,stream->streamfile);
if (bytes != data->data_buffer_size) goto decode_fail;
stream->offset += bytes;
/* decode all frames in the superframe block */
for (iframe = 0; iframe < data->info.framesInSuperframe; iframe++) {
status = Atrac9Decode(data->handle, buffer, data->sample_buffer + data->samples_filled*channels, &bytes_used);
if (status < 0) goto decode_fail;
buffer += bytes_used;
data->samples_filled += data->info.frameSamples;
}
}
}
return;
decode_fail:
/* on error just put some 0 samples */
VGM_LOG("ATRAC9: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done));
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels);
}
void reset_atrac9(VGMSTREAM *vgmstream) {
atrac9_codec_data *data = vgmstream->codec_data;
if (!data) return;
if (!data->handle)
goto fail;
#if 0
/* reopen/flush, not needed as superframes decode separatedly and there is no carried state */
{
int status;
uint8_t config_data[4];
Atrac9ReleaseHandle(data->handle);
data->handle = Atrac9GetHandle();
if (!data->handle) goto fail;
put_32bitBE(config_data, data->config.config_data);
status = Atrac9InitDecoder(data->handle, config_data);
if (status < 0) goto fail;
}
#endif
data->samples_used = 0;
data->samples_filled = 0;
data->samples_to_discard = data->config.encoder_delay;
return;
fail:
return; /* decode calls should fail... */
}
void seek_atrac9(VGMSTREAM *vgmstream, int32_t num_sample) {
atrac9_codec_data *data = vgmstream->codec_data;
if (!data) return;
reset_atrac9(vgmstream);
/* find closest offset to desired sample, and samples to discard after that offset to reach loop */
{
int32_t seek_sample = data->config.encoder_delay + num_sample;
off_t seek_offset;
int32_t seek_discard;
int32_t superframe_samples = data->info.frameSamples * data->info.framesInSuperframe;
size_t superframe_number, superframe_back;
superframe_number = (seek_sample / superframe_samples); /* closest */
/* decoded frames affect each other slightly, so move offset back to make PCM stable
* and equivalent to a full discard loop */
superframe_back = 1; /* 1 seems enough (even when only 1 subframe in superframe) */
if (superframe_back > superframe_number)
superframe_back = superframe_number;
seek_discard = (seek_sample % superframe_samples) + (superframe_back * superframe_samples);
seek_offset = (superframe_number - superframe_back) * data->info.superframeSize;
data->samples_to_discard = seek_discard; /* already includes encoder delay */
if (vgmstream->loop_ch)
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset + seek_offset;
}
#if 0
//old full discard loop
{
data->samples_to_discard = num_sample;
data->samples_to_discard += data->config.encoder_delay;
/* loop offsets are set during decode; force them to stream start so discard works */
if (vgmstream->loop_ch)
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset;
}
#endif
}
void free_atrac9(atrac9_codec_data *data) {
if (!data) return;
if (data->handle) Atrac9ReleaseHandle(data->handle);
free(data->data_buffer);
free(data->sample_buffer);
free(data);
}
size_t atrac9_bytes_to_samples(size_t bytes, atrac9_codec_data *data) {
return bytes / data->info.superframeSize * (data->info.frameSamples * data->info.framesInSuperframe);
}
#if 0 //not needed (for now)
int atrac9_parse_config(uint32_t atrac9_config, int *out_sample_rate, int *out_channels, size_t *out_frame_size) {
static const int sample_rate_table[16] = {
11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
44100, 48000, 64000, 88200, 96000,128000,176400,192000
};
static const int channel_table[8] = {
1, 2, 2, 6, 8, 4, 0, 0
};
uint32_t sync = (atrac9_config >> 24) & 0xff; /* 8b */
uint8_t sample_rate_index = (atrac9_config >> 20) & 0x0f; /* 4b */
uint8_t channels_index = (atrac9_config >> 17) & 0x07; /* 3b */
/* uint8_t validation bit = (atrac9_config >> 16) & 0x01; */ /* 1b */
size_t frame_size = (atrac9_config >> 5) & 0x7FF; /* 11b */
size_t superframe_index = (atrac9_config >> 3) & 0x3; /* 2b */
/* uint8_t unused = (atrac9_config >> 0) & 0x7);*/ /* 3b */
if (sync != 0xFE)
goto fail;
if (out_sample_rate)
*out_sample_rate = sample_rate_table[sample_rate_index];
if (out_channels)
*out_channels = channel_table[channels_index];
if (out_frame_size)
*out_frame_size = (frame_size+1) * (1 << superframe_index);
return 1;
fail:
return 0;
}
#endif
#endif

+ 1
- 1
Frameworks/vgmstream/vgmstream/src/coding/celt_fsb_decoder.c View File

@@ -157,7 +157,7 @@ void decode_celt_fsb(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_d
decode_fail:
/* on error just put some 0 samples */
VGM_LOG("CELT: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done));
VGM_LOG("CELT: decode fail at %x, missing %i samples\n", (uint32_t)stream->offset, (samples_to_do - samples_done));
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels);
}


+ 29
- 0
Frameworks/vgmstream/vgmstream/src/coding/circus_decoder.c View File

@@ -0,0 +1,29 @@
#include "coding.h"
/* Circus XPCM mode 2 decoding, verified vs EF.exe (info from foo_adpcm/libpcm and https://github.com/lioncash/ExtractData) */
void decode_circus_adpcm(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
int i, sample_pos = 0;
int32_t hist = stream->adpcm_history1_32;
int scale = stream->adpcm_scale;
off_t frame_offset = stream->offset; /* frame size is 1 */
for (i = first_sample; i < first_sample + samples_to_do; i++) {
int8_t code = read_8bit(frame_offset+i,stream->streamfile);
hist += code << scale;
if (code == 0) {
if (scale > 0)
scale--;
}
else if (code == 127 || code == -128) {
if (scale < 8)
scale++;
}
outbuf[sample_pos] = hist;
}
stream->adpcm_history1_32 = hist;
stream->adpcm_scale = scale;
}

+ 23
- 4
Frameworks/vgmstream/vgmstream/src/coding/coding.h View File

@@ -21,6 +21,7 @@ void decode_snds_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspac
void decode_otns_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
void decode_wv6_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_ffta2_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);

void decode_ms_ima(VGMSTREAM * vgmstream,VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
void decode_ref_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
@@ -164,6 +165,12 @@ void decode_xmd(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing,
/* derf_decoder */
void decode_derf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);

/* circus_decoder */
void decode_circus_adpcm(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);

/* pcfx_decoder */
void decode_pcfx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int mode);
size_t pcfx_bytes_to_samples(size_t bytes, int channels);

/* ea_mt_decoder*/
ea_mt_codec_data *init_ea_mt(int channels, int type);
@@ -267,6 +274,7 @@ void free_celt_fsb(celt_codec_data *data);
/* ffmpeg_decoder */
ffmpeg_codec_data *init_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size);
ffmpeg_codec_data *init_ffmpeg_header_offset(STREAMFILE *streamFile, uint8_t * header, uint64_t header_size, uint64_t start, uint64_t size);
ffmpeg_codec_data *init_ffmpeg_header_offset_subsong(STREAMFILE *streamFile, uint8_t * header, uint64_t header_size, uint64_t start, uint64_t size, int target_subsong);

void decode_ffmpeg(VGMSTREAM *stream, sample * outbuf, int32_t samples_to_do, int channels);
void reset_ffmpeg(VGMSTREAM *vgmstream);
@@ -278,9 +286,14 @@ void ffmpeg_set_skip_samples(ffmpeg_codec_data * data, int skip_samples);
/* ffmpeg_decoder_custom_opus.c (helper-things) */
ffmpeg_codec_data * init_ffmpeg_switch_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
ffmpeg_codec_data * init_ffmpeg_ue4_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
size_t ffmpeg_make_opus_header(uint8_t * buf, int buf_size, int channels, int skip, int sample_rate);
size_t switch_opus_get_samples(off_t offset, size_t data_size, int sample_rate, STREAMFILE *streamFile);
size_t ue4_opus_get_samples(off_t offset, size_t data_size, int sample_rate, STREAMFILE *streamFile);
ffmpeg_codec_data * init_ffmpeg_ea_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
ffmpeg_codec_data * init_ffmpeg_x_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);

size_t switch_opus_get_samples(off_t offset, size_t data_size, STREAMFILE *streamFile);

size_t switch_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);
size_t ue4_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);
size_t ea_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);

#endif

@@ -314,7 +327,6 @@ typedef struct {

/* output */
int32_t num_samples;
int32_t skip_samples;
int32_t loop_start_sample;
int32_t loop_end_sample;
} ms_sample_data;
@@ -325,6 +337,9 @@ void wma_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, int block_ali
void xma1_parse_fmt_chunk(STREAMFILE *streamFile, off_t chunk_offset, int * channels, int * sample_rate, int * loop_flag, int32_t * loop_start_b, int32_t * loop_end_b, int32_t * loop_subframe, int be);
void xma2_parse_fmt_chunk_extra(STREAMFILE *streamFile, off_t chunk_offset, int * loop_flag, int32_t * out_num_samples, int32_t * out_loop_start_sample, int32_t * out_loop_end_sample, int be);
void xma2_parse_xma2_chunk(STREAMFILE *streamFile, off_t chunk_offset, int * channels, int * sample_rate, int * loop_flag, int32_t * num_samples, int32_t * loop_start_sample, int32_t * loop_end_sample);

void xma_fix_raw_samples(VGMSTREAM *vgmstream, STREAMFILE*streamFile, off_t stream_offset, size_t stream_size, off_t chunk_offset, int fix_num_samples, int fix_loop_samples);

int riff_get_fact_skip_samples(STREAMFILE * streamFile, off_t start_offset);

size_t atrac3_bytes_to_samples(size_t bytes, int full_block_align);
@@ -345,4 +360,8 @@ typedef struct {
int r_bits(vgm_bitstream * ib, int num_bits, uint32_t * value);
int w_bits(vgm_bitstream * ob, int num_bits, uint32_t value);


/* helper to pass a wrapped, clamped, fake extension-ed, SF to another meta */
STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* extension);

#endif /*_CODING_H*/

+ 334
- 132
Frameworks/vgmstream/vgmstream/src/coding/coding_utils.c View File

@@ -328,6 +328,35 @@ int ffmpeg_make_riff_xwma(uint8_t * buf, size_t buf_size, int codec, size_t data
if (buf_size < riff_size)
return -1;

/* XWMA encoder only allows a few channel/sample rate/bitrate combinations,
* but some create identical files with fake bitrate (1ch 22050hz at
* 20/48/192kbps are all 20kbps, with the exact same codec data).
* Decoder needs correct bitrate to work, so it's normalized here. */
/* (may be removed once FFmpeg fixes this) */
if (codec == 0x161) { /* WMAv2 only */
int ch = channels;
int sr = sample_rate;
int br = avg_bps * 8;

/* Must be a bug in MS's encoder, as later versions of xWMAEncode remove these bitrates */
if (ch == 1) {
if (sr == 22050 && (br==48000 || br==192000))
br = 20000;
else if (sr == 32000 && (br==48000 || br==192000))
br = 20000;
else if (sr == 44100 && (br==96000 || br==192000))
br = 48000;
}
else if (ch == 2) {
if (sr == 22050 && (br==48000 || br==192000))
br = 32000;
else if (sr == 32000 && (br==192000))
br = 48000;
}

avg_bps = br / 8;
}

memcpy(buf+0x00, "RIFF", 4);
put_32bitLE(buf+0x04, (int32_t)(riff_size-4-4 + data_size)); /* riff size */
memcpy(buf+0x08, "XWMA", 4);
@@ -341,7 +370,7 @@ int ffmpeg_make_riff_xwma(uint8_t * buf, size_t buf_size, int codec, size_t data
put_16bitLE(buf+0x20, block_align); /* block align */
put_16bitLE(buf+0x22, 16); /* bits per sample */
put_16bitLE(buf+0x24, 0); /* extra size */
/* here goes the "dpds" table, but it's optional and not needed by FFmpeg */
/* here goes the "dpds" seek table, but it's optional and not needed by FFmpeg (and also buggy) */

memcpy(buf+0x26, "data", 4);
put_32bitLE(buf+0x2a, data_size); /* data size */
@@ -410,85 +439,93 @@ fail:
/* XMA PARSING */
/* ******************************************** */

static void ms_audio_parse_header(STREAMFILE *streamFile, int xma_version, off_t offset_b, int bits_frame_size, size_t *first_frame_b, size_t *packet_skip_count, size_t *header_size_b) {
if (xma_version == 1) { /* XMA1 */
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
*first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside the packet */
*packet_skip_count = read_bitsBE_b(offset_b+21, 11, streamFile); /* packets to skip for next packet of this stream */
*header_size_b = 32;
} else if (xma_version == 2) { /* XMA2 */
//frame_count = read_bitsBE_b(offset_b+0, 6, streamFile); /* frames that begin in this packet */
*first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside this packet */
//packet_metadata = read_bitsBE_b(offset_b+21, 3, streamFile); /* packet_metadata (always 1) */
*packet_skip_count = read_bitsBE_b(offset_b+24, 8, streamFile); /* packets to skip for next packet of this stream */
*header_size_b = 32;
} else { /* WMAPRO(v3) */
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
*first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside the packet */
*packet_skip_count = 0; /* xwma has no need to skip packets since it uses real multichannel audio */
*header_size_b = 4+2+bits_frame_size; /* variable-sized header */
}


/* XMA2 packets with XMA1 RIFF (transmogrified), remove the packet metadata flag */
if (xma_version == 1 && (*packet_skip_count & 0x700) == 0x100) {
//VGM_LOG("MS_SAMPLES: XMA1 transmogrified packet header at 0x%lx\n", (off_t)offset_b/8);
*packet_skip_count &= ~0x100;
}

/* full packet skip, no new frames start in this packet (prev frames can end here)
* standardized to some value */
if (*packet_skip_count == 0x7FF) { /* XMA1, 11b */
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip at 0x%x\n", (uint32_t)offset_b/8);
*packet_skip_count = 0x800;
}
else if (*packet_skip_count == 0xFF) { /* XMA2, 8b*/
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip at 0x%x\n", (uint32_t)offset_b/8);
*packet_skip_count = 0x800;
}

/* unusual but not impossible, as the encoder can interleave packets in any way */
VGM_ASSERT((*packet_skip_count > 10 && *packet_skip_count < 0x800),
"MS_SAMPLES: found big packet skip %i at 0x%x\n", *packet_skip_count, (uint32_t)offset_b/8);
}

/**
* Find total and loop samples of Microsoft audio formats (WMAPRO/XMA1/XMA2) by reading frame headers.
*
* The stream is made of packets, each containing N small frames of X samples. Frames are further divided into subframes.
* XMA1/XMA2 can divided into streams for multichannel (1/2ch ... 1/2ch). From the file start, packet 1..N is owned by
* stream 1..N. Then must follow "packet_skip" value to find the stream next packet, as they are arbitrarily interleaved.
* We only need to follow the first stream, as all must contain the same number of samples.
*
* XMA1/XMA2/WMAPRO data only differs in the packet headers.
*/
static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, int start_packet, int channels_per_packet, int bytes_per_packet, int samples_per_frame, int samples_per_subframe, int bits_frame_size) {
int frames = 0, samples = 0, loop_start_frame = 0, loop_end_frame = 0, start_skip = 0, end_skip = 0;
static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, int channels_per_packet, int bytes_per_packet, int samples_per_frame, int samples_per_subframe, int bits_frame_size) {
int frames = 0, samples = 0, loop_start_frame = 0, loop_end_frame = 0;

size_t first_frame_b, packet_skip_count = 0, frame_size_b, packet_size_b, header_size_b;
size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
off_t offset_b, packet_offset_b, frame_offset_b;

size_t packet_size = bytes_per_packet;
size_t packet_size_b = packet_size * 8;
off_t offset = msd->data_offset;
off_t max_offset = msd->data_offset + msd->data_size;
off_t stream_offset_b = msd->data_offset * 8;

offset += start_packet * packet_size;
packet_size_b = packet_size * 8;

/* read packets */
while (offset < max_offset) {
offset_b = offset * 8; /* global offset in bits */
offset += packet_size; /* global offset in bytes */

/* packet header */
if (msd->xma_version == 1) { /* XMA1 */
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside the packet */
packet_skip_count = read_bitsBE_b(offset_b+21, 11, streamFile); /* packets to skip for next packet of this stream */
header_size_b = 32;
} else if (msd->xma_version == 2) { /* XMA2 */
//frame_count = read_bitsBE_b(offset_b+0, 6, streamFile); /* frames that begin in this packet */
first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside this packet */
//packet_metadata = read_bitsBE_b(offset_b+21, 3, streamFile); /* packet_metadata (always 1) */
packet_skip_count = read_bitsBE_b(offset_b+24, 8, streamFile); /* packets to skip for next packet of this stream */
header_size_b = 32;
} else { /* WMAPRO(v3) */
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
first_frame_b = read_bitsBE_b(offset_b+6, bits_frame_size, streamFile); /* offset in bits inside the packet */
packet_skip_count = 0; /* xwma has no need to skip packets since it uses real multichannel audio */
header_size_b = 4+2+bits_frame_size; /* variable-sized header */
}


/* XMA2 packets with XMA1 RIFF (transmogrified), remove the packet metadata flag */
if (msd->xma_version == 1 && (packet_skip_count & 0x700) == 0x100) {
//VGM_LOG("MS_SAMPLES: XMA1 transmogrified packet header at 0x%lx\n", (off_t)offset_b/8);
packet_skip_count &= ~0x100;
}

/* full packet skip, no new frames start in this packet (prev frames can end here) */
if (packet_skip_count == 0x7FF) { /* XMA1, 11b */
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);
packet_skip_count = 0;
continue;
}
else if (packet_skip_count == 0xFF) { /* XMA2, 8b*/
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);
packet_skip_count = 0;
continue;
ms_audio_parse_header(streamFile, msd->xma_version, offset_b, bits_frame_size, &first_frame_b, &packet_skip_count, &header_size_b);
if (packet_skip_count > 0x7FF) {
continue; /* full skip */
}
offset += packet_size * (packet_skip_count); /* skip packets not owned by the first stream, since we only need samples from it */

/* unusual but not impossible, as the encoder can interleave packets in any way */
VGM_ASSERT(packet_skip_count > 10, "MS_SAMPLES: found big packet skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);

packet_offset_b = header_size_b + first_frame_b;
/* skip packets not owned by the first stream for next time */
offset += packet_size * (packet_skip_count);


/* read packet frames */
while (packet_offset_b < packet_size_b) {
frame_offset_b = offset_b + packet_offset_b; /* in bits for aligment stuff */

/* loops, later adjusted with subframe (seems correct vs tests) */
/* frame loops, later adjusted with subframes (seems correct vs tests) */
if (msd->loop_flag && (offset_b + packet_offset_b) - stream_offset_b == msd->loop_start_b)
loop_start_frame = frames;
if (msd->loop_flag && (offset_b + packet_offset_b) - stream_offset_b == msd->loop_end_b)
@@ -497,7 +534,6 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
/* frame header */
frame_size_b = read_bitsBE_b(frame_offset_b, bits_frame_size, streamFile);
frame_offset_b += bits_frame_size;
//;VGM_LOG("MS_SAMPLES: frame_offset=0x%lx (0b%lx), frame_size=0x%x (0b%x)\n", (off_t)frame_offset_b/8,(off_t)frame_offset_b, frame_size_b/8, frame_size_b);

/* stop when packet padding starts (0x00 for XMA1 or 0xFF in XMA2) */
if (frame_size_b == 0 || frame_size_b == (0xffffffff >> (32 - bits_frame_size))) {
@@ -506,12 +542,77 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
packet_offset_b += frame_size_b; /* including header */


samples += samples_per_frame;
frames++;

/* last bit in frame = more frames flag, end packet to avoid reading garbage in some cases
* (last frame spilling to other packets also has this flag, though it's ignored here) */
if (packet_offset_b < packet_size_b && !read_bitsBE_b(offset_b + packet_offset_b - 1, 1, streamFile)) {
break;
}
}
}

/* result */
msd->num_samples = samples;
if (msd->loop_flag && loop_end_frame > loop_start_frame) {
msd->loop_start_sample = loop_start_frame * samples_per_frame + msd->loop_start_subframe * samples_per_subframe;
msd->loop_end_sample = loop_end_frame * samples_per_frame + (msd->loop_end_subframe) * samples_per_subframe;
}

/* the above can't properly read skips for WMAPro ATM, but should fixed to 1 frame anyway */
if (msd->xma_version == 0) {
msd->num_samples -= samples_per_frame; /* FFmpeg does skip this */
#if 0
msd->num_samples += (samples_per_frame / 2); /* but doesn't add extra samples */
#endif
}
}

/* simlar to the above but only gets skips */
static void ms_audio_get_skips(STREAMFILE *streamFile, int xma_version, off_t data_offset, int channels_per_packet, int bytes_per_packet, int samples_per_frame, int bits_frame_size, int *out_start_skip, int *out_end_skip) {
int start_skip = 0, end_skip = 0;

size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
off_t offset_b, packet_offset_b, frame_offset_b;

size_t packet_size = bytes_per_packet;
size_t packet_size_b = packet_size * 8;
off_t offset = data_offset;

/* read packet */
{
offset_b = offset * 8; /* global offset in bits */
offset += packet_size; /* global offset in bytes */

/* packet header */
ms_audio_parse_header(streamFile, 2, offset_b, bits_frame_size, &first_frame_b, &packet_skip_count, &header_size_b);
if (packet_skip_count > 0x7FF) {
return; /* full skip */
}

packet_offset_b = header_size_b + first_frame_b;

/* read packet frames */
while (packet_offset_b < packet_size_b) {
frame_offset_b = offset_b + packet_offset_b; /* in bits for aligment stuff */

/* frame header */
frame_size_b = read_bitsBE_b(frame_offset_b, bits_frame_size, streamFile);
frame_offset_b += bits_frame_size;

/* stop when packet padding starts (0x00 for XMA1 or 0xFF in XMA2) */
if (frame_size_b == 0 || frame_size_b == (0xffffffff >> (32 - bits_frame_size))) {
break;
}
packet_offset_b += frame_size_b; /* including header */

/* find skips (info from FFmpeg) */
if (channels_per_packet && (msd->xma_version == 1 || msd->xma_version == 2)) {
if (channels_per_packet && (xma_version == 1 || xma_version == 2)) {
int flag;
int tilehdr_size = 15; //todo incorrect but usable for XMA, fix for WMAPro (complex calcs, see ffmpeg decode_tilehdr)
int len_tilehdr_size = 15; //todo incorrect but usable for XMA, fix for WMAPro (complex, see ffmpeg decode_tilehdr)

frame_offset_b += tilehdr_size;
frame_offset_b += len_tilehdr_size;

/* ignore "postproc transform" */
if (channels_per_packet > 1) {
@@ -526,7 +627,7 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
}
}

/* get start/end skips to get the proper number of samples */
/* get start/end skips to get the proper number of samples (both can be 0) */
flag = read_bitsBE_b(frame_offset_b, 1, streamFile);
frame_offset_b += 1;
if (flag) {
@@ -535,14 +636,13 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
frame_offset_b += 1;
if (flag) {
int new_skip = read_bitsBE_b(frame_offset_b, 10, streamFile);
VGM_LOG("MS_SAMPLES: start_skip %i at 0x%"PRIx64" (bit 0x%"PRIx64")\n", new_skip, (off64_t)frame_offset_b/8, (off64_t)frame_offset_b);
VGM_ASSERT(start_skip, "MS_SAMPLES: more than one start_skip (%i)\n", new_skip); //ignore, happens due to incorrect tilehdr_size
//;VGM_LOG("MS_SAMPLES: start_skip %i at 0x%x (bit 0x%x)\n", new_skip, (uint32_t)frame_offset_b/8, (uint32_t)frame_offset_b);
frame_offset_b += 10;

if (new_skip > samples_per_frame) /* from xmaencode */
new_skip = samples_per_frame;

if (start_skip==0)
if (start_skip==0) /* only use first skip */
start_skip = new_skip;
}

@@ -551,46 +651,25 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
frame_offset_b += 1;
if (flag) {
int new_skip = read_bitsBE_b(frame_offset_b, 10, streamFile);
VGM_LOG("MS_SAMPLES: end_skip %i at 0x%"PRIx64" (bit 0x%"PRIx64")\n", new_skip, (off64_t)frame_offset_b/8, (off64_t)frame_offset_b);
VGM_ASSERT(end_skip, "MS_SAMPLES: more than one end_skip (%i)\n", new_skip);//ignore, happens due to incorrect tilehdr_size
//;VGM_LOG("MS_SAMPLES: end_skip %i at 0x%x (bit 0x%x)\n", new_skip, (uint32_t)frame_offset_b/8, (uint32_t)frame_offset_b);
frame_offset_b += 10;

if (new_skip > samples_per_frame) /* from xmaencode */
new_skip = samples_per_frame;

end_skip = new_skip;
end_skip = new_skip; /* always use last skip */
}
}
}


samples += samples_per_frame;
frames++;

/* last bit in frame = more frames flag, end packet to avoid reading garbage in some cases
* (last frame spilling to other packets also has this flag, though it's ignored here) */
if (packet_offset_b < packet_size_b && !read_bitsBE_b(offset_b + packet_offset_b - 1, 1, streamFile)) {
break;
}
}
}


//todo FFmpeg seems to decode 1 subframe late vs xmaencode, and doesn't write 128 init samples, so skips are not useful ATM
//samples = samples + 128 - start_skip - end_skip; /* 128 init samples added by xmaencode */
msd->num_samples = samples;
msd->skip_samples = start_skip;

if (msd->loop_flag && loop_end_frame > loop_start_frame) {
msd->loop_start_sample = loop_start_frame * samples_per_frame + msd->loop_start_subframe * samples_per_subframe;
msd->loop_end_sample = loop_end_frame * samples_per_frame + msd->loop_end_subframe * samples_per_subframe;

//todo maybe this is needed
//msd->loop_start_sample -= start_skip;
//msd->loop_end_sample -= start_skip;
}
/* output results */
if (out_start_skip) *out_start_skip = start_skip;
if (out_end_skip) *out_end_skip = end_skip;
}


static int wma_get_samples_per_frame(int version, int sample_rate, uint32_t decode_flags) {
int frame_len_bits;

@@ -618,33 +697,40 @@ static int wma_get_samples_per_frame(int version, int sample_rate, uint32_t deco
return 1 << frame_len_bits;
}

void xma_get_samples(ms_sample_data * msd, STREAMFILE *streamFile) {
const int bytes_per_packet = 2048;
const int samples_per_frame = 512;
const int samples_per_subframe = 128;

static int xma_get_channels_per_stream(STREAMFILE* streamFile, off_t chunk_offset, int channels) {
int start_stream = 0;
int channels_per_stream = 0;

/* get from stream config (needed to find skips) */
if (msd->chunk_offset) {
int format = read_16bitLE(msd->chunk_offset,streamFile);
if (chunk_offset) {
int format = read_16bitLE(chunk_offset,streamFile);
if (format == 0x0165 || format == 0x6501) { /* XMA1 */
channels_per_stream = read_8bit(msd->chunk_offset + 0x0C + 0x14*start_stream + 0x11,streamFile);
channels_per_stream = read_8bit(chunk_offset + 0x0C + 0x14*start_stream + 0x11,streamFile);
} else if (format == 0x0166 || format == 0x6601) { /* new XMA2 */
channels_per_stream = msd->channels > 1 ? 2 : 1;
channels_per_stream = channels > 1 ? 2 : 1;
} else { /* old XMA2 */
int version = read_8bit(msd->chunk_offset,streamFile);
channels_per_stream = read_8bit(msd->chunk_offset + 0x20 + (version==3 ? 0x00 : 0x08) + 0x4*start_stream + 0x00,streamFile);
int version = read_8bit(chunk_offset,streamFile);
channels_per_stream = read_8bit(chunk_offset + 0x20 + (version==3 ? 0x00 : 0x08) + 0x4*start_stream + 0x00,streamFile);
}
}
else if (msd->channels) {
channels_per_stream = msd->channels > 1 ? 2 : 1;
else if (channels) {
channels_per_stream = channels == 1 ? 1 : 2; /* default for XMA without RIFF chunks, most common */
}

if (channels_per_stream > 2)
channels_per_stream = 0;

ms_audio_get_samples(msd, streamFile, start_stream, channels_per_stream, bytes_per_packet, samples_per_frame, samples_per_subframe, 15);
return channels_per_stream;