| OLD | NEW |
| 1 /* Copyright (c) 2011 Xiph.Org Foundation, Skype Limited | 1 /* Copyright (c) 2011 Xiph.Org Foundation, Skype Limited |
| 2 Written by Jean-Marc Valin and Koen Vos */ | 2 Written by Jean-Marc Valin and Koen Vos */ |
| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } else if (len<2) | 159 } else if (len<2) |
| 160 { | 160 { |
| 161 *size = -1; | 161 *size = -1; |
| 162 return -1; | 162 return -1; |
| 163 } else { | 163 } else { |
| 164 *size = 4*data[1] + data[0]; | 164 *size = 4*data[1] + data[0]; |
| 165 return 2; | 165 return 2; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 int opus_packet_get_samples_per_frame(const unsigned char *data, |
| 170 opus_int32 Fs) |
| 171 { |
| 172 int audiosize; |
| 173 if (data[0]&0x80) |
| 174 { |
| 175 audiosize = ((data[0]>>3)&0x3); |
| 176 audiosize = (Fs<<audiosize)/400; |
| 177 } else if ((data[0]&0x60) == 0x60) |
| 178 { |
| 179 audiosize = (data[0]&0x08) ? Fs/50 : Fs/100; |
| 180 } else { |
| 181 audiosize = ((data[0]>>3)&0x3); |
| 182 if (audiosize == 3) |
| 183 audiosize = Fs*60/1000; |
| 184 else |
| 185 audiosize = (Fs<<audiosize)/100; |
| 186 } |
| 187 return audiosize; |
| 188 } |
| 189 |
| 169 int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, | 190 int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, |
| 170 int self_delimited, unsigned char *out_toc, | 191 int self_delimited, unsigned char *out_toc, |
| 171 const unsigned char *frames[48], opus_int16 size[48], | 192 const unsigned char *frames[48], opus_int16 size[48], |
| 172 int *payload_offset, opus_int32 *packet_offset) | 193 int *payload_offset, opus_int32 *packet_offset) |
| 173 { | 194 { |
| 174 int i, bytes; | 195 int i, bytes; |
| 175 int count; | 196 int count; |
| 176 int cbr; | 197 int cbr; |
| 177 unsigned char ch, toc; | 198 unsigned char ch, toc; |
| 178 int framesize; | 199 int framesize; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 341 } |
| 321 | 342 |
| 322 int opus_packet_parse(const unsigned char *data, opus_int32 len, | 343 int opus_packet_parse(const unsigned char *data, opus_int32 len, |
| 323 unsigned char *out_toc, const unsigned char *frames[48], | 344 unsigned char *out_toc, const unsigned char *frames[48], |
| 324 opus_int16 size[48], int *payload_offset) | 345 opus_int16 size[48], int *payload_offset) |
| 325 { | 346 { |
| 326 return opus_packet_parse_impl(data, len, 0, out_toc, | 347 return opus_packet_parse_impl(data, len, 0, out_toc, |
| 327 frames, size, payload_offset, NULL); | 348 frames, size, payload_offset, NULL); |
| 328 } | 349 } |
| 329 | 350 |
| OLD | NEW |