Go to the documentation of this file.
118 grad_range[1] =
get_bits(gb, 6) + 1;
124 if (grad_range[0] >= grad_range[1] || grad_range[1] > 31)
127 if (grad_value[0] > 31 || grad_value[1] > 31)
130 if (
b->grad_boundary >
b->q_unit_cnt)
133 values = grad_value[1] - grad_value[0];
134 sign = 1 - 2*(
values < 0);
135 base = grad_value[0] + sign;
137 curve =
s->alloc_curve[grad_range[1] - grad_range[0] - 1];
139 for (
int i = 0;
i <=
b->q_unit_cnt;
i++)
140 b->gradient[
i] = grad_value[
i >= grad_range[0]];
142 for (
int i = grad_range[0];
i < grad_range[1];
i++)
143 b->gradient[
i] =
base + sign*((
int)(scale*curve[
i - grad_range[0]]));
151 memset(
c->precision_mask, 0,
sizeof(
c->precision_mask));
152 for (
int i = 1;
i <
b->q_unit_cnt;
i++) {
153 const int delta =
FFABS(
c->scalefactors[
i] -
c->scalefactors[
i - 1]) - 1;
155 const int neg =
c->scalefactors[
i - 1] >
c->scalefactors[
i];
161 for (
int i = 0;
i <
b->q_unit_cnt;
i++) {
162 c->precision_coarse[
i] =
c->scalefactors[
i];
163 c->precision_coarse[
i] +=
c->precision_mask[
i] -
b->gradient[
i];
164 if (
c->precision_coarse[
i] < 0)
166 switch (
b->grad_mode) {
168 c->precision_coarse[
i] >>= 1;
171 c->precision_coarse[
i] = (3 *
c->precision_coarse[
i]) >> 3;
174 c->precision_coarse[
i] >>= 2;
179 for (
int i = 0;
i <
b->q_unit_cnt;
i++)
180 c->precision_coarse[
i] =
c->scalefactors[
i] -
b->gradient[
i];
184 for (
int i = 0;
i <
b->q_unit_cnt;
i++)
185 c->precision_coarse[
i] =
FFMAX(
c->precision_coarse[
i], 1);
187 for (
int i = 0;
i <
b->grad_boundary;
i++)
188 c->precision_coarse[
i]++;
190 for (
int i = 0;
i <
b->q_unit_cnt;
i++) {
191 c->precision_fine[
i] = 0;
192 if (
c->precision_coarse[
i] > 15) {
193 c->precision_fine[
i] =
FFMIN(
c->precision_coarse[
i], 30) - 15;
194 c->precision_coarse[
i] = 15;
204 if (
b->has_band_ext) {
205 if (
b->q_unit_cnt < 13 ||
b->q_unit_cnt > 20)
209 b->channel[1].band_ext =
get_bits(gb, 2);
210 b->channel[1].band_ext = ext_band > 2 ?
b->channel[1].band_ext : 4;
217 if (!
b->has_band_ext_data)
220 if (!
b->has_band_ext) {
226 b->channel[0].band_ext =
get_bits(gb, 2);
227 b->channel[0].band_ext = ext_band > 2 ?
b->channel[0].band_ext : 4;
230 for (
int i = 0;
i <= stereo;
i++) {
233 for (
int j = 0; j <
count; j++) {
242 for (
int i = 0;
i <= stereo;
i++) {
245 for (
int j = 0; j <
count; j++) {
256 int channel_idx,
int first_in_pkt)
258 static const uint8_t mode_map[2][4] = { { 0, 1, 2, 3 }, { 0, 2, 3, 4 } };
259 const int mode = mode_map[channel_idx][
get_bits(gb, 2)];
261 memset(
c->scalefactors, 0,
sizeof(
c->scalefactors));
263 if (first_in_pkt && (
mode == 4 || ((
mode == 3) && !channel_idx))) {
277 for (
int i = 1;
i <
b->band_ext_q_unit;
i++) {
279 c->scalefactors[
i] =
val & ((1 <<
len) - 1);
282 for (
int i = 0;
i <
b->band_ext_q_unit;
i++)
283 c->scalefactors[
i] +=
base - sf_weights[
i];
290 for (
int i = 0;
i <
b->band_ext_q_unit;
i++)
296 const int *baseline =
mode == 4 ?
c->scalefactors_prev :
297 channel_idx ?
b->channel[0].scalefactors :
298 c->scalefactors_prev;
299 const int baseline_len =
mode == 4 ?
b->q_unit_cnt_prev :
300 channel_idx ?
b->band_ext_q_unit :
304 const int unit_cnt =
FFMIN(
b->band_ext_q_unit, baseline_len);
307 for (
int i = 0;
i < unit_cnt;
i++) {
309 c->scalefactors[
i] = baseline[
i] + dist;
312 for (
int i = unit_cnt;
i <
b->band_ext_q_unit;
i++)
318 const int *baseline = channel_idx ?
b->channel[0].scalefactors :
319 c->scalefactors_prev;
320 const int baseline_len = channel_idx ?
b->band_ext_q_unit :
325 const int unit_cnt =
FFMIN(
b->band_ext_q_unit, baseline_len);
330 for (
int i = 1;
i < unit_cnt;
i++) {
332 c->scalefactors[
i] =
val & ((1 <<
len) - 1);
335 for (
int i = 0;
i < unit_cnt;
i++)
336 c->scalefactors[
i] +=
base + baseline[
i];
338 for (
int i = unit_cnt;
i <
b->band_ext_q_unit;
i++)
344 for (
int i = 0;
i <
b->band_ext_q_unit;
i++)
345 if (
c->scalefactors[
i] < 0 ||
c->scalefactors[
i] > 31)
348 memcpy(
c->scalefactors_prev,
c->scalefactors,
sizeof(
c->scalefactors));
357 const int last_sf =
c->scalefactors[
c->q_unit_cnt];
359 memset(
c->codebookset, 0,
sizeof(
c->codebookset));
361 if (
c->q_unit_cnt <= 1)
363 if (
s->samplerate_idx > 7)
366 c->scalefactors[
c->q_unit_cnt] =
c->scalefactors[
c->q_unit_cnt - 1];
368 if (
c->q_unit_cnt > 12) {
369 for (
int i = 0;
i < 12;
i++)
370 avg +=
c->scalefactors[
i];
374 for (
int i = 8;
i <
c->q_unit_cnt;
i++) {
375 const int prev =
c->scalefactors[
i - 1];
376 const int cur =
c->scalefactors[
i ];
377 const int next =
c->scalefactors[
i + 1];
379 if ((cur -
min >= 3 || 2*cur - prev - next >= 3))
380 c->codebookset[
i] = 1;
384 for (
int i = 12;
i <
c->q_unit_cnt;
i++) {
385 const int cur =
c->scalefactors[
i];
387 const int min =
FFMIN(
c->scalefactors[
i + 1],
c->scalefactors[
i - 1]);
388 if (
c->codebookset[
i])
391 c->codebookset[
i] = (((cur -
min) >= 2) && (cur >= (
avg - cnd)));
394 c->scalefactors[
c->q_unit_cnt] = last_sf;
400 const int max_prec =
s->samplerate_idx > 7 ? 1 : 7;
402 memset(
c->q_coeffs_coarse, 0,
sizeof(
c->q_coeffs_coarse));
404 for (
int i = 0;
i <
c->q_unit_cnt;
i++) {
407 const int prec =
c->precision_coarse[
i] + 1;
409 if (prec <= max_prec) {
410 const int cb =
c->codebookset[
i];
412 const VLC *
tab = &
s->coeff_vlc[
cb][prec][cbi];
416 for (
int j = 0; j < groups; j++) {
419 for (
int k = 0; k < huff->
value_cnt; k++) {
427 for (
int j = 0; j <
bands; j++)
436 memset(
c->q_coeffs_fine, 0,
sizeof(
c->q_coeffs_fine));
438 for (
int i = 0;
i <
c->q_unit_cnt;
i++) {
441 const int len =
c->precision_fine[
i] + 1;
443 if (
c->precision_fine[
i] <= 0)
454 memset(
c->coeffs, 0,
sizeof(
c->coeffs));
456 for (
int i = 0;
i <
c->q_unit_cnt;
i++) {
464 const float vc =
c->q_coeffs_coarse[j] * coarse_c;
465 const float vf =
c->q_coeffs_fine[j] * fine_c;
466 c->coeffs[j] = vc + vf;
474 float *
src =
b->channel[
b->cpe_base_channel].coeffs;
475 float *dst =
b->channel[!
b->cpe_base_channel].coeffs;
480 if (
b->q_unit_cnt <=
b->stereo_q_unit)
483 for (
int i =
b->stereo_q_unit; i < b->q_unit_cnt;
i++) {
484 const int sign =
b->is_signs[
i];
488 dst[j] = sign*
src[j];
495 for (
int i = 0;
i <= stereo;
i++) {
496 float *coeffs =
b->channel[
i].coeffs;
497 for (
int j = 0; j <
b->q_unit_cnt; j++) {
500 const int scalefactor =
b->channel[
i].scalefactors[j];
512 for (
int i = 0;
i <
count;
i += 2) {
521 c->coeffs[
start +
i] /= maxval;
525 const int s_unit,
const int e_unit)
527 for (
int i = s_unit;
i < e_unit;
i++) {
531 c->coeffs[j] *= sf[
i - s_unit];
538 const int g_units[4] = {
542 FFMAX(g_units[2], 22),
545 const int g_bins[4] = {
552 for (
int ch = 0;
ch <= stereo;
ch++) {
556 for (
int i = 0;
i < 3;
i++)
557 for (
int j = 0; j < (g_bins[
i + 1] - g_bins[
i + 0]); j++)
558 c->coeffs[g_bins[
i] + j] =
c->coeffs[g_bins[
i] - j - 1];
560 switch (
c->band_ext) {
562 float sf[6] = { 0.0f };
563 const int l = g_units[3] - g_units[0] - 1;
596 for (
int i = g_units[0];
i < g_units[3];
i++)
604 const float g_sf[2] = {
609 for (
int i = 0;
i < 2;
i++)
610 for (
int j = g_bins[
i + 0]; j < g_bins[
i + 1]; j++)
611 c->coeffs[j] *= g_sf[
i];
618 for (
int i = g_bins[0];
i < g_bins[3];
i++) {
620 c->coeffs[
i] *= scale;
626 const float g_sf[3] = { 0.7079468f*m, 0.5011902f*m, 0.3548279f*m };
628 for (
int i = 0;
i < 3;
i++)
629 for (
int j = g_bins[
i + 0]; j < g_bins[
i + 1]; j++)
630 c->coeffs[j] *= g_sf[
i];
639 int frame_idx,
int block_idx)
647 const int precision = reuse_params ? 8 : 4;
648 c->q_unit_cnt =
b->q_unit_cnt = 2;
650 memset(
c->scalefactors, 0,
sizeof(
c->scalefactors));
651 memset(
c->q_coeffs_fine, 0,
sizeof(
c->q_coeffs_fine));
652 memset(
c->q_coeffs_coarse, 0,
sizeof(
c->q_coeffs_coarse));
654 for (
int i = 0;
i <
b->q_unit_cnt;
i++) {
656 c->precision_coarse[
i] = precision;
657 c->precision_fine[
i] = 0;
660 for (
int i = 0;
i <
c->q_unit_cnt;
i++) {
664 c->q_coeffs_coarse[j] =
get_bits(gb,
c->precision_coarse[
i] + 1);
673 if (first_in_pkt && reuse_params) {
680 int stereo_band, ext_band;
681 const int min_band_count =
s->samplerate_idx > 7 ? 1 : 3;
683 b->band_count =
get_bits(gb, 4) + min_band_count;
686 b->band_ext_q_unit =
b->stereo_q_unit =
b->q_unit_cnt;
695 stereo_band =
get_bits(gb, 4) + min_band_count;
696 if (stereo_band >
b->band_count) {
705 if (
b->has_band_ext) {
706 ext_band =
get_bits(gb, 4) + min_band_count;
707 if (ext_band < b->band_count) {
726 b->cpe_base_channel = 0;
730 for (
int i =
b->stereo_q_unit; i < b->q_unit_cnt;
i++)
743 for (
int i = 0;
i <= stereo;
i++) {
745 c->q_unit_cnt =
i ==
b->cpe_base_channel ?
b->q_unit_cnt :
757 b->q_unit_cnt_prev =
b->has_band_ext ?
b->band_ext_q_unit :
b->q_unit_cnt;
762 if (
b->has_band_ext &&
b->has_band_ext_data)
766 for (
int i = 0;
i <= stereo;
i++) {
768 const int dst_idx =
s->block_config->plane_map[block_idx][
i];
769 const int wsize = 1 <<
s->frame_log2;
770 const ptrdiff_t
offset = wsize*frame_idx*
sizeof(float);
771 float *dst = (
float *)(
frame->extended_data[dst_idx] +
offset);
773 s->imdct.imdct_half(&
s->imdct,
s->temp,
c->coeffs);
774 s->fdsp->vector_fmul_window(dst,
c->prev_win,
s->temp,
775 s->imdct_win, wsize >> 1);
776 memcpy(
c->prev_win,
s->temp + (wsize >> 1),
sizeof(
float)*wsize >> 1);
783 int *got_frame_ptr,
AVPacket *avpkt)
799 for (
int j = 0; j <
s->block_config->count; j++) {
816 for (
int j = 0; j <
s->block_config->count; j++) {
819 for (
int i = 0;
i <= stereo;
i++) {
821 memset(
c->prev_win, 0,
sizeof(
c->prev_win));
830 for (
int i = 1;
i < 7;
i++)
832 for (
int i = 2;
i < 6;
i++)
834 for (
int i = 0;
i < 2;
i++)
835 for (
int j = 0; j < 8; j++)
836 for (
int k = 0; k < 4; k++)
849 int version, block_config_idx, superframe_idx, alloc_c_len;
881 block_config_idx =
get_bits(&gb, 3);
882 if (block_config_idx > 5) {
898 s->avg_frame_size =
get_bits(&gb, 11) + 1;
901 if (superframe_idx & 1) {
906 s->frame_count = 1 << superframe_idx;
909 if (
ff_mdct_init(&
s->imdct,
s->frame_log2 + 1, 1, 1.0f / 32768.0f))
917 for (
int i = 0;
i < (1 <<
s->frame_log2);
i++) {
918 const int len = 1 <<
s->frame_log2;
919 const float sidx = (
i + 0.5f) /
len;
920 const float eidx = (
len -
i - 0.5f) /
len;
923 s->imdct_win[
i] = s_c / ((s_c * s_c) + (e_c * e_c));
928 for (
int i = 1;
i <= alloc_c_len;
i++)
929 for (
int j = 0; j <
i; j++)
933 for (
int i = 1;
i < 7;
i++) {
941 for (
int i = 2;
i < 6;
i++) {
946 for (
int j = 0; j < nums; j++)
950 hf->
codes, 2, 2, sym,
sizeof(*sym),
sizeof(*sym), 0);
954 for (
int i = 0;
i < 2;
i++) {
955 for (
int j = 0; j < 8; j++) {
956 for (
int k = 0; k < 4; k++) {
static av_cold int atrac9_decode_close(AVCodecContext *avctx)
int32_t q_coeffs_coarse[256]
@ AV_SAMPLE_FMT_FLTP
float, planar
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static av_cold int init(AVCodecContext *avctx)
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
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static double cb(void *priv, double x, double y)
static const float at9_band_ext_scales_m2[]
static int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c, GetBitContext *gb, int channel_idx, int first_in_pkt)
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
static const int at9_tab_samplerates[]
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static void calc_codebook_idx(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c)
static const ATRAC9BlockConfig at9_block_layout[]
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static void read_coeffs_fine(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c, GetBitContext *gb)
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint8_t at9_tab_band_ext_cnt[][6]
static void calc_precision(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c)
if it could not because there are no more frames
static const struct twinvq_data tab
int flags
AV_CODEC_FLAG_*.
uint8_t alloc_curve[48][48]
static void scale_band_ext_coeffs(ATRAC9ChannelData *c, float sf[6], const int s_unit, const int e_unit)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int parse_band_ext(ATRAC9Context *s, ATRAC9BlockData *b, GetBitContext *gb, int stereo)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t at9_tab_sri_max_bands[]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
const uint8_t at9_q_unit_to_codebookidx[]
static void fill_with_noise(ATRAC9Context *s, ATRAC9ChannelData *c, int start, int count)
void av_bmg_get(AVLFG *lfg, double out[2])
Get the next two numbers generated by a Box-Muller Gaussian generator using the random numbers issued...
void ff_free_vlc(VLC *vlc)
static const float bands[]
static const float at9_band_ext_scales_m0[][5][32]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AVCodec ff_atrac9_decoder
static void flush(AVCodecContext *avctx)
static const HuffmanCodebook at9_huffman_sf_unsigned[]
static unsigned int get_bits1(GetBitContext *s)
static av_cold int atrac9_decode_init(AVCodecContext *avctx)
int32_t q_coeffs_fine[256]
static int parse_gradient(ATRAC9Context *s, ATRAC9BlockData *b, GetBitContext *gb)
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
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
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
Context structure for the Lagged Fibonacci PRNG.
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() 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 void apply_band_extension(ATRAC9Context *s, ATRAC9BlockData *b, const int stereo)
enum AVSampleFormat sample_fmt
audio sample format
const char const char void * val
static void dequantize(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c)
static const uint8_t at9_tab_band_q_unit_map[]
static const HuffmanCodebook at9_huffman_sf_signed[]
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 offset
static void skip_bits1(GetBitContext *s)
static int atrac9_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static const int at9_q_unit_to_coeff_idx[]
int channels
number of audio channels
static const float at9_quant_step_coarse[]
#define DECLARE_ALIGNED(n, t, v)
int32_t scalefactors_prev[31]
const ATRAC9BlockConfig * block_config
#define i(width, name, range_min, range_max)
static const uint8_t at9_tab_band_ext_lengths[][6][4]
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 int atrac9_decode_block(ATRAC9Context *s, GetBitContext *gb, ATRAC9BlockData *b, AVFrame *frame, int frame_idx, int block_idx)
static const float at9_band_ext_scales_m3[][2]
static const float at9_scalefactor_c[]
static const float at9_band_ext_scales_m4[]
const char * name
Name of the codec implementation.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
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
static const uint8_t * align_get_bits(GetBitContext *s)
#define FF_ARRAY_ELEMS(a)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
static const float at9_quant_step_fine[]
static av_const int sign_extend(int val, unsigned bits)
static void atrac9_decode_flush(AVCodecContext *avctx)
static void apply_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, const int stereo)
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 values
static void read_coeffs_coarse(ATRAC9Context *s, ATRAC9BlockData *b, ATRAC9ChannelData *c, GetBitContext *gb)
static const uint8_t at9_tab_sf_weights[][32]
static const uint8_t at9_tab_band_ext_group[][3]
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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 const uint8_t at9_tab_b_dist[]
static const HuffmanCodebook at9_huffman_coeffs[][8][4]
static const uint8_t at9_tab_sri_frame_log2[]
static void apply_intensity_stereo(ATRAC9Context *s, ATRAC9BlockData *b, const int stereo)
static const uint8_t at9_q_unit_to_coeff_cnt[]