1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
/*
* Copyright (C) 2001-2008 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* xine audio decoder plugin using ffmpeg
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "../../libffmpeg/ffmpeg_config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <pthread.h>
#include <math.h>
#define LOG_MODULE "ffmpeg_audio_dec"
#define LOG_VERBOSE
/*
#define LOG
*/
#include "xine_internal.h"
#include "buffer.h"
#include "xineutils.h"
#include "bswap.h"
#include "ffmpeg_decoder.h"
#define AUDIOBUFSIZE (64 * 1024)
#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
# define AVAUDIO 3
#else
# define AVAUDIO 2
#endif
typedef struct {
audio_decoder_class_t decoder_class;
} ff_audio_class_t;
typedef struct ff_audio_decoder_s {
audio_decoder_t audio_decoder;
xine_stream_t *stream;
int output_open;
int audio_channels;
int audio_bits;
int audio_sample_rate;
unsigned char *buf;
int bufsize;
int size;
AVCodecContext *context;
AVCodec *codec;
char *decode_buffer;
int decoder_ok;
AVCodecParserContext *parser_context;
} ff_audio_decoder_t;
#include "ff_audio_list.h"
#define malloc16(s) realloc16(NULL,s)
#define free16(p) realloc16(p,0)
static void *realloc16 (void *m, size_t s) {
unsigned long diff, diff2;
unsigned char *p = m, *q;
if (p) {
diff = p[-1];
if (s == 0) {
free (p - diff);
return (NULL);
}
q = realloc (p - diff, s + 16);
if (!q) return (q);
diff2 = 16 - ((unsigned long)q & 15);
if (diff2 != diff) memmove (q + diff2, q + diff, s);
} else {
if (s == 0) return (NULL);
q = malloc (s + 16);
if (!q) return (q);
diff2 = 16 - ((unsigned long)q & 15);
}
q += diff2;
q[-1] = diff2;
return (q);
}
static void ff_audio_ensure_buffer_size(ff_audio_decoder_t *this, int size) {
if (size > this->bufsize) {
this->bufsize = size + size / 2;
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_audio_dec: increasing buffer to %d to avoid overflow.\n"),
this->bufsize);
this->buf = realloc16 (this->buf, this->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
}
}
static void ff_audio_handle_special_buffer(ff_audio_decoder_t *this, buf_element_t *buf) {
if (buf->decoder_info[1] == BUF_SPECIAL_STSD_ATOM) {
this->context->extradata_size = buf->decoder_info[2];
this->context->extradata = malloc(buf->decoder_info[2] +
FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(this->context->extradata, buf->decoder_info_ptr[2],
buf->decoder_info[2]);
}
}
static void ff_audio_init_codec(ff_audio_decoder_t *this, unsigned int codec_type) {
size_t i;
this->codec = NULL;
for(i = 0; i < sizeof(ff_audio_lookup)/sizeof(ff_codec_t); i++)
if(ff_audio_lookup[i].type == codec_type) {
pthread_mutex_lock (&ffmpeg_lock);
this->codec = avcodec_find_decoder(ff_audio_lookup[i].id);
pthread_mutex_unlock (&ffmpeg_lock);
_x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
ff_audio_lookup[i].name);
break;
}
if (!this->codec) {
xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_audio_dec: couldn't find ffmpeg decoder for buf type 0x%X\n"),
codec_type);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
return;
}
/* Current ffmpeg audio decoders usually use 16 bits/sample
* buf->decoder_info[2] can't be used as it doesn't refer to the output
* bits/sample for some codecs (e.g. MS ADPCM) */
this->audio_bits = 16;
this->context->bits_per_sample = this->audio_bits;
this->context->sample_rate = this->audio_sample_rate;
this->context->channels = this->audio_channels;
this->context->codec_id = this->codec->id;
this->context->codec_type = this->codec->type;
this->context->codec_tag = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC);
/* Use parser for AAC LATM and MPEG.
* Fixes:
* - DVB streams where multiple AAC LATM frames are packed to single PES
* - DVB streams where MPEG audio frames do not follow PES packet boundaries
*/
#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94)
if (codec_type == BUF_AUDIO_AAC_LATM ||
codec_type == BUF_AUDIO_MPEG) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: using parser\n");
this->parser_context = av_parser_init(this->codec->id);
if (!this->parser_context) {
xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
"ffmpeg_audio_dec: couldn't init parser\n");
}
}
#endif
}
static int ff_audio_open_codec(ff_audio_decoder_t *this, unsigned int codec_type) {
if ( !this->codec ) {
ff_audio_init_codec(this, codec_type);
}
if ( !this->codec ) {
xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_audio_dec: trying to open null codec\n"));
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
return -1;
}
pthread_mutex_lock (&ffmpeg_lock);
if (avcodec_open (this->context, this->codec) < 0) {
pthread_mutex_unlock (&ffmpeg_lock);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_audio_dec: couldn't open decoder\n"));
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
return -1;
}
pthread_mutex_unlock (&ffmpeg_lock);
this->decoder_ok = 1;
return 1;
}
static void ff_handle_header_buffer(ff_audio_decoder_t *this, buf_element_t *buf)
{
unsigned int codec_type = buf->type & (BUF_MAJOR_MASK | BUF_DECODER_MASK);
xine_waveformatex *audio_header;
/* accumulate init data */
ff_audio_ensure_buffer_size(this, this->size + buf->size);
xine_fast_memcpy(this->buf + this->size, buf->content, buf->size);
this->size += buf->size;
if (!(buf->decoder_flags & BUF_FLAG_FRAME_END)) {
return;
}
if(buf->decoder_flags & BUF_FLAG_STDHEADER) {
this->audio_sample_rate = buf->decoder_info[1];
this->audio_channels = buf->decoder_info[3];
if(this->size) {
audio_header = (xine_waveformatex *)this->buf;
this->context->block_align = audio_header->nBlockAlign;
this->context->bit_rate = audio_header->nAvgBytesPerSec * 8;
if(audio_header->cbSize > 0) {
this->context->extradata = malloc(audio_header->cbSize);
this->context->extradata_size = audio_header->cbSize;
memcpy( this->context->extradata,
(uint8_t *)audio_header + sizeof(xine_waveformatex),
audio_header->cbSize );
}
}
} else {
short *ptr;
switch(codec_type) {
case BUF_AUDIO_14_4:
this->audio_sample_rate = 8000;
this->audio_channels = 1;
this->context->block_align = 240;
break;
case BUF_AUDIO_28_8:
this->audio_sample_rate = _X_BE_16(&this->buf[0x30]);
this->audio_channels = this->buf[0x37];
/* this->audio_bits = buf->content[0x35] */
this->context->block_align = _X_BE_32(&this->buf[0x18]);
this->context->extradata_size = 5*sizeof(short);
this->context->extradata = malloc(this->context->extradata_size);
ptr = (short *) this->context->extradata;
ptr[0] = _X_BE_16(&this->buf[0x2C]); /* subpacket size */
ptr[1] = _X_BE_16(&this->buf[0x28]); /* subpacket height */
ptr[2] = _X_BE_16(&this->buf[0x16]); /* subpacket flavour */
ptr[3] = _X_BE_32(&this->buf[0x18]); /* coded frame size */
ptr[4] = 0; /* codec's data length */
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
"ffmpeg_audio_dec: 28_8 audio channels %d bits %d sample rate %d block align %d\n",
this->audio_channels, this->audio_bits, this->audio_sample_rate,
this->context->block_align);
break;
case BUF_AUDIO_COOK:
{
int version;
int data_len;
int extradata;
version = _X_BE_16 (this->buf+4);
if (version == 4) {
this->audio_sample_rate = _X_BE_16 (this->buf+48);
this->audio_bits = _X_BE_16 (this->buf+52);
this->audio_channels = _X_BE_16 (this->buf+54);
data_len = _X_BE_32 (this->buf+67);
extradata = 71;
} else {
this->audio_sample_rate = _X_BE_16 (this->buf+54);
this->audio_bits = _X_BE_16 (this->buf+58);
this->audio_channels = _X_BE_16 (this->buf+60);
data_len = _X_BE_32 (this->buf+74);
extradata = 78;
}
this->context->block_align = _X_BE_16 (this->buf+44);
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
"ffmpeg_audio_dec: cook audio channels %d bits %d sample rate %d block align %d\n",
this->audio_channels, this->audio_bits, this->audio_sample_rate,
this->context->block_align);
if (extradata + data_len > this->size)
break; /* abort early - extradata length is bad */
if (extradata > INT_MAX - data_len)
break;/*integer overflow*/
this->context->extradata_size = data_len;
this->context->extradata = malloc(this->context->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
xine_fast_memcpy (this->context->extradata, this->buf + extradata,
this->context->extradata_size);
break;
}
default:
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
"ffmpeg_audio_dec: unknown header with buf type 0x%X\n", codec_type);
break;
}
}
ff_audio_init_codec(this, codec_type);
this->size = 0;
}
static void ff_audio_reset_parser(ff_audio_decoder_t *this)
{
/* reset parser */
if (this->parser_context) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: resetting parser\n");
pthread_mutex_lock (&ffmpeg_lock);
av_parser_close(this->parser_context);
this->parser_context = av_parser_init(this->codec->id);
pthread_mutex_unlock (&ffmpeg_lock);
}
}
static int ff_audio_decode(xine_t *xine,
AVCodecContext *ctx,
AVCodecParserContext *parser_ctx,
int16_t *decode_buffer, int *decode_buffer_size,
uint8_t *buf, int size)
{
int consumed;
int parser_consumed = 0;
#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94)
if (parser_ctx) {
uint8_t *outbuf;
int outsize;
do {
int ret = av_parser_parse2(parser_ctx, ctx,
&outbuf, &outsize,
buf, size,
0, 0, 0);
parser_consumed += ret;
buf += ret;
size -= ret;
} while (size > 0 && outsize <= 0);
/* nothing to decode ? */
if (outsize <= 0) {
*decode_buffer_size = 0;
xprintf (xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: not enough data to decode\n");
return parser_consumed;
}
/* decode next packet */
buf = outbuf;
size = outsize;
}
#endif /* LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94) */
#if AVAUDIO > 2
AVPacket avpkt;
av_init_packet (&avpkt);
avpkt.data = buf;
avpkt.size = size;
avpkt.flags = AV_PKT_FLAG_KEY;
consumed = avcodec_decode_audio3 (ctx,
decode_buffer, decode_buffer_size,
&avpkt);
#else
consumed = avcodec_decode_audio2 (ctx,
decode_buffer, decode_buffer_size,
buf, size);
#endif
if (consumed < 0) {
xprintf (xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: error decompressing audio frame (%d)\n", consumed);
} else if (parser_consumed && consumed != size) {
xprintf (xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: decoder didn't consume all data\n");
}
return parser_consumed ? parser_consumed : consumed;
}
static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
ff_audio_decoder_t *this = (ff_audio_decoder_t *) this_gen;
int bytes_consumed;
int decode_buffer_size;
int offset;
int out;
audio_buffer_t *audio_buffer;
int bytes_to_send;
unsigned int codec_type = buf->type & (BUF_MAJOR_MASK | BUF_DECODER_MASK);
if (buf->decoder_flags & BUF_FLAG_SPECIAL) {
ff_audio_handle_special_buffer(this, buf);
return;
}
if (buf->decoder_flags & BUF_FLAG_HEADER) {
ff_handle_header_buffer(this, buf);
return;
} else {
if( !this->decoder_ok ) {
if (ff_audio_open_codec(this, codec_type) < 0) {
return;
}
}
if( buf->decoder_flags & BUF_FLAG_PREVIEW )
return;
ff_audio_ensure_buffer_size(this, this->size + buf->size);
xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
this->size += buf->size;
if (this->parser_context || buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
offset = 0;
/* pad input data */
memset(&this->buf[this->size], 0, FF_INPUT_BUFFER_PADDING_SIZE);
while (this->size>0) {
decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
bytes_consumed =
ff_audio_decode(this->stream->xine, this->context,
this->parser_context,
(int16_t *)this->decode_buffer, &decode_buffer_size,
&this->buf[offset], this->size);
if (bytes_consumed<0) {
this->size=0;
return;
} else if (bytes_consumed == 0 && decode_buffer_size == 0) {
if (offset)
memmove(this->buf, &this->buf[offset], this->size);
return;
}
if (!this->output_open) {
if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
this->audio_bits = this->context->bits_per_sample;
this->audio_sample_rate = this->context->sample_rate;
this->audio_channels = this->context->channels;
}
if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_audio_dec: cannot read codec parameters from packet\n"));
/* try to decode next packet. */
/* there shouldn't be any output yet */
decode_buffer_size = 0;
/* pts applies only to first audio packet */
buf->pts = 0;
} else {
this->output_open = (this->stream->audio_out->open) (this->stream->audio_out,
this->stream, this->audio_bits, this->audio_sample_rate,
_x_ao_channels2mode(this->audio_channels));
if (!this->output_open) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
"ffmpeg_audio_dec: error opening audio output\n");
this->size = 0;
return;
}
}
}
/* dispatch the decoded audio */
out = 0;
while (out < decode_buffer_size) {
int stream_status = xine_get_status(this->stream);
if (stream_status == XINE_STATUS_QUIT || stream_status == XINE_STATUS_STOP) {
this->size = 0;
return;
}
audio_buffer =
this->stream->audio_out->get_buffer (this->stream->audio_out);
if (audio_buffer->mem_size == 0) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: Help! Allocated audio buffer with nothing in it!\n");
return;
}
/* fill up this buffer */
if (codec_type == BUF_AUDIO_WMAPRO) {
/* the above codecs output float samples, not 16-bit integers */
int bytes_per_sample = sizeof(float);
if (((decode_buffer_size - out) * 2 / bytes_per_sample) > audio_buffer->mem_size)
bytes_to_send = audio_buffer->mem_size * bytes_per_sample / 2;
else
bytes_to_send = decode_buffer_size - out;
int16_t *int_buffer = calloc(1, bytes_to_send * 2 / bytes_per_sample);
int i;
for (i = 0; i < (bytes_to_send / bytes_per_sample); i++) {
float *float_sample = (float *)&this->decode_buffer[i * bytes_per_sample + out];
int_buffer[i] = (int16_t)lrintf(*float_sample * 32768.);
}
out += bytes_to_send;
bytes_to_send = bytes_to_send * 2 / bytes_per_sample;
xine_fast_memcpy(audio_buffer->mem, int_buffer, bytes_to_send);
free(int_buffer);
} else {
if ((decode_buffer_size - out) > audio_buffer->mem_size)
bytes_to_send = audio_buffer->mem_size;
else
bytes_to_send = decode_buffer_size - out;
xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[out], bytes_to_send);
out += bytes_to_send;
}
/* byte count / 2 (bytes / sample) / channels */
audio_buffer->num_frames = bytes_to_send / 2 / this->audio_channels;
audio_buffer->vpts = buf->pts;
buf->pts = 0; /* only first buffer gets the real pts */
this->stream->audio_out->put_buffer (this->stream->audio_out,
audio_buffer, this->stream);
}
this->size -= bytes_consumed;
offset += bytes_consumed;
}
/* reset internal accumulation buffer */
this->size = 0;
}
}
}
static void ff_audio_reset (audio_decoder_t *this_gen) {
ff_audio_decoder_t *this = (ff_audio_decoder_t *) this_gen;
this->size = 0;
/* try to reset the wma decoder */
if( this->decoder_ok ) {
pthread_mutex_lock (&ffmpeg_lock);
avcodec_close (this->context);
if (avcodec_open (this->context, this->codec) < 0)
this->decoder_ok = 0;
pthread_mutex_unlock (&ffmpeg_lock);
}
ff_audio_reset_parser(this);
}
static void ff_audio_discontinuity (audio_decoder_t *this_gen) {
ff_audio_decoder_t *this = (ff_audio_decoder_t *) this_gen;
this->size = 0;
ff_audio_reset_parser(this);
}
static void ff_audio_dispose (audio_decoder_t *this_gen) {
ff_audio_decoder_t *this = (ff_audio_decoder_t *) this_gen;
if (this->parser_context) {
pthread_mutex_lock (&ffmpeg_lock);
av_parser_close(this->parser_context);
this->parser_context = NULL;
pthread_mutex_unlock (&ffmpeg_lock);
}
if( this->context && this->decoder_ok ) {
pthread_mutex_lock (&ffmpeg_lock);
avcodec_close (this->context);
pthread_mutex_unlock (&ffmpeg_lock);
}
if (this->output_open)
this->stream->audio_out->close (this->stream->audio_out, this->stream);
this->output_open = 0;
free16 (this->buf);
free16 (this->decode_buffer);
if(this->context && this->context->extradata)
free(this->context->extradata);
if(this->context)
av_free(this->context);
free (this_gen);
}
static audio_decoder_t *ff_audio_open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
ff_audio_decoder_t *this ;
this = calloc(1, sizeof (ff_audio_decoder_t));
this->audio_decoder.decode_data = ff_audio_decode_data;
this->audio_decoder.reset = ff_audio_reset;
this->audio_decoder.discontinuity = ff_audio_discontinuity;
this->audio_decoder.dispose = ff_audio_dispose;
this->output_open = 0;
this->audio_channels = 0;
this->stream = stream;
this->buf = NULL;
this->size = 0;
this->bufsize = 0;
this->decoder_ok = 0;
ff_audio_ensure_buffer_size(this, AUDIOBUFSIZE);
this->context = avcodec_alloc_context();
this->decode_buffer = malloc16 (AVCODEC_MAX_AUDIO_FRAME_SIZE);
return &this->audio_decoder;
}
static char *ff_audio_get_identifier (audio_decoder_class_t *this) {
return "ffmpeg audio";
}
static char *ff_audio_get_description (audio_decoder_class_t *this) {
return "ffmpeg based audio decoder plugin";
}
static void ff_audio_dispose_class (audio_decoder_class_t *this) {
free (this);
}
void *init_audio_plugin (xine_t *xine, void *data) {
ff_audio_class_t *this ;
this = calloc(1, sizeof (ff_audio_class_t));
this->decoder_class.open_plugin = ff_audio_open_plugin;
this->decoder_class.get_identifier = ff_audio_get_identifier;
this->decoder_class.get_description = ff_audio_get_description;
this->decoder_class.dispose = ff_audio_dispose_class;
pthread_once( &once_control, init_once_routine );
return this;
}
decoder_info_t dec_info_ffmpeg_audio = {
supported_audio_types, /* supported types */
7 /* priority */
};
|