[MPlayer-dev-eng] [PATCH] Chapter support improvement
Ulion
ulion2002 at gmail.com
Mon Dec 10 12:24:00 CET 2007
2007/12/10, Nico Sabbi <Nicola.Sabbi at poste.it>:
> Il Monday 10 December 2007 11:59:28 Ulion ha scritto:
> > Hello,
> >
> > I recent found chapter in mkv is really a good design, certainly
> > dvd also support it. But for mplayer, its chapter support is not
> > good enough, then I wrote several patches to improve it.
> >
> > First patch adds 3 functions for demuxer to get chapter infos:
> >
> > +/// Get current chapter index if available.
> > +int demuxer_get_current_chapter(demuxer_t *demuxer);
> > +/// Get chapter name by index.
> > +char *demuxer_chapter_name(demuxer_t *demuxer, int chapter);
> > +/// Get total chapter number.
> > +int demuxer_chapter_count(demuxer_t *demuxer);
> >
> > Second patch make chapter become a mplayer property, now we can
> > get/set/print/step up/step down on the chapter property.
> >
> > Third patch add chapter support for libmenu, it bases on
> > Benjanmin's menu_chapsel.c patch, but using functions from my first
> > patch.
>
>
> >+char *demuxer_chapter_name(demuxer_t *demuxer, int chapter) {
> >+ if (!demuxer->num_chapters || !demuxer->chapters) {
> >+ }
> >+ else {
> >+ if (chapter >=0 && chapter < demuxer->num_chapters &&
> >+ demuxer->chapters[chapter].name)
> >+ return strdup(demuxer->chapters[chapter].name);
> >+ }
> >+ return NULL;
> >+}
> >
>
> the demuxer part is fine, except for the above function, that I'd
> replace with:
>
> char *demuxer_chapter_name(demuxer_t *demuxer, int chapter) {
> if (demuxer->num_chapters && demuxer->chapters &&
> demuxer->chapters[chapter].name)
> return strdup(demuxer->chapters[chapter].name);
> return NULL;
> }
>
Why not check input chapter's value in valid range, else there will be
a crash for invalid array index.
Ulion
More information about the MPlayer-dev-eng
mailing list