[libbluray-devel] [PATCH 2/2] Fix current chapter lookup

Petri Hintukainen phintuka at users.sourceforge.net
Sun Apr 10 11:24:02 CEST 2016


On pe, 2016-04-08 at 14:10 -0600, John Stebbins wrote:
> ...and simplify
> 
> If the current position is before the first chapter in the current
> clip,
> chapter lookup fails.  This can be seen in US Star Wars IV release
> where
> chapter events jump from chapter 3 back to 1.
> ---
>  src/libbluray/bdnav/navigation.c | 18 ++++--------------
>  src/libbluray/bdnav/navigation.h |  2 +-
>  src/libbluray/bluray.c           |  2 +-
>  3 files changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/src/libbluray/bdnav/navigation.c
> b/src/libbluray/bdnav/navigation.c
> index a263c16..e28eeb9 100644
> --- a/src/libbluray/bdnav/navigation.c
> +++ b/src/libbluray/bdnav/navigation.c
> @@ -734,32 +734,22 @@ NAV_CLIP* nav_chapter_search(NAV_TITLE *title,
> unsigned chapter, uint32_t *clip_
>      return clip;
>  }
>  
> -uint32_t nav_chapter_get_current(NAV_CLIP *clip, uint32_t clip_pkt)
> +uint32_t nav_chapter_get_current(NAV_TITLE * title, uint32_t
> title_pkt)
>  {
>      NAV_MARK * mark;
> -    NAV_TITLE *title;
>      uint32_t ii;
>  
> -    // Clip can be null if we haven't started the first clip yet
> -    if (clip == NULL) {
> +    if (title == NULL) {
>          return 0;
>      }
> -    title = clip->title;
>      for (ii = 0; ii < title->chap_list.count; ii++) {
>          mark = &title->chap_list.mark[ii];
> -        if (mark->clip_ref > clip->ref)
> -        {
> -            if (ii)
> -                return ii-1;
> -            else
> -                return 0;
> -        }
> -        if (mark->clip_ref == clip->ref && mark->clip_pkt <=
> clip_pkt) {
> +        if (mark->title_pkt <= title_pkt) {
>              if ( ii == title->chap_list.count - 1 ) {
>                  return ii;
>              }
>              mark = &title->chap_list.mark[ii+1];
> -            if (mark->clip_ref != clip->ref || mark->clip_pkt >
> clip_pkt) {
> +            if (mark->title_pkt > title_pkt) {
>                  return ii;
>              }
>          }
> diff --git a/src/libbluray/bdnav/navigation.h
> b/src/libbluray/bdnav/navigation.h
> index 67a020a..113d813 100644
> --- a/src/libbluray/bdnav/navigation.h
> +++ b/src/libbluray/bdnav/navigation.h
> @@ -146,7 +146,7 @@ BD_PRIVATE NAV_CLIP* nav_packet_search(NAV_TITLE
> *title, uint32_t pkt, uint32_t
>  BD_PRIVATE NAV_CLIP* nav_time_search(NAV_TITLE *title, uint32_t
> tick, uint32_t *clip_pkt, uint32_t *out_pkt);
>  BD_PRIVATE void nav_clip_time_search(NAV_CLIP *clip, uint32_t tick,
> uint32_t *clip_pkt, uint32_t *out_pkt);
>  BD_PRIVATE NAV_CLIP* nav_chapter_search(NAV_TITLE *title, unsigned
> chapter, uint32_t *clip_pkt, uint32_t *out_pkt);
> -BD_PRIVATE uint32_t nav_chapter_get_current(NAV_CLIP *clip, uint32_t
> clip_pkt);
> +BD_PRIVATE uint32_t nav_chapter_get_current(NAV_TITLE *title,
> uint32_t title_pkt);
>  BD_PRIVATE NAV_CLIP* nav_mark_search(NAV_TITLE *title, unsigned
> mark, uint32_t *clip_pkt, uint32_t *out_pkt);
>  BD_PRIVATE uint32_t nav_angle_change_search(NAV_CLIP *clip, uint32_t
> pkt, uint32_t *time);
>  BD_PRIVATE NAV_CLIP* nav_set_angle(NAV_TITLE *title, NAV_CLIP *clip,
> unsigned angle);
> diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
> index f9f2502..b760a49 100644
> --- a/src/libbluray/bluray.c
> +++ b/src/libbluray/bluray.c
> @@ -1678,7 +1678,7 @@ uint32_t bd_get_current_chapter(BLURAY *bd)
>      bd_mutex_lock(&bd->mutex);
>  
>      if (bd->title) {
> -        ret = nav_chapter_get_current(bd->st0.clip, SPN(bd
> ->st0.clip_pos));
> +        ret = nav_chapter_get_current(bd->title, SPN(bd->s_pos));
>      }
>  
>      bd_mutex_unlock(&bd->mutex);

LGTM



More information about the libbluray-devel mailing list