lavf/brstm: handle a BFSTM endianness oddity
authorRodger Combs <rodger.combs@gmail.com>
Sat, 20 Jun 2015 10:01:26 +0000 (05:01 -0500)
committerPaul B Mahol <onemda@gmail.com>
Sun, 21 Jun 2015 10:32:13 +0000 (10:32 +0000)
libavformat/brstm.c

index 0014b48..45bdb72 100644 (file)
@@ -296,7 +296,17 @@ static int read_header(AVFormatContext *s)
                     ret = AVERROR(ENOMEM);
                     goto fail;
                 }
-                avio_read(s->pb, b->adpc, asize);
+                if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
+                    // Big-endian BFSTMs have little-endian SEEK tables
+                    // for some strange reason.
+                    int i;
+                    for (i = 0; i < asize; i += 2) {
+                        b->adpc[i+1] = avio_r8(s->pb);
+                        b->adpc[i]   = avio_r8(s->pb);
+                    }
+                } else {
+                    avio_read(s->pb, b->adpc, asize);
+                }
                 avio_skip(s->pb, size - asize);
             }
             break;