1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/src/opus_private.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,129 @@ 1.4 +/* Copyright (c) 2012 Xiph.Org Foundation 1.5 + Written by Jean-Marc Valin */ 1.6 +/* 1.7 + Redistribution and use in source and binary forms, with or without 1.8 + modification, are permitted provided that the following conditions 1.9 + are met: 1.10 + 1.11 + - Redistributions of source code must retain the above copyright 1.12 + notice, this list of conditions and the following disclaimer. 1.13 + 1.14 + - Redistributions in binary form must reproduce the above copyright 1.15 + notice, this list of conditions and the following disclaimer in the 1.16 + documentation and/or other materials provided with the distribution. 1.17 + 1.18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.19 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 1.22 + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.29 +*/ 1.30 + 1.31 + 1.32 +#ifndef OPUS_PRIVATE_H 1.33 +#define OPUS_PRIVATE_H 1.34 + 1.35 +#include "arch.h" 1.36 +#include "opus.h" 1.37 +#include "celt.h" 1.38 + 1.39 +struct OpusRepacketizer { 1.40 + unsigned char toc; 1.41 + int nb_frames; 1.42 + const unsigned char *frames[48]; 1.43 + opus_int16 len[48]; 1.44 + int framesize; 1.45 +}; 1.46 + 1.47 +typedef struct ChannelLayout { 1.48 + int nb_channels; 1.49 + int nb_streams; 1.50 + int nb_coupled_streams; 1.51 + unsigned char mapping[256]; 1.52 +} ChannelLayout; 1.53 + 1.54 +int validate_layout(const ChannelLayout *layout); 1.55 +int get_left_channel(const ChannelLayout *layout, int stream_id, int prev); 1.56 +int get_right_channel(const ChannelLayout *layout, int stream_id, int prev); 1.57 +int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev); 1.58 + 1.59 + 1.60 + 1.61 +#define MODE_SILK_ONLY 1000 1.62 +#define MODE_HYBRID 1001 1.63 +#define MODE_CELT_ONLY 1002 1.64 + 1.65 +#define OPUS_SET_VOICE_RATIO_REQUEST 11018 1.66 +#define OPUS_GET_VOICE_RATIO_REQUEST 11019 1.67 + 1.68 +/** Configures the encoder's expected percentage of voice 1.69 + * opposed to music or other signals. 1.70 + * 1.71 + * @note This interface is currently more aspiration than actuality. It's 1.72 + * ultimately expected to bias an automatic signal classifier, but it currently 1.73 + * just shifts the static bitrate to mode mapping around a little bit. 1.74 + * 1.75 + * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive. 1.76 + * @hideinitializer */ 1.77 +#define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x) 1.78 +/** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO 1.79 + * 1.80 + * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive. 1.81 + * @hideinitializer */ 1.82 +#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x) 1.83 + 1.84 + 1.85 +#define OPUS_SET_FORCE_MODE_REQUEST 11002 1.86 +#define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x) 1.87 + 1.88 +typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int); 1.89 +void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); 1.90 +void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); 1.91 + 1.92 +int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, 1.93 + int bitrate, opus_val16 tonality, float *mem, int buffering, 1.94 + downmix_func downmix); 1.95 + 1.96 +int encode_size(int size, unsigned char *data); 1.97 + 1.98 +opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs); 1.99 + 1.100 +opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, 1.101 + int variable_duration, int C, opus_int32 Fs, int bitrate_bps, 1.102 + int delay_compensation, downmix_func downmix 1.103 +#ifndef DISABLE_FLOAT_API 1.104 + , float *subframe_mem 1.105 +#endif 1.106 + ); 1.107 + 1.108 +opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, 1.109 + unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, 1.110 + const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int analysis_channels, downmix_func downmix); 1.111 + 1.112 +int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len, 1.113 + opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, 1.114 + opus_int32 *packet_offset, int soft_clip); 1.115 + 1.116 +/* Make sure everything's aligned to sizeof(void *) bytes */ 1.117 +static OPUS_INLINE int align(int i) 1.118 +{ 1.119 + return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *); 1.120 +} 1.121 + 1.122 +int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, 1.123 + int self_delimited, unsigned char *out_toc, 1.124 + const unsigned char *frames[48], opus_int16 size[48], 1.125 + int *payload_offset, opus_int32 *packet_offset); 1.126 + 1.127 +opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, 1.128 + unsigned char *data, opus_int32 maxlen, int self_delimited, int pad); 1.129 + 1.130 +int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len); 1.131 + 1.132 +#endif /* OPUS_PRIVATE_H */