if(ctx->zeroes)
return 0;
}else{
- t = get_unary(gb, 0, 33);
+ t = get_unary_0_33(gb);
if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1));
ctx->zeroes = t;
if(ctx->zeroes){
t = 0;
ctx->zero = 0;
}else{
- t = get_unary(gb, 0, 33);
+ t = get_unary_0_33(gb);
if(get_bits_count(gb) >= ctx->data_size){
*last = 1;
return 0;
}
if(t == 16) {
- t2 = get_unary(gb, 0, 33);
+ t2 = get_unary_0_33(gb);
if(t2 < 2) t += t2;
else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
}
return count;
}
-static int wavpack_decode_init(AVCodecContext *avctx)
+static av_cold int wavpack_decode_init(AVCodecContext *avctx)
{
WavpackContext *s = avctx->priv_data;
s->avctx = avctx;
s->stereo = (avctx->channels == 2);
-
- return 0;
-}
-
-static int wavpack_decode_close(AVCodecContext *avctx)
-{
-// WavpackContext *s = avctx->priv_data;
+ avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
return 0;
}
static int wavpack_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
WavpackContext *s = avctx->priv_data;
int16_t *samples = data;
int samplecount;
int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0;
- uint8_t* buf_end = buf + buf_size;
+ const uint8_t* buf_end = buf + buf_size;
int i, j, id, size, ssize, weights, t;
if (buf_size == 0){
sizeof(WavpackContext),
wavpack_decode_init,
NULL,
- wavpack_decode_close,
+ NULL,
wavpack_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("WavPack"),
};