Skip to content

Commit e7f495e

Browse files
committed
Implement --channels individual switch
1 parent ec08f7b commit e7f495e

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

man/opusenc.1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,13 @@ Ignore the data length in Wave headers.
312312
The length will always be ignored when it is implausible (very small or very
313313
large), but some stdin usage may still need this option to avoid truncation.
314314
.TP
315-
.B --channels <ambix>
315+
.B --channels <ambix, individual>
316316
Override the format of the input channels.
317317
The "ambix" option indicates that the input is ambisonics using ACN channel
318318
ordering with SN3D normalization. All channels in a full ambisonics order must
319319
be included. A pair of non-diegetic stereo channels can be optionally placed
320-
after the ambisonics channels.
320+
after the ambisonics channels. The option "individual" forces uncoupled
321+
channels.
321322
.SS "Diagnostic options"
322323
.TP
323324
.BI --serial " N"

src/encoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#define CHANNELS_FORMAT_DEFAULT 0
2020
#define CHANNELS_FORMAT_AMBIX 1
21+
#define CHANNELS_FORMAT_INDIVIDUAL 2
2122

2223
typedef long (*audio_read_func)(void *src, float *buffer, int samples);
2324

src/opusenc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void usage(void)
176176
printf(" --raw-chan n Set number of channels for raw input (default: 2)\n");
177177
printf(" --raw-endianness n 1 for big endian, 0 for little (default: 0)\n");
178178
printf(" --ignorelength Ignore the data length in Wave headers\n");
179-
printf(" --channels <ambix> Override the format of the input channels\n");
179+
printf(" --channels Override the format of the input channels (ambix, individual)\n");
180180
printf("\nDiagnostic options:\n");
181181
printf(" --serial n Force use of a specific stream serial number\n");
182182
printf(" --save-range file Save check values for every frame to a file\n");
@@ -637,9 +637,11 @@ int main(int argc, char **argv)
637637
} else if (strcmp(optname, "channels")==0) {
638638
if (strcmp(optarg, "ambix")==0) {
639639
inopt.channels_format=CHANNELS_FORMAT_AMBIX;
640+
} else if (strcmp(optarg, "individual")==0) {
641+
inopt.channels_format=CHANNELS_FORMAT_INDIVIDUAL;
640642
} else {
641643
fatal("Invalid input format: %s\n"
642-
"--channels only supports 'ambix'\n",
644+
"--channels only supports 'ambix' or 'individual'\n",
643645
optarg);
644646
}
645647
} else if (strcmp(optname, "serial")==0) {
@@ -881,6 +883,11 @@ int main(int argc, char **argv)
881883
fatal("Error: downmixing is currently unimplemented for ambisonics input.\n");
882884
}
883885

886+
if (downmix>0&&inopt.channels_format==CHANNELS_FORMAT_INDIVIDUAL) {
887+
/*Downmix of uncoupled channels not specified.*/
888+
fatal("Error: downmixing is currently unimplemented for independent input.\n");
889+
}
890+
884891
if (inopt.channels_format==CHANNELS_FORMAT_DEFAULT) {
885892
if (downmix==0&&inopt.channels>2&&bitrate>0&&bitrate<(16000*inopt.channels)) {
886893
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)
904911
(including the non-diegetic stereo track). For other orders with no
905912
demixing matrices currently available, use channel mapping 2.*/
906913
mapping_family=(chan>=4&&chan<=18)?3:2;
914+
} else if (inopt.channels_format==CHANNELS_FORMAT_INDIVIDUAL) {
915+
mapping_family=255;
907916
} else {
908917
mapping_family=chan>8?255:chan>2;
909918
}

0 commit comments

Comments
 (0)