Commit 4dcf71aa authored by Paul B Mahol's avatar Paul B Mahol

takdec: stop decoding in case of unknown bps

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 56519d7d
...@@ -146,7 +146,7 @@ static const struct CParam { ...@@ -146,7 +146,7 @@ static const struct CParam {
{ 0x1A, 0x1800000, 0x1800000, 0x6800000, 0xC000000 }, { 0x1A, 0x1800000, 0x1800000, 0x6800000, 0xC000000 },
}; };
static void tak_set_bps(AVCodecContext *avctx, int bps) static int tak_set_bps(AVCodecContext *avctx, int bps)
{ {
switch (bps) { switch (bps) {
case 8: case 8:
...@@ -158,7 +158,12 @@ static void tak_set_bps(AVCodecContext *avctx, int bps) ...@@ -158,7 +158,12 @@ static void tak_set_bps(AVCodecContext *avctx, int bps)
case 24: case 24:
avctx->sample_fmt = AV_SAMPLE_FMT_S32P; avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
break; break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid/unsupported bits per sample\n");
return AVERROR_INVALIDDATA;
} }
return 0;
} }
static int get_shift(int sample_rate) static int get_shift(int sample_rate)
...@@ -185,6 +190,7 @@ static int get_scale(int sample_rate, int shift) ...@@ -185,6 +190,7 @@ static int get_scale(int sample_rate, int shift)
static av_cold int tak_decode_init(AVCodecContext *avctx) static av_cold int tak_decode_init(AVCodecContext *avctx)
{ {
TAKDecContext *s = avctx->priv_data; TAKDecContext *s = avctx->priv_data;
int ret;
ff_tak_init_crc(); ff_tak_init_crc();
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);
...@@ -196,7 +202,8 @@ static av_cold int tak_decode_init(AVCodecContext *avctx) ...@@ -196,7 +202,8 @@ static av_cold int tak_decode_init(AVCodecContext *avctx)
s->uval = get_scale(avctx->sample_rate, get_shift(avctx->sample_rate)); s->uval = get_scale(avctx->sample_rate, get_shift(avctx->sample_rate));
s->subframe_scale = get_scale(avctx->sample_rate, 1); s->subframe_scale = get_scale(avctx->sample_rate, 1);
tak_set_bps(avctx, avctx->bits_per_coded_sample); if ((ret = tak_set_bps(avctx, avctx->bits_per_coded_sample)) < 0)
return ret;
return 0; return 0;
} }
...@@ -775,7 +782,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, ...@@ -775,7 +782,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
if (s->ti.bps != avctx->bits_per_raw_sample) { if (s->ti.bps != avctx->bits_per_raw_sample) {
avctx->bits_per_raw_sample = s->ti.bps; avctx->bits_per_raw_sample = s->ti.bps;
tak_set_bps(avctx, avctx->bits_per_raw_sample); if ((ret = tak_set_bps(avctx, avctx->bits_per_raw_sample)) < 0)
return ret;
} }
if (s->ti.sample_rate != avctx->sample_rate) { if (s->ti.sample_rate != avctx->sample_rate) {
avctx->sample_rate = s->ti.sample_rate; avctx->sample_rate = s->ti.sample_rate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment