blob: c948f771e3953cbdefd0982f8050346512491b22 [file] [log] [blame]
Alexandre Lision744f7422013-09-25 11:39:37 -04001/* Copyright (c) 2012 Xiph.Org Foundation
2 Written by Jean-Marc Valin */
3/*
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
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.
26*/
27
28
29#ifndef OPUS_PRIVATE_H
30#define OPUS_PRIVATE_H
31
32#include "arch.h"
33#include "opus.h"
34
35struct OpusRepacketizer {
36 unsigned char toc;
37 int nb_frames;
38 const unsigned char *frames[48];
39 opus_int16 len[48];
40 int framesize;
41};
42
43
44#define MODE_SILK_ONLY 1000
45#define MODE_HYBRID 1001
46#define MODE_CELT_ONLY 1002
47
48#define OPUS_SET_VOICE_RATIO_REQUEST 11018
49#define OPUS_GET_VOICE_RATIO_REQUEST 11019
50
51/** Configures the encoder's expected percentage of voice
52 * opposed to music or other signals.
53 *
54 * @note This interface is currently more aspiration than actuality. It's
55 * ultimately expected to bias an automatic signal classifier, but it currently
56 * just shifts the static bitrate to mode mapping around a little bit.
57 *
58 * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive.
59 * @hideinitializer */
60#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
62 *
63 * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive.
64 * @hideinitializer */
65#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x)
66
67
68#define OPUS_SET_FORCE_MODE_REQUEST 11002
69#define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x)
70
71
72int encode_size(int size, unsigned char *data);
73
74int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len,
75 opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, int *packet_offset);
76
77/* Make sure everything's aligned to sizeof(void *) bytes */
78static inline int align(int i)
79{
80 return (i+sizeof(void *)-1)&-((int)sizeof(void *));
81}
82
83opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen, int self_delimited);
84
85#endif /* OPUS_PRIVATE_H */