mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
Add libmodplug support.
This commit is contained in:
parent
073effb6e4
commit
26c7ff9317
@ -61,6 +61,7 @@ easier to use. The changes are:
|
||||
- Apple ProRes decoder
|
||||
- CELT in Ogg demuxing
|
||||
- G.723.1 demuxer and decoder
|
||||
- libmodplug support (--enable-libmodplug)
|
||||
|
||||
|
||||
version 0.8:
|
||||
|
@ -287,6 +287,7 @@ Muxers/Demuxers:
|
||||
img2.c Michael Niedermayer
|
||||
iss.c Stefan Gehrer
|
||||
jvdec.c Peter Ross
|
||||
libmodplug.c Clément Bœsch
|
||||
libnut.c Oded Shimon
|
||||
lmlm4.c Ivo van Poorten
|
||||
lxfdec.c Tomas Härdin
|
||||
|
5
configure
vendored
5
configure
vendored
@ -176,6 +176,7 @@ External library support:
|
||||
--enable-libfaac enable FAAC support via libfaac [no]
|
||||
--enable-libfreetype enable libfreetype [no]
|
||||
--enable-libgsm enable GSM support via libgsm [no]
|
||||
--enable-libmodplug enable ModPlug via libmodplug [no]
|
||||
--enable-libmp3lame enable MP3 encoding via libmp3lame [no]
|
||||
--enable-libnut enable NUT (de)muxing via libnut,
|
||||
native (de)muxer exists [no]
|
||||
@ -1003,6 +1004,7 @@ CONFIG_LIST="
|
||||
libfaac
|
||||
libfreetype
|
||||
libgsm
|
||||
libmodplug
|
||||
libmp3lame
|
||||
libnut
|
||||
libopencore_amrnb
|
||||
@ -1495,6 +1497,7 @@ libgsm_decoder_deps="libgsm"
|
||||
libgsm_encoder_deps="libgsm"
|
||||
libgsm_ms_decoder_deps="libgsm"
|
||||
libgsm_ms_encoder_deps="libgsm"
|
||||
libmodplug_decode_deps="libmodplug"
|
||||
libmp3lame_encoder_deps="libmp3lame"
|
||||
libopencore_amrnb_decoder_deps="libopencore_amrnb"
|
||||
libopencore_amrnb_encoder_deps="libopencore_amrnb"
|
||||
@ -3026,6 +3029,7 @@ enabled libdirac && require_pkg_config dirac \
|
||||
enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
|
||||
enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
|
||||
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
|
||||
enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
|
||||
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
|
||||
enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
|
||||
enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
|
||||
@ -3352,6 +3356,7 @@ echo "libdirac enabled ${libdirac-no}"
|
||||
echo "libfaac enabled ${libfaac-no}"
|
||||
echo "libaacplus enabled ${libaacplus-no}"
|
||||
echo "libgsm enabled ${libgsm-no}"
|
||||
echo "libmodplug enabled ${libmodplug-no}"
|
||||
echo "libmp3lame enabled ${libmp3lame-no}"
|
||||
echo "libnut enabled ${libnut-no}"
|
||||
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
|
||||
|
@ -324,6 +324,7 @@ OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o
|
||||
OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER) += yuv4mpeg.o
|
||||
|
||||
# external libraries
|
||||
OBJS-$(CONFIG_LIBMODPLUG_DEMUXER) += libmodplug.o
|
||||
OBJS-$(CONFIG_LIBNUT_DEMUXER) += libnut.o riff.o
|
||||
OBJS-$(CONFIG_LIBNUT_MUXER) += libnut.o riff.o
|
||||
|
||||
|
@ -242,6 +242,9 @@ void av_register_all(void)
|
||||
REGISTER_MUXDEMUX (YUV4MPEGPIPE, yuv4mpegpipe);
|
||||
|
||||
/* external libraries */
|
||||
#if CONFIG_LIBMODPLUG
|
||||
REGISTER_DEMUXER (LIBMODPLUG, libmodplug);
|
||||
#endif
|
||||
REGISTER_MUXDEMUX (LIBNUT, libnut);
|
||||
|
||||
/* protocols */
|
||||
|
110
libavformat/libmodplug.c
Normal file
110
libavformat/libmodplug.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* ModPlug demuxer
|
||||
* @todo ModPlug options (noise reduction, reverb, bass boost, ...)
|
||||
* @todo metadata
|
||||
*/
|
||||
|
||||
#include <libmodplug/modplug.h>
|
||||
#include "avformat.h"
|
||||
|
||||
typedef struct ModPlugContext {
|
||||
ModPlugFile *f;
|
||||
uint8_t buf[5 * 1<<20]; ///< input file content, 5M max
|
||||
} ModPlugContext;
|
||||
|
||||
static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
{
|
||||
AVStream *st;
|
||||
AVIOContext *pb = s->pb;
|
||||
ModPlug_Settings settings;
|
||||
ModPlugContext *modplug = s->priv_data;
|
||||
|
||||
int sz = avio_read(pb, modplug->buf, sizeof modplug->buf);
|
||||
|
||||
ModPlug_GetSettings(&settings);
|
||||
settings.mChannels = 2;
|
||||
settings.mBits = 16;
|
||||
settings.mFrequency = 44100;
|
||||
settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; // best quality
|
||||
settings.mLoopCount = 0; // prevents looping forever
|
||||
ModPlug_SetSettings(&settings);
|
||||
|
||||
modplug->f = ModPlug_Load(modplug->buf, sz);
|
||||
if (!modplug->f)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
st = av_new_stream(s, 0);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
av_set_pts_info(st, 64, 1, 1000);
|
||||
st->duration = ModPlug_GetLength(modplug->f);
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
st->codec->codec_id = CODEC_ID_PCM_S16LE;
|
||||
st->codec->channels = settings.mChannels;
|
||||
st->codec->sample_rate = settings.mFrequency;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
int ret, n;
|
||||
ModPlugContext *modplug = s->priv_data;
|
||||
uint8_t buf[512];
|
||||
|
||||
n = ModPlug_Read(modplug->f, buf, sizeof buf);
|
||||
if (n <= 0)
|
||||
return AVERROR(EIO);
|
||||
|
||||
ret = av_new_packet(pkt, n);
|
||||
if (ret)
|
||||
return ret;
|
||||
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
|
||||
pkt->size = n;
|
||||
memcpy(pkt->data, buf, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int modplug_read_close(AVFormatContext *s)
|
||||
{
|
||||
ModPlugContext *modplug = s->priv_data;
|
||||
ModPlug_Unload(modplug->f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int modplug_read_seek(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
|
||||
{
|
||||
const ModPlugContext *modplug = s->priv_data;
|
||||
ModPlug_Seek(modplug->f, (int)ts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVInputFormat ff_libmodplug_demuxer = {
|
||||
.name = "libmodplug",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ModPlug demuxer"),
|
||||
.priv_data_size = sizeof(ModPlugContext),
|
||||
.read_header = modplug_read_header,
|
||||
.read_packet = modplug_read_packet,
|
||||
.read_close = modplug_read_close,
|
||||
.read_seek = modplug_read_seek,
|
||||
.extensions = "669,abc,amf,ams,dbm,dmf,dsm,far,it,mdl,med,mid,mod,mt2,mtm,okt,psm,ptm,s3m,stm,ult,umx,xm"
|
||||
",itgz,itr,itz,mdgz,mdr,mdz,s3gz,s3r,s3z,xmgz,xmr,xmz", // compressed mods
|
||||
};
|
@ -24,7 +24,7 @@
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 53
|
||||
#define LIBAVFORMAT_VERSION_MINOR 13
|
||||
#define LIBAVFORMAT_VERSION_MINOR 14
|
||||
#define LIBAVFORMAT_VERSION_MICRO 0
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user