annotate libmpcodecs/ad_speex.c @ 36782:06344efeded3

configure: improve FFmpeg check. If internal FFmpeg is not available we should fall back to external automatically instead of trying to build without (which is currently broken it seems). Also we can compile without internal copy as long as the necessary headers can be found. Two are required that FFmpeg does not install: libavformat/internal.h libavutil/x86/asm.h
author reimar
date Mon, 17 Feb 2014 23:25:32 +0000
parents a93891202051
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
1 /*
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
2 * Speex decoder by Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de>
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
3 *
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
4 * This code may be be relicensed under the terms of the GNU LGPL when it
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
5 * becomes part of the FFmpeg project (ffmpeg.org)
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
6 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
7 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
10 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
12 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
17 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
18 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
19 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
22 */
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 20962
diff changeset
23
18157
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
24 #include <stdlib.h>
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
25 #include <speex/speex.h>
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
26 #include <speex/speex_stereo.h>
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
27 #include <speex/speex_header.h>
34174
a93891202051 Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents: 33240
diff changeset
28
a93891202051 Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents: 33240
diff changeset
29 #include "config.h"
a93891202051 Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents: 33240
diff changeset
30 #include "mp_msg.h"
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
31 #include "ad_internal.h"
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
32
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
33 static const ad_info_t info = {
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
34 "Speex audio decoder",
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
35 "speex",
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
36 "Reimar Döffinger",
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
37 "",
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
38 ""
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
39 };
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
40
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
41 LIBAD_EXTERN(speex)
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
42
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
43 typedef struct {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
44 SpeexBits bits;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
45 void *dec_context;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
46 SpeexStereoState stereo;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
47 SpeexHeader *hdr;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
48 } context_t;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
49
18157
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
50 #define MAX_FRAMES_PER_PACKET 100
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
51
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
52 static int preinit(sh_audio_t *sh) {
18157
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
53 sh->audio_out_minsize = 2 * 320 * MAX_FRAMES_PER_PACKET * 2 * sizeof(short);
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
54 return 1;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
55 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
56
30842
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
57 static int read_le32(const uint8_t **src) {
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
58 const uint8_t *p = *src;
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
59 *src += 4;
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
60 return p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
61 }
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
62
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
63 static int init(sh_audio_t *sh) {
18879
cc65a585fdcc rm unnecesary casts from void* - part 3
reynaldo
parents: 18157
diff changeset
64 context_t *ctx = calloc(1, sizeof(context_t));
30842
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
65 const uint8_t *hdr = (const uint8_t *)(sh->wf + 1);
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
66 const SpeexMode *spx_mode;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
67 const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack
33240
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
68 if (sh->wf && sh->wf->cbSize >= 80)
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
69 ctx->hdr = speex_packet_to_header((char *)&sh->wf[1], sh->wf->cbSize);
30842
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
70 if (!ctx->hdr && sh->wf->cbSize == 0x72 && hdr[0] == 1 && hdr[1] == 0) {
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
71 // speex.acm format: raw SpeexHeader dump
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
72 ctx->hdr = calloc(1, sizeof(*ctx->hdr));
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
73 hdr += 2;
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
74 hdr += 8; // identifier string
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
75 hdr += 20; // version string
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
76 ctx->hdr->speex_version_id = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
77 ctx->hdr->header_size = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
78 ctx->hdr->rate = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
79 ctx->hdr->mode = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
80 ctx->hdr->mode_bitstream_version = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
81 ctx->hdr->nb_channels = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
82 ctx->hdr->bitrate = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
83 ctx->hdr->frame_size = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
84 ctx->hdr->vbr = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
85 ctx->hdr->frames_per_packet = read_le32(&hdr);
482aa22c785e Support extradata format of the speex.acm windows codec formerly available
reimar
parents: 30841
diff changeset
86 }
30841
a1bf34d75484 Fix crash if speex_packet_to_header fails.
reimar
parents: 30633
diff changeset
87 if (!ctx->hdr) {
33240
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
88 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Invalid or missing extradata! Assuming defaults.\n");
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
89 ctx->hdr = calloc(1, sizeof(*ctx->hdr));
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
90 ctx->hdr->frames_per_packet = 1;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
91 ctx->hdr->mode = 0;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
92 if (sh->wf) {
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
93 ctx->hdr->nb_channels = sh->wf->nChannels;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
94 ctx->hdr->rate = sh->wf->nSamplesPerSec;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
95 if (ctx->hdr->rate > 16000)
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
96 ctx->hdr->mode = 2;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
97 else if (ctx->hdr->rate > 8000)
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
98 ctx->hdr->mode = 1;
1ff13ad1bc59 Setup default speex modes, allows decoding of speex in flv which does not
reimar
parents: 32617
diff changeset
99 }
30841
a1bf34d75484 Fix crash if speex_packet_to_header fails.
reimar
parents: 30633
diff changeset
100 }
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
101 if (ctx->hdr->nb_channels != 1 && ctx->hdr->nb_channels != 2) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
102 mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of channels (%i), "
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
103 "assuming mono\n", ctx->hdr->nb_channels);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
104 ctx->hdr->nb_channels = 1;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
105 }
18157
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
106 if (ctx->hdr->frames_per_packet > MAX_FRAMES_PER_PACKET) {
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
107 mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of frames per packet (%i), "
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
108 "assuming 1\n", ctx->hdr->frames_per_packet);
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
109 ctx->hdr->frames_per_packet = 1;
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
110 }
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
111 switch (ctx->hdr->mode) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
112 case 0:
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
113 spx_mode = &speex_nb_mode; break;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
114 case 1:
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
115 spx_mode = &speex_wb_mode; break;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
116 case 2:
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
117 spx_mode = &speex_uwb_mode; break;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
118 default:
18157
2c7219c38e56 bug fixes: left-over mode variable used uninitialized,
reimar
parents: 17429
diff changeset
119 mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Unknown speex mode (%i)\n", ctx->hdr->mode);
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
120 spx_mode = &speex_nb_mode;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
121 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
122 ctx->dec_context = speex_decoder_init(spx_mode);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
123 speex_bits_init(&ctx->bits);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
124 memcpy(&ctx->stereo, &st_st, sizeof(ctx->stereo)); // hack part 2
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
125 sh->channels = ctx->hdr->nb_channels;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
126 sh->samplerate = ctx->hdr->rate;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
127 sh->samplesize = 2;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
128 sh->sample_format = AF_FORMAT_S16_NE;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
129 sh->context = ctx;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
130 return 1;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
131 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
132
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
133 static void uninit(sh_audio_t *sh) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
134 context_t *ctx = sh->context;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
135 if (ctx) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
136 speex_bits_destroy(&ctx->bits);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
137 speex_decoder_destroy(ctx->dec_context);
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30842
diff changeset
138 free(ctx->hdr);
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
139 free(ctx);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
140 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
141 ctx = NULL;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
142 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
143
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
144 static int decode_audio(sh_audio_t *sh, unsigned char *buf,
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
145 int minlen, int maxlen) {
32617
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
146 double pts;
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
147 context_t *ctx = sh->context;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
148 int len, framelen, framesamples;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
149 char *packet;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
150 int i, err;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
151 speex_decoder_ctl(ctx->dec_context, SPEEX_GET_FRAME_SIZE, &framesamples);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
152 framelen = framesamples * ctx->hdr->nb_channels * sizeof(short);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
153 if (maxlen < ctx->hdr->frames_per_packet * framelen) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
154 mp_msg(MSGT_DECAUDIO, MSGL_V, "maxlen too small in decode_audio\n");
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
155 return -1;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
156 }
32617
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
157 len = ds_get_packet_pts(sh->ds, (unsigned char **)&packet, &pts);
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
158 if (len <= 0) return -1;
32617
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
159 if (sh->pts == MP_NOPTS_VALUE)
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
160 sh->pts = 0;
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
161 if (pts != MP_NOPTS_VALUE) {
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
162 sh->pts = pts;
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
163 sh->pts_bytes = 0;
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
164 }
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
165 speex_bits_read_from(&ctx->bits, packet, len);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
166 i = ctx->hdr->frames_per_packet;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
167 do {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
168 err = speex_decode_int(ctx->dec_context, &ctx->bits, (short *)buf);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
169 if (err == -2)
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
170 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Error decoding file.\n");
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
171 if (ctx->hdr->nb_channels == 2)
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
172 speex_decode_stereo_int((short *)buf, framesamples, &ctx->stereo);
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
173 buf = &buf[framelen];
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
174 } while (--i > 0);
32617
1baaacf00bbb Improve speex codec pts handling, make audio timestamps work reasonably
reimar
parents: 32602
diff changeset
175 sh->pts_bytes += ctx->hdr->frames_per_packet * framelen;
16916
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
176 return ctx->hdr->frames_per_packet * framelen;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
177 }
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
178
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
179 static int control(sh_audio_t *sh, int cmd, void *arg, ...) {
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
180 return CONTROL_UNKNOWN;
56f3945e2a61 Speex audio decoding
reimar
parents:
diff changeset
181 }