33 #define BITSTREAM_READER_LE
45 #define MAX_CHANNELS 2
46 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
107 frame_len_bits += av_log2(avctx->
channels);
115 sample_rate_half = (sample_rate + 1) / 2;
117 for (i = 0; i < 96; i++) {
168 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
171 #define GET_BITS_SAFE(out, nbits) do { \
172 if (get_bits_left(gb) < nbits) \
173 return AVERROR_INVALIDDATA; \
174 out = get_bits(gb, nbits); \
192 for (ch = 0; ch < s->
channels; ch++) {
218 while (i < s->frame_len) {
236 memset(coeffs + i, 0, (j - i) *
sizeof(*coeffs));
238 while (s->
bands[k] < i)
242 if (s->
bands[k] == i)
249 coeffs[i] = -q * coeff;
251 coeffs[i] = q * coeff;
278 int shift = av_log2(count);
279 for (i = 0; i < count; i++) {
280 out[i] = (s->
previous[i] * (count - i) + out[i] * i) >> shift;
312 int *got_frame_ptr,
AVPacket *avpkt)
317 int ret, consumed = 0;
326 if (avpkt->
size < 4) {
336 consumed = avpkt->
size;
363 .
name =
"binkaudio_rdft",
375 .
name =
"binkaudio_dct",
av_cold void ff_rdft_end(RDFTContext *s)
static const int16_t coeffs[28]
static float get_float(GetBitContext *gb)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void(* dct_calc)(struct DCTContext *s, FFTSample *data)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int decode_end(AVCodecContext *avctx)
static void skip_bits_long(GetBitContext *s, int n)
AVFrame * coded_frame
the picture in the bitstream
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
FmtConvertContext fmt_conv
static const uint8_t rle_length_tab[16]
#define DECLARE_ALIGNED(n, t, v)
int16_t previous[BINK_BLOCK_MAX_SIZE/16]
coeffs from previous audio block
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int16_t current[BINK_BLOCK_MAX_SIZE/16]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
void(* float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels)
Convert multiple arrays of float to an interleaved array of int16_t.
union BinkAudioContext::@11 trans
enum AVSampleFormat sample_fmt
audio sample format
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_left(GetBitContext *gb)
#define BINK_BLOCK_MAX_SIZE
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void get_bits_align32(GetBitContext *s)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
float * prev_ptr[MAX_CHANNELS]
pointers to the overlap points in the coeffs array
void(* rdft_calc)(struct RDFTContext *s, FFTSample *z)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
static float quant_table[96]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
static av_cold int decode_init(AVCodecContext *avctx)
AVCodec ff_binkaudio_rdft_decoder
int overlap_len
overlap size (samples)
#define GET_BITS_SAFE(out, nbits)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
int sample_rate
samples per second
AVCodec ff_binkaudio_dct_decoder
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned int get_bits1(GetBitContext *s)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void skip_bits(GetBitContext *s, int n)
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
Set up DCT.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
float * coeffs_ptr[MAX_CHANNELS]
pointers to the coeffs arrays for float_to_int16_interleave
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int decode_block(BinkAudioContext *s, int16_t *out, int use_dct)
Decode Bink Audio block.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int frame_len
transform size (samples)
int version_b
Bink version 'b'.
const uint16_t ff_wma_critical_freqs[25]
common internal api header.
FFTSample coeffs[BINK_BLOCK_MAX_SIZE]
av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
int channels
number of audio channels
av_cold void ff_dct_end(DCTContext *s)
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
Set up a real FFT.
int nb_samples
number of audio samples (per channel) described by this frame