From 8538aa1a754ca5be32af8394ceeb807b1796a9d8 Mon Sep 17 00:00:00 2001 From: bnnm Date: Wed, 27 Dec 2017 01:02:24 +0100 Subject: [PATCH] Rename at3_decoder.c to at3plus_decoder.c and add init function --- src/coding/{at3_decoder.c => at3plus_decoder.c} | 17 +++++++++++++++-- src/coding/coding.h | 3 ++- src/libvgmstream.vcxproj | 2 +- src/libvgmstream.vcxproj.filters | 2 +- src/meta/riff.c | 6 +----- 5 files changed, 20 insertions(+), 10 deletions(-) rename src/coding/{at3_decoder.c => at3plus_decoder.c} (86%) diff --git a/src/coding/at3_decoder.c b/src/coding/at3plus_decoder.c similarity index 86% rename from src/coding/at3_decoder.c rename to src/coding/at3plus_decoder.c index a8b444ec..57f56ef9 100644 --- a/src/coding/at3_decoder.c +++ b/src/coding/at3plus_decoder.c @@ -4,6 +4,20 @@ #ifdef VGM_USE_MAIATRAC3PLUS #include "maiatrac3plus.h" +maiatrac3plus_codec_data *init_at3plus() { + + maiatrac3plus_codec_data *data = malloc(sizeof(maiatrac3plus_codec_data)); + data->buffer = 0; + data->samples_discard = 0; + data->handle = Atrac3plusDecoder_openContext(); + if (!data->handle) goto fail; + + return data; + +fail: + return NULL; +} + void decode_at3plus(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) { VGMSTREAMCHANNEL *ch = &vgmstream->ch[0]; maiatrac3plus_codec_data *data = vgmstream->codec_data; @@ -25,8 +39,7 @@ void decode_at3plus(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, data->samples_discard = 0; } - for (i = 0; i < samples_to_do; i++) - { + for (i = 0; i < samples_to_do; i++) { outbuf[i*channelspacing] = data->buffer[(first_sample+i)*data->channels+channel]; } diff --git a/src/coding/coding.h b/src/coding/coding.h index 76cb4102..74c6a0eb 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -205,7 +205,8 @@ void free_mp4_aac(mp4_aac_codec_data * data); #endif #ifdef VGM_USE_MAIATRAC3PLUS -/* at3_decoder */ +/* at3plus_decoder */ +maiatrac3plus_codec_data *init_at3plus(); void decode_at3plus(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel); void reset_at3plus(VGMSTREAM *vgmstream); void seek_at3plus(VGMSTREAM *vgmstream, int32_t num_sample); diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index da04898c..eb18f501 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -133,7 +133,7 @@ - + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 9abfc79c..16c1576f 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -1171,7 +1171,7 @@ meta\Source Files - + coding\Source Files diff --git a/src/meta/riff.c b/src/meta/riff.c index 79650daf..714a1762 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -445,11 +445,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { #endif #ifdef VGM_USE_MAIATRAC3PLUS case coding_AT3plus: { - maiatrac3plus_codec_data *data = malloc(sizeof(maiatrac3plus_codec_data)); - data->buffer = 0; - data->samples_discard = 0; - data->handle = Atrac3plusDecoder_openContext(); - vgmstream->codec_data = data; + vgmstream->codec_data = init_at3plus(); /* get rough total samples but favor fact_samples if available (skip isn't correctly handled for now) */ vgmstream->num_samples = atrac3plus_bytes_to_samples(data_size, fmt.block_size);