cleanup: move channel mappings to .h

This commit is contained in:
bnnm 2023-05-07 22:00:30 +02:00
parent a6b8dcefc0
commit e839f0635f
8 changed files with 57 additions and 46 deletions

View File

@ -1,4 +1,5 @@
#include "coding.h" #include "coding.h"
#include "../util/channel_mappings.h"
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG

View File

@ -2,6 +2,7 @@
#include "hca_keys.h" #include "hca_keys.h"
#include "../coding/coding.h" #include "../coding/coding.h"
#include "../coding/hca_decoder_clhca.h" #include "../coding/hca_decoder_clhca.h"
#include "../util/channel_mappings.h"
#ifdef VGM_DEBUG_OUTPUT #ifdef VGM_DEBUG_OUTPUT
//#define HCA_BRUTEFORCE //#define HCA_BRUTEFORCE

View File

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
#include "../util/channel_mappings.h"
#include "ogg_vorbis_streamfile.h" #include "ogg_vorbis_streamfile.h"

View File

@ -3,6 +3,7 @@
#include "../coding/coding.h" #include "../coding/coding.h"
#include "../layout/layout.h" #include "../layout/layout.h"
#include "../util.h" #include "../util.h"
#include "../util/channel_mappings.h"
#include "riff_ogg_streamfile.h" #include "riff_ogg_streamfile.h"
/* RIFF - Resource Interchange File Format, standard container used in many games */ /* RIFF - Resource Interchange File Format, standard container used in many games */

View File

@ -3,6 +3,7 @@
#include "../coding/coding.h" #include "../coding/coding.h"
#include "../util/chunks.h" #include "../util/chunks.h"
#include "../util/endianness.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. /* Wwise uses a custom RIFF/RIFX header, non-standard enough that it's parsed it here.

View File

@ -1,6 +1,7 @@
#include "vgmstream.h" #include "vgmstream.h"
#include "mixing.h" #include "mixing.h"
#include "plugins.h" #include "plugins.h"
#include "util/channel_mappings.h"
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
@ -1187,7 +1188,7 @@ typedef enum {
void mixing_macro_downmix(VGMSTREAM* vgmstream, int max /*, mapping_t output_mapping*/) { void mixing_macro_downmix(VGMSTREAM* vgmstream, int max /*, mapping_t output_mapping*/) {
mixing_data *data = vgmstream->mixing_data; mixing_data *data = vgmstream->mixing_data;
int ch, output_channels, mp_in, mp_out, ch_in, ch_out; 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_max = 1.0;
const double vol_sqrt = 1 / sqrt(2); const double vol_sqrt = 1 / sqrt(2);
const double vol_half = 1 / 2; const double vol_half = 1 / 2;

View File

@ -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

View File

@ -762,50 +762,6 @@ typedef enum {
} meta_t; } 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 { typedef struct {
int config_set; /* some of the mods below are set */ 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 */ 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 */ 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) */ 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 */ /* other config */