Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement --channels discrete format option #80

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions man/opusenc.1
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ambix>
.B --channels <ambix, discrete>
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"
Expand Down
1 change: 1 addition & 0 deletions src/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 11 additions & 2 deletions src/opusenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ambix> 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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand All @@ -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;
}
Expand Down