Go to the documentation of this file.
31 #include "config_components.h"
37 #define BITSTREAM_READER_LE
47 #define MAX_DCT_CHANNELS 6
48 #define MAX_CHANNELS 2
49 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
115 s->frame_len = 1 << frame_len_bits;
116 s->overlap_len =
s->frame_len / 16;
120 s->root = 2.0 / (sqrt(
s->frame_len) * 32768.0);
122 s->root =
s->frame_len / (sqrt(
s->frame_len) * 32768.0);
123 for (
i = 0;
i < 96;
i++) {
125 s->quant_table[
i] =
expf(
i * 0.15289164787221953823
f) *
s->root;
129 for (
s->num_bands = 1;
s->num_bands < 25;
s->num_bands++)
135 for (
i = 1;
i <
s->num_bands;
i++)
137 s->bands[
s->num_bands] =
s->frame_len;
143 else if (CONFIG_BINKAUDIO_DCT_DECODER)
165 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
201 for (
i = 0;
i <
s->num_bands;
i++) {
211 while (i < s->frame_len) {
224 j =
FFMIN(j,
s->frame_len);
228 memset(coeffs +
i, 0, (j -
i) *
sizeof(*coeffs));
230 while (
s->bands[k] <
i)
234 if (
s->bands[k] ==
i)
252 if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
254 s->trans.dct.dct_calc(&
s->trans.dct, coeffs);
256 else if (CONFIG_BINKAUDIO_RDFT_DECODER)
257 s->trans.rdft.rdft_calc(&
s->trans.rdft, coeffs);
266 out[ch + ch_offset][
i] = (
s->previous[ch + ch_offset][
i] * (count - j) +
267 out[ch + ch_offset][
i] * j) / count;
269 memcpy(
s->previous[ch + ch_offset], &
out[ch + ch_offset][
s->frame_len -
s->overlap_len],
270 s->overlap_len *
sizeof(*
s->previous[ch + ch_offset]));
283 else if (CONFIG_BINKAUDIO_DCT_DECODER)
309 if (
s->pkt->size < 4) {
324 if (
s->ch_offset == 0) {
325 frame->nb_samples =
s->frame_len;
340 memset(gb, 0,
sizeof(*gb));
343 if (
s->ch_offset >=
s->channels) {
369 .
p.
name =
"binkaudio_rdft",
383 .
p.
name =
"binkaudio_dct",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
@ AV_SAMPLE_FMT_FLTP
float, planar
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int version_b
Bink version 'b'.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
int sample_rate
samples per second
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static float get_float(GetBitContext *gb)
#define BINK_BLOCK_MAX_SIZE
static int get_bits_count(const GetBitContext *s)
This structure describes decoded (raw) audio or video data.
int nb_channels
Number of channels in this layout.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
const struct AVCodec * codec
AVChannelLayout ch_layout
Audio channel layout.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
av_cold void ff_rdft_end(RDFTContext *s)
static int quant(float coef, const float Q, const float rounding)
Quantize one coefficient.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static av_cold int decode_end(AVCodecContext *avctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int binkaudio_receive_frame(AVCodecContext *avctx, AVFrame *frame)
@ AV_CODEC_ID_BINKAUDIO_DCT
const uint16_t ff_wma_critical_freqs[25]
union BinkAudioContext::@24 trans
static void flush(AVCodecContext *avctx)
int overlap_len
overlap size (samples)
struct AVCodecInternal * internal
Private context used for internal data.
static unsigned int get_bits1(GetBitContext *s)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
static int decode_block(BinkAudioContext *s, float **out, int use_dct, int channels, int ch_offset)
Decode Bink Audio block.
const FFCodec ff_binkaudio_dct_decoder
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
float previous[MAX_DCT_CHANNELS][BINK_BLOCK_MAX_SIZE/16]
coeffs from previous audio block
enum AVSampleFormat sample_fmt
audio sample format
const FFCodec ff_binkaudio_rdft_decoder
static const uint8_t rle_length_tab[16]
int frame_len
transform size (samples)
av_cold void ff_dct_end(DCTContext *s)
static av_cold int decode_init(AVCodecContext *avctx)
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
Set up a real FFT.
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
Set up DCT.
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static void get_bits_align32(GetBitContext *s)
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const char * name
Name of the codec implementation.
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 float power(float r, float g, float b, float max)
#define FF_CODEC_RECEIVE_FRAME_CB(func)
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 again
This structure stores compressed data.
static const double coeff[2][5]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void decode_flush(AVCodecContext *avctx)
@ AV_CODEC_ID_BINKAUDIO_RDFT