OLD | NEW |
1 /* Copyright (c) 2012 Xiph.Org Foundation | 1 /* Copyright (c) 2012 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 13 matching lines...) Expand all Loading... |
24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 | 28 |
29 #ifndef OPUS_PRIVATE_H | 29 #ifndef OPUS_PRIVATE_H |
30 #define OPUS_PRIVATE_H | 30 #define OPUS_PRIVATE_H |
31 | 31 |
32 #include "arch.h" | 32 #include "arch.h" |
33 #include "opus.h" | 33 #include "opus.h" |
| 34 #include "celt.h" |
34 | 35 |
35 struct OpusRepacketizer { | 36 struct OpusRepacketizer { |
36 unsigned char toc; | 37 unsigned char toc; |
37 int nb_frames; | 38 int nb_frames; |
38 const unsigned char *frames[48]; | 39 const unsigned char *frames[48]; |
39 short len[48]; | 40 opus_int16 len[48]; |
40 int framesize; | 41 int framesize; |
41 }; | 42 }; |
42 | 43 |
| 44 typedef struct ChannelLayout { |
| 45 int nb_channels; |
| 46 int nb_streams; |
| 47 int nb_coupled_streams; |
| 48 unsigned char mapping[256]; |
| 49 } ChannelLayout; |
| 50 |
| 51 int validate_layout(const ChannelLayout *layout); |
| 52 int get_left_channel(const ChannelLayout *layout, int stream_id, int prev); |
| 53 int get_right_channel(const ChannelLayout *layout, int stream_id, int prev); |
| 54 int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev); |
| 55 |
| 56 |
43 | 57 |
44 #define MODE_SILK_ONLY 1000 | 58 #define MODE_SILK_ONLY 1000 |
45 #define MODE_HYBRID 1001 | 59 #define MODE_HYBRID 1001 |
46 #define MODE_CELT_ONLY 1002 | 60 #define MODE_CELT_ONLY 1002 |
47 | 61 |
48 #define OPUS_SET_VOICE_RATIO_REQUEST 11018 | 62 #define OPUS_SET_VOICE_RATIO_REQUEST 11018 |
49 #define OPUS_GET_VOICE_RATIO_REQUEST 11019 | 63 #define OPUS_GET_VOICE_RATIO_REQUEST 11019 |
50 | 64 |
51 /** Configures the encoder's expected percentage of voice | 65 /** Configures the encoder's expected percentage of voice |
52 * opposed to music or other signals. | 66 * opposed to music or other signals. |
53 * | 67 * |
54 * @note This interface is currently more aspiration than actuality. It's | 68 * @note This interface is currently more aspiration than actuality. It's |
55 * ultimately expected to bias an automatic signal classifier, but it currently | 69 * ultimately expected to bias an automatic signal classifier, but it currently |
56 * just shifts the static bitrate to mode mapping around a little bit. | 70 * just shifts the static bitrate to mode mapping around a little bit. |
57 * | 71 * |
58 * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive. | 72 * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive. |
59 * @hideinitializer */ | 73 * @hideinitializer */ |
60 #define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x
) | 74 #define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x
) |
61 /** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO | 75 /** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO |
62 * | 76 * |
63 * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive
. | 77 * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive
. |
64 * @hideinitializer */ | 78 * @hideinitializer */ |
65 #define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_p
tr(x) | 79 #define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_p
tr(x) |
66 | 80 |
67 | 81 |
68 #define OPUS_SET_FORCE_MODE_REQUEST 11002 | 82 #define OPUS_SET_FORCE_MODE_REQUEST 11002 |
69 #define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x) | 83 #define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x) |
70 | 84 |
| 85 typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int
); |
| 86 void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, in
t c1, int c2, int C); |
| 87 void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int
c1, int c2, int C); |
| 88 |
| 89 int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, |
| 90 int bitrate, opus_val16 tonality, opus_val32 *mem, int buffering
, |
| 91 downmix_func downmix); |
71 | 92 |
72 int encode_size(int size, unsigned char *data); | 93 int encode_size(int size, unsigned char *data); |
73 | 94 |
| 95 opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_
int32 Fs); |
| 96 |
| 97 opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, |
| 98 int variable_duration, int C, opus_int32 Fs, int bitrate_bps, |
| 99 int delay_compensation, downmix_func downmix, opus_val32 *subframe_mem); |
| 100 |
| 101 opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
size, |
| 102 unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, |
| 103 const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int an
alysis_channels, downmix_func downmix); |
| 104 |
74 int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 le
n, | 105 int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 le
n, |
75 opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, int *
packet_offset); | 106 opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, |
| 107 int *packet_offset, int soft_clip); |
76 | 108 |
77 /* Make sure everything's aligned to sizeof(void *) bytes */ | 109 /* Make sure everything's aligned to sizeof(void *) bytes */ |
78 static inline int align(int i) | 110 static inline int align(int i) |
79 { | 111 { |
80 return (i+sizeof(void *)-1)&-((int)sizeof(void *)); | 112 return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *); |
81 } | 113 } |
82 | 114 |
83 opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int
end, unsigned char *data, opus_int32 maxlen, int self_delimited); | 115 opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int
end, unsigned char *data, opus_int32 maxlen, int self_delimited); |
84 | 116 |
85 #endif /* OPUS_PRIVATE_H */ | 117 #endif /* OPUS_PRIVATE_H */ |
OLD | NEW |