Mercurial > libavcodec.hg
comparison mpc.c @ 4536:0430aafe6f01 libavcodec
Use AVRandom
author | kostya |
---|---|
date | Sat, 17 Feb 2007 11:41:59 +0000 |
parents | e3b224087a85 |
children | 777f250df232 |
comparison
equal
deleted
inserted
replaced
4535:e3b224087a85 | 4536:0430aafe6f01 |
---|---|
27 */ | 27 */ |
28 | 28 |
29 #include "avcodec.h" | 29 #include "avcodec.h" |
30 #include "bitstream.h" | 30 #include "bitstream.h" |
31 #include "dsputil.h" | 31 #include "dsputil.h" |
32 #include "random.h" | |
32 | 33 |
33 #ifdef CONFIG_MPEGAUDIO_HP | 34 #ifdef CONFIG_MPEGAUDIO_HP |
34 #define USE_HIGHPRECISION | 35 #define USE_HIGHPRECISION |
35 #endif | 36 #endif |
36 #include "mpegaudio.h" | 37 #include "mpegaudio.h" |
48 typedef struct { | 49 typedef struct { |
49 DSPContext dsp; | 50 DSPContext dsp; |
50 int IS, MSS, gapless; | 51 int IS, MSS, gapless; |
51 int lastframelen, bands; | 52 int lastframelen, bands; |
52 int oldDSCF[2][BANDS]; | 53 int oldDSCF[2][BANDS]; |
53 int rnd; | 54 AVRandomState rnd; |
54 int frames_to_skip; | 55 int frames_to_skip; |
55 /* for synthesis */ | 56 /* for synthesis */ |
56 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); | 57 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); |
57 int synth_buf_offset[MPA_MAX_CHANNELS]; | 58 int synth_buf_offset[MPA_MAX_CHANNELS]; |
58 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); | 59 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); |
79 if(avctx->extradata_size < 16){ | 80 if(avctx->extradata_size < 16){ |
80 av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); | 81 av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); |
81 return -1; | 82 return -1; |
82 } | 83 } |
83 memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); | 84 memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); |
84 c->rnd = 0xDEADBEEF; | 85 av_init_random(0xDEADBEEF, &c->rnd); |
85 dsputil_init(&c->dsp, avctx); | 86 dsputil_init(&c->dsp, avctx); |
86 c->dsp.bswap_buf(buf, avctx->extradata, 4); | 87 c->dsp.bswap_buf(buf, avctx->extradata, 4); |
87 ff_mpa_synth_init(mpa_window); | 88 ff_mpa_synth_init(mpa_window); |
88 init_get_bits(&gb, buf, 128); | 89 init_get_bits(&gb, buf, 128); |
89 | 90 |
133 } | 134 } |
134 vlc_inited = 1; | 135 vlc_inited = 1; |
135 return 0; | 136 return 0; |
136 } | 137 } |
137 | 138 |
138 // XXX replace with something better | |
139 static int av_always_inline mpc_rnd(MPCContext *c) | |
140 { | |
141 c->rnd = c->rnd * 27 + 17; | |
142 return c->rnd; | |
143 } | |
144 | |
145 /** | 139 /** |
146 * Process decoded Musepack data and produce PCM | 140 * Process decoded Musepack data and produce PCM |
147 * @todo make it available for MPC8 and MPC6 | 141 * @todo make it available for MPC8 and MPC6 |
148 */ | 142 */ |
149 static void mpc_synth(MPCContext *c, int16_t *out) | 143 static void mpc_synth(MPCContext *c, int16_t *out) |
173 { | 167 { |
174 int i, i1, t; | 168 int i, i1, t; |
175 switch(idx){ | 169 switch(idx){ |
176 case -1: | 170 case -1: |
177 for(i = 0; i < SAMPLES_PER_BAND; i++){ | 171 for(i = 0; i < SAMPLES_PER_BAND; i++){ |
178 t = mpc_rnd(c); | 172 *dst++ = (av_random(&c->rnd) & 0x3FC) - 510; |
179 *dst++ = ((t>>24)& 0xFF) + ((t>>16) & 0xFF) + ((t>>8) & 0xFF) + (t & 0xFF) - 510; | |
180 } | 173 } |
181 break; | 174 break; |
182 case 1: | 175 case 1: |
183 i1 = get_bits1(gb); | 176 i1 = get_bits1(gb); |
184 for(i = 0; i < SAMPLES_PER_BAND/3; i++){ | 177 for(i = 0; i < SAMPLES_PER_BAND/3; i++){ |