28 #define UNCHECKED_BITSTREAM_READER 1
50 #define MAX_LSPS_ALIGN16 16
53 #define MAX_FRAMESIZE 160
54 #define MAX_SIGNAL_HISTORY 416
55 #define MAX_SFRAMESIZE (MAX_FRAMESIZE * MAX_FRAMES)
56 #define SFRAME_CACHE_MAXSIZE 256
146 int history_nsamples;
153 int denoise_strength;
155 int denoise_tilt_corr;
164 int frame_lsp_bitsize;
166 int sframe_lsp_bitsize;
173 int block_pitch_nbits;
175 int block_pitch_range;
178 int block_delta_pitch_hrange;
182 uint16_t block_conv_table[4];
196 int has_residual_lsps;
244 int aw_first_pulse_off[2];
247 int aw_next_pulse_off_cache;
255 float gain_pred_err[6];
274 float sin[511], cos[511];
276 float postfilter_agc;
308 int cntr[8] = { 0 }, n, res;
310 memset(vbm_tree, 0xff,
sizeof(vbm_tree[0]) * 25);
311 for (n = 0; n < 17; n++) {
315 vbm_tree[res * 3 + cntr[res]++] = n;
325 10, 10, 10, 12, 12, 12,
328 static const uint16_t codes[] = {
329 0x0000, 0x0001, 0x0002,
330 0x000c, 0x000d, 0x000e,
331 0x003c, 0x003d, 0x003e,
332 0x00fc, 0x00fd, 0x00fe,
333 0x03fc, 0x03fd, 0x03fe,
334 0x0ffc, 0x0ffd, 0x0ffe,
335 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff
339 bits, 1, 1, codes, 2, 2, 132);
347 int n,
flags, pitch_range, lsp16_flag;
360 "Invalid extradata size %d (should be 46)\n",
374 memcpy(&s->
sin[255], s->
cos, 256 *
sizeof(s->
cos[0]));
375 for (n = 0; n < 255; n++) {
376 s->
sin[n] = -s->
sin[510 - n];
377 s->
cos[510 - n] = s->
cos[n];
383 "Invalid denoise filter strength %d (max=11)\n",
391 lsp16_flag = flags & 0x1000;
401 for (n = 0; n < s->
lsps; n++)
413 if (pitch_range <= 0) {
423 int min_sr = ((((1 << 8) - 50) * 400) + 0xFF) >> 8,
427 "Unsupported samplerate %d (min=%d, max=%d)\n",
477 const float *speech_synth,
478 int size,
float alpha,
float *gain_mem)
481 float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;
482 float mem = *gain_mem;
484 for (i = 0; i <
size; i++) {
485 speech_energy += fabsf(speech_synth[i]);
486 postfilter_energy += fabsf(in[i]);
488 gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
490 for (i = 0; i <
size; i++) {
491 mem = alpha * mem + gain_scale_factor;
492 out[i] = in[i] * mem;
520 float optimal_gain = 0, dot;
528 if (dot > optimal_gain) {
532 }
while (--ptr >= end);
534 if (optimal_gain <= 0)
540 if (optimal_gain <= dot) {
541 dot = dot / (dot + 0.6 * optimal_gain);
546 for (n = 0; n <
size; n++)
547 out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);
576 int fcb_type,
float *coeffs,
int remainder)
579 float irange, angle_mul, gain_mul, range, sq;
584 #define log_range(var, assign) do { \
585 float tmp = log10f(assign); var = tmp; \
586 max = FFMAX(max, tmp); min = FFMIN(min, tmp); \
588 log_range(last_coeff, lpcs[1] * lpcs[1]);
589 for (n = 1; n < 64; n++)
590 log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] +
591 lpcs[n * 2 + 1] * lpcs[n * 2 + 1]);
602 irange = 64.0 / range;
605 angle_mul = gain_mul * (8.0 * M_LN10 / M_PI);
606 for (n = 0; n <= 64; n++) {
609 idx =
FFMAX(0,
lrint((max - lpcs[n]) * irange) - 1);
611 lpcs[n] = angle_mul * pwr;
614 idx = (pwr * gain_mul - 0.0295) * 70.570526123;
617 powf(1.0331663, idx - 127);
630 idx = 255 + av_clip(lpcs[64], -255, 255);
631 coeffs[0] = coeffs[0] * s->
cos[idx];
632 idx = 255 + av_clip(lpcs[64] - 2 * lpcs[63], -255, 255);
633 last_coeff = coeffs[64] * s->
cos[idx];
635 idx = 255 + av_clip(-lpcs[64] - 2 * lpcs[n - 1], -255, 255);
636 coeffs[n * 2 + 1] = coeffs[n] * s->
sin[idx];
637 coeffs[n * 2] = coeffs[n] * s->
cos[idx];
641 idx = 255 + av_clip( lpcs[64] - 2 * lpcs[n - 1], -255, 255);
642 coeffs[n * 2 + 1] = coeffs[n] * s->
sin[idx];
643 coeffs[n * 2] = coeffs[n] * s->
cos[idx];
651 memset(&coeffs[remainder], 0,
sizeof(coeffs[0]) * (128 - remainder));
655 coeffs[remainder - 1] = 0;
662 for (n = 0; n < remainder; n++)
693 float *synth_pf,
int size,
696 int remainder, lim, n;
702 tilted_lpcs[0] = 1.0;
703 memcpy(&tilted_lpcs[1], lpcs,
sizeof(lpcs[0]) * s->
lsps);
704 memset(&tilted_lpcs[s->
lsps + 1], 0,
705 sizeof(tilted_lpcs[0]) * (128 - s->
lsps - 1));
707 tilted_lpcs, s->
lsps + 2);
713 remainder =
FFMIN(127 - size, size - 1);
718 memset(&synth_pf[size], 0,
sizeof(synth_pf[0]) * (128 - size));
721 synth_pf[0] *= coeffs[0];
722 synth_pf[1] *= coeffs[1];
723 for (n = 1; n < 64; n++) {
724 float v1 = synth_pf[n * 2], v2 = synth_pf[n * 2 + 1];
725 synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1];
726 synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1];
734 for (n = 0; n < lim; n++)
744 for (n = 0; n < lim; n++)
746 if (lim < remainder) {
775 float *samples,
int size,
776 const float *lpcs,
float *zero_exc_pf,
777 int fcb_type,
int pitch)
781 *synth_filter_in = zero_exc_pf;
790 synth_filter_in = synth_filter_in_buf;
794 synth_filter_in, size, s->
lsps);
795 memcpy(&synth_pf[-s->
lsps], &synth_pf[size - s->
lsps],
796 sizeof(synth_pf[0]) * s->
lsps);
808 (
const float[2]) { -1.99997, 1.0 },
809 (
const float[2]) { -1.9330735188, 0.93589198496 },
829 const uint16_t *values,
830 const uint16_t *
sizes,
831 int n_stages,
const uint8_t *table,
833 const double *base_q)
837 memset(lsps, 0, num *
sizeof(*lsps));
838 for (n = 0; n < n_stages; n++) {
839 const uint8_t *t_off = &table[values[n] * num];
840 double base = base_q[n], mul = mul_q[n];
842 for (m = 0; m < num; m++)
843 lsps[m] += base + mul * t_off[m];
845 table += sizes[n] * num;
862 static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 };
863 static const double mul_lsf[4] = {
864 5.2187144800e-3, 1.4626986422e-3,
865 9.6179549166e-4, 1.1325736225e-3
867 static const double base_lsf[4] = {
868 M_PI * -2.15522e-1, M_PI * -6.1646e-2,
869 M_PI * -3.3486e-2, M_PI * -5.7408e-2
887 double *i_lsps,
const double *old,
888 double *a1,
double *a2,
int q_mode)
890 static const uint16_t vec_sizes[3] = { 128, 64, 64 };
891 static const double mul_lsf[3] = {
892 2.5807601174e-3, 1.2354460219e-3, 1.1763821673e-3
894 static const double base_lsf[3] = {
895 M_PI * -1.07448e-1, M_PI * -5.2706e-2, M_PI * -5.1634e-2
897 const float (*ipol_tab)[2][10] = q_mode ?
899 uint16_t interpol, v[3];
909 for (n = 0; n < 10; n++) {
910 double delta = old[n] - i_lsps[n];
911 a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n];
912 a1[10 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n];
924 static const uint16_t vec_sizes[5] = { 256, 64, 128, 64, 128 };
925 static const double mul_lsf[5] = {
926 3.3439586280e-3, 6.9908173703e-4,
927 3.3216608306e-3, 1.0334960326e-3,
930 static const double base_lsf[5] = {
931 M_PI * -1.27576e-1, M_PI * -2.4292e-2,
932 M_PI * -1.28094e-1, M_PI * -3.2128e-2,
956 double *i_lsps,
const double *old,
957 double *a1,
double *a2,
int q_mode)
959 static const uint16_t vec_sizes[3] = { 128, 128, 128 };
960 static const double mul_lsf[3] = {
961 1.2232979501e-3, 1.4062241527e-3, 1.6114744851e-3
963 static const double base_lsf[3] = {
964 M_PI * -5.5830e-2, M_PI * -5.2908e-2, M_PI * -5.4776e-2
966 const float (*ipol_tab)[2][16] = q_mode ?
968 uint16_t interpol, v[3];
978 for (n = 0; n < 16; n++) {
979 double delta = old[n] - i_lsps[n];
980 a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n];
981 a1[16 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n];
1008 static const int16_t start_offset[94] = {
1009 -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11,
1010 13, 15, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26,
1011 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43,
1012 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67,
1013 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91,
1014 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115,
1015 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
1016 141, 143, 145, 147, 149, 151, 153, 155, 157, 159
1022 if ((bits =
get_bits(gb, 6)) >= 54) {
1024 bits += (bits - 54) * 3 +
get_bits(gb, 2);
1030 for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ;
1043 if (start_offset[bits] < 0)
1060 uint16_t use_mask_mem[9];
1061 uint16_t *use_mask = use_mask_mem + 2;
1070 pulse_start, n, idx, range, aidx, start_off = 0;
1079 if (block_idx == 0) {
1088 pulse_start = s->
aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0;
1093 memset(&use_mask[-2], 0, 2 *
sizeof(use_mask[0]));
1094 memset( use_mask, -1, 5 *
sizeof(use_mask[0]));
1095 memset(&use_mask[5], 0, 2 *
sizeof(use_mask[0]));
1099 uint16_t *use_mask_ptr = &use_mask[idx >> 4];
1100 int first_sh = 16 - (idx & 15);
1101 *use_mask_ptr++ &= 0xFFFFu << first_sh;
1102 excl_range -= first_sh;
1103 if (excl_range >= 16) {
1104 *use_mask_ptr++ = 0;
1105 *use_mask_ptr &= 0xFFFF >> (excl_range - 16);
1107 *use_mask_ptr &= 0xFFFF >> excl_range;
1112 for (n = 0; n <= aidx; pulse_start++) {
1113 for (idx = pulse_start; idx < 0; idx += fcb->
pitch_lag) ;
1115 if (use_mask[0]) idx = 0x0F;
1116 else if (use_mask[1]) idx = 0x1F;
1117 else if (use_mask[2]) idx = 0x2F;
1118 else if (use_mask[3]) idx = 0x3F;
1119 else if (use_mask[4]) idx = 0x4F;
1123 if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) {
1124 use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15));
1130 fcb->
x[fcb->
n] = start_off;
1154 int n, v_mask, i_mask, sh, n_pulses;
1168 for (n = n_pulses - 1; n >= 0; n--, val >>= sh) {
1169 fcb->
y[fcb->
n] = (val & v_mask) ? -1.0 : 1.0;
1170 fcb->
x[fcb->
n] = (val & i_mask) * n_pulses + n +
1172 while (fcb->
x[fcb->
n] < 0)
1178 int num2 = (val & 0x1FF) >> 1,
delta, idx;
1180 if (num2 < 1 * 79) {
delta = 1; idx = num2 + 1; }
1181 else if (num2 < 2 * 78) {
delta = 3; idx = num2 + 1 - 1 * 77; }
1182 else if (num2 < 3 * 77) {
delta = 5; idx = num2 + 1 - 2 * 76; }
1183 else {
delta = 7; idx = num2 + 1 - 3 * 75; }
1184 v = (val & 0x200) ? -1.0 : 1.0;
1189 fcb->
x[fcb->
n + 1] = idx;
1190 fcb->
y[fcb->
n + 1] = (val & 1) ? -v : v;
1208 static int pRNG(
int frame_cntr,
int block_num,
int block_size)
1220 static const unsigned int div_tbl[9][2] = {
1221 { 8332, 3 * 715827883
U },
1222 { 4545, 0 * 390451573
U },
1223 { 3124, 11 * 268435456
U },
1224 { 2380, 15 * 204522253
U },
1225 { 1922, 23 * 165191050
U },
1226 { 1612, 23 * 138547333
U },
1227 { 1388, 27 * 119304648
U },
1228 { 1219, 16 * 104755300
U },
1229 { 1086, 39 * 93368855
U }
1231 unsigned int z, y, x =
MUL16(block_num, 1877) + frame_cntr;
1232 if (x >= 0xFFFF) x -= 0xFFFF;
1234 y = x - 9 *
MULH(477218589, x);
1235 z = (uint16_t) (x * div_tbl[y][0] +
UMULH(x, div_tbl[y][1]));
1237 return z % (1000 - block_size);
1245 int block_idx,
int size,
1267 for (n = 0; n <
size; n++)
1276 int block_idx,
int size,
1277 int block_pitch_sh2,
1281 static const float gain_coeff[6] = {
1282 0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
1285 int n, idx, gain_weight;
1289 memset(pulses, 0,
sizeof(*pulses) * size);
1306 for (n = 0; n <
size; n++)
1318 for (n = 0; n < 5; n++) {
1324 fcb.
x[fcb.
n] = n + 5 * pos1;
1325 fcb.
y[fcb.
n++] = sign;
1326 if (n < frame_desc->dbl_pulses) {
1328 fcb.
x[fcb.
n] = n + 5 * pos2;
1329 fcb.
y[fcb.
n++] = (pos1 < pos2) ? -sign : sign;
1349 for (n = 0; n < gain_weight; n++)
1355 for (n = 0; n <
size; n +=
len) {
1357 int abs_idx = block_idx * size + n;
1360 int pitch = (pitch_sh16 + 0x6FFF) >> 16;
1361 int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
1362 idx = idx_sh16 >> 16;
1365 next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
1367 next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
1378 int block_pitch = block_pitch_sh2 >> 2;
1379 idx = block_pitch_sh2 & 3;
1386 sizeof(
float) * size);
1391 acb_gain, fcb_gain, size);
1411 int block_idx,
int size,
1412 int block_pitch_sh2,
1413 const double *lsps,
const double *prev_lsps,
1415 float *excitation,
float *synth)
1426 frame_desc, excitation);
1429 fac = (block_idx + 0.5) / frame_desc->
n_blocks;
1430 for (n = 0; n < s->
lsps; n++)
1431 i_lsps[n] = cos(prev_lsps[n] + fac * (lsps[n] - prev_lsps[n]));
1455 const double *lsps,
const double *prev_lsps,
1456 float *excitation,
float *synth)
1459 int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val;
1467 "Invalid frame type VLC code, skipping\n");
1490 int fac = n * 2 + 1;
1492 pitch[n] = (
MUL16(fac, cur_pitch_val) +
1534 last_block_pitch = av_clip(block_pitch,
1540 if (block_pitch < t1) {
1544 if (block_pitch < t2) {
1549 if (block_pitch < t3) {
1556 pitch[n] = bl_pitch_sh2 >> 2;
1561 bl_pitch_sh2 = pitch[n] << 2;
1570 synth_block(s, gb, n, block_nsamples, bl_pitch_sh2,
1572 &excitation[n * block_nsamples],
1573 &synth[n * block_nsamples]);
1582 for (n = 0; n < s->
lsps; n++)
1583 i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n]));
1589 for (n = 0; n < s->
lsps; n++)
1590 i_lsps[n] = cos(lsps[n]);
1592 postfilter(s, &synth[80], &samples[80], 80, lpcs,
1596 memcpy(samples, synth, 160 *
sizeof(synth[0]));
1636 lsps[0] =
FFMAX(lsps[0], 0.0015 * M_PI);
1637 for (n = 1; n < num; n++)
1638 lsps[n] =
FFMAX(lsps[n], lsps[n - 1] + 0.0125 * M_PI);
1639 lsps[num - 1] =
FFMIN(lsps[num - 1], 0.9985 * M_PI);
1643 for (n = 1; n < num; n++) {
1644 if (lsps[n] < lsps[n - 1]) {
1645 for (m = 1; m < num; m++) {
1646 double tmp = lsps[m];
1647 for (l = m - 1; l >= 0; l--) {
1648 if (lsps[l] <= tmp)
break;
1649 lsps[l + 1] = lsps[l];
1671 int n, need_bits, bd_idx;
1693 int aw_idx_is_ext = 0;
1723 need_bits = 2 * !aw_idx_is_ext;
1757 int n, res, n_samples = 480;
1766 s->
lsps *
sizeof(*synth));
1793 if ((n_samples =
get_bits(gb, 12)) > 480) {
1795 "Superframe encodes >480 samples (%d), not allowed\n",
1804 for (n = 0; n < s->
lsps; n++)
1805 prev_lsps[n] = s->
prev_lsps[n] - mean_lsf[n];
1812 for (n = 0; n < s->
lsps; n++) {
1813 lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]);
1814 lsps[1][n] = mean_lsf[n] + (a1[s->
lsps + n] - a2[n * 2 + 1]);
1815 lsps[2][n] += mean_lsf[n];
1817 for (n = 0; n < 3; n++)
1828 samples = (
float *)frame->
data[0];
1831 for (n = 0; n < 3; n++) {
1835 if (s->
lsps == 10) {
1840 for (m = 0; m < s->
lsps; m++)
1841 lsps[n][m] += mean_lsf[m];
1847 lsps[n], n == 0 ? s->
prev_lsps : lsps[n - 1],
1849 &synth[s->
lsps + n * MAX_FRAMESIZE]))) {
1869 s->
lsps *
sizeof(*synth));
1900 }
while (res == 0x3F);
1925 int rmn_bytes, rmn_bits;
1928 if (rmn_bits < nbits)
1932 rmn_bits &= 7; rmn_bytes >>= 3;
1933 if ((rmn_bits =
FFMIN(rmn_bits, nbits)) > 0)
1936 FFMIN(nbits - rmn_bits, rmn_bytes << 3));
1951 int *got_frame_ptr,
AVPacket *avpkt)
2005 }
else if (*got_frame_ptr) {
2047 for (n = 0; n < s->
lsps; n++)
Description of frame types.
static void aw_pulse_set1(WMAVoiceContext *s, GetBitContext *gb, int block_idx, AMRFixed *fcb)
Apply first set of pitch-adaptive window pulses.
av_cold void ff_rdft_end(RDFTContext *s)
static const uint8_t wmavoice_dq_lsp16r2[0x500]
int do_apf
whether to apply the averaged projection filter (APF)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int pRNG(int frame_cntr, int block_num, int block_size)
Generate a random number from frame_cntr and block_idx, which will lief in the range [0...
static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
Set up the variable bit mode (VBM) tree from container extradata.
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
float gain_pred_err[6]
cache for gain prediction
This structure describes decoded (raw) audio or video data.
int aw_next_pulse_off_cache
the position (relative to start of the second block) at which pulses should start to be positioned...
int frame_lsp_bitsize
size (in bits) of LSPs, when encoded per-frame (independent coding)
uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE+FF_INPUT_BUFFER_PADDING_SIZE]
cache for superframe data split over multiple packets
float postfilter_agc
gain control memory, used in adaptive_gain_control()
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)
Apply an order 2 rational transfer function in-place.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void postfilter(WMAVoiceContext *s, const float *synth, float *samples, int size, const float *lpcs, float *zero_exc_pf, int fcb_type, int pitch)
Averaging projection filter, the postfilter used in WMAVoice.
memory handling functions
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)
float implementation of weighted sum of two vectors.
static void skip_bits_long(GetBitContext *s, int n)
float synth_filter_out_buf[0x80+MAX_LSPS_ALIGN16]
aligned buffer for postfilter speech synthesis
static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb, const int *pitch)
Parse the offset of the first pitch-adaptive window pulses, and the distribution of pulses between th...
int aw_n_pulses[2]
number of AW-pulses in each block; note that this number can be negative (in which case it basically ...
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
static void stabilize_lsps(double *lsps, int num)
Ensure minimum value for first item, maximum value for last value, proper spacing between each value ...
#define DECLARE_ALIGNED(n, t, v)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static const float wmavoice_gain_codebook_fcb[128]
static const uint8_t wmavoice_dq_lsp16i1[0x640]
static const uint8_t wmavoice_dq_lsp16r1[0x500]
int spillover_nbits
number of bits of the previous packet's last superframe preceding this packet's first full superframe...
void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
Add fixed vector to an array from a sparse representation.
int block_pitch_nbits
number of bits used to specify the first block's pitch value
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)
Synthesize output samples for a single frame.
static void calc_input_response(WMAVoiceContext *s, float *lpcs, int fcb_type, float *coeffs, int remainder)
Derive denoise filter coefficients (in real domain) from the LPCs.
static void dequant_lsp10i(GetBitContext *gb, double *lsps)
Parse 10 independently-coded LSPs.
#define MAX_LSPS_ALIGN16
same as MAX_LSPS; needs to be multiple
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb, int block_idx, AMRFixed *fcb)
Apply second set of pitch-adaptive window pulses.
static const float wmavoice_ipol1_coeffs[17 *9]
static const uint8_t wmavoice_dq_lsp16i2[0x3c0]
Per-block pitch with signal generation using a Hamming sinc window function.
int spillover_bitsize
number of bits used to specify spillover_nbits in the packet header = ceil(log2(ctx->block_align << 3...
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int block_delta_pitch_nbits
number of bits used to specify the delta pitch between this and the last block's pitch value...
no adaptive codebook (only hardcoded fixed)
enum AVSampleFormat sample_fmt
audio sample format
Sparse representation for the algebraic codebook (fixed) vector.
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]
index of first sample to which to apply AW-pulses, or -0xff if unset
int has_residual_lsps
if set, superframes contain one set of LSPs that cover all frames, encoded as independent and residua...
float tilted_lpcs_pf[0x80]
aligned buffer for LPC tilting
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static float tilt_factor(const float *lpcs, int n_lpcs)
Get the tilt factor of a formant filter from its transfer function.
Pitch-adaptive window (AW) pulse signals, used in particular for low-bitrate streams.
static const uint8_t wmavoice_dq_lsp10r[0x1400]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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)
Dequantize LSPs.
static int check_bits_for_superframe(GetBitContext *orig_gb, WMAVoiceContext *s)
Test if there's enough bits to read 1 superframe.
static const float wmavoice_ipol2_coeffs[32]
Hamming-window sinc function (num = 32, x = [ 0, 31 ]): (0.54 + 0.46 * cos(2 * M_PI * x / (num - 1)))...
static int get_bits_count(const GetBitContext *s)
float dcf_mem[2]
DC filter history.
bitstream reader API header.
static av_cold void wmavoice_flush(AVCodecContext *ctx)
float synth_history[MAX_LSPS]
see excitation_history
double prev_lsps[MAX_LSPS]
LSPs of the last frame of the previous superframe.
static void copy_bits(PutBitContext *pb, const uint8_t *data, int size, GetBitContext *gb, int nbits)
Copy (unaligned) bits from gb/data/size to pb.
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const double wmavoice_mean_lsf16[2][16]
int sframe_cache_size
set to >0 if we have data from an (incomplete) superframe from a previous packet that spilled over in...
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const float wmavoice_gain_silence[256]
int denoise_filter_cache_size
samples in denoise_filter_cache
int history_nsamples
number of samples in history for signal prediction (through ACB)
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]
LUT for 1.071575641632 * pow(1.0331663, n - 127)
void av_log(void *avcl, int level, const char *fmt,...)
Windows Media Voice (WMAVoice) tables.
const char * name
Name of the codec implementation.
int denoise_tilt_corr
Whether to apply tilt correction to the Wiener filter coefficients (postfilter)
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
int aw_idx_is_ext
whether the AW index was encoded in 8 bits (instead of 6)
uint16_t block_conv_table[4]
boundaries for block pitch unit/scale conversion
hardcoded (fixed) codebook with per-block gain values
DCTContext dst
contexts for phase shift (in Hilbert transform, part of postfilter)
int lsp_def_mode
defines different sets of LSP defaults [0, 1]
uint64_t channel_layout
Audio channel layout.
static int put_bits_count(PutBitContext *s)
int skip_bits_next
number of bits to skip at the next call to wmavoice_decode_packet() (since they're part of the previo...
static void dequant_lsp16r(GetBitContext *gb, double *i_lsps, const double *old, double *a1, double *a2, int q_mode)
Parse 16 independently-coded LSPs, and then derive the tables to generate LSPs for the other frames f...
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int min_pitch_val
base value for pitch parsing code
WMA Voice decoding context.
static void wiener_denoise(WMAVoiceContext *s, int fcb_type, float *synth_pf, int size, const float *lpcs)
This function applies a Wiener filter on the (noisy) speech signal as a means to denoise it...
int denoise_strength
strength of denoising in Wiener filter [0-11]
audio channel layout utility functions
#define log_range(var, assign)
#define MAX_LSPS
maximum filter order
static VLC frame_type_vlc
Frame type VLC coding.
int pitch_nbits
number of bits used to specify the pitch value in the frame header
#define MAX_BLOCKS
maximum number of blocks per frame
float denoise_coeffs_pf[0x80]
aligned buffer for denoise coefficients
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)
Parse 10 independently-coded LSPs, and then derive the tables to generate LSPs for the other frames f...
static av_always_inline unsigned UMULH(unsigned a, unsigned b)
Innovation (fixed) codebook pulse sets in combinations of either single pulses or pulse pairs...
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
void(* rdft_calc)(struct RDFTContext *s, FFTSample *z)
static int kalman_smoothen(WMAVoiceContext *s, int pitch, const float *in, float *out, int size)
Kalman smoothing function.
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
Apply tilt compensation filter, 1 - tilt * z-1.
if(ac->has_optimized_func)
void ff_sine_window_init(float *window, int n)
Generate a sine window.
static const float wmavoice_gain_universal[64]
void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
Reconstruct LPC coefficients from the line spectral pair frequencies.
static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
Set up decoder with parameters from demuxer (extradata etc.).
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int sframe_lsp_bitsize
size (in bits) of LSPs, when encoded per superframe (residual coding)
static const uint8_t last_coeff[3]
static const struct frame_type_desc frame_descs[17]
float denoise_filter_cache[MAX_FRAMESIZE]
Libavcodec external API header.
int sample_rate
samples per second
static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Packet decoding: a packet is anything that the (ASF) demuxer contains, and we expect that the demuxer...
main external API structure.
static int parse_packet_header(WMAVoiceContext *s)
Parse the packet header at the start of each packet (input data to this decoder). ...
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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)
Parse data in a single block.
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)
Set up DCT.
int pitch_diff_sh16
((cur_pitch_val - last_pitch_val) << 16) / MAX_FRAMESIZE
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define MAX_SFRAMESIZE
maximum number of samples per superframe
int lsp_q_mode
defines quantizer defaults [0, 1]
int frame_cntr
current frame index [0 - 0xFFFE]; is only used for comfort noise in pRNG()
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP zero synthesis filter.
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)
Adaptive gain control (as used in postfilter).
static const float mean_lsf[10]
#define SFRAME_CACHE_MAXSIZE
maximum cache size for frame data that
uint8_t fcb_type
Fixed codebook type (FCB_TYPE_*)
static void dequant_lsp16i(GetBitContext *gb, double *lsps)
Parse 16 independently-coded LSPs.
RDFTContext irdft
contexts for FFT-calculation in the postfilter (for denoise filter)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int synth_superframe(AVCodecContext *ctx, AVFrame *frame, int *got_frame_ptr)
Synthesize output samples for a single superframe.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
#define CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
static void synth_block_hardcoded(WMAVoiceContext *s, GetBitContext *gb, int block_idx, int size, const struct frame_type_desc *frame_desc, float *excitation)
Parse hardcoded signal for a single block.
uint8_t n_blocks
amount of blocks per frame (each block (contains 160/n_blocks samples)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static av_cold void wmavoice_init_static_data(AVCodec *codec)
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
float excitation_history[MAX_SIGNAL_HISTORY]
cache of the signal of previous superframes, used as a history for signal generation ...
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_cold int init(AVCodecParserContext *s)
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)
comfort noise during silence generated from a hardcoded (fixed) codebook with per-frame (low) gain va...
void ff_acelp_interpolatef(float *out, const float *in, const float *filter_coeffs, int precision, int frac_pos, int filter_length, int length)
Floating point version of ff_acelp_interpolate()
int block_delta_pitch_hrange
1/2 range of the delta (full range is from -this to +this-1)
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
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
PutBitContext pb
bitstream writer for sframe_cache
uint8_t acb_type
Adaptive codebook type (ACB_TYPE_*)
static const float wmavoice_denoise_power_table[12][64]
LUT for f(x,y) = pow((y + 6.9) / 64, 0.025 * (x + 1)).
int dc_level
Predicted amount of DC noise, based on which a DC removal filter is used.
#define VLC_NBITS
number of bits to read per VLC iteration
static const float wmavoice_lsp16_intercoeff_a[32][2][16]
float cos[511]
8-bit cosine/sine windows over [-pi,pi] range
#define AV_CH_LAYOUT_MONO
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
Set up a real FFT.
int aw_pulse_range
the range over which aw_pulse_set1() can apply the pulse, relative to the value in aw_first_pulse_off...
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
float zero_exc_pf[MAX_SIGNAL_HISTORY+MAX_SFRAMESIZE]
zero filter output (i.e.
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)
Parse FCB/ACB signal for a single block.
uint8_t dbl_pulses
how many pulse vectors have pulse pairs (rather than just one single pulse) only if fcb_type == FCB_T...
adaptive codebook with per-frame pitch, which we interpolate to get a per-sample pitch.
#define MAX_SIGNAL_HISTORY
maximum excitation signal history
uint16_t frame_size
the amount of bits that make up the block data (per frame)
GetBitContext gb
packet bitreader.