OLD | NEW |
1 /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited | 1 /* Copyright (c) 2010-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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 513 |
514 /** Parse an opus packet into one or more frames. | 514 /** Parse an opus packet into one or more frames. |
515 * Opus_decode will perform this operation internally so most applications do | 515 * Opus_decode will perform this operation internally so most applications do |
516 * not need to use this function. | 516 * not need to use this function. |
517 * This function does not copy the frames, the returned pointers are pointers i
nto | 517 * This function does not copy the frames, the returned pointers are pointers i
nto |
518 * the input packet. | 518 * the input packet. |
519 * @param [in] data <tt>char*</tt>: Opus packet to be parsed | 519 * @param [in] data <tt>char*</tt>: Opus packet to be parsed |
520 * @param [in] len <tt>opus_int32</tt>: size of data | 520 * @param [in] len <tt>opus_int32</tt>: size of data |
521 * @param [out] out_toc <tt>char*</tt>: TOC pointer | 521 * @param [out] out_toc <tt>char*</tt>: TOC pointer |
522 * @param [out] frames <tt>char*[48]</tt> encapsulated frames | 522 * @param [out] frames <tt>char*[48]</tt> encapsulated frames |
523 * @param [out] size <tt>short[48]</tt> sizes of the encapsulated frames | 523 * @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
524 * @param [out] payload_offset <tt>int*</tt>: returns the position of the paylo
ad within the packet (in bytes) | 524 * @param [out] payload_offset <tt>int*</tt>: returns the position of the paylo
ad within the packet (in bytes) |
525 * @returns number of frames | 525 * @returns number of frames |
526 */ | 526 */ |
527 OPUS_EXPORT int opus_packet_parse( | 527 OPUS_EXPORT int opus_packet_parse( |
528 const unsigned char *data, | 528 const unsigned char *data, |
529 opus_int32 len, | 529 opus_int32 len, |
530 unsigned char *out_toc, | 530 unsigned char *out_toc, |
531 const unsigned char *frames[48], | 531 const unsigned char *frames[48], |
532 short size[48], | 532 opus_int16 size[48], |
533 int *payload_offset | 533 int *payload_offset |
534 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | 534 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
535 | 535 |
536 /** Gets the bandwidth of an Opus packet. | 536 /** Gets the bandwidth of an Opus packet. |
537 * @param [in] data <tt>char*</tt>: Opus packet | 537 * @param [in] data <tt>char*</tt>: Opus packet |
538 * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) | 538 * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
539 * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) | 539 * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
540 * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) | 540 * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
541 * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) | 541 * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
542 * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) | 542 * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
(...skipping 16 matching lines...) Expand all Loading... |
559 * @param [in] data <tt>char*</tt>: Opus packet | 559 * @param [in] data <tt>char*</tt>: Opus packet |
560 * @returns Number of channels | 560 * @returns Number of channels |
561 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type | 561 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type |
562 */ | 562 */ |
563 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsign
ed char *data) OPUS_ARG_NONNULL(1); | 563 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsign
ed char *data) OPUS_ARG_NONNULL(1); |
564 | 564 |
565 /** Gets the number of frames in an Opus packet. | 565 /** Gets the number of frames in an Opus packet. |
566 * @param [in] packet <tt>char*</tt>: Opus packet | 566 * @param [in] packet <tt>char*</tt>: Opus packet |
567 * @param [in] len <tt>opus_int32</tt>: Length of packet | 567 * @param [in] len <tt>opus_int32</tt>: Length of packet |
568 * @returns Number of frames | 568 * @returns Number of frames |
| 569 * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
569 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type | 570 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type |
570 */ | 571 */ |
571 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned
char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); | 572 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned
char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
572 | 573 |
573 /** Gets the number of samples of an Opus packet. | 574 /** Gets the number of samples of an Opus packet. |
574 * @param [in] packet <tt>char*</tt>: Opus packet | 575 * @param [in] packet <tt>char*</tt>: Opus packet |
575 * @param [in] len <tt>opus_int32</tt>: Length of packet | 576 * @param [in] len <tt>opus_int32</tt>: Length of packet |
576 * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. | 577 * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
577 * This must be a multiple of 400, or | 578 * This must be a multiple of 400, or |
578 * inaccurate results will be returned. | 579 * inaccurate results will be returned. |
579 * @returns Number of samples | 580 * @returns Number of samples |
| 581 * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
580 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type | 582 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type |
581 */ | 583 */ |
582 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigne
d char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); | 584 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigne
d char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
583 | 585 |
584 /** Gets the number of samples of an Opus packet. | 586 /** Gets the number of samples of an Opus packet. |
585 * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state | 587 * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
586 * @param [in] packet <tt>char*</tt>: Opus packet | 588 * @param [in] packet <tt>char*</tt>: Opus packet |
587 * @param [in] len <tt>opus_int32</tt>: Length of packet | 589 * @param [in] len <tt>opus_int32</tt>: Length of packet |
588 * @returns Number of samples | 590 * @returns Number of samples |
| 591 * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
589 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type | 592 * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an
unsupported type |
590 */ | 593 */ |
591 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDe
coder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OP
US_ARG_NONNULL(2); | 594 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDe
coder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OP
US_ARG_NONNULL(2); |
| 595 |
| 596 /** Applies soft-clipping to bring a float signal within the [-1,1] range. If |
| 597 * the signal is already in that range, nothing is done. If there are values |
| 598 * outside of [-1,1], then the signal is clipped as smoothly as possible to |
| 599 * both fit in the range and avoid creating excessive distortion in the |
| 600 * process. |
| 601 * @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
| 602 * @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
| 603 * @param [in] channels <tt>int</tt>: Number of channels |
| 604 * @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clip
ping process (one float per channel, initialized to zero) |
| 605 */ |
| 606 OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, fl
oat *softclip_mem); |
| 607 |
| 608 |
592 /**@}*/ | 609 /**@}*/ |
593 | 610 |
594 /** @defgroup opus_repacketizer Repacketizer | 611 /** @defgroup opus_repacketizer Repacketizer |
595 * @{ | 612 * @{ |
596 * | 613 * |
597 * The repacketizer can be used to merge multiple Opus packets into a single | 614 * The repacketizer can be used to merge multiple Opus packets into a single |
598 * packet or alternatively to split Opus packets that have previously been | 615 * packet or alternatively to split Opus packets that have previously been |
599 * merged. Splitting valid Opus packets is always guaranteed to succeed, | 616 * merged. Splitting valid Opus packets is always guaranteed to succeed, |
600 * whereas merging valid packets only succeeds if all frames have the same | 617 * whereas merging valid packets only succeeds if all frames have the same |
601 * mode, bandwidth, and frame size, and when the total duration of the merged | 618 * mode, bandwidth, and frame size, and when the total duration of the merged |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 */ | 911 */ |
895 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacke
tizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); | 912 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacke
tizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
896 | 913 |
897 /**@}*/ | 914 /**@}*/ |
898 | 915 |
899 #ifdef __cplusplus | 916 #ifdef __cplusplus |
900 } | 917 } |
901 #endif | 918 #endif |
902 | 919 |
903 #endif /* OPUS_H */ | 920 #endif /* OPUS_H */ |
OLD | NEW |