diff --git a/man/opusenc.1 b/man/opusenc.1 index 27f652b..ca9e79f 100644 --- a/man/opusenc.1 +++ b/man/opusenc.1 @@ -312,12 +312,13 @@ Ignore the data length in Wave headers. The length will always be ignored when it is implausible (very small or very large), but some stdin usage may still need this option to avoid truncation. .TP -.B --channels +.B --channels Override the format of the input channels. The "ambix" option indicates that the input is ambisonics using ACN channel ordering with SN3D normalization. All channels in a full ambisonics order must be included. A pair of non-diegetic stereo channels can be optionally placed -after the ambisonics channels. +after the ambisonics channels. The option "discrete" forces uncoupled +channels. .SS "Diagnostic options" .TP .BI --serial " N" diff --git a/src/encoder.h b/src/encoder.h index 4cc99aa..ffec1ed 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -18,6 +18,7 @@ #define CHANNELS_FORMAT_DEFAULT 0 #define CHANNELS_FORMAT_AMBIX 1 +#define CHANNELS_FORMAT_DISCRETE 2 typedef long (*audio_read_func)(void *src, float *buffer, int samples); diff --git a/src/opusenc.c b/src/opusenc.c index 06838e5..c7aa108 100644 --- a/src/opusenc.c +++ b/src/opusenc.c @@ -176,7 +176,7 @@ static void usage(void) printf(" --raw-chan n Set number of channels for raw input (default: 2)\n"); printf(" --raw-endianness n 1 for big endian, 0 for little (default: 0)\n"); printf(" --ignorelength Ignore the data length in Wave headers\n"); - printf(" --channels Override the format of the input channels\n"); + printf(" --channels Override the format of the input channels (ambix, discrete)\n"); printf("\nDiagnostic options:\n"); printf(" --serial n Force use of a specific stream serial number\n"); printf(" --save-range file Save check values for every frame to a file\n"); @@ -637,9 +637,11 @@ int main(int argc, char **argv) } else if (strcmp(optname, "channels")==0) { if (strcmp(optarg, "ambix")==0) { inopt.channels_format=CHANNELS_FORMAT_AMBIX; + } else if (strcmp(optarg, "discrete")==0) { + inopt.channels_format=CHANNELS_FORMAT_DISCRETE; } else { fatal("Invalid input format: %s\n" - "--channels only supports 'ambix'\n", + "--channels only supports 'ambix' or 'discrete'\n", optarg); } } else if (strcmp(optname, "serial")==0) { @@ -881,6 +883,11 @@ int main(int argc, char **argv) fatal("Error: downmixing is currently unimplemented for ambisonics input.\n"); } + if (downmix>0&&inopt.channels_format==CHANNELS_FORMAT_DISCRETE) { + /*Downmix of uncoupled channels not specified.*/ + fatal("Error: downmixing is currently unimplemented for independent input.\n"); + } + if (inopt.channels_format==CHANNELS_FORMAT_DEFAULT) { if (downmix==0&&inopt.channels>2&&bitrate>0&&bitrate<(16000*inopt.channels)) { if (!quiet) fprintf(stderr,"Notice: Surround bitrate less than 16 kbit/s per channel, downmixing.\n"); @@ -904,6 +911,8 @@ int main(int argc, char **argv) (including the non-diegetic stereo track). For other orders with no demixing matrices currently available, use channel mapping 2.*/ mapping_family=(chan>=4&&chan<=18)?3:2; + } else if (inopt.channels_format==CHANNELS_FORMAT_DISCRETE) { + mapping_family=255; } else { mapping_family=chan>8?255:chan>2; }