Vitor Sessak a écrit : > On 07/15/2010 09:35 PM, Ronald S. Bultje wrote: >> Hi, >> >> On Thu, Jul 15, 2010 at 3:12 PM, Sebastian Vater >> <cdgs.basty-gM/ye1e23mwn+bqq9rb...@public.gmane.org> wrote: >>> Just a question for understanding...what's the advantage of using >>> enum's >>> then? The only one I see straight away is that there is less space >>> required (saving 4 characters by replacing '#define ' with ' '). >> >> Documentation tools (e.g. doxy) will group them together and treat >> them as a group of related properties, rather than separate entities. >> That's a big one for a huge project such as FFmpeg, where in the >> future many people will look at and modify your code, without >> necessarily understanding everything at the beginning. > > Not to mention having variables of the type "enum Whatever" instead of > a plain int, which tell immediately which kind of constants should be > assigned to it.
Hi I have excellent news! libavsequencer now flawlessly integrates into FFmpeg, just check out my latest git. Please do a git pull --rebase, Stefano had problems without using it. Here are the module.[ch] part of the BSS to review. This version compiles perfectly. -- Best regards, :-) Basty/CDGS (-:
diff --git a/libavsequencer/module.c b/libavsequencer/module.c new file mode 100644 index 0000000..e9303a8 --- /dev/null +++ b/libavsequencer/module.c @@ -0,0 +1,72 @@ +/* + * Implement AVSequencer module stuff + * Copyright (c) 2010 Sebastian Vater <cdgs.ba...@googlemail.com> + * + * 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 + * Implement AVSequencer module stuff. + */ + +#include "libavutil/log.h" +#include "libavsequencer/avsequencer.h" + +static const char *module_name(void *p) +{ + AVSequencerModule *module = p; + AVMetadataTag *tag = av_metadata_get(module->metadata, "title", NULL, AV_METADATA_IGNORE_SUFFIX); + + return tag->value; +} + +static const AVClass avseq_module_class = { + "AVSequencer Module", + module_name, + NULL, + LIBAVUTIL_VERSION_INT, +}; + +int avseq_module_open(AVSequencerContext *avctx, AVSequencerModule *module) { + AVSequencerModule **module_list; + uint16_t modules; + + if (!avctx) + return AVERROR_INVALIDDATA; + + module_list = avctx->module_list; + modules = avctx->modules; + + if (!(module && ++modules)) { + return AVERROR_INVALIDDATA; + } else if (!(module_list = av_realloc(module_list, modules * sizeof(AVSequencerModule *)))) { + av_log(avctx, AV_LOG_ERROR, "cannot allocate module storage container.\n"); + return AVERROR(ENOMEM); + } + + module->av_class = &avseq_module_class; + + if (!module->channels) + module->channels = 64; + + module_list[modules] = module; + avctx->module_list = module_list; + avctx->modules = modules; + + return 0; +}
diff --git a/libavsequencer/module.h b/libavsequencer/module.h new file mode 100755 index 0000000..abd9792 --- /dev/null +++ b/libavsequencer/module.h @@ -0,0 +1,108 @@ +/* + * AVSequencer music module management + * Copyright (c) 2010 Sebastian Vater <cdgs.ba...@googlemail.com> + * + * 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 + */ + +#ifndef AVSEQUENCER_MODULE_H +#define AVSEQUENCER_MODULE_H + +#include "libavutil/log.h" +#include "libavformat/avformat.h" +#include "libavsequencer/song.h" +#include "libavsequencer/instr.h" + +/** + * Sequencer module structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + */ +typedef struct AVSequencerModule { + /** + * information on struct for av_log + * - set by avseq_alloc_context + */ + const AVClass *av_class; + + /** Metadata information: Original module file name, module name, + * module message, artist, genre, album, begin and finish date of + * composition and comment. */ + AVMetadata *metadata; + + /** Array (of size songs) of pointers containing every sub-song + for this module. */ + AVSequencerSong **song_list; + + /** Number of sub-songs attached to this module. */ + uint16_t songs; + + /** Array (of size instruments) of pointers containing every + instrument for this module. */ + AVSequencerInstrument **instrument_list; + + /** Number of instruments attached to this module. */ + uint16_t instruments; + + /** Array (of size envelopes) of pointers containing every + evelope for this module. */ + AVSequencerEnvelope **envelope_list; + + /** Number of envelopes attached to this module. */ + uint16_t envelopes; + + /** Array (of size keyboards) of pointers containing every + keyboard definition list for this module. */ + AVSequencerKeyboard **keyboard_list; + + /** Number of keyboard definitions attached to this module. */ + uint16_t keyboards; + + /** Array (of size arpeggios) of pointers containing every + arpeggio envelope definition list for this module. */ + AVSequencerArpeggio **arpeggio_list; + + /** Number of arpeggio definitions attached to this module. */ + uint16_t arpeggios; + + /** Forced duration of the module, in AV_TIME_BASE fractional + seconds. This is the total sum of all sub-song durations + this module contains or zero if the duration is unknown and + also cannot be automatically determined. The composer then can + set manually a duration after which the player can skip over to + the next module if it is playing back in once mode. */ + uint64_t forced_duration; + + /** Maximum number of virtual channels, including NNA (New Note + Action) background channels to be allocated and processed by + the mixing engine (defaults to 64). */ + uint16_t channels; + + /** Array of pointers containing every unknown data field where + the last element is indicated by a NULL pointer reference. The + first 64-bit of the unknown data contains an unique identifier + for this chunk and the second 64-bit data is actual unsigned + length of the following raw data. Some formats are chunk based + and can store information, which can't be handled by some + other, in case of a transition the unknown data is kept as is. + Some programs write editor settings for module in those chunks, + which then won't get lost in that case. */ + uint8_t **unknown_data; +} AVSequencerModule; + +#endif /* AVSEQUENCER_MODULE_H */
_______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc