diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-26 16:57:25 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-26 16:57:25 +0300 |
commit | ff559b8e90c343eb465400d77fe8881eff09c6e3 (patch) | |
tree | f97a23e6945e91be5be86baf2cfc06e0d384e867 /libmpcodecs/ad_speex.c | |
parent | d2e25a90c40c47b97becaa6eaefa16e61f7f0cdf (diff) | |
parent | b864ff1b8d73616e2e5bab1e00ef2bdb8fe50278 (diff) | |
download | mpv-ff559b8e90c343eb465400d77fe8881eff09c6e3.tar.bz2 mpv-ff559b8e90c343eb465400d77fe8881eff09c6e3.tar.xz |
Merge svn changes up to r30907
Diffstat (limited to 'libmpcodecs/ad_speex.c')
-rw-r--r-- | libmpcodecs/ad_speex.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c index 4eca5293df..a93a245492 100644 --- a/libmpcodecs/ad_speex.c +++ b/libmpcodecs/ad_speex.c @@ -52,8 +52,15 @@ static int preinit(sh_audio_t *sh) { return 1; } +static int read_le32(const uint8_t **src) { + const uint8_t *p = *src; + *src += 4; + return p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); +} + static int init(sh_audio_t *sh) { context_t *ctx = calloc(1, sizeof(context_t)); + const uint8_t *hdr = (const uint8_t *)(sh->wf + 1); const SpeexMode *spx_mode; const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack if (!sh->wf || sh->wf->cbSize < 80) { @@ -61,6 +68,27 @@ static int init(sh_audio_t *sh) { return 0; } ctx->hdr = speex_packet_to_header((char *)&sh->wf[1], sh->wf->cbSize); + if (!ctx->hdr && sh->wf->cbSize == 0x72 && hdr[0] == 1 && hdr[1] == 0) { + // speex.acm format: raw SpeexHeader dump + ctx->hdr = calloc(1, sizeof(*ctx->hdr)); + hdr += 2; + hdr += 8; // identifier string + hdr += 20; // version string + ctx->hdr->speex_version_id = read_le32(&hdr); + ctx->hdr->header_size = read_le32(&hdr); + ctx->hdr->rate = read_le32(&hdr); + ctx->hdr->mode = read_le32(&hdr); + ctx->hdr->mode_bitstream_version = read_le32(&hdr); + ctx->hdr->nb_channels = read_le32(&hdr); + ctx->hdr->bitrate = read_le32(&hdr); + ctx->hdr->frame_size = read_le32(&hdr); + ctx->hdr->vbr = read_le32(&hdr); + ctx->hdr->frames_per_packet = read_le32(&hdr); + } + if (!ctx->hdr) { + mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Invalid extradata!\n"); + return 0; + } if (ctx->hdr->nb_channels != 1 && ctx->hdr->nb_channels != 2) { mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of channels (%i), " "assuming mono\n", ctx->hdr->nb_channels); |