diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index 51ab7ea..a51fbe2 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -50,7 +50,19 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
         if (!header)
             av_log(avctx, AV_LOG_WARNING, "Invalid Speex header\n");
     }
-    if (header) {
+    
+    if (avctx->codec_tag == MKTAG('S', 'P', 'X', 'N')) {
+        if (!avctx->extradata || avctx->extradata && avctx->extradata_size < 47) {
+            av_log(avctx, AV_LOG_ERROR, "Missing or invalid extradata.\n");
+            return AVERROR_INVALIDDATA;
+        }
+        if (avctx->extradata[37] != 10) {
+            av_log(avctx, AV_LOG_ERROR, "Unsupported compression mode.\n");
+            return AVERROR_PATCHWELCOME;
+        }
+        avctx->channels    = 1;
+        spx_mode           = 0;
+    } else if (header) {
         avctx->channels    = header->nb_channels;
         spx_mode           = header->mode;
         speex_header_free(header);
@@ -73,6 +85,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", spx_mode);
         return AVERROR_INVALIDDATA;
     }
+    if (avctx->codec_tag != MKTAG('S', 'P', 'X', 'N'))
     avctx->sample_rate = 8000 << spx_mode;
     s->frame_size      =  160 << spx_mode;

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 3271056..813a018 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -292,6 +292,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
     { AV_CODEC_ID_QDM2,            MKTAG('Q', 'D', 'M', '2') },
     { AV_CODEC_ID_QDMC,            MKTAG('Q', 'D', 'M', 'C') },
     { AV_CODEC_ID_SPEEX,           MKTAG('s', 'p', 'e', 'x') }, /* Flash Media Server */
+    { AV_CODEC_ID_SPEEX,           MKTAG('S', 'P', 'X', 'N') },
     { AV_CODEC_ID_WMAV2,           MKTAG('W', 'M', 'A', '2') },
     { AV_CODEC_ID_NONE, 0 },
 };
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d7d7f21..bcf44de 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1010,7 +1010,7 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if ((uint64_t)atom.size > (1<<30))
         return AVERROR_INVALIDDATA;
 
-    if (st->codec->codec_id == AV_CODEC_ID_QDM2 || st->codec->codec_id == AV_CODEC_ID_QDMC) {
+    if (st->codec->codec_id == AV_CODEC_ID_QDM2 || st->codec->codec_id == AV_CODEC_ID_QDMC || st->codec->codec_id == AV_CODEC_ID_SPEEX) {
         // pass all frma atom to codec, needed at least for QDMC and QDM2
         av_free(st->codec->extradata);
         st->codec->extradata_size = 0;
