mirror of https://github.com/mpv-player/mpv
ad_speex: support decoding stream without header packet
Setup default speex modes, allows decoding of speex in flv which does not contain a header packet. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33327 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
e7e4d1d802
commit
84b2296c34
|
@ -63,10 +63,7 @@ static int init(sh_audio_t *sh) {
|
||||||
const uint8_t *hdr = (const uint8_t *)(sh->wf + 1);
|
const uint8_t *hdr = (const uint8_t *)(sh->wf + 1);
|
||||||
const SpeexMode *spx_mode;
|
const SpeexMode *spx_mode;
|
||||||
const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack
|
const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack
|
||||||
if (!sh->wf || sh->wf->cbSize < 80) {
|
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);
|
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) {
|
if (!ctx->hdr && sh->wf->cbSize == 0x72 && hdr[0] == 1 && hdr[1] == 0) {
|
||||||
// speex.acm format: raw SpeexHeader dump
|
// speex.acm format: raw SpeexHeader dump
|
||||||
|
@ -86,8 +83,18 @@ static int init(sh_audio_t *sh) {
|
||||||
ctx->hdr->frames_per_packet = read_le32(&hdr);
|
ctx->hdr->frames_per_packet = read_le32(&hdr);
|
||||||
}
|
}
|
||||||
if (!ctx->hdr) {
|
if (!ctx->hdr) {
|
||||||
mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Invalid extradata!\n");
|
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Invalid or missing extradata! Assuming defaults.\n");
|
||||||
goto err_out;
|
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) {
|
if (ctx->hdr->nb_channels != 1 && ctx->hdr->nb_channels != 2) {
|
||||||
mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of channels (%i), "
|
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->sample_format = AF_FORMAT_S16_NE;
|
||||||
sh->context = ctx;
|
sh->context = ctx;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
err_out:
|
|
||||||
if (ctx)
|
|
||||||
free(ctx->hdr);
|
|
||||||
free(ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninit(sh_audio_t *sh) {
|
static void uninit(sh_audio_t *sh) {
|
||||||
|
|
Loading…
Reference in New Issue