rendered paste bodydiff --git a/libavcodec/Makefile b/libavcodec/Makefileindex 19243a5..0af31c5 100644--- a/libavcodec/Makefile+++ b/libavcodec/Makefile@@ -170,6 +170,7 @@ OBJS-$(CONFIG_RV20_ENCODER) += rv10.o mpegvideo_enc.o motion_est.o ra OBJS-$(CONFIG_SGI_DECODER) += sgidec.o OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o golomb.o+OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_lag.o acelp_math.o acelp_vectors.o acelp_filters.o OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMC_DECODER) += smc.odiff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.cindex 6b321da..5c9c950 100644--- a/libavcodec/allcodecs.c+++ b/libavcodec/allcodecs.c@@ -202,6 +202,7 @@ void avcodec_register_all(void) REGISTER_DECODER (RA_144, ra_144); REGISTER_DECODER (RA_288, ra_288); REGISTER_DECODER (SHORTEN, shorten);+ REGISTER_DECODER (SIPR, sipr); REGISTER_DECODER (SMACKAUD, smackaud); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER (SONIC_LS, sonic_ls);diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.hindex 10f7dc9..4da39f5 100644--- a/libavcodec/avcodec.h+++ b/libavcodec/avcodec.h@@ -298,6 +298,7 @@ enum CodecID { CODEC_ID_WMAPRO, CODEC_ID_WMALOSSLESS, CODEC_ID_G729,+ CODEC_ID_SIPR, /* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= 0x17000,diff --git a/libavcodec/sipr.c b/libavcodec/sipr.cnew file mode 100644index 0000000..770c0be--- /dev/null+++ b/libavcodec/sipr.c@@ -0,0 +1,384 @@+#include <inttypes.h>+#include <stdio.h>+#include <math.h>+#include <limits.h>+#include <string.h>++#include "avcodec.h"+#include "random.h"+#define ALT_BITSTREAM_READER_LE+#include "bitstream.h"++#define FRAC_BITS 15+#include "mathops.h"++#include "lsp.h"+#include "acelp_math.h"+#include "acelp_vectors.h"+#include "acelp_pitch_lag.h"+#include "acelp_filters.h"+++#define LP_FILT_ORDER 16+#define L_INTERPOL 11+#define L_SUBFR_16k0 80+#define PIT_MIN 30+#define PIT_MAX 281++#define LSFQ_DIFF_MIN 161 // 50.0 * PI / 8000 in (2.13)+#define LSFQ_MIN LSFQ_DIFF_MIN+#define LSFQ_MAX 25736 // PI in (2.13)++#include "siprdata.h"++typedef struct+{+ int bit_rate;+ int bytes_per_frame;+ int bits_per_frame;++ int len_frame;+ int dec_parms[23];+ AVRandomState random_state;++ const uint8_t* bit_table;++ int old_T0;++ int16_t A_past[LP_FILT_ORDER+1];+ int16_t B_past[LP_FILT_ORDER+1];++ int16_t* exc;++ int16_t past_gain_pit;+ int16_t past_gain_code;+ int16_t past_lsf_q[LP_FILT_ORDER];+ int16_t past_qua_en[2];+ int16_t past_q_target[LP_FILT_ORDER];+ int k; // ma_predictor_prev++ int16_t old_exc[L_INTERPOL + PIT_MAX + 2 * L_SUBFR_16k0];++ int16_t mem_preemph[LP_FILT_ORDER];+ int16_t mem_syn[LP_FILT_ORDER + 2 * L_SUBFR_16k0];++ int16_t lsfold[LP_FILT_ORDER];+} Sipr_Context;++Sipr_Context sctx;++// Same as AMR @12.2 without gray decoding+static void DEC_ACELP_45_85(int* parm, int16_t* code)+{+ int i;++ memset(code, 0, L_SUBFR_16k0 * sizeof(int16_t));++ for(i=0; i<5; i++)+ {+ int index_1 = i + ((parm[i] >> 4) & 0xf) * 5;+ int index_2 = i + ( parm[i] & 0xf) * 5;+ int pulse = (parm[i] & 0x100) ? -8192 : 8192;++ code[index_1] = pulse;+ code[index_2] += (index_2 < index_1) ? -pulse : pulse;+ }+}++static void lsf_restore_from_previous(int16_t* lsf, int16_t *past_q_target, int16_t* past_lsf_q, int k_prev)+{+ int i;++ memcpy(lsf, past_lsf_q, LP_FILT_ORDER * sizeof(int16_t));++ for(i=0; i<LP_FILT_ORDER; i++)+ {+ int tmp = lsf[i] - ((ma_predictor[k_prev] * past_q_target[i]) >> 15);+ past_q_target[i] = (tmp * ma_predictor_sum_inv[k_prev]) >> 13;+ }+}++static int lsf_decode(int16_t* past_q_target, int16_t* lsf, const int* parm)+{+ int i;+ int16_t isp_q[LP_FILT_ORDER];+ int ma_pred_mode = parm[0];++ isp_q[0] = dico1_lsf[parm[1]][0];+ isp_q[1] = dico1_lsf[parm[1]][1];+ isp_q[2] = dico1_lsf[parm[1]][2];++ isp_q[3] = dico2_lsf[parm[2]][0];+ isp_q[4] = dico2_lsf[parm[2]][1];+ isp_q[5] = dico2_lsf[parm[2]][2];++ isp_q[6] = dico3_lsf[parm[3]][0];+ isp_q[7] = dico3_lsf[parm[3]][1];+ isp_q[8] = dico3_lsf[parm[3]][2];++ isp_q[9] = dico4_lsf[parm[4]][0];+ isp_q[10] = dico4_lsf[parm[4]][1];+ isp_q[11] = dico4_lsf[parm[4]][2];++ isp_q[12] = dico5_lsf[parm[5]][0];+ isp_q[13] = dico5_lsf[parm[5]][1];+ isp_q[14] = dico5_lsf[parm[5]][2];+ isp_q[15] = dico5_lsf[parm[5]][3];++ for(i=0; i<LP_FILT_ORDER; i++)+ {+ lsf[i] = (isp_q[i] * ma_predictor_sum[ma_pred_mode] ++ past_q_target[i] * ma_predictor[ma_pred_mode]) >> 15;+ }+ memcpy(past_q_target, isp_q, LP_FILT_ORDER * sizeof(int16_t));++ return ma_pred_mode;+}++static int dec_lag3(int index, int pit_min, int pit_max, int i_subfr, int old_T0)+{+ if(i_subfr == 0)+ {+ if(index < 390)+ return index + 89;+ else+ return 3*index - 689;+ }+ else+ {+ int T0_min = FFMIN(FFMAX(old_T0 - 10, pit_min), pit_max - 19) ;+ if(index < 62)+ return index + 3*T0_min - 1;+ else+ return 3*old_T0 + 1;+ }+}++static int decod_frame_16k(Sipr_Context * ctx, int* parm, int16_t* out_data)+{+ int16_t code[L_SUBFR_16k0];+ int16_t gain_pitch, gain_code;+ int16_t Az[2][LP_FILT_ORDER + 1];+ int16_t lsp[LP_FILT_ORDER];+ int16_t lsf[LP_FILT_ORDER];+ int16_t synth[LP_FILT_ORDER + 2 * L_SUBFR_16k0];++ int bfi, i, i_subfr, T0, T0_frac;+ int16_t B[LP_FILT_ORDER];+ int16_t var348[LP_FILT_ORDER + 30];+ float s;++ bfi = *parm++;+ if(bfi)+ {+ bfi = 1;+ for(i=0; i<5; i++)+ {+ parm[i+8] = av_random(&ctx->random_state) & 0x1ff;+ parm[i+16] = av_random(&ctx->random_state) & 0x1ff;+ }+ lsf_restore_from_previous(lsf, ctx->past_q_target, ctx->past_lsf_q, ctx->k);+ }+ else+ {+ ctx->k = lsf_decode(ctx->past_q_target, lsf, parm);+ ff_acelp_reorder_lsf(lsf, LSFQ_DIFF_MIN, LSFQ_MIN, LSFQ_MAX, LP_FILT_ORDER);+ memcpy(ctx->past_lsf_q, lsf, LP_FILT_ORDER * sizeof(int16_t));+ }+ ff_acelp_lsf2lsp(lsp, lsf, LP_FILT_ORDER);+ parm+=6;++ ff_acelp_lp_decode(&Az[0][0], &Az[1][0], lsp, ctx->lsfold, LP_FILT_ORDER);+ memcpy(ctx->lsfold, lsp, LP_FILT_ORDER * sizeof(int16_t));++ memcpy(synth, ctx->mem_syn, LP_FILT_ORDER * sizeof(int16_t));+ for(i_subfr=0; i_subfr < 2 * L_SUBFR_16k0; i_subfr += L_SUBFR_16k0)+ {+ if(bfi)+ {+ T0 = ctx->old_T0 + 1;+ T0_frac = 0;+ }+ else+ {+ int T0_3x = dec_lag3(parm[0], PIT_MIN, PIT_MAX, i_subfr, ctx->old_T0);+ T0 = T0_3x/3;+ T0_frac = T0_3x%3 - 1;+ }+ ctx->old_T0 = T0;++ if(bfi)+ gain_pitch = ctx->past_gain_pit * 0.95;+ else+ gain_pitch = qua_gain_pitch[parm[1]];+ ctx->past_gain_pit = FFMIN(gain_pitch, 1<<14);++ ff_acelp_interpolate_pitch_vector(+ &ctx->exc[i_subfr], T0, (T0_frac+1)<<1, L_SUBFR_16k0);++ DEC_ACELP_45_85(parm+2, code);++ ff_acelp_fc_enchance_harmonics(code, T0, ctx->past_gain_pit, L_SUBFR_16k0);++ if(bfi)+ {+ ff_acelp_update_past_gain_erasure(ctx->past_qua_en, 2);+ gain_code = (ctx->past_gain_code * 6554 ) >> 13; // 0.8 in Q13+ }+ else+ {+ int gain_corr_factor = qua_gain_code[parm[7]];+ gain_code = ff_acelp_decode_gain_code(+ gain_corr_factor,+ code,+ 19<<13,+ ctx->past_qua_en,+ gain_prediction_coeff,+ L_SUBFR_16k0,+ 2);+ ff_acelp_update_past_gain(ctx->past_qua_en, gain_corr_factor, 2);+ }+ ctx->past_gain_code = gain_code;++ ff_acelp_build_excitation(+ &ctx->exc[i_subfr],+ &ctx->exc[i_subfr],+ code,+ gain_pitch,+ gain_code,+ L_SUBFR_16k0);++ ff_acelp_lp_synthesis_filter(+ &synth[i_subfr+16],+ &Az[i_subfr?1:0][0],+ &ctx->exc[i_subfr],+ L_SUBFR_16k0,+ LP_FILT_ORDER + 1,+ 0);+ parm+=8;+ }+ memcpy(ctx->mem_syn, synth + 2*L_SUBFR_16k0, LP_FILT_ORDER * sizeof(int16_t));+ memmove(ctx->old_exc, ctx->old_exc + 2 * L_SUBFR_16k0, (L_INTERPOL+PIT_MAX) * sizeof(int16_t));+++ /* postfilter start */+ memcpy(synth, ctx->mem_preemph, LP_FILT_ORDER * sizeof(int16_t));+ memcpy(var348, synth, LP_FILT_ORDER * sizeof(int16_t));++ ff_acelp_weighted_filter(B, ctx->A_past, weight_pow, LP_FILT_ORDER + 1);+ ff_acelp_lp_synthesis_filter(+ var348 + LP_FILT_ORDER,+ ctx->B_past,+ synth + LP_FILT_ORDER,+ 30,+ LP_FILT_ORDER + 1,+ 0);+ ff_acelp_lp_synthesis_filter(+ synth + LP_FILT_ORDER,+ B,+ synth + LP_FILT_ORDER,+ 2 * L_SUBFR_16k0,+ LP_FILT_ORDER + 1,+ 0);+ for(i=0, s=0; i<30; i++, s+=1.0/30)+ synth[i + LP_FILT_ORDER] =+ (1.0 - i / 30.0) * var348[i + LP_FILT_ORDER] ++ (i / 30.0) * synth[i + LP_FILT_ORDER];++ memcpy(ctx->B_past, B, LP_FILT_ORDER * sizeof(int16_t));+ memcpy(ctx->A_past, &Az[1][0], (LP_FILT_ORDER + 1) * sizeof(int16_t));+ memcpy(ctx->mem_preemph, synth + 2 * L_SUBFR_16k0, LP_FILT_ORDER * sizeof(int16_t));+ /* postfilter end */+++ for(i=0; i<ctx->len_frame; i++)+ out_data[i] = av_clip_int16(synth[i + LP_FILT_ORDER] << 1);++ return ctx->len_frame;+}++/**+ * extract decoding parameters from the input bitstream+ *+ * @param q pointer to the decoder context+ * @param in_buf pointer to the input bitstream+ * @param bitalloc_tab pointer to the bitallocation table+ * @param nparms number of parameters to extract+ */++static void decode_parameters(Sipr_Context *ctx, const uint8_t *in_buf, const int *bitalloc_tab, int nparms)+{+ int i;+ GetBitContext gb;++ init_get_bits(&gb, in_buf, ctx->bits_per_frame);++ for (i=0; i<nparms; i++) {+ ctx->dec_parms[i+1] = get_bits(&gb, bitalloc_tab[i]);+ av_log(NULL,AV_LOG_DEBUG,"%x ",ctx->dec_parms[i+1]);+ }+ av_log(NULL,AV_LOG_DEBUG,"\n");+}++static void init_decod_16k(Sipr_Context * ctx)+{+ int i;++ ctx->len_frame = 2 * L_SUBFR_16k0;++ ctx->past_qua_en[0] = -14;+ ctx->past_qua_en[1] = -14;++ ctx->exc = ctx->old_exc + L_INTERPOL + PIT_MAX;++ ctx->B_past[0] = ctx->A_past[0] = 4096;++ for(i=0; i<LP_FILT_ORDER; i++)+ {+ ctx->past_lsf_q[i] = (i+1) * LSFQ_MAX / (LP_FILT_ORDER + 1);+ ctx->lsfold[i] = ff_cos(ctx->past_lsf_q[i]);+ }++}+static int ff_sipr_decoder_init(AVCodecContext * avctx)+{+ Sipr_Context *ctx = avctx->priv_data;++ ctx->bit_rate = avctx->bit_rate;+ ctx->bytes_per_frame = avctx->block_align;+ ctx->bits_per_frame = avctx->block_align * 8;++ if(ctx->bytes_per_frame != 20) {+ av_log(avctx,AV_LOG_ERROR,"Invalid framesize detected: %d\n",ctx->bytes_per_frame);+ return -1;+ }+ init_decod_16k(ctx);++ return 0;+}++static int ff_sipr_decode_frame(AVCodecContext *avctx,+ void *data, int *data_size,+ const uint8_t *buf, int buf_size)+{+ Sipr_Context *ctx = avctx->priv_data;++ if (buf_size < avctx->block_align)+ return buf_size;+ decode_parameters(ctx, buf, bit_16k0, 22);+ ctx->dec_parms[0] = 0;+ *data_size = decod_frame_16k(ctx, ctx->dec_parms, data) * 2;+ return *data_size;+};++AVCodec sipr_decoder =+{+ "sipr",+ CODEC_TYPE_AUDIO,+ CODEC_ID_SIPR,+ sizeof(Sipr_Context),+ ff_sipr_decoder_init,+ NULL,+ NULL,+ ff_sipr_decode_frame,+};diff --git a/libavcodec/siprdata.h b/libavcodec/siprdata.hnew file mode 100644index 0000000..c08629a--- /dev/null+++ b/libavcodec/siprdata.h@@ -0,0 +1,504 @@+#ifndef FFMPEG_SIPRDATA_H+#define FFMPEG_SIPRDATA_H++static const int16_t gain_prediction_coeff[2] = {6554, 4915};+/* (0.15) */+static const int16_t ma_predictor[2] = { 3932, 16384 };+static const int16_t ma_predictor_sum[2] = { 28836, 16384 };+static const int16_t ma_predictor_sum_inv[2] = { 9309, 16384 };++static const int bit_16k0[22] = {1,7,8,7,7,7,9,4,9,9,9,9,9,5,6,4,9,9,9,9,9,5,};++static const int16_t weight_pow[17] =+{ 32768, 16384, 8192, 4096, 2048, 1024, 512, 256,+ 128, 64, 32, 16, 8, 4, 2, 1,+ 0+};++static const int qua_gain_code[32] =+{ /* (4.13) */+ 614, 867, 1157, 1543,+ 1942, 2308, 2681, 3078,+ 3454, 3876, 4348, 4879,+ 5475, 6143, 6892, 7733,+ 8677, 9736, 10924, 12257,+ 13752, 15430, 17313, 19426,+ 21796, 25025, 29066, 34545,+ 43490, 57994, 77337, 109242,+};++static const int16_t qua_gain_pitch[16] =+{ /* (1.14) */+ 0, 3277, 6554, 8192, 9830, 11469, 12288, 13107,+ 13926, 14746, 15565, 16384, 17203, 18022, 18842, 19661,+};++static const int16_t dico1_lsf[128][3] =+{ /* (2,13) */+ { 340, 607, 1904,}, { 302, 556, 2469,},+ { 615, 939, 2305,}, { 657, 970, 1944,},+ { 572, 849, 1509,}, { 737, 1072, 1691,},+ { 778, 1139, 2152,}, { 880, 1295, 1898,},+ { 761, 1173, 2484,}, { 611, 967, 2713,},+ { 906, 1390, 2234,}, { 971, 1387, 2519,},+ { 809, 1225, 2801,}, { 789, 1578, 2653,},+ { 964, 1717, 2429,}, { 1037, 1486, 2852,},+ { 542, 1482, 2923,}, { 884, 1352, 3127,},+ { 854, 1731, 3013,}, { 1213, 1634, 2520,},+ { 1250, 1714, 2816,}, { 1198, 1667, 3098,},+ { 1008, 1953, 2731,}, { 1059, 1515, 3382,},+ { 1028, 1903, 3295,}, { 1034, 2112, 3056,},+ { 1433, 1968, 3048,}, { 1371, 1937, 2626,},+ { 1328, 1761, 3425,}, { 1261, 2251, 3306,},+ { 1295, 2245, 2824,}, { 1050, 1953, 3699,},+ { 864, 2163, 3486,}, { 1561, 2107, 3509,},+ { 1438, 1860, 3820,}, { 782, 1739, 3507,},+ { 1262, 2368, 3799,}, { 668, 1888, 3749,},+ { 900, 2193, 3997,}, { 1043, 1518, 3797,},+ { 799, 1878, 4100,}, { 1210, 2025, 4085,},+ { 558, 1666, 4035,}, { 523, 2070, 4047,},+ { 759, 2443, 3821,}, { 479, 1407, 3787,},+ { 751, 1162, 3895,}, { 478, 1408, 4243,},+ { 536, 1797, 4385,}, { 462, 1027, 4160,},+ { 829, 1261, 4317,}, { 385, 893, 3764,},+ { 578, 1026, 3445,}, { 831, 1251, 3499,},+ { 557, 1485, 3359,}, { 651, 1056, 3082,},+ { 327, 666, 3197,}, { 503, 1025, 4649,},+ { 578, 1972, 3152,}, { 1142, 1595, 4181,},+ { 499, 1578, 4795,}, { 960, 1473, 4715,},+ { 601, 2262, 4332,}, { 886, 2077, 4492,},+ { 603, 2206, 4786,}, { 1319, 1875, 4565,},+ { 948, 2485, 4321,}, { 1113, 2484, 4700,},+ { 1041, 2039, 5078,}, { 1320, 2403, 4248,},+ { 1564, 2028, 4276,}, { 1530, 2245, 4841,},+ { 1587, 2546, 4532,}, { 1266, 2839, 4203,},+ { 1420, 2809, 4967,}, { 1513, 3027, 4542,},+ { 1850, 2793, 4213,}, { 1753, 2293, 3907,},+ { 1871, 2969, 4795,}, { 1633, 3018, 3778,},+ { 1009, 2874, 3835,}, { 1332, 2619, 3530,},+ { 1774, 2514, 3491,}, { 1308, 2779, 3115,},+ { 1652, 2340, 3071,}, { 756, 2614, 3335,},+ { 2140, 2841, 3185,}, { 2341, 2901, 3757,},+ { 673, 2791, 4291,}, { 970, 3056, 4595,},+ { 596, 2827, 4807,}, { 891, 2675, 5136,},+ { 1188, 3368, 4830,}, { 1690, 3504, 4457,},+ { 1826, 3406, 4951,}, { 1355, 3293, 5321,},+ { 814, 3881, 4683,}, { 593, 3404, 5447,},+ { 1355, 3902, 5391,}, { 1755, 2973, 5411,},+ { 2124, 3549, 5314,}, { 1467, 2543, 5347,},+ { 1057, 2955, 5727,}, { 440, 2696, 5616,},+ { 1160, 2218, 5675,}, { 1513, 2932, 6113,},+ { 432, 2056, 5406,}, { 625, 1535, 5355,},+ { 542, 2086, 6302,}, { 453, 1210, 5921,},+ { 488, 1071, 5193,}, { 566, 3524, 6603,},+ { 728, 4110, 5723,}, { 1176, 3802, 6178,},+ { 732, 4658, 6244,}, { 1820, 3706, 5985,},+ { 1554, 4425, 5847,}, { 2368, 4337, 5984,},+ { 2046, 4158, 4788,}, { 1612, 4742, 6945,},+ { 2235, 5721, 6157,}, { 1091, 5758, 6500,},+ { 644, 4940, 7314,}, { 3107, 4181, 4821,},+ { 3591, 5439, 5689,}, { 2440, 3242, 4545,},+ { 4188, 4413, 4716,}, { 1161, 1568, 2141,},+}; // dico1_lsf++static const int16_t dico2_lsf[256][3] =+{ /* (2,13) */+ { 3534, 4377, 5629,}, { 3537, 4806, 5567,},+ { 3449, 4272, 6067,}, { 3385, 4423, 6458,},+ { 3325, 4908, 6200,}, { 4124, 4757, 6219,},+ { 4162, 4735, 5469,}, { 4052, 5200, 6032,},+ { 3910, 4642, 6729,}, { 3828, 5131, 6634,},+ { 4321, 5137, 6596,}, { 3949, 5602, 6330,},+ { 4606, 5209, 6156,}, { 4469, 5072, 5712,},+ { 4349, 5531, 6515,}, { 4736, 5313, 6635,},+ { 4218, 5393, 7066,}, { 4633, 5222, 7066,},+ { 4559, 5570, 6950,}, { 4123, 5738, 6880,},+ { 4242, 4946, 7079,}, { 4447, 5224, 7399,},+ { 4439, 5910, 7099,}, { 4433, 5597, 7474,},+ { 3879, 5629, 7220,}, { 3897, 5117, 7229,},+ { 4146, 5830, 7421,}, { 4090, 5399, 7579,},+ { 4243, 4975, 7589,}, { 3534, 5267, 7505,},+ { 3692, 5629, 7696,}, { 3856, 5164, 7845,},+ { 3657, 4799, 7584,}, { 4000, 4663, 7423,},+ { 3296, 5215, 7820,}, { 3138, 4807, 7493,},+ { 3463, 4790, 8000,}, { 3442, 4874, 7014,},+ { 3611, 4368, 7305,}, { 3562, 4297, 7902,},+ { 3199, 4363, 7059,}, { 3000, 4068, 7639,},+ { 2819, 5152, 7561,}, { 3145, 5390, 7252,},+ { 3543, 5368, 6992,}, { 3408, 5780, 7320,},+ { 3193, 5669, 7668,}, { 3117, 5511, 6588,},+ { 2754, 5905, 7646,}, { 3291, 6102, 7634,},+ { 3213, 6249, 7137,}, { 3655, 5914, 6790,},+ { 3728, 6059, 7439,}, { 3660, 5963, 7977,},+ { 3075, 5912, 8161,}, { 3383, 6299, 7998,},+ { 3430, 6555, 7623,}, { 3965, 6303, 7684,},+ { 3978, 5888, 7786,}, { 3882, 6346, 8194,},+ { 3843, 6669, 7932,}, { 4001, 5893, 8304,},+ { 3477, 6106, 8460,}, { 3494, 6674, 8260,},+ { 4269, 6446, 8002,}, { 4297, 6002, 7844,},+ { 4316, 6244, 8362,}, { 4433, 5852, 8147,},+ { 4161, 5556, 7917,}, { 4301, 5434, 8263,},+ { 4422, 6281, 7657,}, { 4693, 6201, 8032,},+ { 4614, 5560, 7873,}, { 4709, 5895, 7771,},+ { 4823, 5819, 8132,}, { 4525, 5223, 7846,},+ { 4689, 5401, 8284,}, { 5006, 5515, 7890,},+ { 4763, 5739, 7450,}, { 4814, 5381, 7495,},+ { 5129, 5733, 7559,}, { 4818, 5767, 7139,},+ { 5086, 5514, 7212,}, { 4853, 6138, 7572,},+ { 5159, 5925, 7224,}, { 4856, 6115, 7185,},+ { 4519, 6027, 7454,}, { 5075, 5625, 6836,},+ { 4752, 5855, 6742,}, { 5278, 5971, 6737,},+ { 5048, 6385, 6993,}, { 4513, 6322, 6922,},+ { 4341, 5926, 6575,}, { 4881, 5699, 6347,},+ { 3971, 6287, 6874,}, { 4167, 6228, 7257,},+ { 4636, 6469, 7313,}, { 5188, 6256, 7498,},+ { 5001, 6564, 7441,}, { 4221, 6664, 7425,},+ { 3716, 6529, 7225,}, { 4606, 6871, 7517,},+ { 3776, 6794, 7527,}, { 4666, 6532, 7828,},+ { 5018, 6366, 7851,}, { 4857, 6869, 7910,},+ { 4240, 6852, 7946,}, { 4083, 7125, 7703,},+ { 4512, 7224, 7842,}, { 4536, 6886, 8188,},+ { 4625, 6510, 8350,}, { 5008, 6598, 8219,},+ { 5239, 6638, 7845,}, { 5074, 6997, 8311,},+ { 5267, 6993, 8003,}, { 4666, 6936, 8563,},+ { 5026, 6681, 8618,}, { 5334, 6818, 8491,},+ { 5388, 6513, 8143,}, { 5573, 6829, 8241,},+ { 5345, 6406, 8541,}, { 5385, 6920, 8781,},+ { 5172, 7148, 8635,}, { 5484, 7167, 8419,},+ { 5719, 6979, 8598,}, { 5741, 6529, 8512,},+ { 5543, 7212, 8746,}, { 5568, 7519, 8595,},+ { 5809, 7357, 8673,}, { 5460, 7230, 9083,},+ { 5621, 7487, 8913,}, { 5857, 7279, 8983,},+ { 5758, 6919, 9006,}, { 5279, 7489, 8828,},+ { 5862, 7660, 8821,}, { 6054, 7568, 9083,},+ { 5669, 7689, 9249,}, { 6282, 7525, 8808,},+ { 6113, 7209, 8583,}, { 5906, 7486, 8278,},+ { 6289, 7033, 9015,}, { 6389, 7624, 8416,},+ { 6266, 7315, 8140,}, { 5913, 7014, 8236,},+ { 6333, 6927, 8306,}, { 6575, 7165, 8580,},+ { 6116, 6762, 8643,}, { 6013, 6605, 8281,},+ { 6408, 7004, 7901,}, { 6087, 6681, 7940,},+ { 5966, 7077, 7827,}, { 5674, 6697, 7909,},+ { 6181, 6844, 7557,}, { 5838, 6663, 7485,},+ { 5802, 6318, 7821,}, { 5763, 6415, 8143,},+ { 5530, 6959, 7630,}, { 5475, 6407, 7713,},+ { 5706, 6290, 7439,}, { 5386, 6613, 7339,},+ { 5427, 5988, 7610,}, { 5444, 6154, 7943,},+ { 5445, 6091, 7227,}, { 5607, 6343, 7011,},+ { 5133, 5936, 7850,}, { 5143, 6206, 8199,},+ { 5318, 5859, 8192,}, { 5607, 6175, 8294,},+ { 5297, 6005, 8709,}, { 4812, 6112, 8484,},+ { 5024, 5620, 8413,}, { 4436, 5776, 8584,},+ { 4773, 5592, 8966,}, { 4676, 6367, 8934,},+ { 4317, 5184, 8666,}, { 3761, 5686, 8714,},+ { 3966, 6312, 8802,}, { 3816, 5360, 8274,},+ { 3641, 5102, 8725,}, { 4031, 4735, 8621,},+ { 3758, 4889, 8321,}, { 4275, 5018, 8136,},+ { 3234, 5063, 8415,}, { 3967, 4669, 8002,},+ { 3503, 4410, 8560,}, { 3424, 5569, 8151,},+ { 2913, 4551, 8223,}, { 3128, 4839, 8931,},+ { 2770, 5238, 8068,}, { 3151, 3948, 8535,},+ { 3058, 5657, 8668,}, { 3629, 4431, 9219,},+ { 3347, 5442, 9270,}, { 3968, 5062, 9256,},+ { 3124, 6316, 9103,}, { 3007, 6475, 8469,},+ { 2874, 6449, 7829,}, { 3518, 6968, 8790,},+ { 3199, 7260, 8336,}, { 3258, 6979, 7858,},+ { 4101, 6836, 8453,}, { 3746, 7181, 8046,},+ { 3670, 7699, 8596,}, { 4261, 7487, 8167,},+ { 4244, 6919, 9122,}, { 4625, 7439, 8756,},+ { 4818, 7398, 8106,}, { 4291, 7997, 8570,},+ { 3953, 7610, 9303,}, { 5252, 7464, 8198,},+ { 5000, 7948, 8398,}, { 4970, 6992, 9071,},+ { 4600, 8291, 8937,}, { 5331, 8149, 8997,},+ { 5568, 7960, 8364,}, { 5086, 7503, 9588,},+ { 5330, 6583, 8975,}, { 5605, 7252, 7990,},+ { 5111, 7070, 7568,}, { 5897, 7207, 9530,},+ { 5918, 8294, 9092,}, { 6157, 7996, 8520,},+ { 5827, 6348, 8871,}, { 6043, 7748, 9565,},+ { 6256, 7904, 9153,}, { 6414, 7399, 9333,},+ { 6704, 7416, 8970,}, { 6637, 8010, 9430,},+ { 6698, 8058, 8732,}, { 6613, 7566, 9746,},+ { 7036, 7705, 9284,}, { 6956, 7652, 8602,},+ { 6744, 8460, 9278,}, { 6732, 7358, 8225,},+ { 7258, 8148, 8879,}, { 7077, 8284, 9749,},+ { 6292, 8180, 9707,}, { 6729, 8748, 9864,},+ { 7507, 8584, 9370,}, { 6046, 8713, 9656,},+ { 6438, 8337, 10307,}, { 5663, 8165, 9897,},+ { 6056, 7657, 10263,}, { 6168, 8989, 10488,},+ { 5051, 8700, 9440,}, { 7450, 8972, 9968,},+ { 6913, 9169, 10510,}, { 7459, 8495, 11208,},+ { 7918, 9605, 10556,}, { 8555, 8944, 9242,},+ { 7554, 7824, 8046,}, { 3828, 8486, 9313,},+ { 5681, 6155, 9531,}, { 6812, 7132, 7296,},+ { 6244, 6588, 7202,}, { 2950, 7339, 9355,},+}; // dico2_lsf++static const int16_t dico3_lsf[128][3] =+{ /* (2,13) */+ { 7990, 9362, 11256,}, { 8163, 9506, 11953,},+ { 7759, 9978, 11770,}, { 8434, 10166, 11646,},+ { 8375, 10096, 10973,}, { 8833, 9763, 11321,},+ { 8218, 10689, 11411,}, { 8636, 10128, 12196,},+ { 8911, 10386, 11726,}, { 9040, 9866, 11880,},+ { 8902, 10453, 11198,}, { 9329, 10133, 11503,},+ { 8775, 10873, 11542,}, { 9298, 10741, 11452,},+ { 8659, 10738, 12043,}, { 9325, 10470, 11982,},+ { 8963, 10442, 12252,}, { 9217, 10866, 12046,},+ { 9097, 11141, 11732,}, { 9666, 10445, 11749,},+ { 9643, 11027, 11733,}, { 9134, 10908, 12457,},+ { 9363, 10408, 12443,}, { 9593, 10786, 12402,},+ { 9802, 10393, 12281,}, { 9831, 11025, 12203,},+ { 9470, 11184, 12519,}, { 9512, 10086, 12109,},+ { 9452, 11347, 12041,}, { 9408, 10627, 12844,},+ { 9823, 10443, 12719,}, { 9789, 10905, 12784,},+ { 9492, 10092, 12722,}, { 9322, 11044, 12903,},+ { 9700, 11309, 12842,}, { 8990, 10265, 12781,},+ { 8981, 11294, 12668,}, { 8734, 10727, 12633,},+ { 8983, 10674, 13151,}, { 9368, 11519, 12894,},+ { 8539, 11161, 12940,}, { 9175, 11321, 13271,},+ { 8528, 11161, 12345,}, { 8351, 10515, 12977,},+ { 8918, 11383, 12125,}, { 8793, 11700, 13162,},+ { 8899, 11815, 12592,}, { 8301, 11732, 12534,},+ { 8371, 11139, 11853,}, { 7775, 11153, 12312,},+ { 8180, 10451, 12249,}, { 9367, 11667, 12412,},+ { 9816, 11483, 12429,}, { 10003, 11163, 12612,},+ { 10052, 11442, 11972,}, { 10327, 11127, 12238,},+ { 10059, 10687, 11986,}, { 10173, 10747, 12532,},+ { 10313, 11581, 12511,}, { 10403, 11184, 12722,},+ { 10264, 11052, 11722,}, { 10068, 11502, 12877,},+ { 10279, 10926, 13058,}, { 10093, 11278, 13109,},+ { 10343, 11671, 13004,}, { 10096, 11616, 13204,},+ { 10423, 11531, 13290,}, { 9755, 11482, 13154,},+ { 9812, 11744, 12950,}, { 10287, 11797, 13293,},+ { 9901, 11422, 13454,}, { 10007, 11878, 13361,},+ { 10255, 11542, 13546,}, { 9473, 11792, 13300,},+ { 10450, 11809, 13531,}, { 10141, 11869, 13772,},+ { 10346, 12079, 13383,}, { 10594, 11867, 13240,},+ { 10171, 12060, 13026,}, { 10597, 12110, 13625,},+ { 10784, 11696, 13559,}, { 10803, 12303, 13219,},+ { 10669, 11996, 12709,}, { 11050, 11787, 12963,},+ { 10706, 11438, 12867,}, { 10709, 11488, 12273,},+ { 9981, 11890, 12548,}, { 11399, 11917, 13379,},+ { 11632, 11864, 12509,}, { 11364, 12331, 13085,},+ { 11342, 11654, 11963,}, { 9472, 12114, 12823,},+ { 9695, 11072, 13173,}, { 10100, 10922, 13583,},+ { 9879, 10533, 13177,}, { 9401, 10789, 13478,},+ { 9447, 10206, 13231,}, { 9511, 11494, 13870,},+ { 9655, 10348, 13830,}, { 8718, 11000, 13708,},+ { 8915, 9987, 13549,}, { 9056, 9782, 12911,},+ { 9143, 9926, 12373,}, { 8428, 9880, 12738,},+ { 8770, 9552, 12360,}, { 9166, 10035, 10777,},+ { 9556, 10407, 11124,}, { 8673, 9663, 10466,},+ { 9909, 10683, 11434,}, { 9056, 12485, 13076,},+ { 9499, 12225, 13706,}, { 10153, 11037, 14222,},+ { 8475, 12374, 14024,}, { 10041, 12176, 14265,},+ { 10206, 12597, 13642,}, { 9242, 13022, 13900,},+ { 10594, 12420, 14164,}, { 10525, 11819, 14180,},+ { 11126, 12288, 14061,}, { 11026, 12614, 13738,},+ { 10805, 12933, 14279,}, { 11389, 12727, 14195,},+ { 11124, 12462, 14708,}, { 11721, 12528, 13638,},+ { 11363, 13114, 14670,}, { 11924, 13015, 14120,},+ { 11933, 13327, 14849,}, { 8473, 11296, 14701,},+}; // dico3_lsf++static const int16_t dico4_lsf[128][3] =+{ /* (2,13) */+ { 12644, 13402, 15386,}, { 12884, 13622, 16210,},+ { 13117, 14184, 15730,}, { 13231, 14130, 15071,},+ { 12600, 14573, 15478,}, { 12884, 14418, 16333,},+ { 13443, 14270, 16200,}, { 12194, 13977, 16342,},+ { 12877, 15010, 16026,}, { 13211, 14982, 15626,},+ { 13676, 14611, 15861,}, { 13490, 14921, 16111,},+ { 13414, 14694, 16590,}, { 13069, 15012, 16573,},+ { 13531, 15092, 16564,}, { 13364, 15451, 16200,},+ { 13897, 14716, 16448,}, { 13893, 15209, 16294,},+ { 13826, 14926, 16918,}, { 13439, 15181, 17008,},+ { 13748, 15411, 16733,}, { 13230, 15417, 16752,},+ { 13788, 15717, 16445,}, { 13927, 15333, 17089,},+ { 14260, 15093, 16718,}, { 14215, 15528, 16798,},+ { 13632, 15618, 17150,}, { 13403, 15837, 16738,},+ { 13934, 15849, 16952,}, { 14063, 15680, 17304,},+ { 14264, 15559, 16333,}, { 14420, 15808, 17097,},+ { 14340, 16019, 16703,}, { 14717, 15643, 16680,},+ { 14402, 15237, 17181,}, { 14430, 15606, 17491,},+ { 14369, 15954, 17462,}, { 14845, 15644, 17209,},+ { 14433, 16296, 17141,}, { 14696, 16074, 17387,},+ { 14076, 16092, 17385,}, { 14426, 16168, 17664,},+ { 14532, 15869, 17829,}, { 14123, 15839, 17725,},+ { 14866, 16074, 17654,}, { 14666, 16324, 17706,},+ { 14322, 16474, 17700,}, { 14214, 16169, 17968,},+ { 13861, 16213, 17679,}, { 14733, 16183, 17954,},+ { 14509, 16392, 17998,}, { 14712, 16573, 17852,},+ { 14966, 16438, 17829,}, { 14777, 16501, 17461,},+ { 14841, 16391, 18166,}, { 14772, 16744, 18117,},+ { 15230, 16197, 17946,}, { 15138, 16652, 18164,},+ { 15041, 16843, 17786,}, { 14392, 16904, 17876,},+ { 15536, 16708, 17888,}, { 15356, 16491, 17408,},+ { 15295, 17094, 18199,}, { 15362, 16659, 18580,},+ { 14769, 17121, 18492,}, { 15889, 17091, 18096,},+ { 14247, 16576, 18539,}, { 15248, 17356, 18794,},+ { 15660, 17456, 18506,}, { 15885, 17156, 18807,},+ { 16216, 17518, 18586,}, { 15751, 17776, 19048,},+ { 13747, 17496, 18626,}, { 16306, 17922, 19150,},+ { 14732, 15688, 18442,}, { 13755, 16573, 18065,},+ { 13661, 17115, 17720,}, { 13981, 15828, 18334,},+ { 14010, 16614, 17386,}, { 13488, 15900, 17930,},+ { 13814, 15739, 17550,}, { 13578, 15965, 17371,},+ { 13633, 15396, 17849,}, { 13608, 15305, 17403,},+ { 14022, 15297, 17507,}, { 13218, 15560, 17396,},+ { 13082, 16047, 17546,}, { 13054, 15044, 17739,},+ { 13402, 14796, 17274,}, { 12936, 15119, 17162,},+ { 12427, 15253, 17479,}, { 12724, 15709, 17107,},+ { 13038, 14596, 16981,}, { 12610, 14544, 17695,},+ { 12384, 14523, 17002,}, { 12454, 15039, 16621,},+ { 12825, 13915, 16945,}, { 13130, 14213, 17561,},+ { 11795, 14168, 17339,}, { 13520, 14254, 16887,},+ { 12444, 13617, 17714,}, { 12293, 13246, 16747,},+ { 12409, 14171, 18335,}, { 11907, 15102, 17803,},+ { 13586, 14632, 17980,}, { 12472, 15073, 18463,},+ { 12766, 15661, 17965,}, { 13917, 14716, 17378,},+ { 13518, 15316, 18491,}, { 14317, 15201, 17944,},+ { 12967, 16443, 18046,}, { 13053, 16170, 18729,},+ { 13130, 16163, 17003,}, { 13320, 16609, 17497,},+ { 13759, 16288, 17009,}, { 12474, 16461, 17426,},+ { 12121, 16311, 18134,}, { 11838, 15931, 17281,},+ { 12809, 15659, 16515,}, { 12528, 17279, 18579,},+ { 14970, 16166, 16995,}, { 15377, 15891, 17336,},+ { 15348, 15757, 16638,}, { 14473, 15164, 16259,},+ { 13775, 15302, 15711,}, { 14627, 15425, 15724,},+ { 14121, 14964, 15856,}, { 13641, 14592, 15376,},+}; // dico4_lsf++static const int16_t dico5_lsf[128][4] =+{ /* (2,13) */+ { 17579, 18373, 20845, 21696,},+ { 17469, 19411, 21302, 21744,},+ { 17909, 18954, 21243, 22260,},+ { 18154, 19526, 20992, 21960,},+ { 17760, 19266, 20911, 22779,},+ { 18110, 19205, 20215, 22222,},+ { 18679, 19457, 20867, 22221,},+ { 18545, 19297, 21417, 22173,},+ { 18159, 19678, 21245, 22615,},+ { 18182, 19554, 21662, 22371,},+ { 18302, 19904, 21382, 22242,},+ { 18199, 19163, 21496, 22953,},+ { 18596, 19525, 20902, 23004,},+ { 18629, 19780, 21715, 22389,},+ { 18825, 19779, 21343, 22803,},+ { 18396, 19676, 21852, 22989,},+ { 18345, 20107, 21601, 22894,},+ { 17981, 19812, 21523, 23195,},+ { 17973, 19937, 22020, 23016,},+ { 17464, 19524, 21534, 22906,},+ { 18790, 20163, 21745, 23122,},+ { 18804, 20030, 21988, 22690,},+ { 18858, 19779, 22093, 23122,},+ { 18548, 20134, 22156, 23090,},+ { 18375, 20037, 21996, 23523,},+ { 18525, 20496, 21895, 23118,},+ { 18219, 20403, 22236, 23190,},+ { 19018, 20253, 22232, 23097,},+ { 18908, 20493, 21911, 22847,},+ { 18899, 20467, 22253, 23393,},+ { 18709, 20641, 22396, 23101,},+ { 18670, 20337, 22613, 23331,},+ { 18870, 20486, 21872, 23631,},+ { 18891, 20835, 22054, 23329,},+ { 19121, 20677, 22197, 23017,},+ { 19182, 20535, 22425, 23219,},+ { 19191, 20537, 21778, 23161,},+ { 19432, 20560, 22147, 23087,},+ { 19331, 20807, 22181, 23426,},+ { 19191, 20802, 22597, 23352,},+ { 19397, 20875, 22328, 23113,},+ { 19490, 20656, 22479, 23270,},+ { 19709, 20785, 22255, 23180,},+ { 19393, 20266, 22299, 23394,},+ { 19676, 20919, 22508, 23242,},+ { 19480, 21047, 22535, 23379,},+ { 19736, 20751, 22724, 23461,},+ { 19341, 20425, 22762, 23440,},+ { 20047, 20995, 22456, 23201,},+ { 19741, 20305, 22282, 22869,},+ { 19733, 20809, 22137, 22716,},+ { 19743, 21315, 22361, 23062,},+ { 19924, 21009, 22053, 23489,},+ { 19348, 20946, 21925, 22885,},+ { 19893, 20703, 21721, 22996,},+ { 19372, 20488, 21933, 22635,},+ { 20218, 21112, 22052, 22835,},+ { 19882, 20720, 21565, 22384,},+ { 19529, 20333, 21411, 22756,},+ { 19297, 20129, 21869, 23006,},+ { 19502, 20418, 21720, 23640,},+ { 18883, 20295, 21440, 22736,},+ { 19102, 20124, 21726, 22317,},+ { 19174, 20615, 21334, 22128,},+ { 19295, 20076, 20913, 22540,},+ { 19214, 20133, 21200, 23231,},+ { 18830, 19939, 21355, 21997,},+ { 18964, 19902, 21604, 23423,},+ { 18442, 20525, 21669, 22489,},+ { 18576, 19983, 20601, 22501,},+ { 19032, 20131, 20885, 21588,},+ { 18650, 19807, 21250, 23773,},+ { 18953, 20026, 22131, 23684,},+ { 18503, 19331, 21785, 23436,},+ { 18547, 19277, 22127, 22665,},+ { 18568, 19516, 22515, 23381,},+ { 18265, 19970, 22486, 23292,},+ { 17892, 19371, 22161, 23140,},+ { 17781, 19729, 22099, 23747,},+ { 17967, 19023, 21910, 23555,},+ { 18344, 19422, 22399, 24084,},+ { 18100, 19155, 22805, 23563,},+ { 17662, 19842, 22636, 23356,},+ { 17286, 19584, 22080, 23081,},+ { 17581, 20216, 22205, 23048,},+ { 17185, 18784, 22305, 23381,},+ { 17536, 18919, 21762, 22936,},+ { 17133, 19549, 22890, 23623,},+ { 16800, 20050, 22205, 23162,},+ { 16746, 19221, 21691, 22963,},+ { 17267, 20295, 21568, 22770,},+ { 17142, 18241, 21537, 22745,},+ { 17543, 18698, 21243, 23593,},+ { 17543, 18887, 22031, 24295,},+ { 17969, 18981, 21940, 22221,},+ { 18032, 19083, 20828, 23498,},+ { 18004, 18914, 21295, 24173,},+ { 17864, 18848, 20091, 23084,},+ { 17883, 18761, 20144, 23826,},+ { 17587, 18497, 20528, 24268,},+ { 18162, 18917, 20607, 24294,},+ { 17537, 20016, 20398, 22412,},+ { 18166, 19207, 20285, 21193,},+ { 17779, 20279, 21104, 21608,},+ { 16351, 20401, 21167, 21828,},+ { 17882, 20877, 22149, 22884,},+ { 17826, 20443, 22518, 23464,},+ { 18565, 20479, 22327, 23847,},+ { 18721, 21000, 22111, 22848,},+ { 18324, 21104, 22522, 23268,},+ { 18108, 20837, 22961, 23552,},+ { 17143, 20620, 22904, 23598,},+ { 17307, 21378, 22600, 23344,},+ { 18924, 21142, 22856, 23446,},+ { 18844, 20616, 22988, 23640,},+ { 18517, 21639, 22942, 23489,},+ { 18258, 20088, 23042, 23644,},+ { 19036, 19965, 22696, 23463,},+ { 19111, 20664, 22362, 23930,},+ { 19102, 21281, 22448, 23093,},+ { 19454, 20959, 23146, 23821,},+ { 19478, 20989, 22350, 23931,},+ { 19544, 21602, 22835, 23385,},+ { 20018, 21227, 22776, 23449,},+ { 19677, 21190, 22709, 24224,},+ { 20475, 21412, 22481, 23214,},+ { 20409, 21667, 22921, 23513,},+ { 20247, 20737, 21048, 21642,},+}; // dico5_lsf++#endif // FFMPEG_SIPRDATA_Hdiff --git a/libavformat/riff.c b/libavformat/riff.cindex 322e813..439712d 100644--- a/libavformat/riff.c+++ b/libavformat/riff.c@@ -183,6 +183,7 @@ const AVCodecTag codec_wav_tags[] = { { CODEC_ID_ADPCM_IMA_DK3, 0x0062 }, /* rogue format number */ { CODEC_ID_VOXWARE, 0x0075 }, { CODEC_ID_AAC, 0x00ff },+ { CODEC_ID_SIPR, 0x0130 }, { CODEC_ID_WMAV1, 0x0160 }, { CODEC_ID_WMAV2, 0x0161 }, { CODEC_ID_WMAPRO, 0x0162 },diff --git a/libavformat/rmdec.c b/libavformat/rmdec.cindex c4bda1f..1d7d528 100644--- a/libavformat/rmdec.c+++ b/libavformat/rmdec.c@@ -23,6 +23,16 @@ #include "avformat.h" #include "rm.h" +static unsigned char sipr_swaps[38][2]={+ {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},+ {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},+ {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},+ {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},+ {77,80} };++static unsigned char sipr_subpk_size[4]={+ 29, 19, 37, 20};+ static inline void get_strl(ByteIOContext *pb, char *buf, int buf_size, int len) { int i;@@ -127,7 +137,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, } rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);- } else if ((!strcmp(buf, "cook")) || (!strcmp(buf, "atrc"))) {+ } else if ((!strcmp(buf, "cook")) || (!strcmp(buf, "atrc")) || (!strcmp(buf, "sipr"))) { int codecdata_length, i; get_be16(pb); get_byte(pb); if (((version >> 16) & 0xff) == 5)@@ -139,6 +149,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, } if (!strcmp(buf, "cook")) st->codec->codec_id = CODEC_ID_COOK;+ else if (!strcmp(buf, "sipr")) st->codec->codec_id = CODEC_ID_SIPR; else st->codec->codec_id = CODEC_ID_ATRAC3; st->codec->extradata_size= codecdata_length; st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);@@ -146,6 +157,8 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, ((uint8_t*)st->codec->extradata)[i] = get_byte(pb); rm->audio_framesize = st->codec->block_align; st->codec->block_align = rm->sub_packet_size;+ if (st->codec->codec_id == CODEC_ID_SIPR)+ st->codec->block_align = sipr_subpk_size[flavor]; if(rm->audio_framesize >= UINT_MAX / sub_packet_h){ av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");@@ -561,7 +574,8 @@ ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { if ((st->codec->codec_id == CODEC_ID_RA_288) || (st->codec->codec_id == CODEC_ID_COOK) ||- (st->codec->codec_id == CODEC_ID_ATRAC3)) {+ (st->codec->codec_id == CODEC_ID_ATRAC3) ||+ (st->codec->codec_id == CODEC_ID_SIPR)) { int x; int sps = rm->sub_packet_size; int cfs = rm->coded_framesize;@@ -584,6 +598,33 @@ ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, for (x = 0; x < w/sps; x++) get_buffer(pb, rm->audiobuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps); break;+ case CODEC_ID_SIPR:+ get_buffer(pb, rm->audiobuf + y * w, w);+ if (y == h - 1) {+ int n;+ int bs = h * w * 2 / 96; // nibbles per subpacket+ // Perform reordering+ for(n=0; n < 38; n++) {+ int j;+ int i = bs * sipr_swaps[n][0];+ int o = bs * sipr_swaps[n][1];+ // swap nibbles of block 'i' with 'o'+ for(j = 0;j < bs; j++) {+ int x = (i & 1) ? (rm->audiobuf[i >> 1] >> 4) : (rm->audiobuf[i >> 1] & 0x0F);+ int y = (o & 1) ? (rm->audiobuf[o >> 1] >> 4) : (rm->audiobuf[o >> 1] & 0x0F);+ if(o & 1)+ rm->audiobuf[o >> 1] = (rm->audiobuf[o >> 1] & 0x0F) | (x << 4);+ else+ rm->audiobuf[o >> 1] = (rm->audiobuf[o >> 1] & 0xF0) | x;+ if(i & 1)+ rm->audiobuf[i >> 1] = (rm->audiobuf[i >> 1] & 0x0F) | (y << 4);+ else+ rm->audiobuf[i >> 1] = (rm->audiobuf[i >> 1] & 0xF0) | y;+ ++i; ++o;+ }+ }+ }+ break; } if (++(rm->sub_packet_cnt) < h)