Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-04 14:30:25 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-10-04 14:30:25 +0400
commit741f5b021a0494676de0dab543f8a9591ec2e01e (patch)
tree51b8243f64192e37c61bf03d18a25f40fd4c0d6d /libavcodec/libspeexdec.c
parent047dcfabc7e8932490836be94ef3b2ecc8289ab0 (diff)
parent29abb04e73b0580ebe38703cadb988d26df6a76a (diff)
Merge commit '29abb04e73b0580ebe38703cadb988d26df6a76a'
* commit '29abb04e73b0580ebe38703cadb988d26df6a76a': libspeexdec: If the channel count is not valid, decode as stereo. libspeexdec: improve setting of Speex mode and sample rate libspeex: Add a private option for enabling VAD xtea: Test inplace decryption xtea: Fix CBC decryption when src==dst xtea: Factorize testing into a separate function configure: Refactor HAVE_ options available on the command line avconv/avprobe: Add missing 'void' to exit_program() definition Allow use of strncpy() blowfish: Add more tests blowfish: Fix CBC decryption with dst==src blowfish: Factorize testing into a separate function Conflicts: configure libavcodec/libspeexdec.c libavutil/xtea.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libspeexdec.c')
-rw-r--r--libavcodec/libspeexdec.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index 60859b7e4b..490e6925f5 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -39,35 +39,42 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;
const SpeexMode *mode;
-
- // defaults in the case of a missing header
- if (avctx->sample_rate <= 8000)
- mode = &speex_nb_mode;
- else if (avctx->sample_rate <= 16000)
- mode = &speex_wb_mode;
- else
- mode = &speex_uwb_mode;
+ int spx_mode;
if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
- avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
s->frame_size = s->header->frame_size;
-
- mode = speex_lib_get_mode(s->header->mode);
- if (!mode) {
- av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d\n", s->header->mode);
- return AVERROR_INVALIDDATA;
+ spx_mode = s->header->mode;
+ } else {
+ switch (avctx->sample_rate) {
+ case 8000: spx_mode = 0; break;
+ case 16000: spx_mode = 1; break;
+ case 32000: spx_mode = 2; break;
+ default:
+ /* libspeex can handle any mode if initialized as ultra-wideband */
+ av_log(avctx, AV_LOG_WARNING, "Invalid sample rate: %d\n"
+ "Decoding as 32kHz ultra-wideband\n",
+ avctx->sample_rate);
+ spx_mode = 2;
}
- } else
- av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n");
+ }
+
+ mode = speex_lib_get_mode(spx_mode);
+ if (!mode) {
+ av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", spx_mode);
+ return AVERROR_INVALIDDATA;
+ }
+ avctx->sample_rate = 8000 << spx_mode;
- if (avctx->channels > 2) {
- av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
- return AVERROR(EINVAL);
+ if (avctx->channels < 1 || avctx->channels > 2) {
+ /* libspeex can handle mono or stereo if initialized as stereo */
+ av_log(avctx, AV_LOG_ERROR, "Invalid channel count: %d.\n"
+ "Decoding as stereo.\n", avctx->channels);
+ avctx->channels = 2;
}
speex_bits_init(&s->bits);