[FFmpeg-cvslog] avcodec/wmaprodec: improve xma2 extradata parsing

Paul B Mahol git at videolan.org
Fri Sep 3 20:10:41 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Sep  3 11:24:03 2021 +0200| [094397ce06d4e150633324253eb91d24dae4c87b] | committer: Paul B Mahol

avcodec/wmaprodec: improve xma2 extradata parsing

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=094397ce06d4e150633324253eb91d24dae4c87b
---

 libavcodec/wmaprodec.c | 8 +++++---
 1 file 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)) {



More information about the ffmpeg-cvslog mailing list