Commit 33406576 authored by hpi1's avatar hpi1

nav_set_angle(): Factorized NAV_CLIP filling to _fill_clip()

parent 2e93e629
......@@ -388,6 +388,7 @@ _extrapolate_title(NAV_TITLE *title)
static void _fill_clip(NAV_TITLE *title,
MPLS_CLIP *mpls_clip,
uint8_t connection_condition, uint32_t in_time, uint32_t out_time,
unsigned pi_angle_count,
NAV_CLIP *clip,
unsigned ref, uint32_t *pos, uint32_t *time)
......@@ -396,13 +397,20 @@ static void _fill_clip(NAV_TITLE *title,
clip->title = title;
clip->ref = ref;
clip->angle = 0;
if (title->angle >= pi_angle_count) {
clip->angle = 0;
} else {
clip->angle = title->angle;
}
strncpy(clip->name, mpls_clip[clip->angle].clip_id, 5);
strncpy(&clip->name[5], ".m2ts", 6);
clip->clip_id = atoi(mpls_clip[clip->angle].clip_id);
path = str_printf("%s"DIR_SEP"BDMV"DIR_SEP"CLIPINF"DIR_SEP"%s.clpi",
title->root, mpls_clip[clip->angle].clip_id);
clpi_free(clip->cl);
clip->cl = clpi_parse(path, 0);
X_FREE(path);
if (clip->cl == NULL) {
......@@ -472,7 +480,8 @@ NAV_TITLE* nav_title_open(const char *root, const char *playlist)
clip = &title->clip_list.clip[ii];
_fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, clip, ii, &pos, &time);
_fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, pi->angle_count,
clip, ii, &pos, &time);
}
// sub paths
......@@ -493,7 +502,8 @@ NAV_TITLE* nav_title_open(const char *root, const char *playlist)
MPLS_SUB_PI *pi = &title->pl->sub_path[ss].sub_play_item[ii];
NAV_CLIP *clip = &sub_path->clip_list.clip[ii];
_fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, clip, ii, &pos, &time);
_fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, 0,
clip, ii, &pos, &time);
}
}
}
......@@ -744,7 +754,6 @@ NAV_CLIP* nav_next_clip(NAV_TITLE *title, NAV_CLIP *clip)
NAV_CLIP* nav_set_angle(NAV_TITLE *title, NAV_CLIP *clip, unsigned angle)
{
char *path;
int ii;
uint32_t pos = 0;
uint32_t time = 0;
......@@ -770,48 +779,9 @@ NAV_CLIP* nav_set_angle(NAV_TITLE *title, NAV_CLIP *clip, unsigned angle)
pi = &title->pl->play_item[ii];
clip = &title->clip_list.clip[ii];
if (title->angle >= pi->angle_count) {
clip->angle = 0;
} else {
clip->angle = title->angle;
}
clpi_free(clip->cl);
clip->ref = ii;
strncpy(clip->name, pi->clip[clip->angle].clip_id, 5);
strncpy(&clip->name[5], ".m2ts", 6);
clip->clip_id = atoi(pi->clip[clip->angle].clip_id);
path = str_printf("%s"DIR_SEP"BDMV"DIR_SEP"CLIPINF"DIR_SEP"%s.clpi",
title->root, pi->clip[clip->angle].clip_id);
clip->cl = clpi_parse(path, 0);
X_FREE(path);
if (clip->cl == NULL) {
clip->start_pkt = 0;
clip->end_pkt = 0;
continue;
}
switch (pi->connection_condition) {
case 5:
case 6:
clip->start_pkt = 0;
clip->connection = CONNECT_SEAMLESS;
break;
default:
clip->start_pkt = clpi_lookup_spn(clip->cl, pi->in_time, 1,
pi->clip[clip->angle].stc_id);
clip->connection = CONNECT_NON_SEAMLESS;
break;
}
clip->end_pkt = clpi_lookup_spn(clip->cl, pi->out_time, 0,
pi->clip[clip->angle].stc_id);
clip->in_time = pi->in_time;
clip->out_time = pi->out_time;
clip->pos = pos;
pos += clip->end_pkt - clip->start_pkt;
clip->start_time = time;
time += clip->out_time - clip->in_time;
_fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, pi->angle_count,
clip, ii, &pos, &time);
}
_extrapolate_title(title);
return clip;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment