Use 90kHz timebase internally

This commit is contained in:
Andreas Öman 2010-06-13 19:29:31 +00:00
parent 95f2727a36
commit 2a9e1169f4
9 changed files with 22 additions and 29 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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),

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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 */