]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpc.c
Add some forgotten lib prefixes to Makefile variables.
[ffmpeg] / libavcodec / mpc.c
index a500479c0e667e67255bcf3da98abb3ade9c8d42..34ded32e475a47efdb875f2cd1b7fa7f291905b5 100644 (file)
@@ -29,6 +29,7 @@
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
+#include "random.h"
 
 #ifdef CONFIG_MPEGAUDIO_HP
 #define USE_HIGHPRECISION
@@ -50,7 +51,7 @@ typedef struct {
     int IS, MSS, gapless;
     int lastframelen, bands;
     int oldDSCF[2][BANDS];
-    int rnd;
+    AVRandomState rnd;
     int frames_to_skip;
     /* for synthesis */
     DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]);
@@ -73,7 +74,6 @@ static int mpc7_decode_init(AVCodecContext * avctx)
     MPCContext *c = avctx->priv_data;
     GetBitContext gb;
     uint8_t buf[16];
-    float f1=1.20050805774840750476 * 256;
     static int vlc_inited = 0;
 
     if(avctx->extradata_size < 16){
@@ -81,7 +81,7 @@ static int mpc7_decode_init(AVCodecContext * avctx)
         return -1;
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
-    c->rnd = 0xDEADBEEF;
+    av_init_random(0xDEADBEEF, &c->rnd);
     dsputil_init(&c->dsp, avctx);
     c->dsp.bswap_buf(buf, avctx->extradata, 4);
     ff_mpa_synth_init(mpa_window);
@@ -135,13 +135,6 @@ static int mpc7_decode_init(AVCodecContext * avctx)
     return 0;
 }
 
-// XXX replace with something better
-static int av_always_inline mpc_rnd(MPCContext *c)
-{
-    c->rnd = c->rnd * 27 + 17;
-    return c->rnd;
-}
-
 /**
  * Process decoded Musepack data and produce PCM
  * @todo make it available for MPC8 and MPC6
@@ -169,15 +162,15 @@ static void mpc_synth(MPCContext *c, int16_t *out)
 /**
  * Fill samples for given subband
  */
-static void inline idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *dst)
+static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *dst)
 {
     int i, i1, t;
     switch(idx){
     case -1:
         for(i = 0; i < SAMPLES_PER_BAND; i++){
-            t = mpc_rnd(c);
-            *dst++ = ((t>>24)& 0xFF) + ((t>>16) & 0xFF) + ((t>>8) & 0xFF) + (t & 0xFF) - 510;
+            *dst++ = (av_random(&c->rnd) & 0x3FC) - 510;
         }
+        break;
     case 1:
         i1 = get_bits1(gb);
         for(i = 0; i < SAMPLES_PER_BAND/3; i++){