|
|
@ -128,7 +128,7 @@ static av_cold int decode_init(AVCodecContext *avctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RALFContext *ctx = avctx->priv_data; |
|
|
|
RALFContext *ctx = avctx->priv_data; |
|
|
|
int i, j, k; |
|
|
|
int i, j, k; |
|
|
|
int ret; |
|
|
|
int ret, channels; |
|
|
|
|
|
|
|
|
|
|
|
if (avctx->extradata_size < 24 || memcmp(avctx->extradata, "LSD:", 4)) { |
|
|
|
if (avctx->extradata_size < 24 || memcmp(avctx->extradata, "LSD:", 4)) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, "Extradata is not groovy, dude\n"); |
|
|
|
av_log(avctx, AV_LOG_ERROR, "Extradata is not groovy, dude\n"); |
|
|
@ -141,17 +141,17 @@ static av_cold int decode_init(AVCodecContext *avctx) |
|
|
|
return AVERROR_PATCHWELCOME; |
|
|
|
return AVERROR_PATCHWELCOME; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
avctx->channels = AV_RB16(avctx->extradata + 8); |
|
|
|
channels = AV_RB16(avctx->extradata + 8); |
|
|
|
avctx->sample_rate = AV_RB32(avctx->extradata + 12); |
|
|
|
avctx->sample_rate = AV_RB32(avctx->extradata + 12); |
|
|
|
if (avctx->channels < 1 || avctx->channels > 2 |
|
|
|
if (channels < 1 || channels > 2 |
|
|
|
|| avctx->sample_rate < 8000 || avctx->sample_rate > 96000) { |
|
|
|
|| avctx->sample_rate < 8000 || avctx->sample_rate > 96000) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, "Invalid coding parameters %d Hz %d ch\n", |
|
|
|
av_log(avctx, AV_LOG_ERROR, "Invalid coding parameters %d Hz %d ch\n", |
|
|
|
avctx->sample_rate, avctx->channels); |
|
|
|
avctx->sample_rate, channels); |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
avctx->sample_fmt = AV_SAMPLE_FMT_S16P; |
|
|
|
avctx->sample_fmt = AV_SAMPLE_FMT_S16P; |
|
|
|
avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO |
|
|
|
av_channel_layout_uninit(&avctx->ch_layout); |
|
|
|
: AV_CH_LAYOUT_MONO; |
|
|
|
av_channel_layout_default(&avctx->ch_layout, channels); |
|
|
|
|
|
|
|
|
|
|
|
ctx->max_frame_size = AV_RB32(avctx->extradata + 16); |
|
|
|
ctx->max_frame_size = AV_RB32(avctx->extradata + 16); |
|
|
|
if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) { |
|
|
|
if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) { |
|
|
@ -346,7 +346,7 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb, |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (avctx->channels > 1) |
|
|
|
if (avctx->ch_layout.nb_channels > 1) |
|
|
|
dmode = get_bits(gb, 2) + 1; |
|
|
|
dmode = get_bits(gb, 2) + 1; |
|
|
|
else |
|
|
|
else |
|
|
|
dmode = 0; |
|
|
|
dmode = 0; |
|
|
@ -356,7 +356,7 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb, |
|
|
|
bits[0] = 16; |
|
|
|
bits[0] = 16; |
|
|
|
bits[1] = (mode[1] == 2) ? 17 : 16; |
|
|
|
bits[1] = (mode[1] == 2) ? 17 : 16; |
|
|
|
|
|
|
|
|
|
|
|
for (ch = 0; ch < avctx->channels; ch++) { |
|
|
|
for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { |
|
|
|
if ((ret = decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0) |
|
|
|
if ((ret = decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0) |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
if (ctx->filter_params > 1 && ctx->filter_params != FILTER_RAW) { |
|
|
|
if (ctx->filter_params > 1 && ctx->filter_params != FILTER_RAW) { |
|
|
@ -472,7 +472,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, |
|
|
|
while (get_bits_left(&gb) > 0) { |
|
|
|
while (get_bits_left(&gb) > 0) { |
|
|
|
if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size)) |
|
|
|
if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size)) |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->channels); |
|
|
|
ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->ch_layout.nb_channels); |
|
|
|
if (get_bits1(&gb)) { |
|
|
|
if (get_bits1(&gb)) { |
|
|
|
ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9); |
|
|
|
ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|