PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/xbmc/cores/paplayer/vgmstream/src/meta/ps2_npsf.c

http://github.com/elan/plex
C | 70 lines | 43 code | 17 blank | 10 comment | 8 complexity | 9a5f48bac4089a5565229cdaddfe7962 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-3.0, CC-BY-SA-3.0, 0BSD, LGPL-2.1, GPL-3.0, BSD-3-Clause, CC0-1.0, Unlicense, GPL-2.0, AGPL-1.0
  1. #include "meta.h"
  2. #include "../util.h"
  3. /* Sony .ADS with SShd & SSbd Headers */
  4. VGMSTREAM * init_vgmstream_ps2_npsf(STREAMFILE *streamFile) {
  5. VGMSTREAM * vgmstream = NULL;
  6. char filename[260];
  7. int loop_flag=0;
  8. int channel_count;
  9. off_t start_offset;
  10. int i;
  11. /* check extension, case insensitive */
  12. streamFile->get_name(streamFile,filename,sizeof(filename));
  13. if (strcasecmp("npsf",filename_extension(filename))) goto fail;
  14. /* check NPSF Header */
  15. if (read_32bitBE(0x00,streamFile) != 0x4E505346)
  16. goto fail;
  17. /* check loop */
  18. loop_flag = (read_32bitLE(0x14,streamFile)!=0xFFFFFFFF);
  19. channel_count=read_32bitLE(0x0C,streamFile);
  20. /* build the VGMSTREAM */
  21. vgmstream = allocate_vgmstream(channel_count,loop_flag);
  22. if (!vgmstream) goto fail;
  23. /* fill in the vital statistics */
  24. vgmstream->channels = read_32bitLE(0x0C,streamFile);
  25. vgmstream->sample_rate = read_32bitLE(0x18,streamFile);
  26. /* Check for Compression Scheme */
  27. vgmstream->coding_type = coding_PSX;
  28. vgmstream->num_samples = read_32bitLE(0x08,streamFile)*28/16;
  29. /* Get loop point values */
  30. if(vgmstream->loop_flag) {
  31. vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile);
  32. vgmstream->loop_end_sample = read_32bitLE(0x08,streamFile)*28/16;
  33. }
  34. vgmstream->interleave_block_size = read_32bitLE(0x04,streamFile)/2;
  35. vgmstream->layout_type = layout_interleave;
  36. vgmstream->meta_type = meta_PS2_NPSF;
  37. start_offset = (off_t)read_32bitLE(0x10,streamFile);
  38. /* open the file for reading by each channel */
  39. {
  40. for (i=0;i<channel_count;i++) {
  41. vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x8000);
  42. if (!vgmstream->ch[i].streamfile) goto fail;
  43. vgmstream->ch[i].channel_start_offset=
  44. vgmstream->ch[i].offset=
  45. (off_t)(start_offset+vgmstream->interleave_block_size*i);
  46. }
  47. }
  48. return vgmstream;
  49. /* clean up anything we may have opened */
  50. fail:
  51. if (vgmstream) close_vgmstream(vgmstream);
  52. return NULL;
  53. }