From 0f7e19ce7ec4dfe4d0a4e0b21eb22c4392637568 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 30 Aug 2015 14:53:47 +0200 Subject: [PATCH] ffmpeg plugin: add support for MOD and other "tracked music" * ffmpeg can handle these through ModPlug * By default, ffmpoeg will not try these formats because the way to detect them are a bit unsafe (4 bytes at a particular offset in the file serve as an identifier). So, hint the sniffing by giving it a filename of ".mod" to get modplug to be used. This does not affect sniffing in the regular way for other formats. * Add some common tracked music formats to the muxer table. * Fix some tracing to use current (as of ffmpeg 0.10) function names and because some variables were renamed. --- .../media/plugins/ffmpeg/AVFormatReader.cpp | 4 +- .../media/plugins/ffmpeg/MuxerTable.cpp | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp index 742976f915..5da841ce59 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp @@ -257,7 +257,7 @@ StreamBase::Open() fContext->pb = fIOContext; // Allocate our context and probe the input format - if (avformat_open_input(&fContext, "", NULL, NULL) < 0) { + if (avformat_open_input(&fContext, ".mod", NULL, NULL) < 0) { TRACE("StreamBase::Open() - avformat_open_input() failed!\n"); // avformat_open_input() frees the context in case of failure fContext = NULL; @@ -1505,7 +1505,7 @@ AVFormatReader::Sniff(int32* _streamCount) streamDeleter.Detach(); #ifdef TRACE_AVFORMAT_READER - dump_format(const_cast(stream->Context()), 0, "", 0); + av_dump_format(const_cast(stream->Context()), 0, "", 0); #endif if (_streamCount != NULL) diff --git a/src/add-ons/media/plugins/ffmpeg/MuxerTable.cpp b/src/add-ons/media/plugins/ffmpeg/MuxerTable.cpp index 2856694b98..ed22c4e303 100644 --- a/src/add-ons/media/plugins/ffmpeg/MuxerTable.cpp +++ b/src/add-ons/media/plugins/ffmpeg/MuxerTable.cpp @@ -318,6 +318,62 @@ const media_file_format gMuxerTable[] = { "webm", { 0 } }, + { + media_file_format::B_READABLE + | media_file_format::B_KNOWS_RAW_AUDIO + | media_file_format::B_KNOWS_ENCODED_AUDIO, + { 0 }, + B_MISC_FORMAT_FAMILY, + 100, + { 0 }, + "audio/xm", + "Fast Tracker eXtended Module", + "xm", + "xm", + { 0 } + }, + { + media_file_format::B_READABLE + | media_file_format::B_KNOWS_RAW_AUDIO + | media_file_format::B_KNOWS_ENCODED_AUDIO, + { 0 }, + B_MISC_FORMAT_FAMILY, + 100, + { 0 }, + "audio/s3m", + "Scream Tracker 3", + "s3m", + "s3m", + { 0 } + }, + { + media_file_format::B_READABLE + | media_file_format::B_KNOWS_RAW_AUDIO + | media_file_format::B_KNOWS_ENCODED_AUDIO, + { 0 }, + B_MISC_FORMAT_FAMILY, + 100, + { 0 }, + "audio/it", + "Impulse Tracker", + "it", + "it", + { 0 } + }, + { + media_file_format::B_READABLE + | media_file_format::B_KNOWS_RAW_AUDIO + | media_file_format::B_KNOWS_ENCODED_AUDIO, + { 0 }, + B_MISC_FORMAT_FAMILY, + 100, + { 0 }, + "audio/x-mod", + "Protracker MOD", + "mod", + "mod", + { 0 } + }, }; const size_t gMuxerCount = sizeof(gMuxerTable) / sizeof(media_file_format);