Go to the documentation of this file.
35 #define BITSTREAM_READER_LE
44 #define MAX_CHANNELS 2
45 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
108 s->frame_len = 1 << frame_len_bits;
109 s->overlap_len =
s->frame_len / 16;
110 s->block_size = (
s->frame_len -
s->overlap_len) *
s->channels;
113 s->root = 2.0 / (sqrt(
s->frame_len) * 32768.0);
115 s->root =
s->frame_len / (sqrt(
s->frame_len) * 32768.0);
116 for (
i = 0;
i < 96;
i++) {
118 s->quant_table[
i] =
expf(
i * 0.15289164787221953823
f) *
s->root;
122 for (
s->num_bands = 1;
s->num_bands < 25;
s->num_bands++)
128 for (
i = 1;
i <
s->num_bands;
i++)
130 s->bands[
s->num_bands] =
s->frame_len;
136 else if (CONFIG_BINKAUDIO_DCT_DECODER)
158 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
176 for (ch = 0; ch <
s->channels; ch++) {
193 for (
i = 0;
i <
s->num_bands;
i++) {
203 while (i < s->frame_len) {
216 j =
FFMIN(j,
s->frame_len);
220 memset(coeffs +
i, 0, (j -
i) *
sizeof(*coeffs));
222 while (
s->bands[k] <
i)
226 if (
s->bands[k] ==
i)
244 if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
246 s->trans.dct.dct_calc(&
s->trans.dct, coeffs);
248 else if (CONFIG_BINKAUDIO_RDFT_DECODER)
249 s->trans.rdft.rdft_calc(&
s->trans.rdft, coeffs);
252 for (ch = 0; ch <
s->channels; ch++) {
254 int count =
s->overlap_len *
s->channels;
257 for (
i = 0;
i <
s->overlap_len;
i++, j +=
s->channels)
258 out[ch][
i] = (
s->previous[ch][
i] * (count - j) +
259 out[ch][
i] * j) / count;
261 memcpy(
s->previous[ch], &
out[ch][
s->frame_len -
s->overlap_len],
262 s->overlap_len *
sizeof(*
s->previous[ch]));
275 else if (CONFIG_BINKAUDIO_DCT_DECODER)
298 if (
s->pkt->size < 4) {
313 frame->nb_samples =
s->frame_len;
324 memset(gb, 0,
sizeof(*gb));
346 .
name =
"binkaudio_rdft",
360 .
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.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
int version_b
Bink version 'b'.
static int get_bits_left(GetBitContext *gb)
uint64_t channel_layout
Audio channel layout.
int sample_rate
samples per second
#define AV_CH_LAYOUT_MONO
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.
union BinkAudioContext::@23 trans
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const struct AVCodec * codec
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)
const AVCodec ff_binkaudio_rdft_decoder
#define AV_CH_LAYOUT_STEREO
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]
static void flush(AVCodecContext *avctx)
int overlap_len
overlap size (samples)
float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE/16]
coeffs from previous audio block
struct AVCodecInternal * internal
Private context used for internal data.
static CopyRet receive_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
static unsigned int get_bits1(GetBitContext *s)
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
static const uint8_t rle_length_tab[16]
int frame_len
transform size (samples)
av_cold void ff_dct_end(DCTContext *s)
int channels
number of audio channels
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.
static int decode_block(BinkAudioContext *s, float **out, int use_dct)
Decode Bink Audio block.
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
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)
const AVCodec ff_binkaudio_dct_decoder
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