Go to the documentation of this file.
23 #include <opus_multistream.h>
44 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
49 #define OPUS_HEAD_SIZE 19
55 uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
60 "Invalid number of channels %d, defaulting to stereo\n",
channels);
89 "No channel mapping for %d channels.\n",
channels);
94 mapping = mapping_arr;
103 mapping_arr[ch] = mapping[vorbis_offset[ch]];
104 mapping = mapping_arr;
117 ret = opus_multistream_decoder_ctl(opus->
dec, OPUS_SET_GAIN(gain_db));
123 double gain_lin =
ff_exp10(gain_db / (20.0 * 256));
125 opus->
gain.
d = gain_lin;
127 opus->
gain.
i =
FFMIN(gain_lin * 65536, INT_MAX);
131 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
132 ret = opus_multistream_decoder_ctl(opus->
dec,
133 OPUS_SET_PHASE_INVERSION_DISABLED(!opus->apply_phase_inv));
136 "Unable to set phase inversion: %s\n",
151 opus_multistream_decoder_destroy(opus->
dec);
157 #define MAX_FRAME_SIZE (960 * 6)
171 (opus_int16 *)
frame->data[0],
172 frame->nb_samples, 0);
175 (
float *)
frame->data[0],
176 frame->nb_samples, 0);
178 if (nb_samples < 0) {
180 opus_strerror(nb_samples));
184 #ifndef OPUS_SET_GAIN
188 float *pcm = (
float *)
frame->data[0];
189 for (;
i > 0;
i--, pcm++)
192 int16_t *pcm = (int16_t *)
frame->data[0];
193 for (;
i > 0;
i--, pcm++)
199 frame->nb_samples = nb_samples;
209 opus_multistream_decoder_ctl(opus->
dec, OPUS_RESET_STATE);
216 #define OFFSET(x) offsetof(struct libopus_context, x)
217 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
219 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
220 {
"apply_phase_inv",
"Apply intensity stereo phase inversion",
OFFSET(apply_phase_inv),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
FLAGS },
249 .p.wrapper_name =
"libopus",
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
int sample_rate
samples per second
static void libopus_flush(AVCodecContext *avc)
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
static const AVOption libopusdec_options[]
This structure describes decoded (raw) audio or video data.
static const AVClass libopusdec_class
enum AVChannelOrder order
Channel order used in this layout.
static av_cold int libopus_decode_init(AVCodecContext *avc)
int nb_channels
Number of channels in this layout.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
union libopus_context::@85 gain
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int libopus_decode_close(AVCodecContext *avc)
#define FF_CODEC_DECODE_CB(func)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int ff_opus_error_to_averror(int err)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const AVChannelLayout ff_vorbis_ch_layouts[9]
struct AVCodecInternal * internal
Private context used for internal data.
const char * av_default_item_name(void *ptr)
Return the context name.
const uint8_t ff_vorbis_channel_layout_offsets[8][8]
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum AVSampleFormat sample_fmt
audio sample format
enum AVSampleFormat request_sample_fmt
desired sample format
const FFCodec ff_libopus_decoder
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
main external API structure.
static av_const int sign_extend(int val, unsigned bits)
static int libopus_decode(AVCodecContext *avc, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
This structure stores compressed data.