48 #define MAX_LSPS_ALIGN16 16
51 #define MAX_FRAMESIZE 160
52 #define MAX_SIGNAL_HISTORY 416
53 #define MAX_SFRAMESIZE (MAX_FRAMESIZE * MAX_FRAMES)
55 #define SFRAME_CACHE_MAXSIZE 256 181 uint16_t block_conv_table[4];
244 int aw_first_pulse_off[2];
254 float gain_pred_err[6];
273 float sin[511], cos[511];
309 10, 10, 10, 12, 12, 12,
312 static const uint16_t codes[] = {
313 0x0000, 0x0001, 0x0002,
314 0x000c, 0x000d, 0x000e,
315 0x003c, 0x003d, 0x003e,
316 0x00fc, 0x00fd, 0x00fe,
317 0x03fc, 0x03fd, 0x03fe,
318 0x0ffc, 0x0ffd, 0x0ffe,
319 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff
321 int cntr[8] = { 0 },
n, res;
323 memset(vbm_tree, 0xff,
sizeof(vbm_tree[0]) * 25);
324 for (
n = 0;
n < 17;
n++) {
328 vbm_tree[res * 3 + cntr[res]++] =
n;
331 bits, 1, 1, codes, 2, 2, 132);
340 int n,
flags, pitch_range, lsp16_flag;
353 "Invalid extradata size %d (should be 46)\n",
367 memcpy(&s->
sin[255], s->
cos, 256 *
sizeof(s->
cos[0]));
368 for (n = 0; n < 255; n++) {
376 "Invalid denoise filter strength %d (max=11)\n",
384 lsp16_flag = flags & 0x1000;
394 for (n = 0; n < s->
lsps; n++)
406 if (pitch_range <= 0) {
416 int min_sr = ((((1 << 8) - 50) * 400) + 0xFF) >> 8,
420 "Unsupported samplerate %d (min=%d, max=%d)\n",
470 const float *speech_synth,
474 float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;
475 float mem = *gain_mem;
477 for (i = 0; i <
size; i++) {
478 speech_energy += fabsf(speech_synth[i]);
479 postfilter_energy += fabsf(in[i]);
481 gain_scale_factor = (1.0 -
alpha) * speech_energy / postfilter_energy;
483 for (i = 0; i <
size; i++) {
484 mem = alpha * mem + gain_scale_factor;
485 out[
i] = in[
i] *
mem;
513 float optimal_gain = 0, dot;
516 *best_hist_ptr =
NULL;
521 if (dot > optimal_gain) {
525 }
while (--ptr >= end);
527 if (optimal_gain <= 0)
533 if (optimal_gain <= dot) {
534 dot = dot / (dot + 0.6 * optimal_gain);
539 for (n = 0; n <
size; n++)
540 out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);
569 int fcb_type,
float *coeffs,
int remainder)
572 float irange, angle_mul, gain_mul,
range, sq;
577 #define log_range(var, assign) do { \ 578 float tmp = log10f(assign); var = tmp; \ 579 max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ 581 log_range(last_coeff, lpcs[1] * lpcs[1]);
582 for (n = 1; n < 64; n++)
583 log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] +
584 lpcs[n * 2 + 1] * lpcs[n * 2 + 1]);
595 irange = 64.0 /
range;
599 for (n = 0; n <= 64; n++) {
604 lpcs[
n] = angle_mul * pwr;
607 idx = (pwr * gain_mul - 0.0295) * 70.570526123;
610 powf(1.0331663, idx - 127);
623 idx = 255 + av_clip(lpcs[64], -255, 255);
624 coeffs[0] = coeffs[0] * s->
cos[idx];
625 idx = 255 + av_clip(lpcs[64] - 2 * lpcs[63], -255, 255);
626 last_coeff = coeffs[64] * s->
cos[idx];
628 idx = 255 + av_clip(-lpcs[64] - 2 * lpcs[n - 1], -255, 255);
629 coeffs[n * 2 + 1] = coeffs[
n] * s->
sin[idx];
630 coeffs[n * 2] = coeffs[
n] * s->
cos[idx];
634 idx = 255 + av_clip( lpcs[64] - 2 * lpcs[n - 1], -255, 255);
635 coeffs[n * 2 + 1] = coeffs[
n] * s->
sin[idx];
636 coeffs[n * 2] = coeffs[
n] * s->
cos[idx];
644 memset(&coeffs[remainder], 0,
sizeof(coeffs[0]) * (128 - remainder));
648 coeffs[remainder - 1] = 0;
655 for (n = 0; n < remainder; n++)
686 float *synth_pf,
int size,
689 int remainder, lim,
n;
692 float *tilted_lpcs = s->tilted_lpcs_pf,
693 *coeffs = s->denoise_coeffs_pf, tilt_mem = 0;
695 tilted_lpcs[0] = 1.0;
696 memcpy(&tilted_lpcs[1], lpcs,
sizeof(lpcs[0]) * s->
lsps);
697 memset(&tilted_lpcs[s->
lsps + 1], 0,
698 sizeof(tilted_lpcs[0]) * (128 - s->
lsps - 1));
700 tilted_lpcs, s->
lsps + 2);
706 remainder =
FFMIN(127 - size, size - 1);
711 memset(&synth_pf[size], 0,
sizeof(synth_pf[0]) * (128 - size));
714 synth_pf[0] *= coeffs[0];
715 synth_pf[1] *= coeffs[1];
716 for (n = 1; n < 64; n++) {
717 float v1 = synth_pf[n * 2], v2 = synth_pf[n * 2 + 1];
718 synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1];
719 synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1];
727 for (n = 0; n < lim; n++)
737 for (n = 0; n < lim; n++)
739 if (lim < remainder) {
769 const float *lpcs,
float *zero_exc_pf,
774 *synth_filter_in = zero_exc_pf;
783 synth_filter_in = synth_filter_in_buf;
787 synth_filter_in, size, s->
lsps);
788 memcpy(&synth_pf[-s->
lsps], &synth_pf[size - s->
lsps],
789 sizeof(synth_pf[0]) * s->
lsps);
801 (
const float[2]) { -1.99997, 1.0 },
802 (
const float[2]) { -1.9330735188, 0.93589198496 },
823 const uint16_t *
sizes,
826 const double *base_q)
830 memset(lsps, 0, num *
sizeof(*lsps));
831 for (n = 0; n < n_stages; n++) {
832 const uint8_t *t_off = &table[values[
n] * num];
833 double base = base_q[
n], mul = mul_q[
n];
835 for (m = 0; m < num; m++)
836 lsps[m] += base + mul * t_off[m];
838 table += sizes[
n] * num;
855 static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 };
856 static const double mul_lsf[4] = {
857 5.2187144800e-3, 1.4626986422e-3,
858 9.6179549166e-4, 1.1325736225e-3
860 static const double base_lsf[4] = {
861 M_PI * -2.15522e-1,
M_PI * -6.1646e-2,
862 M_PI * -3.3486e-2,
M_PI * -5.7408e-2
880 double *i_lsps,
const double *old,
881 double *
a1,
double *
a2,
int q_mode)
883 static const uint16_t vec_sizes[3] = { 128, 64, 64 };
884 static const double mul_lsf[3] = {
885 2.5807601174e-3, 1.2354460219e-3, 1.1763821673e-3
887 static const double base_lsf[3] = {
888 M_PI * -1.07448e-1,
M_PI * -5.2706e-2,
M_PI * -5.1634e-2
890 const float (*ipol_tab)[2][10] = q_mode ?
902 for (n = 0; n < 10; n++) {
903 double delta = old[
n] - i_lsps[
n];
904 a1[
n] = ipol_tab[
interpol][0][
n] * delta + i_lsps[
n];
905 a1[10 +
n] = ipol_tab[
interpol][1][
n] * delta + i_lsps[
n];
917 static const uint16_t vec_sizes[5] = { 256, 64, 128, 64, 128 };
918 static const double mul_lsf[5] = {
919 3.3439586280e-3, 6.9908173703e-4,
920 3.3216608306e-3, 1.0334960326e-3,
923 static const double base_lsf[5] = {
924 M_PI * -1.27576e-1,
M_PI * -2.4292e-2,
925 M_PI * -1.28094e-1,
M_PI * -3.2128e-2,
949 double *i_lsps,
const double *old,
950 double *
a1,
double *
a2,
int q_mode)
952 static const uint16_t vec_sizes[3] = { 128, 128, 128 };
953 static const double mul_lsf[3] = {
954 1.2232979501e-3, 1.4062241527e-3, 1.6114744851e-3
956 static const double base_lsf[3] = {
959 const float (*ipol_tab)[2][16] = q_mode ?
971 for (n = 0; n < 16; n++) {
972 double delta = old[
n] - i_lsps[
n];
973 a1[
n] = ipol_tab[
interpol][0][
n] * delta + i_lsps[
n];
974 a1[16 +
n] = ipol_tab[
interpol][1][
n] * delta + i_lsps[
n];
1001 static const int16_t start_offset[94] = {
1002 -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11,
1003 13, 15, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26,
1004 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43,
1005 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67,
1006 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91,
1007 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115,
1008 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
1009 141, 143, 145, 147, 149, 151, 153, 155, 157, 159
1015 if ((bits =
get_bits(gb, 6)) >= 54) {
1017 bits += (bits - 54) * 3 +
get_bits(gb, 2);
1023 for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ;
1036 if (start_offset[bits] < 0)
1052 uint16_t use_mask_mem[9];
1053 uint16_t *use_mask = use_mask_mem + 2;
1062 pulse_start,
n, idx,
range, aidx, start_off = 0;
1071 if (block_idx == 0) {
1080 pulse_start = s->
aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0;
1085 memset(&use_mask[-2], 0, 2 *
sizeof(use_mask[0]));
1086 memset( use_mask, -1, 5 *
sizeof(use_mask[0]));
1087 memset(&use_mask[5], 0, 2 *
sizeof(use_mask[0]));
1091 uint16_t *use_mask_ptr = &use_mask[idx >> 4];
1092 int first_sh = 16 - (idx & 15);
1093 *use_mask_ptr++ &= 0xFFFF
u << first_sh;
1094 excl_range -= first_sh;
1095 if (excl_range >= 16) {
1096 *use_mask_ptr++ = 0;
1097 *use_mask_ptr &= 0xFFFF >> (excl_range - 16);
1099 *use_mask_ptr &= 0xFFFF >> excl_range;
1104 for (n = 0; n <= aidx; pulse_start++) {
1105 for (idx = pulse_start; idx < 0; idx += fcb->
pitch_lag) ;
1107 if (use_mask[0]) idx = 0x0F;
1108 else if (use_mask[1]) idx = 0x1F;
1109 else if (use_mask[2]) idx = 0x2F;
1110 else if (use_mask[3]) idx = 0x3F;
1111 else if (use_mask[4]) idx = 0x4F;
1115 if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) {
1116 use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15));
1122 fcb->
x[fcb->
n] = start_off;
1145 int n, v_mask, i_mask, sh, n_pulses;
1159 for (n = n_pulses - 1; n >= 0; n--, val >>= sh) {
1160 fcb->
y[fcb->
n] = (val & v_mask) ? -1.0 : 1.0;
1161 fcb->
x[fcb->
n] = (val & i_mask) * n_pulses + n +
1169 int num2 = (val & 0x1FF) >> 1,
delta, idx;
1171 if (num2 < 1 * 79) {
delta = 1; idx = num2 + 1; }
1172 else if (num2 < 2 * 78) {
delta = 3; idx = num2 + 1 - 1 * 77; }
1173 else if (num2 < 3 * 77) {
delta = 5; idx = num2 + 1 - 2 * 76; }
1174 else {
delta = 7; idx = num2 + 1 - 3 * 75; }
1175 v = (val & 0x200) ? -1.0 : 1.0;
1180 fcb->
x[fcb->
n + 1] = idx;
1181 fcb->
y[fcb->
n + 1] = (val & 1) ? -v : v;
1199 static int pRNG(
int frame_cntr,
int block_num,
int block_size)
1211 static const unsigned int div_tbl[9][2] = {
1212 { 8332, 3 * 715827883
U },
1213 { 4545, 0 * 390451573
U },
1214 { 3124, 11 * 268435456
U },
1215 { 2380, 15 * 204522253
U },
1216 { 1922, 23 * 165191050
U },
1217 { 1612, 23 * 138547333
U },
1218 { 1388, 27 * 119304648
U },
1219 { 1219, 16 * 104755300
U },
1220 { 1086, 39 * 93368855
U }
1222 unsigned int z,
y,
x =
MUL16(block_num, 1877) + frame_cntr;
1223 if (x >= 0xFFFF) x -= 0xFFFF;
1225 y = x - 9 *
MULH(477218589, x);
1226 z = (uint16_t) (x * div_tbl[y][0] +
UMULH(x, div_tbl[y][1]));
1228 return z % (1000 - block_size);
1236 int block_idx,
int size,
1258 for (n = 0; n <
size; n++)
1267 int block_idx,
int size,
1268 int block_pitch_sh2,
1272 static const float gain_coeff[6] = {
1273 0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
1276 int n, idx, gain_weight;
1280 memset(pulses, 0,
sizeof(*pulses) * size);
1298 for (n = 0; n < 5; n++) {
1304 fcb.
x[fcb.
n] = n + 5 * pos1;
1305 fcb.
y[fcb.
n++] = sign;
1308 fcb.
x[fcb.
n] = n + 5 * pos2;
1309 fcb.
y[fcb.
n++] = (pos1 < pos2) ? -sign : sign;
1329 for (n = 0; n < gain_weight; n++)
1335 for (n = 0; n <
size; n +=
len) {
1337 int abs_idx = block_idx * size +
n;
1340 int pitch = (pitch_sh16 + 0x6FFF) >> 16;
1341 int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
1342 idx = idx_sh16 >> 16;
1345 next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
1347 next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
1358 int block_pitch = block_pitch_sh2 >> 2;
1359 idx = block_pitch_sh2 & 3;
1366 sizeof(
float) * size);
1371 acb_gain, fcb_gain, size);
1391 int block_idx,
int size,
1392 int block_pitch_sh2,
1393 const double *lsps,
const double *prev_lsps,
1395 float *excitation,
float *synth)
1406 frame_desc, excitation);
1409 fac = (block_idx + 0.5) / frame_desc->
n_blocks;
1410 for (n = 0; n < s->
lsps; n++)
1411 i_lsps[n] = cos(prev_lsps[n] + fac * (lsps[n] - prev_lsps[n]));
1435 const double *lsps,
const double *prev_lsps,
1436 float *excitation,
float *synth)
1439 int n, n_blocks_x2, log_n_blocks_x2,
av_uninit(cur_pitch_val);
1447 "Invalid frame type VLC code, skipping\n");
1470 int fac = n * 2 + 1;
1472 pitch[
n] = (
MUL16(fac, cur_pitch_val) +
1514 last_block_pitch = av_clip(block_pitch,
1520 if (block_pitch < t1) {
1524 if (block_pitch <
t2) {
1529 if (block_pitch <
t3) {
1536 pitch[
n] = bl_pitch_sh2 >> 2;
1541 bl_pitch_sh2 = pitch[
n] << 2;
1550 synth_block(s, gb, n, block_nsamples, bl_pitch_sh2,
1552 &excitation[n * block_nsamples],
1553 &synth[n * block_nsamples]);
1562 for (n = 0; n < s->
lsps; n++)
1563 i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n]));
1569 for (n = 0; n < s->
lsps; n++)
1570 i_lsps[n] = cos(lsps[n]);
1572 postfilter(s, &synth[80], &samples[80], 80, lpcs,
1576 memcpy(samples, synth, 160 *
sizeof(synth[0]));
1616 lsps[0] =
FFMAX(lsps[0], 0.0015 *
M_PI);
1617 for (n = 1; n < num; n++)
1618 lsps[n] =
FFMAX(lsps[n], lsps[n - 1] + 0.0125 *
M_PI);
1619 lsps[num - 1] =
FFMIN(lsps[num - 1], 0.9985 *
M_PI);
1623 for (n = 1; n < num; n++) {
1624 if (lsps[n] < lsps[n - 1]) {
1625 for (m = 1; m < num; m++) {
1626 double tmp = lsps[
m];
1627 for (l = m - 1; l >= 0; l--) {
1628 if (lsps[l] <= tmp)
break;
1629 lsps[l + 1] = lsps[l];
1651 int n, need_bits, bd_idx;
1673 int aw_idx_is_ext = 0;
1703 need_bits = 2 * !aw_idx_is_ext;
1737 int n, res, n_samples = 480;
1746 s->
lsps *
sizeof(*synth));
1772 if ((n_samples =
get_bits(gb, 12)) > 480) {
1774 "Superframe encodes >480 samples (%d), not allowed\n",
1783 for (n = 0; n < s->
lsps; n++)
1784 prev_lsps[n] = s->
prev_lsps[n] - mean_lsf[n];
1791 for (n = 0; n < s->
lsps; n++) {
1792 lsps[0][
n] = mean_lsf[
n] + (a1[
n] - a2[n * 2]);
1793 lsps[1][
n] = mean_lsf[
n] + (a1[s->
lsps +
n] - a2[n * 2 + 1]);
1794 lsps[2][
n] += mean_lsf[
n];
1796 for (n = 0; n < 3; n++)
1805 samples = (
float *)frame->
data[0];
1808 for (n = 0; n < 3; n++) {
1812 if (s->
lsps == 10) {
1817 for (m = 0; m < s->
lsps; m++)
1818 lsps[n][m] += mean_lsf[m];
1824 lsps[n], n == 0 ? s->
prev_lsps : lsps[n - 1],
1826 &synth[s->
lsps + n * MAX_FRAMESIZE]))) {
1846 s->
lsps *
sizeof(*synth));
1877 }
while (res == 0x3F);
1902 int rmn_bytes, rmn_bits;
1905 if (rmn_bits < nbits)
1909 rmn_bits &= 7; rmn_bytes >>= 3;
1910 if ((rmn_bits =
FFMIN(rmn_bits, nbits)) > 0)
1913 FFMIN(nbits - rmn_bits, rmn_bytes << 3));
1928 int *got_frame_ptr,
AVPacket *avpkt)
1982 }
else if (*got_frame_ptr) {
2024 for (n = 0; n < s->
lsps; n++)
2035 sizeof(*s->synth_filter_out_buf) * s->
lsps);
static void aw_pulse_set1(WMAVoiceContext *s, GetBitContext *gb, int block_idx, AMRFixed *fcb)
av_cold void ff_rdft_end(RDFTContext *s)
static const uint8_t wmavoice_dq_lsp16r2[0x500]
static int pRNG(int frame_cntr, int block_num, int block_size)
static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
float gain_pred_err[6]
cache for gain prediction
int aw_next_pulse_off_cache
uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE+FF_INPUT_BUFFER_PADDING_SIZE]
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, const float zero_coeffs[2], const float pole_coeffs[2], float gain, float mem[2], int n)
static unsigned int get_bits(GetBitContext *s, int n)
static void postfilter(WMAVoiceContext *s, const float *synth, float *samples, int size, const float *lpcs, float *zero_exc_pf, int fcb_type, int pitch)
void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, float weight_coeff_a, float weight_coeff_b, int length)
static void skip_bits_long(GetBitContext *s, int n)
if max(w)>1 w=0.9 *w/max(w)
static av_cold int init(AVCodecContext *avctx)
static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb, const int *pitch)
static int interpol(MBContext *mb, uint32_t *color, int x, int y, int linesize)
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
static void stabilize_lsps(double *lsps, int num)
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
#define DECLARE_ALIGNED(n, t, v)
static const float wmavoice_gain_codebook_fcb[128]
static const uint8_t wmavoice_dq_lsp16i1[0x640]
static const uint8_t wmavoice_dq_lsp16r1[0x500]
void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
static const uint8_t wmavoice_dq_lsp16i3[0x300]
static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *samples, const double *lsps, const double *prev_lsps, float *excitation, float *synth)
static void calc_input_response(WMAVoiceContext *s, float *lpcs, int fcb_type, float *coeffs, int remainder)
static void dequant_lsp10i(GetBitContext *gb, double *lsps)
#define MAX_LSPS_ALIGN16
of 16 for ASM input buffer alignment
static const float wmavoice_ipol1_coeffs[17 *9]
static const uint8_t wmavoice_dq_lsp16i2[0x3c0]
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
int block_delta_pitch_nbits
no adaptive codebook (only hardcoded fixed)
enum AVSampleFormat sample_fmt
sample format
static const uint8_t wmavoice_dq_lsp16r3[0x600]
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
static const float wmavoice_gain_codebook_acb[128]
uint8_t log_n_blocks
log2(n_blocks)
int aw_first_pulse_off[2]
static float tilt_factor(const float *lpcs, int n_lpcs)
static const uint8_t wmavoice_dq_lsp10r[0x1400]
static void dequant_lsps(double *lsps, int num, const uint16_t *values, const uint16_t *sizes, int n_stages, const uint8_t *table, const double *mul_q, const double *base_q)
static int check_bits_for_superframe(GetBitContext *orig_gb, WMAVoiceContext *s)
static const float wmavoice_ipol2_coeffs[32]
static int get_bits_count(const GetBitContext *s)
float dcf_mem[2]
DC filter history.
static av_cold void wmavoice_flush(AVCodecContext *ctx)
float synth_history[MAX_LSPS]
see excitation_history
double prev_lsps[MAX_LSPS]
static void copy_bits(PutBitContext *pb, const uint8_t *data, int size, GetBitContext *gb, int nbits)
static int get_bits_left(GetBitContext *gb)
static double alpha(void *priv, double x, double y)
static const double wmavoice_mean_lsf16[2][16]
static const float wmavoice_lsp10_intercoeff_b[32][2][10]
int block_pitch_range
range of the block pitch
static const float wmavoice_std_codebook[1000]
static const int sizes[][2]
int last_acb_type
frame type [0-2] of the previous frame
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
static const float wmavoice_gain_silence[256]
int denoise_filter_cache_size
samples in denoise_filter_cache
static const uint8_t wmavoice_dq_lsp10i[0xf00]
static const float wmavoice_lsp10_intercoeff_a[32][2][10]
static const float wmavoice_energy_table[128]
void av_log(void *avcl, int level, const char *fmt,...)
Windows Media Voice (WMAVoice) tables.
static void put_bits(J2kEncoderContext *s, int val, int n)
static const uint8_t offset[127][2]
uint16_t block_conv_table[4]
static int put_bits_count(PutBitContext *s)
static void dequant_lsp16r(GetBitContext *gb, double *i_lsps, const double *old, double *a1, double *a2, int q_mode)
#define FF_INPUT_BUFFER_PADDING_SIZE
int min_pitch_val
base value for pitch parsing code
static void wiener_denoise(WMAVoiceContext *s, int fcb_type, float *synth_pf, int size, const float *lpcs)
#define log_range(var, assign)
#define MAX_LSPS
maximum filter order
static VLC frame_type_vlc
#define MAX_BLOCKS
maximum number of blocks per frame
void(* dct_calc)(struct DCTContext *s, FFTSample *data)
static void dequant_lsp10r(GetBitContext *gb, double *i_lsps, const double *old, double *a1, double *a2, int q_mode)
static av_always_inline unsigned UMULH(unsigned a, unsigned b)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
void(* rdft_calc)(struct RDFTContext *s, FFTSample *z)
static int kalman_smoothen(WMAVoiceContext *s, int pitch, const float *in, float *out, int size)
static void flush(AVCodecContext *avctx)
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
void ff_sine_window_init(float *window, int n)
static const float wmavoice_gain_universal[64]
void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const uint8_t last_coeff[3]
static const struct frame_type_desc frame_descs[17]
float denoise_filter_cache[MAX_FRAMESIZE]
int sample_rate
samples per second
static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static int parse_packet_header(WMAVoiceContext *s)
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
AVCodec ff_wmavoice_decoder
int8_t vbm_tree[25]
converts VLC codes to frame type
static unsigned int get_bits1(GetBitContext *s)
static void synth_block(WMAVoiceContext *s, GetBitContext *gb, int block_idx, int size, int block_pitch_sh2, const double *lsps, const double *prev_lsps, const struct frame_type_desc *frame_desc, float *excitation, float *synth)
static av_cold int wmavoice_decode_end(AVCodecContext *ctx)
static void skip_bits(GetBitContext *s, int n)
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
synthesis window for stochastic i
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
#define MAX_SFRAMESIZE
maximum number of samples per superframe
int lsp_q_mode
defines quantizer defaults [0, 1]
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
static av_always_inline av_const long int lrint(double x)
static void adaptive_gain_control(float *out, const float *in, const float *speech_synth, int size, float alpha, float *gain_mem)
static const float mean_lsf[10]
#define SFRAME_CACHE_MAXSIZE
was split over two packets
uint8_t fcb_type
Fixed codebook type (FCB_TYPE_*)
static void dequant_lsp16i(GetBitContext *gb, double *lsps)
uint8_t * data[AV_NUM_DATA_POINTERS]
static int synth_superframe(AVCodecContext *ctx, AVFrame *frame, int *got_frame_ptr)
Synth Windw Norm while(pin< pend)%Until the end...%---Analysis x_w
#define CODEC_CAP_SUBFRAMES
static void synth_block_hardcoded(WMAVoiceContext *s, GetBitContext *gb, int block_idx, int size, const struct frame_type_desc *frame_desc, float *excitation)
static void flush_put_bits(PutBitContext *s)
float excitation_history[MAX_SIGNAL_HISTORY]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
int last_pitch_val
pitch value of the previous frame
#define MAX_FRAMESIZE
maximum number of samples per frame
float silence_gain
set for use in blocks if ACB_TYPE_NONE
static const double wmavoice_mean_lsf10[2][10]
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
av_cold void ff_dct_end(DCTContext *s)
void ff_acelp_interpolatef(float *out, const float *in, const float *filter_coeffs, int precision, int frac_pos, int filter_length, int length)
int block_delta_pitch_hrange
int max_pitch_val
max value + 1 for pitch parsing
int lsps
number of LSPs per frame [10 or 16]
#define MAX_FRAMES
maximum number of frames per superframe
Filter the word “frame” indicates either a video frame or a group of audio samples
static const int8_t pulses[4]
static const float wmavoice_lsp16_intercoeff_b[32][2][16]
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
PutBitContext pb
bitstream writer for sframe_cache
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
uint8_t acb_type
Adaptive codebook type (ACB_TYPE_*)
static const float wmavoice_denoise_power_table[12][64]
#define VLC_NBITS
number of bits to read per VLC iteration
static const float wmavoice_lsp16_intercoeff_a[32][2][16]
#define AV_CH_LAYOUT_MONO
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
float zero_exc_pf[MAX_SIGNAL_HISTORY+MAX_SFRAMESIZE]
static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, int block_idx, int size, int block_pitch_sh2, const struct frame_type_desc *frame_desc, float *excitation)
#define MAX_SIGNAL_HISTORY
maximum excitation signal history
static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb, int block_idx, AMRFixed *fcb)
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 This method is called when a frame is wanted on an output For an 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