[MPlayer-dev-eng] [PATCH] Chapter support improvement
Ulion
ulion2002 at gmail.com
Mon Dec 10 12:18:34 CET 2007
2007/12/10, Ulion <ulion2002 at gmail.com>:
> 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;
> > }
> >
> > As for the rest, at a quick galnce in fill_menu() you forgot to free
> > the chapter name (allocated with strdup()).
>
> I thought there are some code to free it, I will check it, and add
> free code if needed.
Oh, It's my mistake, fixed.
--
Ulion
More information about the MPlayer-dev-eng
mailing list