diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-05-02 00:46:03 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-05-02 00:46:03 +0300 |
commit | 7e65428712beacd416dc3410c52f22ebfd3b4c53 (patch) | |
tree | 79bb2f4388be7031b5505c7745e1a59aff6cff56 /libmpcodecs/ad_speex.c | |
parent | 5c4b059f1608f6d6a981b7d81a14f1c46e40ba52 (diff) | |
parent | d0376729d171a6c0b4cc15928c168f68adefbaa6 (diff) |
Merge branch 'mplayer1_changes'
Diffstat (limited to 'libmpcodecs/ad_speex.c')
-rw-r--r-- | libmpcodecs/ad_speex.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c index f8ddc2f336..c9ac1a42c6 100644 --- a/libmpcodecs/ad_speex.c +++ b/libmpcodecs/ad_speex.c @@ -63,11 +63,8 @@ static int init(sh_audio_t *sh) { 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) { - mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n"); - goto err_out; - } - ctx->hdr = speex_packet_to_header((char *)&sh->wf[1], sh->wf->cbSize); + if (sh->wf && sh->wf->cbSize >= 80) + 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)); @@ -86,8 +83,18 @@ static int init(sh_audio_t *sh) { ctx->hdr->frames_per_packet = read_le32(&hdr); } if (!ctx->hdr) { - mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Invalid extradata!\n"); - goto err_out; + mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Invalid or missing extradata! Assuming defaults.\n"); + ctx->hdr = calloc(1, sizeof(*ctx->hdr)); + ctx->hdr->frames_per_packet = 1; + ctx->hdr->mode = 0; + if (sh->wf) { + ctx->hdr->nb_channels = sh->wf->nChannels; + ctx->hdr->rate = sh->wf->nSamplesPerSec; + if (ctx->hdr->rate > 16000) + ctx->hdr->mode = 2; + else if (ctx->hdr->rate > 8000) + ctx->hdr->mode = 1; + } } if (ctx->hdr->nb_channels != 1 && ctx->hdr->nb_channels != 2) { mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of channels (%i), " @@ -119,12 +126,6 @@ static int init(sh_audio_t *sh) { sh->sample_format = AF_FORMAT_S16_NE; sh->context = ctx; return 1; - -err_out: - if (ctx) - free(ctx->hdr); - free(ctx); - return 0; } static void uninit(sh_audio_t *sh) { |