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)
160 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
178 for (ch = 0; ch <
s->channels; ch++) {
195 for (
i = 0;
i <
s->num_bands;
i++) {
205 while (i < s->frame_len) {
218 j =
FFMIN(j,
s->frame_len);
222 memset(coeffs +
i, 0, (j -
i) *
sizeof(*coeffs));
224 while (
s->bands[k] <
i)
228 if (
s->bands[k] ==
i)
246 if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
248 s->trans.dct.dct_calc(&
s->trans.dct, coeffs);
250 else if (CONFIG_BINKAUDIO_RDFT_DECODER)
251 s->trans.rdft.rdft_calc(&
s->trans.rdft, coeffs);
254 for (ch = 0; ch <
s->channels; ch++) {
256 int count =
s->overlap_len *
s->channels;
259 for (
i = 0;
i <
s->overlap_len;
i++, j +=
s->channels)
260 out[ch][
i] = (
s->previous[ch][
i] * (count - j) +
261 out[ch][
i] * j) / count;
263 memcpy(
s->previous[ch], &
out[ch][
s->frame_len -
s->overlap_len],
264 s->overlap_len *
sizeof(*
s->previous[ch]));
277 else if (CONFIG_BINKAUDIO_DCT_DECODER)
302 if (
s->pkt->size < 4) {
317 frame->nb_samples =
s->frame_len;
328 memset(gb, 0,
sizeof(*gb));
341 .
name =
"binkaudio_rdft",
354 .
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'.
static av_cold int init(AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
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
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)
AVCodec ff_binkaudio_rdft_decoder
This structure describes decoded (raw) audio or video data.
union BinkAudioContext::@23 trans
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
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)
#define AV_CH_LAYOUT_STEREO
#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]
int overlap_len
overlap size (samples)
float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE/16]
coeffs from previous audio block
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.
AVCodec ff_binkaudio_dct_decoder
enum AVSampleFormat sample_fmt
audio sample format
static const uint8_t rle_length_tab[16]
int frame_len
transform size (samples)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
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.
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)
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.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
This structure stores compressed data.
static const double coeff[2][5]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AV_CODEC_ID_BINKAUDIO_RDFT