Mercurial > libavcodec.hg
comparison twinvq.c @ 11949:778bdafd5496 libavcodec
twinvq: remove VLAs
author | mru |
---|---|
date | Fri, 25 Jun 2010 13:43:55 +0000 |
parents | 8b6f3d3b55cb |
children | fdafbcef52f5 |
comparison
equal
deleted
inserted
replaced
11948:e8cf7f5fb715 | 11949:778bdafd5496 |
---|---|
200 // scratch buffers | 200 // scratch buffers |
201 float *tmp_buf; | 201 float *tmp_buf; |
202 } TwinContext; | 202 } TwinContext; |
203 | 203 |
204 #define PPC_SHAPE_CB_SIZE 64 | 204 #define PPC_SHAPE_CB_SIZE 64 |
205 #define PPC_SHAPE_LEN_MAX 60 | |
205 #define SUB_AMP_MAX 4500.0 | 206 #define SUB_AMP_MAX 4500.0 |
206 #define MULAW_MU 100.0 | 207 #define MULAW_MU 100.0 |
207 #define GAIN_BITS 8 | 208 #define GAIN_BITS 8 |
208 #define AMP_MAX 13000.0 | 209 #define AMP_MAX 13000.0 |
209 #define SUB_GAIN_BITS 5 | 210 #define SUB_GAIN_BITS 5 |
210 #define WINDOW_TYPE_BITS 4 | 211 #define WINDOW_TYPE_BITS 4 |
211 #define PGAIN_MU 200 | 212 #define PGAIN_MU 200 |
213 #define LSP_COEFS_MAX 20 | |
214 #define LSP_SPLIT_MAX 4 | |
215 #define CHANNELS_MAX 2 | |
216 #define SUBBLOCKS_MAX 16 | |
217 #define BARK_N_COEF_MAX 4 | |
212 | 218 |
213 /** @note not speed critical, hence not optimized */ | 219 /** @note not speed critical, hence not optimized */ |
214 static void memset_float(float *buf, float val, int size) | 220 static void memset_float(float *buf, float val, int size) |
215 { | 221 { |
216 while (size--) | 222 while (size--) |
725 { | 731 { |
726 const ModeTab *mtab = tctx->mtab; | 732 const ModeTab *mtab = tctx->mtab; |
727 int channels = tctx->avctx->channels; | 733 int channels = tctx->avctx->channels; |
728 int sub = mtab->fmode[ftype].sub; | 734 int sub = mtab->fmode[ftype].sub; |
729 int block_size = mtab->size / sub; | 735 int block_size = mtab->size / sub; |
730 float gain[channels*sub]; | 736 float gain[CHANNELS_MAX*SUBBLOCKS_MAX]; |
731 float ppc_shape[mtab->ppc_shape_len * channels * 4]; | 737 float ppc_shape[PPC_SHAPE_LEN_MAX * CHANNELS_MAX * 4]; |
732 uint8_t bark1[channels][sub][mtab->fmode[ftype].bark_n_coef]; | 738 uint8_t bark1[CHANNELS_MAX][SUBBLOCKS_MAX][BARK_N_COEF_MAX]; |
733 uint8_t bark_use_hist[channels][sub]; | 739 uint8_t bark_use_hist[CHANNELS_MAX][SUBBLOCKS_MAX]; |
734 | 740 |
735 uint8_t lpc_idx1[channels]; | 741 uint8_t lpc_idx1[CHANNELS_MAX]; |
736 uint8_t lpc_idx2[channels][tctx->mtab->lsp_split]; | 742 uint8_t lpc_idx2[CHANNELS_MAX][LSP_SPLIT_MAX]; |
737 uint8_t lpc_hist_idx[channels]; | 743 uint8_t lpc_hist_idx[CHANNELS_MAX]; |
738 | 744 |
739 int i, j, k; | 745 int i, j, k; |
740 | 746 |
741 dequant(tctx, gb, out, ftype, | 747 dequant(tctx, gb, out, ftype, |
742 mtab->fmode[ftype].cb0, mtab->fmode[ftype].cb1, | 748 mtab->fmode[ftype].cb0, mtab->fmode[ftype].cb1, |
769 mtab->ppc_shape_cb + cb_len_p*PPC_SHAPE_CB_SIZE, cb_len_p); | 775 mtab->ppc_shape_cb + cb_len_p*PPC_SHAPE_CB_SIZE, cb_len_p); |
770 } | 776 } |
771 | 777 |
772 for (i = 0; i < channels; i++) { | 778 for (i = 0; i < channels; i++) { |
773 float *chunk = out + mtab->size * i; | 779 float *chunk = out + mtab->size * i; |
774 float lsp[tctx->mtab->n_lsp]; | 780 float lsp[LSP_COEFS_MAX]; |
775 | 781 |
776 for (j = 0; j < sub; j++) { | 782 for (j = 0; j < sub; j++) { |
777 dec_bark_env(tctx, bark1[i][j], bark_use_hist[i][j], i, | 783 dec_bark_env(tctx, bark1[i][j], bark_use_hist[i][j], i, |
778 tctx->tmp_buf, gain[sub*i+j], ftype); | 784 tctx->tmp_buf, gain[sub*i+j], ftype); |
779 | 785 |
1062 int ibps = avctx->bit_rate/(1000 * avctx->channels); | 1068 int ibps = avctx->bit_rate/(1000 * avctx->channels); |
1063 | 1069 |
1064 tctx->avctx = avctx; | 1070 tctx->avctx = avctx; |
1065 avctx->sample_fmt = SAMPLE_FMT_FLT; | 1071 avctx->sample_fmt = SAMPLE_FMT_FLT; |
1066 | 1072 |
1067 if (avctx->channels > 2) { | 1073 if (avctx->channels > CHANNELS_MAX) { |
1068 av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", | 1074 av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", |
1069 avctx->channels); | 1075 avctx->channels); |
1070 return -1; | 1076 return -1; |
1071 } | 1077 } |
1072 | 1078 |