[FFmpeg-devel] [PATCH] lavf: add libopenmpt demuxer

Clément Bœsch u at pkh.me
Sun Jun 19 11:58:52 CEST 2016


On Sun, Jun 19, 2016 at 12:40:57AM +0100, Josh de Kock wrote:
[...]
> +#define OFFSET(x) offsetof(OpenMPTContext, x)
> +#define A AV_OPT_FLAG_AUDIO_PARAM
> +#define D AV_OPT_FLAG_DECODING_PARAM
> +static const AVOption options[] = {
> +    {"sample_rate", "set sample rate",                      OFFSET(sample_rate), AV_OPT_TYPE_INT,            {.i64 = 44100},                   1000, INT_MAX,   A|D},

> +    {"layout",      "set channel layout (default: stereo)", OFFSET(layout),      AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = AV_CH_LAYOUT_STEREO},     0,    INT64_MAX, A|D},

You can drop "(default: stereo)". If it doesn't appear in "ffmpeg -h
demuxer=libopenmpt" then libavutil/opt.c needs some patching (to use
av_get_channel_layout_string()).

> +    {NULL}
> +};
> +
> +static void openmpt_logfunc(const char *message, void *userdata)
> +{
> +    int level = AV_LOG_INFO;
> +    if (strstr(message, "ERROR") != NULL) {
> +        level = AV_LOG_ERROR;
> +    }
> +    av_log(userdata, level, "%s\n", message);
> +}
> +
> +static int probe_openmpt(AVProbeData *p)
> +{
> +    FILE *file = fopen(p->filename, "rb");

Someone needs to confirm, but I wonder if filename can't be NULL under
certain circomstances. Also, you need to check the return value of
fopen().

> +    double ret = openmpt_could_open_propability(openmpt_stream_get_file_callbacks(), file, 1.0, openmpt_logfunc, NULL);

pro...pa?

not proba?

> +    fclose(file);
> +    return ret ? ret * AVPROBE_SCORE_MAX : 0;
> +}
[...]
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +    avpriv_set_pts_info(st, 64, 1, 1000);
> +    if (st->duration > 0)

> +        st->duration = (int64_t)(openmpt->duration*AV_TIME_BASE+0.5);

llrint()?

[...]
> +AVInputFormat ff_libopenmpt_demuxer = {
> +    .name           = "libopenmpt",
> +    .long_name      = NULL_IF_CONFIG_SMALL("Tracker formats (libopenmpt)"),
> +    .priv_data_size = sizeof(OpenMPTContext),
> +    .read_probe     = probe_openmpt,
> +    .read_header    = read_header_openmpt,
> +    .read_packet    = read_packet_openmpt,
> +    .read_close     = read_close_openmpt,
> +    .read_seek      = read_seek_openmpt,
> +    .priv_class     = &class_openmpt,

> +    .extensions     = "mod",

Can you extend this list of extensions? libmodplug has the following
monster:
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

Does libopenmpt documentation (or source) provide such a list?

Anyway, aside from these things, next iteration should be good to go.

Thanks.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160619/26f1654f/attachment.sig>


More information about the ffmpeg-devel mailing list