[MPlayer-dev-eng] [PATCH] Chapter support improvement
Nico Sabbi
Nicola.Sabbi at poste.it
Mon Dec 10 12:14:54 CET 2007
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()).
More information about the MPlayer-dev-eng
mailing list