OLD | NEW |
1 /* Copyright (c) 2011 Xiph.Org Foundation | 1 /* Copyright (c) 2011 Xiph.Org Foundation |
2 Written by Jean-Marc Valin */ | 2 Written by Jean-Marc Valin */ |
3 /* | 3 /* |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 int coupled_streams, | 68 int coupled_streams, |
69 const unsigned char *mapping | 69 const unsigned char *mapping |
70 ) | 70 ) |
71 { | 71 { |
72 int coupled_size; | 72 int coupled_size; |
73 int mono_size; | 73 int mono_size; |
74 int i, ret; | 74 int i, ret; |
75 char *ptr; | 75 char *ptr; |
76 | 76 |
77 if ((channels>255) || (channels<1) || (coupled_streams>streams) || | 77 if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
78 (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) | 78 (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
79 return OPUS_BAD_ARG; | 79 return OPUS_BAD_ARG; |
80 | 80 |
81 st->layout.nb_channels = channels; | 81 st->layout.nb_channels = channels; |
82 st->layout.nb_streams = streams; | 82 st->layout.nb_streams = streams; |
83 st->layout.nb_coupled_streams = coupled_streams; | 83 st->layout.nb_coupled_streams = coupled_streams; |
84 | 84 |
85 for (i=0;i<st->layout.nb_channels;i++) | 85 for (i=0;i<st->layout.nb_channels;i++) |
86 st->layout.mapping[i] = mapping[i]; | 86 st->layout.mapping[i] = mapping[i]; |
87 if (!validate_layout(&st->layout)) | 87 if (!validate_layout(&st->layout)) |
88 return OPUS_BAD_ARG; | 88 return OPUS_BAD_ARG; |
(...skipping 23 matching lines...) Expand all Loading... |
112 int channels, | 112 int channels, |
113 int streams, | 113 int streams, |
114 int coupled_streams, | 114 int coupled_streams, |
115 const unsigned char *mapping, | 115 const unsigned char *mapping, |
116 int *error | 116 int *error |
117 ) | 117 ) |
118 { | 118 { |
119 int ret; | 119 int ret; |
120 OpusMSDecoder *st; | 120 OpusMSDecoder *st; |
121 if ((channels>255) || (channels<1) || (coupled_streams>streams) || | 121 if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
122 (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) | 122 (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
123 { | 123 { |
124 if (error) | 124 if (error) |
125 *error = OPUS_BAD_ARG; | 125 *error = OPUS_BAD_ARG; |
126 return NULL; | 126 return NULL; |
127 } | 127 } |
128 st = (OpusMSDecoder *)opus_alloc(opus_multistream_decoder_get_size(streams, c
oupled_streams)); | 128 st = (OpusMSDecoder *)opus_alloc(opus_multistream_decoder_get_size(streams, c
oupled_streams)); |
129 if (st==NULL) | 129 if (st==NULL) |
130 { | 130 { |
131 if (error) | 131 if (error) |
132 *error = OPUS_ALLOC_FAIL; | 132 *error = OPUS_ALLOC_FAIL; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 bad_arg: | 528 bad_arg: |
529 va_end(ap); | 529 va_end(ap); |
530 return OPUS_BAD_ARG; | 530 return OPUS_BAD_ARG; |
531 } | 531 } |
532 | 532 |
533 | 533 |
534 void opus_multistream_decoder_destroy(OpusMSDecoder *st) | 534 void opus_multistream_decoder_destroy(OpusMSDecoder *st) |
535 { | 535 { |
536 opus_free(st); | 536 opus_free(st); |
537 } | 537 } |
OLD | NEW |