media/libopus/src/opus_private.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Copyright (c) 2012 Xiph.Org Foundation
michael@0 2 Written by Jean-Marc Valin */
michael@0 3 /*
michael@0 4 Redistribution and use in source and binary forms, with or without
michael@0 5 modification, are permitted provided that the following conditions
michael@0 6 are met:
michael@0 7
michael@0 8 - Redistributions of source code must retain the above copyright
michael@0 9 notice, this list of conditions and the following disclaimer.
michael@0 10
michael@0 11 - Redistributions in binary form must reproduce the above copyright
michael@0 12 notice, this list of conditions and the following disclaimer in the
michael@0 13 documentation and/or other materials provided with the distribution.
michael@0 14
michael@0 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
michael@0 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
michael@0 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
michael@0 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
michael@0 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
michael@0 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
michael@0 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
michael@0 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 26 */
michael@0 27
michael@0 28
michael@0 29 #ifndef OPUS_PRIVATE_H
michael@0 30 #define OPUS_PRIVATE_H
michael@0 31
michael@0 32 #include "arch.h"
michael@0 33 #include "opus.h"
michael@0 34 #include "celt.h"
michael@0 35
michael@0 36 struct OpusRepacketizer {
michael@0 37 unsigned char toc;
michael@0 38 int nb_frames;
michael@0 39 const unsigned char *frames[48];
michael@0 40 opus_int16 len[48];
michael@0 41 int framesize;
michael@0 42 };
michael@0 43
michael@0 44 typedef struct ChannelLayout {
michael@0 45 int nb_channels;
michael@0 46 int nb_streams;
michael@0 47 int nb_coupled_streams;
michael@0 48 unsigned char mapping[256];
michael@0 49 } ChannelLayout;
michael@0 50
michael@0 51 int validate_layout(const ChannelLayout *layout);
michael@0 52 int get_left_channel(const ChannelLayout *layout, int stream_id, int prev);
michael@0 53 int get_right_channel(const ChannelLayout *layout, int stream_id, int prev);
michael@0 54 int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev);
michael@0 55
michael@0 56
michael@0 57
michael@0 58 #define MODE_SILK_ONLY 1000
michael@0 59 #define MODE_HYBRID 1001
michael@0 60 #define MODE_CELT_ONLY 1002
michael@0 61
michael@0 62 #define OPUS_SET_VOICE_RATIO_REQUEST 11018
michael@0 63 #define OPUS_GET_VOICE_RATIO_REQUEST 11019
michael@0 64
michael@0 65 /** Configures the encoder's expected percentage of voice
michael@0 66 * opposed to music or other signals.
michael@0 67 *
michael@0 68 * @note This interface is currently more aspiration than actuality. It's
michael@0 69 * ultimately expected to bias an automatic signal classifier, but it currently
michael@0 70 * just shifts the static bitrate to mode mapping around a little bit.
michael@0 71 *
michael@0 72 * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive.
michael@0 73 * @hideinitializer */
michael@0 74 #define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x)
michael@0 75 /** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO
michael@0 76 *
michael@0 77 * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive.
michael@0 78 * @hideinitializer */
michael@0 79 #define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x)
michael@0 80
michael@0 81
michael@0 82 #define OPUS_SET_FORCE_MODE_REQUEST 11002
michael@0 83 #define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x)
michael@0 84
michael@0 85 typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int);
michael@0 86 void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C);
michael@0 87 void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C);
michael@0 88
michael@0 89 int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs,
michael@0 90 int bitrate, opus_val16 tonality, float *mem, int buffering,
michael@0 91 downmix_func downmix);
michael@0 92
michael@0 93 int encode_size(int size, unsigned char *data);
michael@0 94
michael@0 95 opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs);
michael@0 96
michael@0 97 opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size,
michael@0 98 int variable_duration, int C, opus_int32 Fs, int bitrate_bps,
michael@0 99 int delay_compensation, downmix_func downmix
michael@0 100 #ifndef DISABLE_FLOAT_API
michael@0 101 , float *subframe_mem
michael@0 102 #endif
michael@0 103 );
michael@0 104
michael@0 105 opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
michael@0 106 unsigned char *data, opus_int32 out_data_bytes, int lsb_depth,
michael@0 107 const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int analysis_channels, downmix_func downmix);
michael@0 108
michael@0 109 int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len,
michael@0 110 opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited,
michael@0 111 opus_int32 *packet_offset, int soft_clip);
michael@0 112
michael@0 113 /* Make sure everything's aligned to sizeof(void *) bytes */
michael@0 114 static OPUS_INLINE int align(int i)
michael@0 115 {
michael@0 116 return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *);
michael@0 117 }
michael@0 118
michael@0 119 int opus_packet_parse_impl(const unsigned char *data, opus_int32 len,
michael@0 120 int self_delimited, unsigned char *out_toc,
michael@0 121 const unsigned char *frames[48], opus_int16 size[48],
michael@0 122 int *payload_offset, opus_int32 *packet_offset);
michael@0 123
michael@0 124 opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end,
michael@0 125 unsigned char *data, opus_int32 maxlen, int self_delimited, int pad);
michael@0 126
michael@0 127 int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len);
michael@0 128
michael@0 129 #endif /* OPUS_PRIVATE_H */

mercurial