From dbf7b7228ef8aed9d12e4f5d42bab0f0dac28136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 10 Feb 2008 13:55:29 +0000 Subject: [PATCH] extract video framerate from PSI descriptiors --- dvb_support.h | 1 + parsers.c | 2 +- parsers.h | 2 ++ psi.c | 15 +++++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dvb_support.h b/dvb_support.h index cbf4264b..49cc4805 100644 --- a/dvb_support.h +++ b/dvb_support.h @@ -26,6 +26,7 @@ #ifndef DVB_SUPPORT_H #define DVB_SUPPORT_H +#define DVB_DESC_VIDEO_STREAM 0x02 #define DVB_DESC_CA 0x09 #define DVB_DESC_LANGUAGE 0x0a diff --git a/parsers.c b/parsers.c index d2efaae1..be7f5ce0 100644 --- a/parsers.c +++ b/parsers.c @@ -409,7 +409,7 @@ parse_pes_header(th_transport_t *t, th_stream_t *st, uint8_t *buf, size_t len) /** * MPEG2VIDEO frame duration table (in 90kHz clock domain) */ -const static unsigned int mpeg2video_framedurations[16] = { +const unsigned int mpeg2video_framedurations[16] = { 0, 3753, 3750, diff --git a/parsers.h b/parsers.h index 2f6c9488..6b610e14 100644 --- a/parsers.h +++ b/parsers.h @@ -29,4 +29,6 @@ void parse_compute_pts(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt); void parser_enqueue_packet(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt); +extern const unsigned int mpeg2video_framedurations[16]; + #endif /* PARSERS_H */ diff --git a/psi.c b/psi.c index 8e359305..203fe5ec 100644 --- a/psi.c +++ b/psi.c @@ -30,6 +30,7 @@ #include "dvb_support.h" #include "tsdemux.h" #include "strtab.h" +#include "parsers.h" int psi_section_reassemble(psi_section_t *ps, uint8_t *data, int len, @@ -177,7 +178,7 @@ psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) tv_streamtype_t hts_stream_type; th_stream_t *st; char lang[4]; - + int frameduration; if(len < 9) return -1; @@ -222,7 +223,7 @@ psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) ptr += 5; len -= 5; - + frameduration = 0; hts_stream_type = 0; switch(estype) { @@ -253,6 +254,10 @@ psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) break; switch(dtag) { + case DVB_DESC_VIDEO_STREAM: + frameduration = mpeg2video_framedurations[(ptr[0] >> 3) & 0xf]; + break; + case DVB_DESC_LANGUAGE: memcpy(lang, ptr, 3); break; @@ -276,10 +281,12 @@ psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) if(hts_stream_type != 0) { st = transport_add_stream(t, pid, hts_stream_type); st->st_tb = (AVRational){1, 90000}; - memcpy(st->st_lang, lang, 4); + + if(st->st_frame_duration == 0) + st->st_frame_duration = frameduration; } - } + } t->tht_pmt_seen = 1; return 0;