#include <stddef.h>
#include <stdio.h>
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
+#include "libavutil/random_seed.h"
#include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
#include "dsputil.h"
#include "bytestream.h"
#define MC_COOK 0x2000000 //multichannel Cook, not supported
#define SUBBAND_SIZE 20
+#define MAX_SUBPACKETS 5
//#define COOKDEBUG
typedef struct {
int bits_per_subpacket;
int cookversion;
/* states */
- AVRandomState random_state;
+ AVLFG random_state;
/* transform data */
MDCTContext mdct_ctx;
* (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]);
* Buffer alignment needs to be checked. */
- off = (int)((long)inbuffer & 3);
+ off = (intptr_t)inbuffer & 3;
buf = (const uint32_t*) (inbuffer - off);
c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8))));
bytes += 3 + off;
} else {
/* noise coding if subband_coef_index[i] == 0 */
f1 = dither_tab[index];
- if (av_random(&q->random_state) < 0x80000000) f1 = -f1;
+ if (av_lfg_get(&q->random_state) < 0x80000000) f1 = -f1;
}
mlt_p[i] = f1 * rootpow2tab[quant_index+63];
}
static int cook_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- const uint8_t *buf, int buf_size) {
+ AVPacket *avpkt) {
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
COOKContext *q = avctx->priv_data;
if (buf_size < avctx->block_align)
}
#endif
+static av_cold int cook_count_channels(unsigned int mask){
+ int i;
+ int channels = 0;
+ for(i = 0;i<32;i++){
+ if(mask & (1<<i))
+ ++channels;
+ }
+ return channels;
+}
+
/**
* Cook initialization
*
q->bit_rate = avctx->bit_rate;
/* Initialize RNG. */
- av_random_init(&q->random_state, 1);
+ av_lfg_init(&q->random_state, ff_random_get_seed());
/* Initialize extradata related variables. */
q->samples_per_channel = q->samples_per_frame / q->nb_channels;