diff --git a/src/dvb/dvb_multiplex.c b/src/dvb/dvb_multiplex.c index 6edd46b1..ea5262c4 100644 --- a/src/dvb/dvb_multiplex.c +++ b/src/dvb/dvb_multiplex.c @@ -1117,8 +1117,6 @@ dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src) st_src->st_pid, st_src->st_type); - st_dst->st_tb = (AVRational){1, 90000}; - memcpy(st_dst->st_lang, st_src->st_lang, 4); st_dst->st_frame_duration = st_src->st_frame_duration; diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 4f14d0df..c20e9baf 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -33,6 +33,8 @@ #include "spawn.h" #include "transports.h" +static const AVRational mpeg_tc = {1, 90000}; + typedef struct dvr_rec_stream { LIST_ENTRY(dvr_rec_stream) drs_link; @@ -710,12 +712,11 @@ dvr_thread_new_pkt(dvr_entry_t *de, th_pkt_t *pkt) av_init_packet(&avpkt); avpkt.stream_index = st->index; - avpkt.dts = av_rescale_q(dts, AV_TIME_BASE_Q, st->time_base); - avpkt.pts = av_rescale_q(pts, AV_TIME_BASE_Q, st->time_base); + avpkt.dts = av_rescale_q(dts, mpeg_tc, st->time_base); + avpkt.pts = av_rescale_q(pts, mpeg_tc, st->time_base); avpkt.data = buf; avpkt.size = bufsize; - avpkt.duration = - av_rescale_q(pkt->pkt_duration, AV_TIME_BASE_Q, st->time_base); + avpkt.duration = av_rescale_q(pkt->pkt_duration, mpeg_tc, st->time_base); avpkt.flags = pkt->pkt_frametype >= PKT_P_FRAME ? 0 : PKT_FLAG_KEY; r = av_interleaved_write_frame(fctx, &avpkt); break; @@ -734,7 +735,7 @@ dvr_thread_new_pkt(dvr_entry_t *de, th_pkt_t *pkt) tvhlog(LOG_INFO, "dvr", "%s - Skipped %" PRId64 " seconds of commercials", - de->de_ititle, (pkt->pkt_dts - de->de_ts_com_start) / 1000000); + de->de_ititle, (pkt->pkt_dts - de->de_ts_com_start) / 90000); goto outputpacket; } break; diff --git a/src/htsp.c b/src/htsp.c index 786ece1d..a3bf5958 100644 --- a/src/htsp.c +++ b/src/htsp.c @@ -1373,6 +1373,8 @@ const static char frametypearray[PKT_NTYPES] = { [PKT_B_FRAME] = 'B', }; +const static AVRational mpeg_tc = {1, 90000}; + /** * Build a htsmsg from a th_pkt and enqueue it on our HTSP transport */ @@ -1401,10 +1403,15 @@ htsp_stream_deliver(htsp_subscription_t *hs, th_pkt_t *pkt) htsmsg_add_u32(m, "frametype", frametypearray[pkt->pkt_frametype]); htsmsg_add_u32(m, "stream", pkt->pkt_componentindex); - htsmsg_add_s64(m, "dts", pkt->pkt_dts); - htsmsg_add_s64(m, "pts", pkt->pkt_pts); - htsmsg_add_u32(m, "duration", pkt->pkt_duration); htsmsg_add_u32(m, "com", pkt->pkt_commercial); + + int64_t pts = av_rescale_q(pkt->pkt_pts, mpeg_tc, AV_TIME_BASE_Q); + int64_t dts = av_rescale_q(pkt->pkt_dts, mpeg_tc, AV_TIME_BASE_Q); + uint32_t dur = av_rescale_q(pkt->pkt_duration, mpeg_tc, AV_TIME_BASE_Q); + + htsmsg_add_s64(m, "dts", dts); + htsmsg_add_s64(m, "pts", pts); + htsmsg_add_u32(m, "duration", dur); /** * Since we will serialize directly we use 'binptr' which is a binary diff --git a/src/parsers.c b/src/parsers.c index bbd51087..c9dfadf3 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -610,7 +610,7 @@ parse_mpeg2video_pic_start(th_transport_t *t, th_stream_t *st, int *frametype, if(v == 0xffff) st->st_vbv_delay = -1; else - st->st_vbv_delay = av_rescale_q(v, st->st_tb, AV_TIME_BASE_Q); + st->st_vbv_delay = v; return 0; } @@ -1129,9 +1129,9 @@ parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt, pts = dts + ptsoff; /* Rescale to tvheadned internal 1MHz clock */ - pkt->pkt_dts =av_rescale_q(dts, st->st_tb, AV_TIME_BASE_Q); - pkt->pkt_pts =av_rescale_q(pts, st->st_tb, AV_TIME_BASE_Q); - pkt->pkt_duration=av_rescale_q(pkt->pkt_duration, st->st_tb, AV_TIME_BASE_Q); + pkt->pkt_dts = dts; + pkt->pkt_pts = pts; + #if 0 printf("%-12s %d %10"PRId64" %10"PRId64" %10d %10d\n", streaming_component_type2txt(st->st_type), diff --git a/src/psi.c b/src/psi.c index 60b0c2c4..0db404b1 100644 --- a/src/psi.c +++ b/src/psi.c @@ -613,8 +613,6 @@ psi_parse_pmt(th_transport_t *t, const uint8_t *ptr, int len, int chksvcid, st->st_position = position; } - st->st_tb = (AVRational){1, 90000}; - if(memcmp(st->st_lang, lang, 4)) { update |= PMT_UPDATE_LANGUAGE; memcpy(st->st_lang, lang, 4); @@ -1104,7 +1102,6 @@ psi_load_transport_settings(htsmsg_t *m, th_transport_t *t) continue; st = transport_stream_create(t, pid, type); - st->st_tb = (AVRational){1, 90000}; if((v = htsmsg_get_str(c, "language")) != NULL) av_strlcpy(st->st_lang, v, 4); diff --git a/src/rtp.c b/src/rtp.c index 4df381a0..866f1d46 100644 --- a/src/rtp.c +++ b/src/rtp.c @@ -30,8 +30,6 @@ #include "tvhead.h" #include "rtp.h" -static const AVRational mpeg_tc = {1, 90000}; - void rtp_send_mpv(rtp_send_t *sender, void *opaque, rtp_stream_t *rs, const uint8_t *data, size_t len, @@ -45,8 +43,6 @@ rtp_send_mpv(rtp_send_t *sender, void *opaque, rtp_stream_t *rs, if(data[0] != 0x00 || data[1] != 0x00 || data[2] != 0x01) return; // Not a startcode, something is fishy - pts = av_rescale_q(pts, AV_TIME_BASE_Q, mpeg_tc); - if(data[3] == 0xb3) { // Sequence Start code, set Begin-Of-Sequence flags |= 1 << 13; @@ -100,8 +96,6 @@ rtp_send_mpa(rtp_send_t *sender, void *opaque, rtp_stream_t *rs, int offset = 0, s; uint8_t *buf; - pts = av_rescale_q(pts, AV_TIME_BASE_Q, mpeg_tc); - while(len > 0) { s = len > payloadsize ? payloadsize : len; diff --git a/src/transports.c b/src/transports.c index 925aebb4..c69421f5 100644 --- a/src/transports.c +++ b/src/transports.c @@ -652,7 +652,6 @@ transport_stream_create(th_transport_t *t, int pid, st->st_pid = pid; st->st_demuxer_fd = -1; - st->st_tb = (AVRational){1, 90000}; TAILQ_INIT(&st->st_ptsq); TAILQ_INIT(&st->st_durationq); diff --git a/src/tsdemux.c b/src/tsdemux.c index 664e0a25..860f5a31 100644 --- a/src/tsdemux.c +++ b/src/tsdemux.c @@ -140,7 +140,7 @@ ts_extract_pcr(th_transport_t *t, th_stream_t *st, const uint8_t *tsb, pcr |= (uint64_t)tsb[9] << 1; pcr |= ((uint64_t)tsb[10] >> 7) & 0x01; - pcr = av_rescale_q(pcr, mpeg_tc, AV_TIME_BASE_Q); + pcr = pcr; if(pcrp != NULL) *pcrp = pcr; @@ -153,7 +153,7 @@ ts_extract_pcr(th_transport_t *t, th_stream_t *st, const uint8_t *tsb, if(st->st_pcr_real_last != AV_NOPTS_VALUE) { d = (real - st->st_pcr_real_last) - (pcr - st->st_pcr_last); - if(d < -1000000LL || d > 1000000LL) { + if(d < -90000LL || d > 90000LL) { st->st_pcr_recovery_fails++; if(st->st_pcr_recovery_fails > 10) { st->st_pcr_recovery_fails = 0; diff --git a/src/tvhead.h b/src/tvhead.h index 6bbffcb2..f51478c4 100644 --- a/src/tvhead.h +++ b/src/tvhead.h @@ -450,9 +450,6 @@ typedef struct th_stream { /* CA ID's on this stream */ struct caid_list st_caids; - /* Remuxing information */ - AVRational st_tb; - int st_vbv_size; /* Video buffer size (in bytes) */ int st_vbv_delay; /* -1 if CBR */