#include "libavresample/avresample.h"
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#define MAX_FRAME_SIZE 1275
#define MAX_FRAMES 48
#define ROUND_MUL16(a,b) ((MUL16(a, b) + 16384) >> 15)
#define opus_ilog(i) (av_log2(i) + !!(i))
+#define OPUS_TS_HEADER 0x7FE0 // 0x3ff (11 bits)
+#define OPUS_TS_MASK 0xFFE0 // top 11 bits
+
+static const uint8_t opus_default_extradata[30] = {
+ 'O', 'p', 'u', 's', 'H', 'e', 'a', 'd',
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
enum OpusMode {
OPUS_MODE_SILK,
OPUS_MODE_HYBRID,
} RawBitsContext;
typedef struct OpusRangeCoder {
- GetBitContext gb;
+ BitstreamContext bc;
RawBitsContext rb;
unsigned int range;
unsigned int value;
typedef struct SilkContext SilkContext;
-typedef struct CeltIMDCTContext CeltIMDCTContext;
-
typedef struct CeltContext CeltContext;
typedef struct OpusPacket {
typedef struct OpusContext {
OpusStreamContext *streams;
+
+ /* current output buffers for each streams */
+ float **out;
+ int *out_size;
+ /* Buffers for synchronizing the streams when they have different
+ * resampling delays */
+ AVAudioFifo **sync_buffers;
+ /* number of decoded samples for each stream */
+ int *decoded_samples;
+
int nb_streams;
int nb_stereo_streams;
static av_always_inline void opus_rc_normalize(OpusRangeCoder *rc)
{
while (rc->range <= 1<<23) {
- rc->value = ((rc->value << 8) | (get_bits(&rc->gb, 8) ^ 0xFF)) & ((1u << 31) - 1);
+ rc->value = ((rc->value << 8) | (bitstream_read(&rc->bc, 8) ^ 0xFF)) & ((1u << 31) - 1);
rc->range <<= 8;
rc->total_read_bits += 8;
}
enum OpusBandwidth bandwidth, int coded_channels,
int duration_ms);
-/**
- * Init an iMDCT of the length 2 * 15 * (2^N)
- */
-int ff_celt_imdct_init(CeltIMDCTContext **s, int N);
-
-/**
- * Free an iMDCT.
- */
-void ff_celt_imdct_uninit(CeltIMDCTContext **s);
-
-/**
- * Calculate the middle half of the iMDCT
- */
-void ff_celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src,
- int src_stride, float scale);
-
int ff_celt_init(AVCodecContext *avctx, CeltContext **s, int output_channels);
void ff_celt_free(CeltContext **s);