Go to the documentation of this file.
71 for (
int i = 0;
i < 128;
i++) {
76 memset(
ath+
i, 0xFF, (128 -
i));
100 static inline unsigned ceil2(
unsigned a,
unsigned b)
102 return (
b > 0) ? (
a /
b + ((
a %
b) ? 1 : 0)) : 0;
109 int8_t
r[16] = { 0 };
110 float scale = 1.f / 8.f;
127 c->ath_type =
version >= 0x200 ? 0 : 1;
136 if (chunk ==
MKBETAG(
'c',
'o',
'm',
'p')) {
145 c->bands_per_hfr_group =
get_bits(gb, 8);
146 }
else if (chunk ==
MKBETAG(
'd',
'e',
'c', 0)) {
150 c->total_band_count =
get_bits(gb, 8) + 1;
151 c->base_band_count =
get_bits(gb, 8) + 1;
155 c->base_band_count =
c->total_band_count;
156 c->stereo_band_count =
c->total_band_count -
c->base_band_count;
157 c->bands_per_hfr_group = 0;
167 if (chunk ==
MKBETAG(
'v',
'b',
'r', 0)) {
170 }
else if (chunk ==
MKBETAG(
'a',
't',
'h', 0)) {
172 }
else if (chunk ==
MKBETAG(
'r',
'v',
'a', 0)) {
174 }
else if (chunk ==
MKBETAG(
'c',
'o',
'm',
'm')) {
176 }
else if (chunk ==
MKBETAG(
'c',
'i',
'p',
'h')) {
178 }
else if (chunk ==
MKBETAG(
'l',
'o',
'o',
'p')) {
183 }
else if (chunk ==
MKBETAG(
'p',
'a',
'd', 0)) {
198 if (
c->stereo_band_count &&
b > 1) {
201 for (
int i = 0;
i <
c->track_count;
i++, x+=
b) {
210 if (
c->channel_config == 0) {
217 if (
c->channel_config <= 2) {
224 x[0] = 1; x[1] = 2; x[4] = 1; x[5] = 2;
227 x[0] = 1; x[1] = 2; x[4] = 1; x[5] = 2; x[6] = 1; x[7] = 2;
233 if (
c->total_band_count <
c->base_band_count)
236 c->hfr_group_count =
ceil2(
c->total_band_count - (
c->base_band_count +
c->stereo_band_count),
237 c->bands_per_hfr_group);
239 if (
c->base_band_count +
c->stereo_band_count + (
unsigned long)
c->hfr_group_count > 128ULL)
243 c->ch[
i].chan_type =
r[
i];
244 c->ch[
i].count =
c->base_band_count + ((
r[
i] != 2) ?
c->stereo_band_count : 0);
245 c->ch[
i].hfr_scale = &
c->ch[
i].scale_factors[
c->base_band_count +
c->stereo_band_count];
246 if (
c->ch[
i].count > 128)
268 int index,
unsigned band_count,
unsigned base_band_count,
269 unsigned stereo_band_count)
272 float ratio_r = ratio_l - 2.0f;
276 if (ch1->
chan_type != 1 || !stereo_band_count)
279 for (
int i = 0;
i < band_count;
i++) {
280 *(
c2++) = *
c1 * ratio_r;
286 unsigned hfr_group_count,
287 unsigned bands_per_hfr_group,
288 unsigned start_band,
unsigned total_band_count)
290 if (ch->
chan_type == 2 || !bands_per_hfr_group)
293 for (
int i = 0, k = start_band, l = start_band - 1;
i < hfr_group_count;
i++){
294 for (
int j = 0; j < bands_per_hfr_group && k < total_band_count && l >= 0; j++, k++, l--){
307 for (
int i = 0;
i < ch->
count;
i++) {
308 unsigned scale = ch->
scale[
i];
330 unsigned hfr_group_count,
331 int packed_noise_level,
337 if (delta_bits > 5) {
340 }
else if (delta_bits) {
342 int max_value = (1 << delta_bits) - 1;
343 int half_max = max_value >> 1;
346 for (
int i = 1;
i < ch->
count;
i++){
349 if (
delta == max_value) {
365 for (
int i = 1;
i < 8;
i++)
369 for (
int i = 0;
i < hfr_group_count;
i++)
373 for (
int i = 0;
i < ch->
count;
i++) {
377 scale =
c->ath[
i] + ((packed_noise_level +
i) >> 8) - ((scale * 5) >> 1) + 2;
390 int *got_frame_ptr,
AVPacket *avpkt)
394 int ch,
ret, packed_noise_level;
409 frame->nb_samples = 1024;
416 for (ch = 0; ch < avctx->
channels; ch++)
417 unpack(
c, &
c->ch[ch],
c->hfr_group_count, packed_noise_level,
c->ath);
419 for (
int i = 0;
i < 8;
i++) {
420 for (ch = 0; ch < avctx->
channels; ch++)
422 for (ch = 0; ch < avctx->
channels; ch++)
424 c->stereo_band_count +
c->base_band_count,
c->total_band_count);
425 for (ch = 0; ch < avctx->
channels - 1; ch++)
427 c->total_band_count -
c->base_band_count,
428 c->base_band_count,
c->stereo_band_count);
429 for (ch = 0; ch < avctx->
channels; ch++)
@ AV_SAMPLE_FMT_FLTP
float, planar
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
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
int sample_rate
samples per second
static enum AVSampleFormat sample_fmts[]
static void unpack(HCAContext *c, ChannelContext *ch, unsigned hfr_group_count, int packed_noise_level, const uint8_t *ath)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
This structure describes decoded (raw) audio or video data.
static void apply_intensity_stereo(HCAContext *s, ChannelContext *ch1, ChannelContext *ch2, int index, unsigned band_count, unsigned base_band_count, unsigned stereo_band_count)
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 unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static SDL_Window * window
int flags
AV_CODEC_FLAG_*.
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 type
uint8_t bands_per_hfr_group
#define FF_ARRAY_ELEMS(a)
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.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void ath_init1(uint8_t *ath, int sample_rate)
@ AV_TX_FLOAT_MDCT
Standard MDCT with sample data type of float and a scale type of float.
static const float scale_conversion_table[]
static const uint8_t quant_spectrum_bits[]
static av_cold float ath(float f, float add)
Calculate ATH value for given frequency.
static const int8_t quant_spectrum_value[]
static av_cold int decode_init(AVCodecContext *avctx)
static const float quant_step_size[]
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int ath_init(uint8_t *ath, int type, int sample_rate)
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.
static const float dequantizer_scaling_table[]
uint8_t stereo_band_count
static const uint8_t scale_table[]
enum AVSampleFormat sample_fmt
audio sample format
static void reconstruct_hfr(HCAContext *s, ChannelContext *ch, unsigned hfr_group_count, unsigned bands_per_hfr_group, unsigned start_band, unsigned total_band_count)
#define MKBETAG(a, b, c, d)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
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_close(AVCodecContext *avctx)
int channels
number of audio channels
#define DECLARE_ALIGNED(n, t, v)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVSampleFormat
Audio sample formats.
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
static const uint8_t ath_base_curve[656]
const char * name
Name of the codec implementation.
static const uint8_t max_bits_table[]
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
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
static unsigned ceil2(unsigned a, unsigned b)
main external API structure.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Filter the word “frame” indicates either a video frame or a group of audio samples
int8_t scale_factors[128]
static const int factor[16]
static void dequantize_coefficients(HCAContext *c, ChannelContext *ch)
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static const float intensity_ratio_table[]
This structure stores compressed data.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static const int scale_conv_bias
static void run_imdct(HCAContext *c, ChannelContext *ch, int index, float *out)