summaryrefslogtreecommitdiff
path: root/libavcodec/wmaprodec.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-09-03 11:24:03 +0200
committerPaul B Mahol <onemda@gmail.com>2021-09-03 19:10:20 +0200
commit094397ce06d4e150633324253eb91d24dae4c87b (patch)
tree0bcbc0b0f9b37d55886c2ea21b60d8df3f02a730 /libavcodec/wmaprodec.c
parenta3fd78db12ced9d197ebe0267c28b64ec090d355 (diff)
downloadffmpeg-094397ce06d4e150633324253eb91d24dae4c87b.tar.gz
avcodec/wmaprodec: improve xma2 extradata parsing
Diffstat (limited to 'libavcodec/wmaprodec.c')
-rw-r--r--libavcodec/wmaprodec.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 97ad8782c2..513ff7f8d9 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -574,7 +574,8 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu
if (avctx->debug & FF_DEBUG_BITSTREAM)
dump_context(s);
- avctx->channel_layout = channel_mask;
+ if (avctx->codec_id == AV_CODEC_ID_WMAPRO)
+ avctx->channel_layout = channel_mask;
ff_thread_once(&init_static_once, decode_init_static);
@@ -1936,8 +1937,9 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
/* get stream config */
- if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size == 34) { /* XMA2WAVEFORMATEX */
- s->num_streams = (avctx->channels + 1) / 2;
+ if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size >= 34) { /* XMA2WAVEFORMATEX */
+ s->num_streams = AV_RL16(avctx->extradata);
+ avctx->channel_layout = AV_RL32(avctx->extradata + 2);
} else if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size >= 2) { /* XMA2WAVEFORMAT */
s->num_streams = avctx->extradata[1];
if (avctx->extradata_size != (32 + ((avctx->extradata[0]==3)?0:8) + 4*s->num_streams)) {