[MPlayer-dev-eng] [PATCH] Chapter support improvement

Ulion ulion2002 at gmail.com
Mon Dec 10 12:15:52 CET 2007


2007/12/10, Andrew Calkin <calkina at geexbox.org>:
> 2007/12/10, Ulion <ulion2002 at gmail.com>:
> > 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.
>
> From the osdmenu_chapter.diff:
>
> +        else {
> +          char *tmp = malloc(40);
> +          sprintf(tmp, "(%d) of %d", cid + 1, chapter_num);
> +          e->p.txt = tmp;
> +        }
>
> Why malloc a fixed size of 40? You could have a fixed array of 40
> which you point the sprintf/snprintf at (though u probably need much
> less- what is the limit on chapters for mkv? For dvd it is 99), then
> strdup it to allocate the memory for e->p.txt, right?

That  will save memory although not a lot, I will update it.

-- 
Ulion



More information about the MPlayer-dev-eng mailing list