On Tue, Jul 19, 2016 at 04:39:11PM +0100, Josh de Kock wrote: > --- > libavformat/libopenmpt.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c > index 58a02be..670866f 100644 > --- a/libavformat/libopenmpt.c > +++ b/libavformat/libopenmpt.c > @@ -36,14 +36,19 @@ typedef struct OpenMPTContext { > /* options */ > int sample_rate; > int64_t layout; > + int subsong; > } OpenMPTContext; > > + > +#define LIBOPENMPT_SUBSONG_DEFAULT -2 > +
not a really pretty value... > #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 = 48000}, 1000, INT_MAX, > A|D}, > - {"layout", "set channel layout", OFFSET(layout), > AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = AV_CH_LAYOUT_STEREO}, 0, > INT64_MAX, A|D}, > + {"sample_rate", "set sample rate", OFFSET(sample_rate), > AV_OPT_TYPE_INT, {.i64 = 48000}, 1000, > INT_MAX, A|D}, > + {"layout", "set channel layout", OFFSET(layout), > AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = AV_CH_LAYOUT_STEREO}, 0, > INT64_MAX, A|D}, > + {"subsong", "set subsong", OFFSET(subsong), > AV_OPT_TYPE_INT, {.i64 = LIBOPENMPT_SUBSONG_DEFAULT}, -2, > INT_MAX, A|D}, > {NULL} > }; > > @@ -88,6 +93,18 @@ static int read_header_openmpt(AVFormatContext *s) > add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, > "tracker")); > add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, > "message")); > > + if (openmpt->subsong >= > openmpt_module_get_num_subsongs(openmpt->module)) { > + av_log(s, AV_LOG_ERROR, "Invalid subsong index: %d\n", > openmpt->subsong); > + return AVERROR(EINVAL); > + } > + > + if (openmpt->subsong != LIBOPENMPT_SUBSONG_DEFAULT) { > + if (openmpt->subsong >= 0) { > + av_dict_set_int(&s->metadata, "track", openmpt->subsong + 1, 0); > + } > + openmpt_module_select_subsong(openmpt->module, openmpt->subsong); no failure possible? > + } > + you should add an AV_OPT_TYPE_CONST entry associated with "auto", which will be much more accessible for users [...] -- Clément B.
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel