[soc]: r3937 - dvbmuxer/mpegtsenc.c
Author: bcoudurier Date: Sat Jan 10 01:48:25 2009 New Revision: 3937 Log: fix pcr computation, forgot si packets Modified: dvbmuxer/mpegtsenc.c Modified: dvbmuxer/mpegtsenc.c ============================================================================== --- dvbmuxer/mpegtsenc.c Fri Jan 2 00:33:53 2009 (r3936) +++ dvbmuxer/mpegtsenc.c Sat Jan 10 01:48:25 2009 (r3937) @@ -37,9 +37,34 @@ typedef struct MpegTSSection { void *opaque; } MpegTSSection; +typedef struct MpegTSService { + MpegTSSection pmt; /* MPEG2 pmt table context */ + int sid; /* service ID */ + char *name; + char *provider_name; + int pcr_pid; +} MpegTSService; + +typedef struct MpegTSWrite { + MpegTSSection pat; /* MPEG2 pat table */ + MpegTSSection sdt; /* MPEG2 sdt table context */ + MpegTSService **services; + int sdt_packet_count; + int sdt_packet_freq; + int pat_packet_count; + int pat_packet_freq; + int nb_services; + int onid; + int tsid; + int64_t last_pcr; ///< last program clock reference */ + int64_t cur_pcr; ///< last program clock reference */ + int mux_rate; +} MpegTSWrite; + /* NOTE: 4 bytes must be left at the end for the crc32 */ static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) { + MpegTSWrite *ts = ((AVFormatContext*)s->opaque)->priv_data; unsigned int crc; unsigned char packet[TS_PACKET_SIZE]; const unsigned char *buf_ptr; @@ -81,6 +106,7 @@ static void mpegts_write_section(MpegTSS buf_ptr += len1; len -= len1; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate; } } @@ -151,30 +177,6 @@ typedef struct MpegTSWriteStream { uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE]; } MpegTSWriteStream; -typedef struct MpegTSService { - MpegTSSection pmt; /* MPEG2 pmt table context */ - int sid; /* service ID */ - char *name; - char *provider_name; - int pcr_pid; -} MpegTSService; - -typedef struct MpegTSWrite { - MpegTSSection pat; /* MPEG2 pat table */ - MpegTSSection sdt; /* MPEG2 sdt table context */ - MpegTSService **services; - int sdt_packet_count; - int sdt_packet_freq; - int pat_packet_count; - int pat_packet_freq; - int nb_services; - int onid; - int tsid; - int64_t last_pcr; ///< last program clock reference */ - int64_t cur_pcr; ///< last program clock reference */ - int mux_rate; -} MpegTSWrite; - static void mpegts_write_pat(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; @@ -580,7 +582,7 @@ static void mpegts_write_pes(AVFormatCon payload += len; payload_size -= len; put_buffer(s->pb, buf, TS_PACKET_SIZE); - ts->cur_pcr += (TS_PACKET_SIZE+write_pcr)*8*90000LL / ts->mux_rate; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate; } put_flush_packet(s->pb); }
Hi, On Sat, Jan 10, 2009 at 2:48 AM, bcoudurier <subversion@mplayerhq.hu> wrote:
Author: bcoudurier Date: Sat Jan 10 01:48:25 2009 New Revision: 3937
Log: fix pcr computation, forgot si packets
Modified: dvbmuxer/mpegtsenc.c
Modified: dvbmuxer/mpegtsenc.c ============================================================================== --- dvbmuxer/mpegtsenc.c Fri Jan 2 00:33:53 2009 (r3936) +++ dvbmuxer/mpegtsenc.c Sat Jan 10 01:48:25 2009 (r3937) @@ -37,9 +37,34 @@ typedef struct MpegTSSection { void *opaque; } MpegTSSection;
+typedef struct MpegTSService { + MpegTSSection pmt; /* MPEG2 pmt table context */ + int sid; /* service ID */ + char *name; + char *provider_name; + int pcr_pid; +} MpegTSService; + +typedef struct MpegTSWrite { + MpegTSSection pat; /* MPEG2 pat table */ + MpegTSSection sdt; /* MPEG2 sdt table context */ + MpegTSService **services; + int sdt_packet_count; + int sdt_packet_freq; + int pat_packet_count; + int pat_packet_freq; + int nb_services; + int onid; + int tsid; + int64_t last_pcr; ///< last program clock reference */ + int64_t cur_pcr; ///< last program clock reference */ + int mux_rate; +} MpegTSWrite; + /* NOTE: 4 bytes must be left at the end for the crc32 */ static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) { + MpegTSWrite *ts = ((AVFormatContext*)s->opaque)->priv_data; unsigned int crc; unsigned char packet[TS_PACKET_SIZE]; const unsigned char *buf_ptr; @@ -81,6 +106,7 @@ static void mpegts_write_section(MpegTSS
buf_ptr += len1; len -= len1; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate;
Why 8?
} }
@@ -151,30 +177,6 @@ typedef struct MpegTSWriteStream { uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE]; } MpegTSWriteStream;
-typedef struct MpegTSService { - MpegTSSection pmt; /* MPEG2 pmt table context */ - int sid; /* service ID */ - char *name; - char *provider_name; - int pcr_pid; -} MpegTSService; - -typedef struct MpegTSWrite { - MpegTSSection pat; /* MPEG2 pat table */ - MpegTSSection sdt; /* MPEG2 sdt table context */ - MpegTSService **services; - int sdt_packet_count; - int sdt_packet_freq; - int pat_packet_count; - int pat_packet_freq; - int nb_services; - int onid; - int tsid; - int64_t last_pcr; ///< last program clock reference */ - int64_t cur_pcr; ///< last program clock reference */ - int mux_rate; -} MpegTSWrite; - static void mpegts_write_pat(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; @@ -580,7 +582,7 @@ static void mpegts_write_pes(AVFormatCon payload += len; payload_size -= len; put_buffer(s->pb, buf, TS_PACKET_SIZE); - ts->cur_pcr += (TS_PACKET_SIZE+write_pcr)*8*90000LL / ts->mux_rate; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate;
And again...
} put_flush_packet(s->pb); } _______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
It seems like you assume each SI section duration is 8 packets long. Am I correct? Anyway, this does not seem too accurate to me. Have we abandoned the former method of calculating each written SI packet? Tomer
Tomer Barletz wrote:
[...]
@@ -81,6 +106,7 @@ static void mpegts_write_section(MpegTSS
buf_ptr += len1; len -= len1; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate;
Why 8?
Because ts->mux_rate is in bits/s not bytes.
[...]
@@ -580,7 +582,7 @@ static void mpegts_write_pes(AVFormatCon payload += len; payload_size -= len; put_buffer(s->pb, buf, TS_PACKET_SIZE); - ts->cur_pcr += (TS_PACKET_SIZE+write_pcr)*8*90000LL / ts->mux_rate; + ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate;
And again...
See above.
It seems like you assume each SI section duration is 8 packets long. Am I correct?
Nope.
Anyway, this does not seem too accurate to me. Have we abandoned the former method of calculating each written SI packet?
This method is correct, I think. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no
Tomer Barletz wrote:
On Sun, Jan 11, 2009 at 11:51 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
[...]
But a section might spread on more than one packet.
Yes, that's why there is a += in a while loop. What's the problem exactly ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no
participants (3)
-
Baptiste Coudurier -
bcoudurier -
Tomer Barletz