?? decode.c
字號(hào):
break; case 14: /* copy T5 from T3 */ bit_alloc[5][i] = bit_alloc[3][i]; break; case 15: /* copy T5 from T3 and T6 from T1 */ bit_alloc[5][i] = bit_alloc[3][i]; bit_alloc[6][i] = bit_alloc[T6T1][i]; break; case 16: /* copy T5 from T3 and T6 from T2 */ bit_alloc[5][i] = bit_alloc[3][i]; bit_alloc[6][i] = bit_alloc[2][i]; break; case 17: /* copy T5 from T3 and T6 from T4 */ bit_alloc[5][i] = bit_alloc[3][i]; bit_alloc[6][i] = bit_alloc[4][i]; break; case 18: /* copy T5 and T6 from T3 */ bit_alloc[5][i] = bit_alloc[6][i] = bit_alloc[3][i]; break; } } for (i=sblimit; i<SBLIMIT; i++) for (j=*l; j<*m; j++) bit_alloc[j][i] = 0; if (bits_log) { for (j= *l; j < *m; j++) for (i = 0; i < SBLIMIT; i++) { int alloc_bits = 0, alloc_id = bit_alloc[j][i]; if (actual_alloc[j][i] > 0) alloc_bits = 12 * (*alloc)[i][alloc_id].bits * (*alloc)[i][alloc_id].group; printf ("alloc_bi[ %d ][ %2d ]= %3d\n", j, i, alloc_bits); } }}#endifvoid II_decode_bitalloc_ml(Bit_stream *bs, frame_params *fr_ps, unsigned int bit_alloc_ml[7][SBLIMIT], int *m){ int i,j; int sblimit_ml = fr_ps->sblimit_ml; al_table *alloc_ml = fr_ps->alloc_ml; /* JR: no dynamic crosstalk for multilingual channels */ /* JR: no phantom center coding for multilingual channels */ /* JR: no joint coding for multilingual channels */ /* JR: they're really simple, aren't they? */ for (i=0;i<sblimit_ml;i++) for (j=0;j<*m;j++) bit_alloc_ml[j][i] = (char) getbits (bs, (*alloc_ml)[i][0].bits); for (i=sblimit_ml;i<SBLIMIT;i++) for (j=0;j<*m;j++) bit_alloc_ml[j][i] = 0;}/*****************************************************************/*/* The following two functions implement the layer II/* format of scale factor extraction. Layer I involves reading/* 6 bit per subband as scale factor. Layer II requires reading/* first the scfsi which in turn indicate the number of scale factors/* transmitted./* Layer II : II_decode_scale/*/*************************** Layer II stuff ***************************//* 28.9.93 R.S. reading of the prediction coefficients *//* 03.6.94 R.S. read pred-coef. due to MPEG 2 - DIS *//**********************************************************************//* JMZ 09/03/1995 Multilingual adaptations , WtK 7/8/95 *//**********************************************************************/void I_decode_scale (Bit_stream *bs, frame_params *fr_ps, unsigned int bit_alloc[7][SBLIMIT], unsigned int scale_index[7][3][SBLIMIT], int part, int scf_log){ int i,j; int stereo = fr_ps->stereo; int sblimit = fr_ps->sblimit; for (i=0; i<SBLIMIT; i++) for (j=0;j<stereo;j++) if (!bit_alloc[j][i]) scale_index[j][part][i] = SCALE_RANGE-1; else /* 6 bit per scale factor */ scale_index[j][part][i] = getbits (bs, 6);}void II_decode_scale (Bit_stream *bs, frame_params *fr_ps, unsigned int scfsi[7][SBLIMIT], unsigned int bit_alloc[7][SBLIMIT], unsigned int scale_index[7][3][SBLIMIT], int *l, int *m, int scfsi_log){ layer *info = fr_ps->header; int stereo = fr_ps->stereo; int i,j; int px,pci; int sblimit = fr_ps->sblimit; if (*m == stereo) sblimit = fr_ps->sblimit; else sblimit = fr_ps->sblimit_mc; for (i = 0; i < sblimit; i++) { for (j = *l; j < *m; j++) /* 2 bit scfsi */ if (bit_alloc[j][i]) scfsi[j][i] = (char) getbits (bs, 2); else scfsi[j][i] = 4; } for (i = sblimit; i < SBLIMIT; i++) for (j = *l; j < *m; j++) scfsi[j][i] = 4; { for (j= *l; j < *m; j++) for (i = 0; i < SBLIMIT; i++) { int scf_bits; switch (scfsi[j][i]) { /* all three scale factors transmitted */ case 0 : scf_bits = 20; break; /* two scale factors transmitted */ case 1 : case 3 : scf_bits = 14; break; /* only one scale factor transmitted */ case 2 : scf_bits = 8; break; /* no scale factors transmitted */ default : scf_bits = 0; } printf ("scf_bits[ %d ][ %2d ]= %3d\n", j, i, scf_bits); } } /* 3.6.94 R.S. read the prediction coefficients in the mc - part */ if (*m > stereo && *m < 7) if (fr_ps->header->mc_prediction_on == 1) for (i = 0; i < 8; i++) if (fr_ps->header->mc_prediction[i] == 1) for (px = 0; px < pred_coef_table[fr_ps->pred_mode][fr_ps->header->dyn_cross_mode[i]]; px++) if (fr_ps->header->mc_predsi[i][px] != 0) { /* predictors are transfered */ fr_ps->header->mc_delay_comp[i][px] = getbits (bs, 3); for (pci = 0; pci < fr_ps->header->mc_predsi[i][px]; pci++) fr_ps->header->mc_pred_coeff[i][px][pci] = getbits (bs, 8); } else { /* no prediction coef. */ fr_ps->header->mc_pred_coeff[i][px][0] = 127; /* Index 127 -> 0.0 */ fr_ps->header->mc_delay_comp[i][px] = 0; } /* 31/10/95 Ralf Schwalbe LFE */ if (*l == stereo) if (info->lfe) if (info->lfe_alloc) info->lfe_scf = getbits (bs, 6); for (i = 0; i < sblimit; i++) for (j = *l; j < *m; j++) if (bit_alloc[j][i]) switch (scfsi[j][i]) { /* all three scale factors transmitted */ case 0 : scale_index[j][0][i] = getbits (bs, 6); scale_index[j][1][i] = getbits (bs, 6); scale_index[j][2][i] = getbits (bs, 6); break; /* scale factor 1 & 3 transmitted */ case 1 : scale_index[j][0][i] = scale_index[j][1][i] = getbits (bs, 6); scale_index[j][2][i] = getbits (bs, 6); break; /* scale factor 1 & 2 transmitted */ case 3 : scale_index[j][0][i] = getbits (bs, 6); scale_index[j][1][i] = scale_index[j][2][i] = getbits (bs, 6); break; /* only one scale factor transmitted */ case 2 : scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = getbits (bs, 6); break; default : scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1; break; } else scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1; for (i = sblimit; i < SBLIMIT; i++) for (j = *l; j < *m; j++) scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1;}/**********************************************************************//* JMZ 15/03/1995 Multilingual *//**********************************************************************/void II_decode_scale_ml(Bit_stream *bs, frame_params *fr_ps, unsigned int bit_alloc[7][SBLIMIT], unsigned int scale_index[7][3][SBLIMIT], int *m){ int i,j; int px,pci; int sblimit_ml = fr_ps->sblimit_ml; for (i=0;i<sblimit_ml;i++) for (j=0;j<*m;j++) /* 2 bit scfsi */ if (bit_alloc[j][i]) { scfsi[j][i] = (char) getbits (bs, 2); } else scfsi[j][i] = 4; for (i=sblimit_ml;i<SBLIMIT;i++) for (j=0;j<*m;j++) scfsi[j][i] = 4; for (i = 0; i < sblimit_ml; i++) for (j = 0; j < *m; j++) { if (bit_alloc[j][i]) switch (scfsi[j][i]) { /* all three scale factors transmitted */ case 0 : scale_index[j][0][i] = getbits (bs, 6); scale_index[j][1][i] = getbits (bs, 6); scale_index[j][2][i] = getbits (bs, 6); break; /* scale factor 1 & 3 transmitted */ case 1 : scale_index[j][0][i] = scale_index[j][1][i] = getbits (bs, 6); scale_index[j][2][i] = getbits (bs, 6); break; /* scale factor 1 & 2 transmitted */ case 3 : scale_index[j][0][i] = getbits (bs, 6); scale_index[j][1][i] = scale_index[j][2][i] = getbits (bs, 6); break; /* only one scale factor transmitted */ case 2 : scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = getbits (bs, 6); break; default : scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1; break; } else { scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1; } } for (i=sblimit_ml;i<SBLIMIT;i++) for (j=0;j<*m;j++) { scale_index[j][0][i] = scale_index[j][1][i] = scale_index[j][2][i] = SCALE_RANGE-1; }}/**************************************************************/*/* The following two routines take care of reading the/* compressed sample from the bit stream for layer 2./* For layer 1, read the number of bits as indicated/* by the bit_alloc information. For layer 2, if grouping is/* indicated for a particular subband, then the sample size has/* to be read from the bits_group and the merged samples has/* to be decompose into the three distinct samples. Otherwise,/* it is the same for as layer one./*/*************************** Layer II stuff ************************/void I_buffer_sample (Bit_stream *bs, frame_params *fr_ps, unsigned int sample[7][3][SBLIMIT], unsigned int bit_alloc[7][SBLIMIT]){ int i,j,k; int stereo = fr_ps->stereo; int sblimit = fr_ps->sblimit; int jsbound = fr_ps->jsbound; unsigned int s; for (i=0; i<jsbound; i++) for (j=0; j<stereo; j++) if ((k = bit_alloc[j][i]) == 0) sample[j][0][i] = 0; else sample[j][0][i] = (unsigned int) getbits (bs, k+1); for (i=jsbound; i<SBLIMIT; i++) { if ((k = bit_alloc[0][i]) == 0) s = 0; else s = (unsigned int) getbits (bs, k+1); for (j=0; j<stereo; j++) sample[j][0][i] = s; }}void II_buffer_sample (Bit_stream *bs, frame_params *fr_ps, unsigned int sample[7][3][SBLIMIT], unsigned int bit_alloc[7][SBLIMIT]){ int i,j,k,m; int stereo = fr_ps->stereo; int sblimit = fr_ps->sblimit; int jsbound = fr_ps->jsbound; al_table *alloc = fr_ps->alloc; for (i=0;i<sblimit;i++) for (j= 0;j<((i<jsbound)? stereo:1);j++) { if (bit_alloc[j][i]) { /* check for grouping in subband */ if ((*alloc)[i][bit_alloc[j][i]].group==3) { for (m=0;m<3;m++) { k = (*alloc)[i][bit_alloc[j][i]].bits; sample[j][m][i] = (unsigned int) getbits (bs, k); } } else { /* bit_alloc = 3, 5, 9 */ unsigned int nlevels, c=0; nlevels = (*alloc)[i][bit_alloc[j][i]].steps; k=(*alloc)[i][bit_alloc[j][i]].bits; c = (unsigned int) getbits (bs, k); for (k=0;k<3;k++) { sample[j][k][i] = c % nlevels; c /= nlevels; } } } else { /* for no sample transmitted */ for (k=0;k<3;k++) sample[j][k][i] = 0; } if(stereo == 2 && i>= jsbound) /* joint stereo : copy L to R */ for (k=0;k<3;k++) sample[1][k][i] = sample[0][k][i]; } for (i = sblimit; i < SBLIMIT; i++) for (j = 0; j < stereo; j++) for (k = 0; k < 3; k++) sample[j][k][i] = 0;}/******************** mc - layer2 stuff ******************************//* 19.10.93 R.S. */void II_buffer_sample_mc (Bit_stream *bs, frame_params *fr_ps, unsigned int sample[7][3][SBLIMIT], unsigned int bit_alloc[7][SBLIMIT], int ch_start, int channels, int gr){ layer *info = fr_ps->header; int i,j,k,m,sbgr,l; unsigned int nlevels, c=0; int sblimit = fr_ps->sblimit_mc; int transmitted; al_table *alloc = fr_ps->alloc_mc;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -