An audio player for macOS 10.8 and newer. https://kode54.net/cog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

430 lines
27KB

  1. #ifndef _CODING_H
  2. #define _CODING_H
  3. #include "../vgmstream.h"
  4. /* adx_decoder */
  5. void decode_adx(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int32_t frame_bytes, coding_t coding_type);
  6. void adx_next_key(VGMSTREAMCHANNEL * stream);
  7. /* g721_decoder */
  8. void decode_g721(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  9. void g72x_init_state(struct g72x_state *state_ptr);
  10. /* ima_decoder */
  11. void decode_standard_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo, int is_high_first);
  12. void decode_3ds_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  13. void decode_snds_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  14. void decode_otns_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  15. void decode_wv6_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  16. void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  17. void decode_ffta2_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  18. void decode_blitz_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  19. void decode_mtf_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo);
  20. void decode_ms_ima(VGMSTREAM * vgmstream,VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
  21. void decode_ref_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
  22. void decode_xbox_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo);
  23. void decode_xbox_ima_mch(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  24. void decode_nds_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  25. void decode_dat4_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  26. void decode_rad_ima(VGMSTREAM * vgmstream,VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
  27. void decode_rad_ima_mono(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  28. void decode_apple_ima4(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  29. void decode_fsb_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  30. void decode_wwise_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  31. void decode_awc_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  32. void decode_ubi_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  33. void decode_h4m_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, uint16_t frame_format);
  34. size_t ima_bytes_to_samples(size_t bytes, int channels);
  35. size_t ms_ima_bytes_to_samples(size_t bytes, int block_align, int channels);
  36. size_t xbox_ima_bytes_to_samples(size_t bytes, int channels);
  37. size_t dat4_ima_bytes_to_samples(size_t bytes, int channels);
  38. size_t apple_ima4_bytes_to_samples(size_t bytes, int channels);
  39. /* ngc_dsp_decoder */
  40. void decode_ngc_dsp(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  41. void decode_ngc_dsp_subint(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int interleave);
  42. size_t dsp_bytes_to_samples(size_t bytes, int channels);
  43. int32_t dsp_nibbles_to_samples(int32_t nibbles);
  44. void dsp_read_coefs_be(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing);
  45. void dsp_read_coefs_le(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing);
  46. void dsp_read_coefs(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing, int be);
  47. void dsp_read_hist_be(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing);
  48. void dsp_read_hist_le(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing);
  49. void dsp_read_hist(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t offset, off_t spacing, int be);
  50. /* ngc_dtk_decoder */
  51. void decode_ngc_dtk(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  52. /* ngc_afc_decoder */
  53. void decode_ngc_afc(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  54. /* pcm_decoder */
  55. void decode_pcm16le(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  56. void decode_pcm16be(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  57. void decode_pcm16_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int big_endian);
  58. void decode_pcm8(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  59. void decode_pcm8_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  60. void decode_pcm8_unsigned(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  61. void decode_pcm8_unsigned_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  62. void decode_pcm8_sb(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  63. void decode_pcm4(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  64. void decode_pcm4_unsigned(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  65. void decode_ulaw(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  66. void decode_ulaw_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  67. void decode_alaw(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  68. void decode_pcmfloat(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int big_endian);
  69. size_t pcm_bytes_to_samples(size_t bytes, int channels, int bits_per_sample);
  70. /* psx_decoder */
  71. void decode_psx(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int is_badflags, int config);
  72. void decode_psx_configurable(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int frame_size, int config);
  73. void decode_psx_pivotal(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int frame_size);
  74. int ps_find_loop_offsets(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, size_t interleave, int32_t * out_loop_start, int32_t * out_loop_end);
  75. int ps_find_loop_offsets_full(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, size_t interleave, int32_t * out_loop_start, int32_t * out_loop_end);
  76. size_t ps_find_padding(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, size_t interleave, int discard_empty);
  77. size_t ps_bytes_to_samples(size_t bytes, int channels);
  78. size_t ps_cfg_bytes_to_samples(size_t bytes, size_t frame_size, int channels);
  79. int ps_check_format(STREAMFILE *streamFile, off_t offset, size_t max);
  80. /* psv_decoder */
  81. void decode_hevag(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  82. /* xa_decoder */
  83. void decode_xa(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  84. size_t xa_bytes_to_samples(size_t bytes, int channels, int is_blocked, int is_form2);
  85. /* ea_xa_decoder */
  86. void decode_ea_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  87. void decode_ea_xa_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  88. void decode_ea_xa_v2(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
  89. void decode_maxis_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  90. /* ea_xas_decoder */
  91. void decode_ea_xas_v0(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  92. void decode_ea_xas_v1(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  93. /* sdx2_decoder */
  94. void decode_sdx2(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  95. void decode_sdx2_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  96. void decode_cbd2(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  97. void decode_cbd2_int(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  98. /* ws_decoder */
  99. void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  100. /* acm_decoder */
  101. acm_codec_data *init_acm(STREAMFILE *streamFile, int force_channel_number);
  102. void decode_acm(acm_codec_data *data, sample * outbuf, int32_t samples_to_do, int channelspacing);
  103. void reset_acm(acm_codec_data *data);
  104. void free_acm(acm_codec_data *data);
  105. /* nwa_decoder */
  106. void decode_nwa(NWAData *nwa, sample *outbuf, int32_t samples_to_do);
  107. /* msadpcm_decoder */
  108. void decode_msadpcm_stereo(VGMSTREAM * vgmstream, sample_t * outbuf, int32_t first_sample, int32_t samples_to_do);
  109. void decode_msadpcm_mono(VGMSTREAM * vgmstream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  110. void decode_msadpcm_ck(VGMSTREAM * vgmstream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  111. long msadpcm_bytes_to_samples(long bytes, int block_size, int channels);
  112. int msadpcm_check_coefs(STREAMFILE *sf, off_t offset);
  113. /* yamaha_decoder */
  114. void decode_aica(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo);
  115. void decode_aska(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  116. void decode_nxap(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  117. size_t yamaha_bytes_to_samples(size_t bytes, int channels);
  118. size_t aska_bytes_to_samples(size_t bytes, int channels);
  119. /* tgcadpcm_decoder */
  120. void decode_tgc(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int32_t first_sample, int32_t samples_to_do);
  121. /* nds_procyon_decoder */
  122. void decode_nds_procyon(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  123. /* l5_555_decoder */
  124. void decode_l5_555(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  125. /* sassc_decoder */
  126. void decode_sassc(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  127. /* lsf_decode */
  128. void decode_lsf(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  129. /* mtaf_decoder */
  130. void decode_mtaf(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  131. /* mta2_decoder */
  132. void decode_mta2(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  133. /* mc3_decoder */
  134. void decode_mc3(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  135. /* fadpcm_decoder */
  136. void decode_fadpcm(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  137. /* asf_decoder */
  138. void decode_asf(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  139. /* dsa_decoder */
  140. void decode_dsa(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  141. /* xmd_decoder */
  142. void decode_xmd(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, size_t frame_size);
  143. /* derf_decoder */
  144. void decode_derf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  145. /* circus_decoder */
  146. void decode_circus_adpcm(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
  147. /* oki_decoder */
  148. void decode_pcfx(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int mode);
  149. void decode_oki16(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  150. void decode_oki4s(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
  151. size_t oki_bytes_to_samples(size_t bytes, int channels);
  152. /* ptadpcm_decoder */
  153. void decode_ptadpcm(VGMSTREAMCHANNEL *stream, sample_t *outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, size_t frame_size);
  154. size_t ptadpcm_bytes_to_samples(size_t bytes, int channels, size_t frame_size);
  155. /* ubi_adpcm_decoder */
  156. ubi_adpcm_codec_data *init_ubi_adpcm(STREAMFILE *streamFile, off_t offset, int channels);
  157. void decode_ubi_adpcm(VGMSTREAM * vgmstream, sample_t * outbuf, int32_t samples_to_do);
  158. void reset_ubi_adpcm(ubi_adpcm_codec_data *data);
  159. void seek_ubi_adpcm(ubi_adpcm_codec_data *data, int32_t num_sample);
  160. void free_ubi_adpcm(ubi_adpcm_codec_data *data);
  161. int ubi_adpcm_get_samples(ubi_adpcm_codec_data *data);
  162. /* ea_mt_decoder*/
  163. ea_mt_codec_data *init_ea_mt(int channels, int type);
  164. ea_mt_codec_data *init_ea_mt_loops(int channels, int pcm_blocks, int loop_sample, off_t *loop_offsets);
  165. void decode_ea_mt(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
  166. void reset_ea_mt(VGMSTREAM * vgmstream);
  167. void flush_ea_mt(VGMSTREAM *vgmstream);
  168. void seek_ea_mt(VGMSTREAM * vgmstream, int32_t num_sample);
  169. void free_ea_mt(ea_mt_codec_data *data, int channels);
  170. /* relic_decoder */
  171. relic_codec_data* init_relic(int channels, int bitrate, int codec_rate);
  172. void decode_relic(VGMSTREAMCHANNEL* stream, relic_codec_data* data, sample_t* outbuf, int32_t samples_to_do);
  173. void reset_relic(relic_codec_data* data);
  174. void seek_relic(relic_codec_data* data, int32_t num_sample);
  175. void free_relic(relic_codec_data* data);
  176. /* hca_decoder */
  177. hca_codec_data *init_hca(STREAMFILE *streamFile);
  178. void decode_hca(hca_codec_data * data, sample_t * outbuf, int32_t samples_to_do);
  179. void reset_hca(hca_codec_data * data);
  180. void loop_hca(hca_codec_data * data, int32_t num_sample);
  181. void free_hca(hca_codec_data * data);
  182. int test_hca_key(hca_codec_data * data, unsigned long long keycode);
  183. #ifdef VGM_USE_VORBIS
  184. /* ogg_vorbis_decoder */
  185. ogg_vorbis_codec_data* init_ogg_vorbis(STREAMFILE *sf, off_t start, off_t size, ogg_vorbis_io *io);
  186. void decode_ogg_vorbis(ogg_vorbis_codec_data *data, sample_t *outbuf, int32_t samples_to_do, int channels);
  187. void reset_ogg_vorbis(VGMSTREAM *vgmstream);
  188. void seek_ogg_vorbis(VGMSTREAM *vgmstream, int32_t num_sample);
  189. void free_ogg_vorbis(ogg_vorbis_codec_data *data);
  190. int ogg_vorbis_get_comment(ogg_vorbis_codec_data *data, const char **comment);
  191. void ogg_vorbis_get_info(ogg_vorbis_codec_data *data, int *p_channels, int *p_sample_rate);
  192. void ogg_vorbis_get_samples(ogg_vorbis_codec_data *data, int *p_samples);
  193. void ogg_vorbis_set_disable_reordering(ogg_vorbis_codec_data *data, int set);
  194. STREAMFILE* ogg_vorbis_get_streamfile(ogg_vorbis_codec_data *data);
  195. /* vorbis_custom_decoder */
  196. vorbis_custom_codec_data *init_vorbis_custom(STREAMFILE *streamfile, off_t start_offset, vorbis_custom_t type, vorbis_custom_config * config);
  197. void decode_vorbis_custom(VGMSTREAM * vgmstream, sample_t * outbuf, int32_t samples_to_do, int channels);
  198. void reset_vorbis_custom(VGMSTREAM *vgmstream);
  199. void seek_vorbis_custom(VGMSTREAM *vgmstream, int32_t num_sample);
  200. void free_vorbis_custom(vorbis_custom_codec_data *data);
  201. #endif
  202. #ifdef VGM_USE_MPEG
  203. /* mpeg_decoder */
  204. mpeg_codec_data *init_mpeg(STREAMFILE *streamfile, off_t start_offset, coding_t *coding_type, int channels);
  205. mpeg_codec_data *init_mpeg_custom(STREAMFILE *streamFile, off_t start_offset, coding_t *coding_type, int channels, mpeg_custom_t custom_type, mpeg_custom_config *config);
  206. void decode_mpeg(VGMSTREAM * vgmstream, sample_t * outbuf, int32_t samples_to_do, int channels);
  207. void reset_mpeg(VGMSTREAM *vgmstream);
  208. void seek_mpeg(VGMSTREAM *vgmstream, int32_t num_sample);
  209. void free_mpeg(mpeg_codec_data *data);
  210. void flush_mpeg(mpeg_codec_data * data);
  211. long mpeg_bytes_to_samples(long bytes, const mpeg_codec_data *data);
  212. #endif
  213. #ifdef VGM_USE_G7221
  214. /* g7221_decoder */
  215. g7221_codec_data* init_g7221(int channel_count, int frame_size);
  216. void decode_g7221(VGMSTREAM* vgmstream, sample_t* outbuf, int channelspacing, int32_t samples_to_do, int channel);
  217. void reset_g7221(g7221_codec_data* data);
  218. void free_g7221(g7221_codec_data* data);
  219. void set_key_g7221(g7221_codec_data* data, const uint8_t* key);
  220. int test_key_g7221(g7221_codec_data* data, off_t start, STREAMFILE* sf);
  221. #endif
  222. #ifdef VGM_USE_G719
  223. /* g719_decoder */
  224. g719_codec_data *init_g719(int channel_count, int frame_size);
  225. void decode_g719(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
  226. void reset_g719(g719_codec_data * data, int channels);
  227. void free_g719(g719_codec_data * data, int channels);
  228. #endif
  229. #if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
  230. /* mp4_aac_decoder */
  231. void decode_mp4_aac(mp4_aac_codec_data * data, sample * outbuf, int32_t samples_to_do, int channels);
  232. void reset_mp4_aac(VGMSTREAM *vgmstream);
  233. void seek_mp4_aac(VGMSTREAM *vgmstream, int32_t num_sample);
  234. void free_mp4_aac(mp4_aac_codec_data * data);
  235. #endif
  236. #ifdef VGM_USE_MAIATRAC3PLUS
  237. /* at3plus_decoder */
  238. maiatrac3plus_codec_data *init_at3plus();
  239. void decode_at3plus(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
  240. void reset_at3plus(VGMSTREAM *vgmstream);
  241. void seek_at3plus(VGMSTREAM *vgmstream, int32_t num_sample);
  242. void free_at3plus(maiatrac3plus_codec_data *data);
  243. #endif
  244. #ifdef VGM_USE_ATRAC9
  245. /* atrac9_decoder */
  246. atrac9_codec_data *init_atrac9(atrac9_config *cfg);
  247. void decode_atrac9(VGMSTREAM *vgmstream, sample_t * outbuf, int32_t samples_to_do, int channels);
  248. void reset_atrac9(VGMSTREAM *vgmstream);
  249. void seek_atrac9(VGMSTREAM *vgmstream, int32_t num_sample);
  250. void free_atrac9(atrac9_codec_data *data);
  251. size_t atrac9_bytes_to_samples(size_t bytes, atrac9_codec_data *data);
  252. size_t atrac9_bytes_to_samples_cfg(size_t bytes, uint32_t atrac9_config);
  253. #endif
  254. #ifdef VGM_USE_CELT
  255. /* celt_fsb_decoder */
  256. celt_codec_data *init_celt_fsb(int channels, celt_lib_t version);
  257. void decode_celt_fsb(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do, int channels);
  258. void reset_celt_fsb(VGMSTREAM *vgmstream);
  259. void seek_celt_fsb(VGMSTREAM *vgmstream, int32_t num_sample);
  260. void free_celt_fsb(celt_codec_data *data);
  261. #endif
  262. #ifdef VGM_USE_FFMPEG
  263. /* ffmpeg_decoder */
  264. ffmpeg_codec_data *init_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size);
  265. ffmpeg_codec_data *init_ffmpeg_header_offset(STREAMFILE *streamFile, uint8_t * header, uint64_t header_size, uint64_t start, uint64_t size);
  266. 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);
  267. void decode_ffmpeg(VGMSTREAM *stream, sample_t * outbuf, int32_t samples_to_do, int channels);
  268. void reset_ffmpeg(VGMSTREAM *vgmstream);
  269. void seek_ffmpeg(VGMSTREAM *vgmstream, int32_t num_sample);
  270. void free_ffmpeg(ffmpeg_codec_data *data);
  271. void ffmpeg_set_skip_samples(ffmpeg_codec_data * data, int skip_samples);
  272. uint32_t ffmpeg_get_channel_layout(ffmpeg_codec_data * data);
  273. void ffmpeg_set_channel_remapping(ffmpeg_codec_data * data, int *channels_remap);
  274. const char* ffmpeg_get_codec_name(ffmpeg_codec_data * data);
  275. void ffmpeg_set_force_seek(ffmpeg_codec_data * data);
  276. /* ffmpeg_decoder_utils.c (helper-things) */
  277. ffmpeg_codec_data * init_ffmpeg_atrac3_raw(STREAMFILE *sf, off_t offset, size_t data_size, int sample_count, int channels, int sample_rate, int block_align, int encoder_delay);
  278. ffmpeg_codec_data * init_ffmpeg_atrac3_riff(STREAMFILE *sf, off_t offset, int* out_samples);
  279. /* ffmpeg_decoder_custom_opus.c (helper-things) */
  280. typedef struct {
  281. int channels;
  282. int skip;
  283. int sample_rate;
  284. /* multichannel-only */
  285. int coupled_count;
  286. int stream_count;
  287. int channel_mapping[8];
  288. } opus_config;
  289. ffmpeg_codec_data * init_ffmpeg_switch_opus_config(STREAMFILE *streamFile, off_t start_offset, size_t data_size, opus_config* cfg);
  290. ffmpeg_codec_data * init_ffmpeg_switch_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
  291. ffmpeg_codec_data * init_ffmpeg_ue4_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
  292. ffmpeg_codec_data * init_ffmpeg_ea_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
  293. ffmpeg_codec_data * init_ffmpeg_x_opus(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, int skip, int sample_rate);
  294. size_t switch_opus_get_samples(off_t offset, size_t stream_size, STREAMFILE *streamFile);
  295. size_t switch_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);
  296. size_t ue4_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);
  297. size_t ea_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile);
  298. #endif
  299. /* coding_utils */
  300. int ffmpeg_fmt_chunk_swap_endian(uint8_t * chunk, size_t chunk_size, uint16_t codec);
  301. int ffmpeg_make_riff_atrac3plus(uint8_t * buf, size_t buf_size, size_t sample_count, size_t data_size, int channels, int sample_rate, int block_align, int encoder_delay);
  302. int ffmpeg_make_riff_xma1(uint8_t * buf, size_t buf_size, size_t sample_count, size_t data_size, int channels, int sample_rate, int stream_mode);
  303. int ffmpeg_make_riff_xma2(uint8_t * buf, size_t buf_size, size_t sample_count, size_t data_size, int channels, int sample_rate, int block_count, int block_size);
  304. int ffmpeg_make_riff_xma_from_fmt_chunk(uint8_t * buf, size_t buf_size, off_t fmt_offset, size_t fmt_size, size_t data_size, STREAMFILE *streamFile, int big_endian);
  305. int ffmpeg_make_riff_xma2_from_xma2_chunk(uint8_t * buf, size_t buf_size, off_t xma2_offset, size_t xma2_size, size_t data_size, STREAMFILE *streamFile);
  306. int ffmpeg_make_riff_xwma(uint8_t * buf, size_t buf_size, int codec, size_t data_size, int channels, int sample_rate, int avg_bps, int block_align);
  307. /* MS audio format's sample info (struct to avoid passing so much stuff, separate for reusing) */
  308. typedef struct {
  309. /* input */
  310. int xma_version;
  311. off_t data_offset;
  312. size_t data_size;
  313. int channels; /* for skips */
  314. off_t chunk_offset; /* for multistream config */
  315. /* frame offsets */
  316. int loop_flag;
  317. uint32_t loop_start_b;
  318. uint32_t loop_end_b;
  319. uint32_t loop_start_subframe;
  320. uint32_t loop_end_subframe;
  321. /* output */
  322. int32_t num_samples;
  323. int32_t loop_start_sample;
  324. int32_t loop_end_sample;
  325. } ms_sample_data;
  326. void xma_get_samples(ms_sample_data * msd, STREAMFILE *streamFile);
  327. void wmapro_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, int block_align, int sample_rate, uint32_t decode_flags);
  328. void wma_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, int block_align, int sample_rate, uint32_t decode_flags);
  329. 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);
  330. 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);
  331. 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);
  332. 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);
  333. void xma_fix_raw_samples_hb(VGMSTREAM *vgmstream, STREAMFILE *headerFile, STREAMFILE *bodyFile, off_t stream_offset, size_t stream_size, off_t chunk_offset, int fix_num_samples, int fix_loop_samples);
  334. void xma_fix_raw_samples_ch(VGMSTREAM *vgmstream, STREAMFILE*streamFile, off_t stream_offset, size_t stream_size, int channel_per_stream, int fix_num_samples, int fix_loop_samples);
  335. size_t atrac3_bytes_to_samples(size_t bytes, int full_block_align);
  336. size_t atrac3plus_bytes_to_samples(size_t bytes, int full_block_align);
  337. size_t ac3_bytes_to_samples(size_t bytes, int full_block_align, int channels);
  338. size_t aac_get_samples(STREAMFILE *streamFile, off_t start_offset, size_t bytes);
  339. size_t mpeg_get_samples(STREAMFILE *streamFile, off_t start_offset, size_t bytes);
  340. /* An internal struct to pass around and simulate a bitstream. */
  341. typedef enum { BITSTREAM_MSF, BITSTREAM_VORBIS } vgm_bitstream_t;
  342. typedef struct {
  343. uint8_t * buf; /* buffer to read/write*/
  344. size_t bufsize; /* max size of the buffer */
  345. off_t b_off; /* current offset in bits inside the buffer */
  346. vgm_bitstream_t mode; /* read/write modes */
  347. } vgm_bitstream;
  348. int r_bits(vgm_bitstream * ib, int num_bits, uint32_t * value);
  349. int w_bits(vgm_bitstream * ob, int num_bits, uint32_t value);
  350. /* helper to pass a wrapped, clamped, fake extension-ed, SF to another meta */
  351. STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* extension);
  352. #endif /*_CODING_H*/