23 #include <opus_multistream.h>
38 #define OPUS_HEAD_SIZE 19
43 int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled;
44 uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
59 if (nb_streams + nb_coupled != avc->
channels)
63 if (avc->
channels > 2 || channel_map) {
65 "No channel mapping for %d channels.\n", avc->
channels);
70 mapping = mapping_arr;
78 for (ch = 0; ch < avc->
channels; ch++)
79 mapping_arr[ch] = mapping[vorbis_offset[ch]];
80 mapping = mapping_arr;
84 nb_streams, nb_coupled,
92 ret = opus_multistream_decoder_ctl(opus->
dec, OPUS_SET_GAIN(gain_db));
107 opus_multistream_decoder_destroy(opus->
dec);
111 #define MAX_FRAME_SIZE (960 * 6)
127 nb_samples = opus_multistream_decode(opus->
dec, pkt->
data, pkt->
size,
131 nb_samples = opus_multistream_decode_float(opus->
dec, pkt->
data, pkt->
size,
135 if (nb_samples < 0) {
137 opus_strerror(nb_samples));
151 opus_multistream_decoder_ctl(opus->
dec, OPUS_RESET_STATE);
This structure describes decoded (raw) audio or video data.
AVFrame * coded_frame
the picture in the bitstream
AVCodec ff_libopus_decoder
int ff_opus_error_to_averror(int err)
enum AVSampleFormat sample_fmt
audio sample format
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
enum AVSampleFormat request_sample_fmt
Used to request a sample format from the decoder.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
static av_cold int libopus_decode_init(AVCodecContext *avc)
int sample_rate
samples per second
main external API structure.
const uint64_t ff_vorbis_channel_layouts[9]
static void libopus_flush(AVCodecContext *avc)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static av_const int sign_extend(int val, unsigned bits)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int libopus_decode(AVCodecContext *avc, void *frame, int *got_frame_ptr, AVPacket *pkt)
common internal api header.
AVSampleFormat
Audio Sample Formats.
int channels
number of audio channels
static av_cold int libopus_decode_close(AVCodecContext *avc)
const uint8_t ff_vorbis_channel_layout_offsets[8][8]
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame