Make Musepack decoders use LFG pseudorandom generator

Originally committed as revision 17880 to svn://svn.ffmpeg.org/ffmpeg/trunk
release/0.6
Kostya Shishkov 16 years ago
parent d2f532c8a0
commit 74e2a0784e
  1. 1
      libavcodec/mpc.c
  2. 4
      libavcodec/mpc.h
  3. 6
      libavcodec/mpc7.c
  4. 6
      libavcodec/mpc8.c

@ -25,7 +25,6 @@
* divided into 32 subbands. * divided into 32 subbands.
*/ */
#include "libavutil/random.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h" #include "bitstream.h"
#include "dsputil.h" #include "dsputil.h"

@ -28,7 +28,7 @@
#ifndef AVCODEC_MPC_H #ifndef AVCODEC_MPC_H
#define AVCODEC_MPC_H #define AVCODEC_MPC_H
#include "libavutil/random.h" #include "libavutil/lfg.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h" #include "bitstream.h"
#include "dsputil.h" #include "dsputil.h"
@ -62,7 +62,7 @@ typedef struct {
int cur_frame, frames; int cur_frame, frames;
uint8_t *bits; uint8_t *bits;
int buf_size; int buf_size;
AVRandomState rnd; AVLFG rnd;
int frames_to_skip; int frames_to_skip;
/* for synthesis */ /* for synthesis */
DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]);

@ -25,7 +25,7 @@
* divided into 32 subbands. * divided into 32 subbands.
*/ */
#include "libavutil/random.h" #include "libavutil/lfg.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h" #include "bitstream.h"
#include "dsputil.h" #include "dsputil.h"
@ -53,7 +53,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
return -1; return -1;
} }
memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
av_random_init(&c->rnd, 0xDEADBEEF); av_lfg_init(&c->rnd, 0xDEADBEEF);
dsputil_init(&c->dsp, avctx); dsputil_init(&c->dsp, avctx);
c->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)avctx->extradata, 4); c->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)avctx->extradata, 4);
ff_mpc_init(); ff_mpc_init();
@ -118,7 +118,7 @@ static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *
switch(idx){ switch(idx){
case -1: case -1:
for(i = 0; i < SAMPLES_PER_BAND; i++){ for(i = 0; i < SAMPLES_PER_BAND; i++){
*dst++ = (av_random(&c->rnd) & 0x3FC) - 510; *dst++ = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
} }
break; break;
case 1: case 1:

@ -25,7 +25,7 @@
* divided into 32 subbands. * divided into 32 subbands.
*/ */
#include "libavutil/random.h" #include "libavutil/lfg.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h" #include "bitstream.h"
#include "dsputil.h" #include "dsputil.h"
@ -100,7 +100,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
return -1; return -1;
} }
memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
av_random_init(&c->rnd, 0xDEADBEEF); av_lfg_init(&c->rnd, 0xDEADBEEF);
dsputil_init(&c->dsp, avctx); dsputil_init(&c->dsp, avctx);
ff_mpc_init(); ff_mpc_init();
@ -284,7 +284,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
switch(res){ switch(res){
case -1: case -1:
for(j = 0; j < SAMPLES_PER_BAND; j++) for(j = 0; j < SAMPLES_PER_BAND; j++)
c->Q[ch][off + j] = (av_random(&c->rnd) & 0x3FC) - 510; c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break; break;
case 0: case 0:
break; break;

Loading…
Cancel
Save