Prepare ATRAC9 decoder hooks (disabled, not usable at the moment)

This commit is contained in:
bnnm 2017-12-29 00:29:33 +01:00
parent f525b891ee
commit 8789c5918e
4 changed files with 84 additions and 1 deletions

View File

@ -213,6 +213,16 @@ void seek_at3plus(VGMSTREAM *vgmstream, int32_t num_sample);
void free_at3plus(maiatrac3plus_codec_data *data);
#endif
#ifdef VGM_USE_ATRAC9
/* atrac9_decoder */
atrac9_codec_data *init_atrac9(atrac9_config *cfg);
void decode_atrac9(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do, int channels);
void reset_atrac9(VGMSTREAM *vgmstream);
void seek_atrac9(VGMSTREAM *vgmstream, int32_t num_sample);
void free_atrac9(atrac9_codec_data *data);
size_t atrac9_bytes_to_samples(size_t bytes, atrac9_codec_data *data);
#endif
#ifdef VGM_USE_FFMPEG
/* ffmpeg_decoder */
ffmpeg_codec_data * init_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size);

View File

@ -522,6 +522,9 @@ static const coding_info coding_info_list[] = {
#ifdef VGM_USE_MAIATRAC3PLUS
{coding_AT3plus, "ATRAC3plus"},
#endif
#ifdef VGM_USE_ATRAC9
{coding_ATRAC9, "ATRAC9"},
#endif
#ifdef VGM_USE_FFMPEG
{coding_FFmpeg, "FFmpeg"},
#endif

View File

@ -545,7 +545,13 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
reset_at3plus(vgmstream);
}
#endif
#ifdef VGM_USE_ATRAC9
if (vgmstream->coding_type==coding_ATRAC9) {
reset_atrac9(vgmstream);
}
#endif
#ifdef VGM_USE_FFMPEG
if (vgmstream->coding_type==coding_FFmpeg) {
reset_ffmpeg(vgmstream);
@ -740,6 +746,13 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_ATRAC9
if (vgmstream->coding_type == coding_ATRAC9) {
free_atrac9(vgmstream->codec_data);
vgmstream->codec_data = NULL;
}
#endif
if (vgmstream->coding_type==coding_ACM) {
mus_acm_codec_data *data = (mus_acm_codec_data *) vgmstream->codec_data;
@ -1126,6 +1139,10 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
return 2048 - ((maiatrac3plus_codec_data*)vgmstream->codec_data)->samples_discard;
#endif
#ifdef VGM_USE_ATRAC9
case coding_ATRAC9:
return 0; /* varies with config data, usually 256 or 1024 */
#endif
default:
return 0;
@ -1255,6 +1272,10 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
return 0x04;
case coding_EA_MT:
return 0; /* variable (frames of bit counts or PCM frames) */
#ifdef VGM_USE_ATRAC9
case coding_ATRAC9:
return 0; /* varies with config data, usually 0x100-200 */
#endif
default:
return 0;
}
@ -1770,6 +1791,14 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
chan);
}
break;
#endif
#ifdef VGM_USE_ATRAC9
case coding_ATRAC9:
decode_atrac9(vgmstream,
buffer+samples_written*vgmstream->channels,
samples_to_do,
vgmstream->channels);
break;
#endif
case coding_ACM:
/* handled in its own layout, here to quiet compiler */
@ -1973,6 +2002,12 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_ATRAC9
if (vgmstream->coding_type==coding_ATRAC9) {
seek_atrac9(vgmstream, vgmstream->loop_sample);
}
#endif
#ifdef VGM_USE_MPEG
if (vgmstream->coding_type==coding_MPEG_custom ||
vgmstream->coding_type==coding_MPEG_ealayer3 ||

View File

@ -22,6 +22,11 @@ enum { STREAM_NAME_SIZE = 255 }; /* reasonable max */
#define VGM_USE_MPEG
#endif
#ifndef VGM_DISABLE_ATRAC9
//#define VGM_USE_ATRAC9
#endif
/* disabled by default, defined on compile-time for builds that support it*/
//#define VGM_USE_G7221
//#define VGM_USE_G719
@ -197,6 +202,10 @@ typedef enum {
coding_AT3plus, /* Sony ATRAC3plus (MDCT-based) */
#endif
#ifdef VGM_USE_ATRAC9
coding_ATRAC9, /* Sony ATRAC9 (MDCT-based) */
#endif
#ifdef VGM_USE_FFMPEG
coding_FFmpeg, /* Formats handled by FFmpeg (ATRAC3, XMA, AC3, etc) */
#endif
@ -980,6 +989,32 @@ typedef struct {
} maiatrac3plus_codec_data;
#endif
#ifdef VGM_USE_ATRAC9
typedef struct {
int channels; /* to detect weird multichannel */
uint32_t config_data; /* ATRAC9 config header */
int encoder_delay; /* initial samples to discard */
size_t interleave_skip; /* XVAG */
size_t subsong_skip; /* XVAG */
} atrac9_config;
typedef struct {
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 */
} atrac9_codec_data;
#endif
/* with one file this is also used for just ACM */
typedef struct {
int file_count;