diff options
author | Gregory Maxwell <greg@xiph.org> | 2013-11-19 20:29:06 +0400 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2013-11-19 20:29:06 +0400 |
commit | d8302fc093430a342297caae7ee1906bfa6202b0 (patch) | |
tree | f33d81a8e9b1a74dce74c2fc6b97255021a5ea21 /src | |
parent | 733b47f31cfa72eb31323dc8b3dd1ba16074a106 (diff) |
Validate channel count in opus_demo.
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_demo.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/opus_demo.c b/src/opus_demo.c index f2349b23..f8cdf031 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -308,13 +308,6 @@ int main(int argc, char *argv[]) } sampling_rate = (opus_int32)atol(argv[args]); args++; - channels = atoi(argv[args]); - args++; - if (!decode_only) - { - bitrate_bps = (opus_int32)atol(argv[args]); - args++; - } if (sampling_rate != 8000 && sampling_rate != 12000 && sampling_rate != 16000 && sampling_rate != 24000 @@ -326,6 +319,21 @@ int main(int argc, char *argv[]) } frame_size = sampling_rate/50; + channels = atoi(argv[args]); + args++; + + if (channels < 1 || channels > 2) + { + fprintf(stderr, "Opus_demo supports only 1 or 2 channels.\n"); + return EXIT_FAILURE; + } + + if (!decode_only) + { + bitrate_bps = (opus_int32)atol(argv[args]); + args++; + } + /* defaults: */ use_vbr = 1; bandwidth = OPUS_AUTO; |