FFmpeg
libopusdec.c
Go to the documentation of this file.
1 /*
2  * Opus decoder using libopus
3  * Copyright (c) 2012 Nicolas George
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <opus.h>
23 #include <opus_multistream.h>
24 
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/ffmath.h"
28 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 #include "internal.h"
32 #include "vorbis.h"
33 #include "mathops.h"
34 #include "libopus.h"
35 
37  AVClass *class;
38  OpusMSDecoder *dec;
39  int pre_skip;
40 #ifndef OPUS_SET_GAIN
41  union { int i; double d; } gain;
42 #endif
43 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
44  int apply_phase_inv;
45 #endif
46 };
47 
48 #define OPUS_HEAD_SIZE 19
49 
51 {
52  struct libopus_context *opus = avc->priv_data;
53  int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled;
54  uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
55 
56  avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2;
57  if (avc->channels <= 0) {
59  "Invalid number of channels %d, defaulting to stereo\n", avc->channels);
60  avc->channels = 2;
61  }
62 
63  avc->sample_rate = 48000;
66  avc->channel_layout = avc->channels > 8 ? 0 :
68 
69  if (avc->extradata_size >= OPUS_HEAD_SIZE) {
70  opus->pre_skip = AV_RL16(avc->extradata + 10);
71  gain_db = sign_extend(AV_RL16(avc->extradata + 16), 16);
72  channel_map = AV_RL8 (avc->extradata + 18);
73  }
74  if (avc->extradata_size >= OPUS_HEAD_SIZE + 2 + avc->channels) {
76  nb_coupled = avc->extradata[OPUS_HEAD_SIZE + 1];
77  if (nb_streams + nb_coupled != avc->channels)
78  av_log(avc, AV_LOG_WARNING, "Inconsistent channel mapping.\n");
79  mapping = avc->extradata + OPUS_HEAD_SIZE + 2;
80  } else {
81  if (avc->channels > 2 || channel_map) {
82  av_log(avc, AV_LOG_ERROR,
83  "No channel mapping for %d channels.\n", avc->channels);
84  return AVERROR(EINVAL);
85  }
86  nb_streams = 1;
87  nb_coupled = avc->channels > 1;
88  mapping = mapping_arr;
89  }
90 
91  if (avc->channels > 2 && avc->channels <= 8) {
92  const uint8_t *vorbis_offset = ff_vorbis_channel_layout_offsets[avc->channels - 1];
93  int ch;
94 
95  /* Remap channels from Vorbis order to ffmpeg order */
96  for (ch = 0; ch < avc->channels; ch++)
97  mapping_arr[ch] = mapping[vorbis_offset[ch]];
98  mapping = mapping_arr;
99  }
100 
101  opus->dec = opus_multistream_decoder_create(avc->sample_rate, avc->channels,
102  nb_streams, nb_coupled,
103  mapping, &ret);
104  if (!opus->dec) {
105  av_log(avc, AV_LOG_ERROR, "Unable to create decoder: %s\n",
106  opus_strerror(ret));
108  }
109 
110 #ifdef OPUS_SET_GAIN
111  ret = opus_multistream_decoder_ctl(opus->dec, OPUS_SET_GAIN(gain_db));
112  if (ret != OPUS_OK)
113  av_log(avc, AV_LOG_WARNING, "Failed to set gain: %s\n",
114  opus_strerror(ret));
115 #else
116  {
117  double gain_lin = ff_exp10(gain_db / (20.0 * 256));
118  if (avc->sample_fmt == AV_SAMPLE_FMT_FLT)
119  opus->gain.d = gain_lin;
120  else
121  opus->gain.i = FFMIN(gain_lin * 65536, INT_MAX);
122  }
123 #endif
124 
125 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
126  ret = opus_multistream_decoder_ctl(opus->dec,
127  OPUS_SET_PHASE_INVERSION_DISABLED(!opus->apply_phase_inv));
128  if (ret != OPUS_OK)
129  av_log(avc, AV_LOG_WARNING,
130  "Unable to set phase inversion: %s\n",
131  opus_strerror(ret));
132 #endif
133 
134  /* Decoder delay (in samples) at 48kHz */
135  avc->delay = avc->internal->skip_samples = opus->pre_skip;
136 
137  return 0;
138 }
139 
141 {
142  struct libopus_context *opus = avc->priv_data;
143 
144  if (opus->dec) {
145  opus_multistream_decoder_destroy(opus->dec);
146  opus->dec = NULL;
147  }
148  return 0;
149 }
150 
151 #define MAX_FRAME_SIZE (960 * 6)
152 
153 static int libopus_decode(AVCodecContext *avc, void *data,
154  int *got_frame_ptr, AVPacket *pkt)
155 {
156  struct libopus_context *opus = avc->priv_data;
157  AVFrame *frame = data;
158  int ret, nb_samples;
159 
160  frame->nb_samples = MAX_FRAME_SIZE;
161  if ((ret = ff_get_buffer(avc, frame, 0)) < 0)
162  return ret;
163 
164  if (avc->sample_fmt == AV_SAMPLE_FMT_S16)
165  nb_samples = opus_multistream_decode(opus->dec, pkt->data, pkt->size,
166  (opus_int16 *)frame->data[0],
167  frame->nb_samples, 0);
168  else
169  nb_samples = opus_multistream_decode_float(opus->dec, pkt->data, pkt->size,
170  (float *)frame->data[0],
171  frame->nb_samples, 0);
172 
173  if (nb_samples < 0) {
174  av_log(avc, AV_LOG_ERROR, "Decoding error: %s\n",
175  opus_strerror(nb_samples));
176  return ff_opus_error_to_averror(nb_samples);
177  }
178 
179 #ifndef OPUS_SET_GAIN
180  {
181  int i = avc->channels * nb_samples;
182  if (avc->sample_fmt == AV_SAMPLE_FMT_FLT) {
183  float *pcm = (float *)frame->data[0];
184  for (; i > 0; i--, pcm++)
185  *pcm = av_clipf(*pcm * opus->gain.d, -1, 1);
186  } else {
187  int16_t *pcm = (int16_t *)frame->data[0];
188  for (; i > 0; i--, pcm++)
189  *pcm = av_clip_int16(((int64_t)opus->gain.i * *pcm) >> 16);
190  }
191  }
192 #endif
193 
194  frame->nb_samples = nb_samples;
195  *got_frame_ptr = 1;
196 
197  return pkt->size;
198 }
199 
200 static void libopus_flush(AVCodecContext *avc)
201 {
202  struct libopus_context *opus = avc->priv_data;
203 
204  opus_multistream_decoder_ctl(opus->dec, OPUS_RESET_STATE);
205  /* The stream can have been extracted by a tool that is not Opus-aware.
206  Therefore, any packet can become the first of the stream. */
207  avc->internal->skip_samples = opus->pre_skip;
208 }
209 
210 
211 #define OFFSET(x) offsetof(struct libopus_context, x)
212 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
213 static const AVOption libopusdec_options[] = {
214 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
215  { "apply_phase_inv", "Apply intensity stereo phase inversion", OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
216 #endif
217  { NULL },
218 };
219 
220 static const AVClass libopusdec_class = {
221  .class_name = "libopusdec",
222  .item_name = av_default_item_name,
223  .option = libopusdec_options,
224  .version = LIBAVUTIL_VERSION_INT,
225 };
226 
227 
229  .name = "libopus",
230  .long_name = NULL_IF_CONFIG_SMALL("libopus Opus"),
231  .type = AVMEDIA_TYPE_AUDIO,
232  .id = AV_CODEC_ID_OPUS,
233  .priv_data_size = sizeof(struct libopus_context),
235  .close = libopus_decode_close,
236  .decode = libopus_decode,
237  .flush = libopus_flush,
238  .capabilities = AV_CODEC_CAP_DR1,
239  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
240  .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
243  .priv_class = &libopusdec_class,
244  .wrapper_name = "libopus",
245 };
AVCodec
AVCodec.
Definition: avcodec.h:3481
libopus_context::d
double d
Definition: libopusdec.c:41
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
libopus.h
ff_exp10
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: ffmath.h:42
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::channel_layout
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:2276
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:2225
libopus_flush
static void libopus_flush(AVCodecContext *avc)
Definition: libopusdec.c:200
AVCodecInternal::skip_samples
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
Definition: internal.h:185
ch
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
Definition: audioconvert.c:56
libopusdec_options
static const AVOption libopusdec_options[]
Definition: libopusdec.c:213
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
libopusdec_class
static const AVClass libopusdec_class
Definition: libopusdec.c:220
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
AVOption
AVOption.
Definition: opt.h:246
data
const char data[16]
Definition: mxf.c:91
opus.h
libopus_decode_init
static av_cold int libopus_decode_init(AVCodecContext *avc)
Definition: libopusdec.c:50
AV_RL8
#define AV_RL8(x)
Definition: intreadwrite.h:398
libopus_context
Definition: libopusdec.c:36
AVCodecContext::delay
int delay
Codec delay.
Definition: avcodec.h:1721
libopus_context::gain
union libopus_context::@109 gain
libopus_context::i
int i
Definition: libopusdec.c:41
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_cold
#define av_cold
Definition: attributes.h:84
libopus_decode_close
static av_cold int libopus_decode_close(AVCodecContext *avc)
Definition: libopusdec.c:140
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:1667
intreadwrite.h
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:90
nb_streams
static int nb_streams
Definition: ffprobe.c:280
ff_opus_error_to_averror
int ff_opus_error_to_averror(int err)
Definition: libopus.c:28
FLAGS
#define FLAGS
Definition: libopusdec.c:212
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
libopus_decode
static int libopus_decode(AVCodecContext *avc, void *data, int *got_frame_ptr, AVPacket *pkt)
Definition: libopusdec.c:153
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1600
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
OPUS_HEAD_SIZE
#define OPUS_HEAD_SIZE
Definition: libopusdec.c:48
mathops.h
ff_vorbis_channel_layout_offsets
const uint8_t ff_vorbis_channel_layout_offsets[8][8]
Definition: vorbis_data.c:25
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
libopus_context::dec
OpusMSDecoder * dec
Definition: libopusdec.c:38
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1965
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
AVPacket::size
int size
Definition: avcodec.h:1478
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:2233
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: avcodec.h:624
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
OFFSET
#define OFFSET(x)
Definition: libopusdec.c:211
AVCodecContext::request_sample_fmt
enum AVSampleFormat request_sample_fmt
desired sample format
Definition: avcodec.h:2298
AVCodecContext::channels
int channels
number of audio channels
Definition: avcodec.h:2226
MAX_FRAME_SIZE
#define MAX_FRAME_SIZE
Definition: libopusdec.c:151
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
vorbis.h
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1666
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
internal.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
uint8_t
uint8_t
Definition: audio_convert.c:194
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:61
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3488
avcodec.h
ff_libopus_decoder
AVCodec ff_libopus_decoder
Definition: libopusdec.c:228
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
sign_extend
static av_const int sign_extend(int val, unsigned bits)
Definition: mathops.h:130
ffmath.h
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
ff_vorbis_channel_layouts
const uint64_t ff_vorbis_channel_layouts[9]
Definition: vorbis_data.c:47
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
libopus_context::pre_skip
int pre_skip
Definition: libopusdec.c:39
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:63