From aec42c2fef2ba79dabb04cd36eb9069ec9f8dc56 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 29 Apr 2017 10:16:55 +0200 Subject: [PATCH] mkvmuxer: fix DVBSUB packets reordering --- src/muxer/muxer_mkv.c | 6 ++++-- src/packet.c | 14 ++++++++++++++ src/packet.h | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/muxer/muxer_mkv.c b/src/muxer/muxer_mkv.c index 522f1ca58..effb2d41d 100644 --- a/src/muxer/muxer_mkv.c +++ b/src/muxer/muxer_mkv.c @@ -1127,10 +1127,10 @@ mk_mux_write_pkt(mk_muxer_t *mk, th_pkt_t *pkt) mark = 0; if(SCT_ISAUDIO(pkt->pkt_type)) { while ((opkt = pktref_first(&mk->holdq)) != NULL) { - if (pts_diff(opkt->pkt_pts, pkt->pkt_pts) > 90000) + if (pts_diff(pkt->pkt_pts, opkt->pkt_pts) > 90000) break; opkt = pktref_get_first(&mk->holdq); - tvhtrace(LS_MKV, "hold push, pts %"PRId64"\n", opkt->pkt_pts); + tvhtrace(LS_MKV, "hold push, pts %"PRId64", audio pts %"PRId64"\n", opkt->pkt_pts, pkt->pkt_pts); tpkt = pkt_copy_shallow(opkt); pkt_ref_dec(opkt); tpkt->pkt_pcr = tpkt->pkt_pts; @@ -1474,6 +1474,8 @@ mkv_muxer_destroy(muxer_t *m) mk_muxer_t *mk = (mk_muxer_t*)m; mk_chapter_t *ch; + pktref_clear_queue(&mk->holdq); + while((ch = TAILQ_FIRST(&mk->chapters)) != NULL) { TAILQ_REMOVE(&mk->chapters, ch, link); free(ch); diff --git a/src/packet.c b/src/packet.c index bb23ef1e4..08b59ba76 100644 --- a/src/packet.c +++ b/src/packet.c @@ -247,6 +247,20 @@ pktref_remove(struct th_pktref_queue *q, th_pktref_t *pr) } } +/** + * + */ +th_pkt_t * +pktref_first(struct th_pktref_queue *q) +{ + th_pktref_t *pr; + + pr = TAILQ_FIRST(q); + if (pr) + return pr->pr_pkt; + return NULL; +} + /** * */ diff --git a/src/packet.h b/src/packet.h index c3e6e5716..e32182815 100644 --- a/src/packet.h +++ b/src/packet.h @@ -117,8 +117,7 @@ void pktref_enqueue_sorted(struct th_pktref_queue *q, th_pkt_t *pkt, void pktref_remove(struct th_pktref_queue *q, th_pktref_t *pr); -static inline th_pkt_t *pktref_first(struct th_pktref_queue *q) - { return (th_pkt_t *)TAILQ_FIRST(q); } +th_pkt_t *pktref_first(struct th_pktref_queue *q); th_pkt_t *pktref_get_first(struct th_pktref_queue *q); -- 2.47.2