diff --git a/src/coding/ffmpeg_decoder_utils.c b/src/coding/ffmpeg_decoder_utils.c index 3765c6e7..da8699e0 100644 --- a/src/coding/ffmpeg_decoder_utils.c +++ b/src/coding/ffmpeg_decoder_utils.c @@ -1,4 +1,5 @@ #include "coding.h" +#include "../util/channel_mappings.h" #ifdef VGM_USE_FFMPEG diff --git a/src/meta/hca.c b/src/meta/hca.c index 86d912c9..92b5158c 100644 --- a/src/meta/hca.c +++ b/src/meta/hca.c @@ -2,6 +2,7 @@ #include "hca_keys.h" #include "../coding/coding.h" #include "../coding/hca_decoder_clhca.h" +#include "../util/channel_mappings.h" #ifdef VGM_DEBUG_OUTPUT //#define HCA_BRUTEFORCE diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index b008de65..4141b533 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -2,6 +2,7 @@ #include #include "meta.h" #include "../coding/coding.h" +#include "../util/channel_mappings.h" #include "ogg_vorbis_streamfile.h" diff --git a/src/meta/riff.c b/src/meta/riff.c index a46bf91f..8f7ffe81 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -3,6 +3,7 @@ #include "../coding/coding.h" #include "../layout/layout.h" #include "../util.h" +#include "../util/channel_mappings.h" #include "riff_ogg_streamfile.h" /* RIFF - Resource Interchange File Format, standard container used in many games */ diff --git a/src/meta/wwise.c b/src/meta/wwise.c index 852fcc0a..6c78aeec 100644 --- a/src/meta/wwise.c +++ b/src/meta/wwise.c @@ -3,6 +3,7 @@ #include "../coding/coding.h" #include "../util/chunks.h" #include "../util/endianness.h" +#include "../util/channel_mappings.h" /* Wwise uses a custom RIFF/RIFX header, non-standard enough that it's parsed it here. diff --git a/src/mixing.c b/src/mixing.c index 73717bff..896197f6 100644 --- a/src/mixing.c +++ b/src/mixing.c @@ -1,6 +1,7 @@ #include "vgmstream.h" #include "mixing.h" #include "plugins.h" +#include "util/channel_mappings.h" #include #include @@ -1187,7 +1188,7 @@ typedef enum { void mixing_macro_downmix(VGMSTREAM* vgmstream, int max /*, mapping_t output_mapping*/) { mixing_data *data = vgmstream->mixing_data; int ch, output_channels, mp_in, mp_out, ch_in, ch_out; - mapping_t input_mapping, output_mapping; + channel_mapping_t input_mapping, output_mapping; const double vol_max = 1.0; const double vol_sqrt = 1 / sqrt(2); const double vol_half = 1 / 2; diff --git a/src/util/channel_mappings.h b/src/util/channel_mappings.h new file mode 100644 index 00000000..72a0ab12 --- /dev/null +++ b/src/util/channel_mappings.h @@ -0,0 +1,49 @@ +#ifndef _CHANNEL_MAPPING_H +#define _CHANNEL_MAPPING_H + +/* standard WAVEFORMATEXTENSIBLE speaker positions */ +typedef enum { + speaker_FL = (1 << 0), /* front left */ + speaker_FR = (1 << 1), /* front right */ + speaker_FC = (1 << 2), /* front center */ + speaker_LFE = (1 << 3), /* low frequency effects */ + speaker_BL = (1 << 4), /* back left */ + speaker_BR = (1 << 5), /* back right */ + speaker_FLC = (1 << 6), /* front left center */ + speaker_FRC = (1 << 7), /* front right center */ + speaker_BC = (1 << 8), /* back center */ + speaker_SL = (1 << 9), /* side left */ + speaker_SR = (1 << 10), /* side right */ + + speaker_TC = (1 << 11), /* top center*/ + speaker_TFL = (1 << 12), /* top front left */ + speaker_TFC = (1 << 13), /* top front center */ + speaker_TFR = (1 << 14), /* top front right */ + speaker_TBL = (1 << 15), /* top back left */ + speaker_TBC = (1 << 16), /* top back center */ + speaker_TBR = (1 << 17), /* top back left */ + +} speaker_t; + +/* typical mappings that metas may use to set channel_layout (but plugin must actually use it) + * (in order, so 3ch file could be mapped to FL FR FC or FL FR LFE but not LFE FL FR) + * not too sure about names but no clear standards */ +typedef enum { + mapping_MONO = speaker_FC, + mapping_STEREO = speaker_FL | speaker_FR, + mapping_2POINT1 = speaker_FL | speaker_FR | speaker_LFE, + mapping_2POINT1_xiph = speaker_FL | speaker_FR | speaker_FC, /* aka 3STEREO? */ + mapping_QUAD = speaker_FL | speaker_FR | speaker_BL | speaker_BR, + mapping_QUAD_surround = speaker_FL | speaker_FR | speaker_FC | speaker_BC, + mapping_QUAD_side = speaker_FL | speaker_FR | speaker_SL | speaker_SR, + mapping_5POINT0 = speaker_FL | speaker_FR | speaker_LFE | speaker_BL | speaker_BR, + mapping_5POINT0_xiph = speaker_FL | speaker_FR | speaker_FC | speaker_BL | speaker_BR, + mapping_5POINT0_surround = speaker_FL | speaker_FR | speaker_FC | speaker_SL | speaker_SR, + mapping_5POINT1 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR, + mapping_5POINT1_surround = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_SL | speaker_SR, + mapping_7POINT0 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BC | speaker_FLC | speaker_FRC, + mapping_7POINT1 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR | speaker_FLC | speaker_FRC, + mapping_7POINT1_surround = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR | speaker_SL | speaker_SR, +} channel_mapping_t; + +#endif diff --git a/src/vgmstream.h b/src/vgmstream.h index 7effedfb..a56ff06c 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -762,50 +762,6 @@ typedef enum { } meta_t; -/* standard WAVEFORMATEXTENSIBLE speaker positions */ -typedef enum { - speaker_FL = (1 << 0), /* front left */ - speaker_FR = (1 << 1), /* front right */ - speaker_FC = (1 << 2), /* front center */ - speaker_LFE = (1 << 3), /* low frequency effects */ - speaker_BL = (1 << 4), /* back left */ - speaker_BR = (1 << 5), /* back right */ - speaker_FLC = (1 << 6), /* front left center */ - speaker_FRC = (1 << 7), /* front right center */ - speaker_BC = (1 << 8), /* back center */ - speaker_SL = (1 << 9), /* side left */ - speaker_SR = (1 << 10), /* side right */ - - speaker_TC = (1 << 11), /* top center*/ - speaker_TFL = (1 << 12), /* top front left */ - speaker_TFC = (1 << 13), /* top front center */ - speaker_TFR = (1 << 14), /* top front right */ - speaker_TBL = (1 << 15), /* top back left */ - speaker_TBC = (1 << 16), /* top back center */ - speaker_TBR = (1 << 17), /* top back left */ - -} speaker_t; - -/* typical mappings that metas may use to set channel_layout (but plugin must actually use it) - * (in order, so 3ch file could be mapped to FL FR FC or FL FR LFE but not LFE FL FR) - * not too sure about names but no clear standards */ -typedef enum { - mapping_MONO = speaker_FC, - mapping_STEREO = speaker_FL | speaker_FR, - mapping_2POINT1 = speaker_FL | speaker_FR | speaker_LFE, - mapping_2POINT1_xiph = speaker_FL | speaker_FR | speaker_FC, /* aka 3STEREO? */ - mapping_QUAD = speaker_FL | speaker_FR | speaker_BL | speaker_BR, - mapping_QUAD_surround = speaker_FL | speaker_FR | speaker_FC | speaker_BC, - mapping_QUAD_side = speaker_FL | speaker_FR | speaker_SL | speaker_SR, - mapping_5POINT0 = speaker_FL | speaker_FR | speaker_LFE | speaker_BL | speaker_BR, - mapping_5POINT0_xiph = speaker_FL | speaker_FR | speaker_FC | speaker_BL | speaker_BR, - mapping_5POINT0_surround = speaker_FL | speaker_FR | speaker_FC | speaker_SL | speaker_SR, - mapping_5POINT1 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR, - mapping_5POINT1_surround = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_SL | speaker_SR, - mapping_7POINT0 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BC | speaker_FLC | speaker_FRC, - mapping_7POINT1 = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR | speaker_FLC | speaker_FRC, - mapping_7POINT1_surround = speaker_FL | speaker_FR | speaker_FC | speaker_LFE | speaker_BL | speaker_BR | speaker_SL | speaker_SR, -} mapping_t; typedef struct { int config_set; /* some of the mods below are set */ @@ -952,7 +908,7 @@ typedef struct { size_t stream_size; /* info to properly calculate bitrate in case of subsongs */ char stream_name[STREAM_NAME_SIZE]; /* name of the current stream (info), if the file stores it and it's filled */ - /* mapping config (info for plugins) */ + /* mapping config (info for plugins) see channel_mappings.h */ uint32_t channel_layout; /* order: FL FR FC LFE BL BR FLC FRC BC SL SR etc (WAVEFORMATEX flags where FL=lowest bit set) */ /* other config */