Commit 30c0b5cc authored by hpi1's avatar hpi1

m2ts_filter: cut also PG/IG strems

Fixes some main path embedded HDMV menus.
parent 9e2bb8c2
- Fix some main path embedded HDMV menus.
- Fix missing BD_EVENT_ERROR when BD-J is not supported.
2014-08-03: Version 0.6.1
......
......@@ -580,7 +580,8 @@ static int _open_m2ts(BLURAY *bd, BD_STREAM *st)
st->m2ts_filter = m2ts_filter_init((int64_t)st->clip->in_time << 1,
(int64_t)st->clip->out_time << 1,
stn->num_video, stn->num_audio);
stn->num_video, stn->num_audio,
stn->num_ig, stn->num_pg);
_update_clip_psrs(bd, st->clip);
......
......@@ -49,7 +49,8 @@ struct m2ts_filter_s
};
M2TS_FILTER *m2ts_filter_init(int64_t in_pts, int64_t out_pts,
unsigned num_video, unsigned num_audio)
unsigned num_video, unsigned num_audio,
unsigned num_ig, unsigned num_pg)
{
M2TS_FILTER *p = calloc(1, sizeof(*p));
......@@ -59,8 +60,8 @@ M2TS_FILTER *m2ts_filter_init(int64_t in_pts, int64_t out_pts,
p->in_pts = in_pts;
p->out_pts = out_pts;
p->wipe_pid = calloc(num_audio + num_video + 1, sizeof(uint16_t));
p->pass_pid = calloc(num_audio + num_video + 1, sizeof(uint16_t));
p->wipe_pid = calloc(num_audio + num_video + num_ig + num_pg + 1, sizeof(uint16_t));
p->pass_pid = calloc(num_audio + num_video + num_ig + num_pg + 1, sizeof(uint16_t));
if (!p->pass_pid || !p->wipe_pid) {
m2ts_filter_close(&p);
return NULL;
......@@ -74,6 +75,12 @@ M2TS_FILTER *m2ts_filter_init(int64_t in_pts, int64_t out_pts,
for (ii = 0; ii < num_audio; ii++) {
pid[npid++] = 0x1100 + ii;
}
for (ii = 0; ii < num_ig; ii++) {
pid[npid++] = 0x1400 + ii;
}
for (ii = 0; ii < num_pg; ii++) {
pid[npid++] = 0x1200 + ii;
}
}
return p;
......@@ -218,14 +225,25 @@ static int _filter_es_pts(M2TS_FILTER *p, const uint8_t *buf, uint16_t pid)
}
}
if (p->out_pts >= 0) {
/*
* Note: we can't compare against in_pts here (after passing it once):
* PG / IG streams can have timestamps before in_time (except for composition segments), and those are valid.
*/
if (_pid_in_list(p->pass_pid, pid)) {
int64_t pts = _es_timestamp(buf + 4 + payload_offset, 188 - payload_offset);
if (pts > p->out_pts) {
if (pts >= p->out_pts) {
/*
* audio/video streams are cutted after out_time (unit with pts==out_time is included in the clip).
* PG/IG streams are cutted before out_time (unit with pts==out_time is dropped out).
*/
if (pts > p->out_pts ||
(pid >= 0x1200 && pid < 0x1300 /* PG */) ||
(pid >= 0x1400 && pid < 0x1500 /* IG */)) {
M2TS_TRACE("Pid 0x%04x passed OUT timestamp %"PRId64" (pts %"PRId64") -> start wiping\n", pid, p->out_pts, pts);
_remove_pid(p->pass_pid, pid);
_add_pid(p->wipe_pid, pid);
}
}
}
}
......
......@@ -32,7 +32,8 @@
typedef struct m2ts_filter_s M2TS_FILTER;
BD_PRIVATE M2TS_FILTER *m2ts_filter_init(int64_t in_pts, int64_t out_pts,
unsigned num_video, unsigned num_audio);
unsigned num_video, unsigned num_audio,
unsigned num_ig, unsigned num_pg);
BD_PRIVATE void m2ts_filter_close(M2TS_FILTER **);
/*
......
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