FfmpegDecoderPlugin.cxx 18.5 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2014 The Music Player Daemon Project
3
 * http://www.musicpd.org
4 5 6 7 8 9 10 11 12 13
 *
 * This program 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.
 *
 * This program 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.
14 15 16 17
 *
 * 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-1301 USA.
18 19
 */

20 21 22
/* necessary because libavutil/common.h uses UINT64_C */
#define __STDC_CONSTANT_MACROS

23
#include "lib/ffmpeg/Time.hxx"
24
#include "config.h"
25
#include "FfmpegDecoderPlugin.hxx"
26
#include "lib/ffmpeg/Domain.hxx"
27
#include "lib/ffmpeg/Error.hxx"
28
#include "lib/ffmpeg/LogError.hxx"
29
#include "lib/ffmpeg/Init.hxx"
30
#include "lib/ffmpeg/Buffer.hxx"
31
#include "../DecoderAPI.hxx"
32
#include "FfmpegMetaData.hxx"
33
#include "FfmpegIo.hxx"
34
#include "tag/TagBuilder.hxx"
35
#include "tag/TagHandler.hxx"
36 37
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
Max Kellermann's avatar
Max Kellermann committed
38
#include "input/InputStream.hxx"
39
#include "CheckAudioFormat.hxx"
40
#include "util/ConstBuffer.hxx"
41
#include "util/Error.hxx"
42 43
#include "util/Domain.hxx"
#include "LogV.hxx"
44 45

extern "C" {
46 47 48
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
49
#include <libavutil/avutil.h>
50
#include <libavutil/log.h>
51 52 53 54

#if LIBAVUTIL_VERSION_MAJOR >= 53
#include <libavutil/frame.h>
#endif
55
}
56

57 58 59
#include <assert.h>
#include <string.h>

60 61
static AVFormatContext *
FfmpegOpenInput(AVIOContext *pb,
62 63
		const char *filename,
		AVInputFormat *fmt)
64 65
{
	AVFormatContext *context = avformat_alloc_context();
66
	if (context == nullptr)
67
		return nullptr;
68 69

	context->pb = pb;
70 71 72

	avformat_open_input(&context, filename, fmt, nullptr);
	return context;
73 74
}

75
static bool
76
ffmpeg_init(gcc_unused const config_param &param)
77
{
78
	FfmpegInit();
79
	return true;
80 81
}

82
gcc_pure
83
static int
84
ffmpeg_find_audio_stream(const AVFormatContext &format_context)
85
{
86 87
	for (unsigned i = 0; i < format_context.nb_streams; ++i)
		if (format_context.streams[i]->codec->codec_type ==
88
		    AVMEDIA_TYPE_AUDIO)
89 90 91 92 93
			return i;

	return -1;
}

94 95 96 97 98 99
/**
 * Accessor for AVStream::start_time that replaces AV_NOPTS_VALUE with
 * zero.  We can't use AV_NOPTS_VALUE in calculations, and we simply
 * assume that the stream's start time is zero, which appears to be
 * the best way out of that situation.
 */
100
static constexpr int64_t
101 102
start_time_fallback(const AVStream &stream)
{
103
	return FfmpegTimestampFallback(stream.start_time, 0);
104 105
}

106
static void
107 108 109
copy_interleave_frame2(uint8_t *dest, uint8_t **src,
		       unsigned nframes, unsigned nchannels,
		       unsigned sample_size)
110
{
111 112 113 114 115 116
	for (unsigned frame = 0; frame < nframes; ++frame) {
		for (unsigned channel = 0; channel < nchannels; ++channel) {
			memcpy(dest, src[channel] + frame * sample_size,
			       sample_size);
			dest += sample_size;
		}
117 118 119
	}
}

120
/**
121
 * Copy PCM data from a non-empty AVFrame to an interleaved buffer.
122
 */
123
static ConstBuffer<void>
124 125
copy_interleave_frame(const AVCodecContext &codec_context,
		      const AVFrame &frame,
126 127
		      FfmpegBuffer &global_buffer,
		      Error &error)
128
{
129 130
	assert(frame.nb_samples > 0);

131 132 133
	int plane_size;
	const int data_size =
		av_samples_get_buffer_size(&plane_size,
134 135 136
					   codec_context.channels,
					   frame.nb_samples,
					   codec_context.sample_fmt, 1);
137 138 139 140 141
	assert(data_size != 0);
	if (data_size < 0) {
		SetFfmpegError(error, data_size);
		return 0;
	}
142

143
	void *output_buffer;
144 145
	if (av_sample_fmt_is_planar(codec_context.sample_fmt) &&
	    codec_context.channels > 1) {
146 147
		output_buffer = global_buffer.GetT<uint8_t>(data_size);
		if (output_buffer == nullptr) {
148
			/* Not enough memory - shouldn't happen */
149 150 151
			error.SetErrno(ENOMEM);
			return 0;
		}
152

153 154
		copy_interleave_frame2((uint8_t *)output_buffer,
				       frame.extended_data,
155 156 157
				       frame.nb_samples,
				       codec_context.channels,
				       av_get_bytes_per_sample(codec_context.sample_fmt));
158
	} else {
159
		output_buffer = frame.extended_data[0];
160 161
	}

162
	return { output_buffer, (size_t)data_size };
163 164
}

165 166 167 168
/**
 * Decode an #AVPacket and send the resulting PCM data to the decoder
 * API.
 */
169
static DecoderCommand
170
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
171
		   AVPacket packet,
172 173 174
		   AVCodecContext &codec_context,
		   const AVStream &stream,
		   AVFrame &frame,
175
		   FfmpegBuffer &buffer)
176
{
177 178 179
	if (packet.pts >= 0 && packet.pts != (int64_t)AV_NOPTS_VALUE) {
		auto start = start_time_fallback(stream);
		if (packet.pts >= start)
180
			decoder_timestamp(decoder,
181 182
					  FfmpegTimeToDouble(packet.pts - start,
							     stream.time_base));
183
	}
184

185 186
	Error error;

187
	DecoderCommand cmd = DecoderCommand::NONE;
188
	while (packet.size > 0 && cmd == DecoderCommand::NONE) {
189
		int got_frame = 0;
190 191
		int len = avcodec_decode_audio4(&codec_context,
						&frame, &got_frame,
192
						&packet);
193 194
		if (len < 0) {
			/* if error, we skip the frame */
195
			LogFfmpegError(len, "decoding failed, frame skipped");
196 197 198
			break;
		}

199 200
		packet.data += len;
		packet.size -= len;
201

202
		if (!got_frame || frame.nb_samples <= 0)
203 204
			continue;

205
		auto output_buffer =
206
			copy_interleave_frame(codec_context, frame,
207
					      buffer, error);
208
		if (output_buffer.IsNull()) {
209 210
			/* this must be a serious error,
			   e.g. OOM */
211
			LogError(error);
212 213 214
			return DecoderCommand::STOP;
		}

215
		cmd = decoder_data(decoder, is,
216
				   output_buffer.data, output_buffer.size,
217
				   codec_context.bit_rate / 1000);
218
	}
219
	return cmd;
220 221
}

222
gcc_const
223
static SampleFormat
224
ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
225
{
226
	switch (sample_fmt) {
227
	case AV_SAMPLE_FMT_S16:
228
	case AV_SAMPLE_FMT_S16P:
229
		return SampleFormat::S16;
230

231
	case AV_SAMPLE_FMT_S32:
232
	case AV_SAMPLE_FMT_S32P:
233
		return SampleFormat::S32;
234

235
	case AV_SAMPLE_FMT_FLT:
236
	case AV_SAMPLE_FMT_FLTP:
237
		return SampleFormat::FLOAT;
238

239
	default:
240 241 242 243 244 245
		break;
	}

	char buffer[64];
	const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
						    sample_fmt);
246
	if (name != nullptr)
247 248 249
		FormatError(ffmpeg_domain,
			    "Unsupported libavcodec SampleFormat value: %s (%d)",
			    name, sample_fmt);
250
	else
251 252 253
		FormatError(ffmpeg_domain,
			    "Unsupported libavcodec SampleFormat value: %d",
			    sample_fmt);
254
	return SampleFormat::UNDEFINED;
255 256
}

257
static AVInputFormat *
258
ffmpeg_probe(Decoder *decoder, InputStream &is)
259
{
260 261
	constexpr size_t BUFFER_SIZE = 16384;
	constexpr size_t PADDING = 16;
262

263
	unsigned char buffer[BUFFER_SIZE];
264
	size_t nbytes = decoder_read(decoder, is, buffer, BUFFER_SIZE);
265
	if (nbytes <= PADDING || !is.LockRewind(IgnoreError()))
266
		return nullptr;
267 268 269 270 271 272 273

	/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
	   beyond the declared buffer limit, which makes valgrind
	   angry; this workaround removes some padding from the buffer
	   size */
	nbytes -= PADDING;

274
	AVProbeData avpd;
275 276 277 278 279 280

	/* new versions of ffmpeg may add new attributes, and leaving
	   them uninitialized may crash; hopefully, zero-initializing
	   everything we don't know is ok */
	memset(&avpd, 0, sizeof(avpd));

281 282
	avpd.buf = buffer;
	avpd.buf_size = nbytes;
283
	avpd.filename = is.GetURI();
284

285
#ifdef AVPROBE_SCORE_MIME
286
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(56, 5, 1)
287 288 289 290
	/* this attribute was added in libav/ffmpeg version 11, but
	   unfortunately it's "uint8_t" instead of "char", and it's
	   not "const" - wtf? */
	avpd.mime_type = (uint8_t *)const_cast<char *>(is.GetMimeType());
291 292 293 294
#else
	/* API problem fixed in FFmpeg 2.5 */
	avpd.mime_type = is.GetMimeType();
#endif
295 296
#endif

297
	return av_probe_input_format(&avpd, true);
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
static void
FfmpegParseMetaData(AVDictionary &dict, ReplayGainInfo &rg, MixRampInfo &mr)
{
	AVDictionaryEntry *i = nullptr;

	while ((i = av_dict_get(&dict, "", i,
				AV_DICT_IGNORE_SUFFIX)) != nullptr) {
		const char *name = i->key;
		const char *value = i->value;

		if (!ParseReplayGainTag(rg, name, value))
			ParseMixRampTag(mr, name, value);
	}
}

static void
FfmpegParseMetaData(const AVStream &stream,
		    ReplayGainInfo &rg, MixRampInfo &mr)
{
	FfmpegParseMetaData(*stream.metadata, rg, mr);
}

static void
FfmpegParseMetaData(const AVFormatContext &format_context, int audio_stream,
		    ReplayGainInfo &rg, MixRampInfo &mr)
{
326
	assert(audio_stream >= 0);
327

328 329
	FfmpegParseMetaData(*format_context.metadata, rg, mr);
	FfmpegParseMetaData(*format_context.streams[audio_stream],
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
				    rg, mr);
}

static void
FfmpegParseMetaData(Decoder &decoder,
		    const AVFormatContext &format_context, int audio_stream)
{
	ReplayGainInfo rg;
	rg.Clear();

	MixRampInfo mr;
	mr.Clear();

	FfmpegParseMetaData(format_context, audio_stream, rg, mr);

	if (rg.IsDefined())
		decoder_replay_gain(decoder, &rg);

	if (mr.IsDefined())
		decoder_mixramp(decoder, std::move(mr));
}

352 353 354 355 356 357 358 359 360 361 362
static void
FfmpegScanMetadata(const AVStream &stream,
		   const tag_handler &handler, void *handler_ctx)
{
	FfmpegScanDictionary(stream.metadata, &handler, handler_ctx);
}

static void
FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream,
		   const tag_handler &handler, void *handler_ctx)
{
363 364
	assert(audio_stream >= 0);

365
	FfmpegScanDictionary(format_context.metadata, &handler, handler_ctx);
366 367
	FfmpegScanMetadata(*format_context.streams[audio_stream],
			   handler, handler_ctx);
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
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)

static void
FfmpegScanTag(const AVFormatContext &format_context, int audio_stream,
	      TagBuilder &tag)
{
	FfmpegScanMetadata(format_context, audio_stream,
			   full_tag_handler, &tag);
}

/**
 * Check if a new stream tag was received and pass it to
 * decoder_tag().
 */
static void
FfmpegCheckTag(Decoder &decoder, InputStream &is,
	       AVFormatContext &format_context, int audio_stream)
{
	AVStream &stream = *format_context.streams[audio_stream];
	if ((stream.event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) == 0)
		/* no new metadata */
		return;

	/* clear the flag */
	stream.event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;

	TagBuilder tag;
	FfmpegScanTag(format_context, audio_stream, tag);
	if (!tag.IsEmpty())
		decoder_tag(decoder, is, tag.Commit());
}

#endif

404
static void
405 406
FfmpegDecode(Decoder &decoder, InputStream &input,
	     AVFormatContext &format_context)
407
{
408
	const int find_result =
409
		avformat_find_stream_info(&format_context, nullptr);
410
	if (find_result < 0) {
411
		LogError(ffmpeg_domain, "Couldn't find stream info");
412 413
		return;
	}
414

415
	int audio_stream = ffmpeg_find_audio_stream(format_context);
416
	if (audio_stream == -1) {
417
		LogError(ffmpeg_domain, "No audio stream inside");
418 419
		return;
	}
420

421
	AVStream &av_stream = *format_context.streams[audio_stream];
422

423
	AVCodecContext &codec_context = *av_stream.codec;
424 425 426

#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 25, 0)
	const AVCodecDescriptor *codec_descriptor =
427
		avcodec_descriptor_get(codec_context.codec_id);
428 429 430 431
	if (codec_descriptor != nullptr)
		FormatDebug(ffmpeg_domain, "codec '%s'",
			    codec_descriptor->name);
#else
432
	if (codec_context.codec_name[0] != 0)
433
		FormatDebug(ffmpeg_domain, "codec '%s'",
434
			    codec_context.codec_name);
435
#endif
436

437
	AVCodec *codec = avcodec_find_decoder(codec_context.codec_id);
438 439

	if (!codec) {
440
		LogError(ffmpeg_domain, "Unsupported audio codec");
441 442 443
		return;
	}

444
	const SampleFormat sample_format =
445
		ffmpeg_sample_format(codec_context.sample_fmt);
446 447
	if (sample_format == SampleFormat::UNDEFINED) {
		// (error message already done by ffmpeg_sample_format())
448
		return;
449
	}
450

451
	Error error;
452 453
	AudioFormat audio_format;
	if (!audio_format_init_checked(audio_format,
454
				       codec_context.sample_rate,
455
				       sample_format,
456
				       codec_context.channels, error)) {
457
		LogError(error);
458 459 460 461 462 463 464 465
		return;
	}

	/* the audio format must be read from AVCodecContext by now,
	   because avcodec_open() has been demonstrated to fill bogus
	   values into AVCodecContext.channels - a change that will be
	   reverted later by avcodec_decode_audio3() */

466
	const int open_result = avcodec_open2(&codec_context, codec, nullptr);
467
	if (open_result < 0) {
468
		LogError(ffmpeg_domain, "Could not open codec");
469
		return;
470 471
	}

472
	const SignedSongTime total_time =
473
		FromFfmpegTimeChecked(av_stream.duration, av_stream.time_base);
474

475
	decoder_initialized(decoder, audio_format,
476
			    input.IsSeekable(), total_time);
477

478
	FfmpegParseMetaData(decoder, format_context, audio_stream);
479

480 481 482
#if LIBAVUTIL_VERSION_MAJOR >= 53
	AVFrame *frame = av_frame_alloc();
#else
483
	AVFrame *frame = avcodec_alloc_frame();
484
#endif
485
	if (!frame) {
486
		LogError(ffmpeg_domain, "Could not allocate frame");
487 488 489
		return;
	}

490
	FfmpegBuffer interleaved_buffer;
491

492
	DecoderCommand cmd;
493
	do {
494
		AVPacket packet;
495
		if (av_read_frame(&format_context, &packet) < 0)
496 497 498
			/* end of file */
			break;

499
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
500
		FfmpegCheckTag(decoder, input, format_context, audio_stream);
501 502
#endif

503 504
		if (packet.stream_index == audio_stream)
			cmd = ffmpeg_send_packet(decoder, input,
505 506
						 packet, codec_context,
						 av_stream,
507
						 *frame,
508
						 interleaved_buffer);
509 510 511 512
		else
			cmd = decoder_get_command(decoder);

		av_free_packet(&packet);
513

514
		if (cmd == DecoderCommand::SEEK) {
515
			int64_t where =
516
				ToFfmpegTime(decoder_seek_time(decoder),
517 518
					     av_stream.time_base) +
				start_time_fallback(av_stream);
519

520
			if (av_seek_frame(&format_context, audio_stream, where,
521
					  AVSEEK_FLAG_ANY) < 0)
522
				decoder_seek_error(decoder);
523
			else {
524
				avcodec_flush_buffers(&codec_context);
525
				decoder_command_finished(decoder);
526
			}
527
		}
528
	} while (cmd != DecoderCommand::STOP);
529

530 531 532
#if LIBAVUTIL_VERSION_MAJOR >= 53
	av_frame_free(&frame);
#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
533 534
	avcodec_free_frame(&frame);
#else
535
	av_free(frame);
536 537
#endif

538
	avcodec_close(&codec_context);
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
}

static void
ffmpeg_decode(Decoder &decoder, InputStream &input)
{
	AVInputFormat *input_format = ffmpeg_probe(&decoder, input);
	if (input_format == nullptr)
		return;

	FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
		    input_format->name, input_format->long_name);

	AvioStream stream(&decoder, input);
	if (!stream.Open()) {
		LogError(ffmpeg_domain, "Failed to open stream");
		return;
	}

557 558 559
	AVFormatContext *format_context =
		FfmpegOpenInput(stream.io, input.GetURI(), input_format);
	if (format_context == nullptr) {
560 561 562 563 564
		LogError(ffmpeg_domain, "Open failed");
		return;
	}

	FfmpegDecode(decoder, input, *format_context);
565
	avformat_close_input(&format_context);
566 567
}

568 569 570 571 572 573 574 575 576
static bool
FfmpegScanStream(AVFormatContext &format_context,
		 const struct tag_handler &handler, void *handler_ctx)
{
	const int find_result =
		avformat_find_stream_info(&format_context, nullptr);
	if (find_result < 0)
		return false;

577 578 579 580
	const int audio_stream = ffmpeg_find_audio_stream(format_context);
	if (audio_stream < 0)
		return false;

581 582 583 584 585
	const AVStream &stream = *format_context.streams[audio_stream];
	if (stream.duration != (int64_t)AV_NOPTS_VALUE)
		tag_handler_invoke_duration(&handler, handler_ctx,
					    FromFfmpegTime(stream.duration,
							   stream.time_base));
586

587
	FfmpegScanMetadata(format_context, audio_stream, handler, handler_ctx);
588 589 590 591

	return true;
}

592
static bool
593
ffmpeg_scan_stream(InputStream &is,
594
		   const struct tag_handler *handler, void *handler_ctx)
595
{
596 597
	AVInputFormat *input_format = ffmpeg_probe(nullptr, is);
	if (input_format == nullptr)
598
		return false;
599

600 601
	AvioStream stream(nullptr, is);
	if (!stream.Open())
602
		return false;
603

604 605 606
	AVFormatContext *f =
		FfmpegOpenInput(stream.io, is.GetURI(), input_format);
	if (f == nullptr)
607
		return false;
608

609
	bool result = FfmpegScanStream(*f, *handler, handler_ctx);
610
	avformat_close_input(&f);
611
	return result;
612 613 614
}

/**
615 616 617 618
 * A list of extensions found for the formats supported by ffmpeg.
 * This list is current as of 02-23-09; To find out if there are more
 * supported formats, check the ffmpeg changelog since this date for
 * more formats.
619
 */
Max Kellermann's avatar
Max Kellermann committed
620
static const char *const ffmpeg_suffixes[] = {
621 622 623 624 625
	"16sv", "3g2", "3gp", "4xm", "8svx", "aa3", "aac", "ac3", "afc", "aif",
	"aifc", "aiff", "al", "alaw", "amr", "anim", "apc", "ape", "asf",
	"atrac", "au", "aud", "avi", "avm2", "avs", "bap", "bfi", "c93", "cak",
	"cin", "cmv", "cpk", "daud", "dct", "divx", "dts", "dv", "dvd", "dxa",
	"eac3", "film", "flac", "flc", "fli", "fll", "flx", "flv", "g726",
626 627 628
	"gsm", "gxf", "iss", "m1v", "m2v", "m2t", "m2ts",
	"m4a", "m4b", "m4v",
	"mad",
629 630 631
	"mj2", "mjpeg", "mjpg", "mka", "mkv", "mlp", "mm", "mmf", "mov", "mp+",
	"mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu",
	"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
632
	"ogx", "oma", "ogg", "omg", "opus", "psp", "pva", "qcp", "qt", "r3d", "ra",
633 634 635
	"ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
	"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
	"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
636 637
	"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
	"wve",
638
	nullptr
639 640
};

Max Kellermann's avatar
Max Kellermann committed
641
static const char *const ffmpeg_mime_types[] = {
642
	"application/flv",
643
	"application/m4a",
644 645 646 647 648
	"application/mp4",
	"application/octet-stream",
	"application/ogg",
	"application/x-ms-wmz",
	"application/x-ms-wmd",
649
	"application/x-ogg",
650 651 652 653 654
	"application/x-shockwave-flash",
	"application/x-shorten",
	"audio/8svx",
	"audio/16sv",
	"audio/aac",
655
	"audio/aacp",
656
	"audio/ac3",
657
	"audio/aiff"
658 659 660
	"audio/amr",
	"audio/basic",
	"audio/flac",
661 662
	"audio/m4a",
	"audio/mp4",
663 664 665
	"audio/mpeg",
	"audio/musepack",
	"audio/ogg",
666
	"audio/opus",
667 668
	"audio/qcelp",
	"audio/vorbis",
669
	"audio/vorbis+ogg",
670 671 672 673 674 675 676 677 678 679 680 681
	"audio/x-8svx",
	"audio/x-16sv",
	"audio/x-aac",
	"audio/x-ac3",
	"audio/x-aiff"
	"audio/x-alaw",
	"audio/x-au",
	"audio/x-dca",
	"audio/x-eac3",
	"audio/x-flac",
	"audio/x-gsm",
	"audio/x-mace",
682
	"audio/x-matroska",
683 684
	"audio/x-monkeys-audio",
	"audio/x-mpeg",
685 686
	"audio/x-ms-wma",
	"audio/x-ms-wax",
687
	"audio/x-musepack",
688 689 690
	"audio/x-ogg",
	"audio/x-vorbis",
	"audio/x-vorbis+ogg",
691 692 693 694
	"audio/x-pn-realaudio",
	"audio/x-pn-multirate-realaudio",
	"audio/x-speex",
	"audio/x-tta"
695
	"audio/x-voc",
696 697 698 699 700 701 702 703
	"audio/x-wav",
	"audio/x-wma",
	"audio/x-wv",
	"video/anim",
	"video/quicktime",
	"video/msvideo",
	"video/ogg",
	"video/theora",
704
	"video/webm",
705 706 707 708 709 710 711
	"video/x-dv",
	"video/x-flv",
	"video/x-matroska",
	"video/x-mjpeg",
	"video/x-mpeg",
	"video/x-ms-asf",
	"video/x-msvideo",
712 713 714 715
	"video/x-ms-wmv",
	"video/x-ms-wvx",
	"video/x-ms-wm",
	"video/x-ms-wmx",
716 717 718 719 720 721
	"video/x-nut",
	"video/x-pva",
	"video/x-theora",
	"video/x-vid",
	"video/x-wmv",
	"video/x-xvid",
722 723 724 725 726 727

	/* special value for the "ffmpeg" input plugin: all streams by
	   the "ffmpeg" input plugin shall be decoded by this
	   plugin */
	"audio/x-mpd-ffmpeg",

728
	nullptr
729 730
};

731
const struct DecoderPlugin ffmpeg_decoder_plugin = {
732 733 734 735 736 737 738 739 740 741
	"ffmpeg",
	ffmpeg_init,
	nullptr,
	ffmpeg_decode,
	nullptr,
	nullptr,
	ffmpeg_scan_stream,
	nullptr,
	ffmpeg_suffixes,
	ffmpeg_mime_types
742
};