Go to the documentation of this file.
31 #include "config_components.h"
38 #define BITSTREAM_READER_LE
46 #define MAX_DCT_CHANNELS 6
47 #define MAX_CHANNELS 2
48 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
112 s->frame_len = 1 << frame_len_bits;
113 s->overlap_len =
s->frame_len / 16;
117 s->root = 2.0 / (sqrt(
s->frame_len) * 32768.0);
119 s->root =
s->frame_len / (sqrt(
s->frame_len) * 32768.0);
120 for (
i = 0;
i < 96;
i++) {
122 s->quant_table[
i] =
expf(
i * 0.15289164787221953823
f) *
s->root;
126 for (
s->num_bands = 1;
s->num_bands < 25;
s->num_bands++)
132 for (
i = 1;
i <
s->num_bands;
i++)
134 s->bands[
s->num_bands] =
s->frame_len;
141 }
else if (CONFIG_BINKAUDIO_DCT_DECODER) {
142 float scale = 1.0 / (1 << frame_len_bits);
165 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
200 for (
i = 0;
i <
s->num_bands;
i++) {
210 while (i < s->frame_len) {
223 j =
FFMIN(j,
s->frame_len);
227 memset(coeffs +
i, 0, (j -
i) *
sizeof(*coeffs));
229 while (
s->bands[k] <
i)
233 if (
s->bands[k] ==
i)
251 if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
253 s->tx_fn(
s->tx,
out[ch + ch_offset], coeffs,
sizeof(
float));
254 }
else if (CONFIG_BINKAUDIO_RDFT_DECODER) {
255 for (
int i = 2;
i <
s->frame_len;
i += 2)
258 coeffs[
s->frame_len + 0] = coeffs[1];
259 coeffs[
s->frame_len + 1] = coeffs[1] = 0;
270 out[ch + ch_offset][
i] = (
s->previous[ch + ch_offset][
i] * (count - j) +
271 out[ch + ch_offset][
i] * j) / count;
273 memcpy(
s->previous[ch + ch_offset], &
out[ch + ch_offset][
s->frame_len -
s->overlap_len],
274 s->overlap_len *
sizeof(*
s->previous[ch + ch_offset]));
302 new_pkt = !
s->pkt->data;
310 if (
s->pkt->size < 4) {
325 if (
s->ch_offset == 0) {
343 memset(gb, 0,
sizeof(*gb));
346 if (
s->ch_offset >=
s->channels) {
372 .
p.
name =
"binkaudio_rdft",
386 .
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int nb_channels
Number of channels in this layout.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
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.
static av_always_inline float scale(float x, float s)
static const uint8_t quant[64]
#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.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
int(* init)(AVBSFContext *ctx)
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]
#define CODEC_LONG_NAME(str)
#define LOCAL_ALIGNED_32(t, v,...)
int overlap_len
overlap size (samples)
struct AVCodecInternal * internal
Private context used for internal data.
static unsigned int get_bits1(GetBitContext *s)
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
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.
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
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const uint8_t rle_length_tab[16]
int frame_len
transform size (samples)
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
static av_cold int decode_init(AVCodecContext *avctx)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int nb_samples
number of audio samples (per channel) described by this frame
#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)
uint8_t ** extended_data
pointers to the data planes/channels.
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
const char * name
Name of the codec implementation.
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
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
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
void(* flush)(AVBSFContext *ctx)
This structure stores compressed data.
@ AV_TX_FLOAT_DCT
Real to real (DCT) transforms.
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