mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
mpegtsdemux: create function for pcr parsing
This commit is contained in:
parent
37f1decf78
commit
f89a0abca0
3 changed files with 23 additions and 32 deletions
|
@ -199,6 +199,21 @@ mpegts_packetizer_finalize (GObject * object)
|
|||
G_OBJECT_CLASS (mpegts_packetizer_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
guint64
|
||||
mpegts_packetizer_compute_pcr (const guint8 * data)
|
||||
{
|
||||
guint32 pcr1;
|
||||
guint16 pcr2;
|
||||
guint64 pcr, pcr_ext;
|
||||
|
||||
pcr1 = GST_READ_UINT32_BE (data);
|
||||
pcr2 = GST_READ_UINT16_BE (data + 4);
|
||||
pcr = ((guint64) pcr1) << 1;
|
||||
pcr |= (pcr2 & 0x8000) >> 15;
|
||||
pcr_ext = (pcr2 & 0x01ff);
|
||||
return pcr * 300 + pcr_ext % 300;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mpegts_packetizer_parse_adaptation_field_control (MpegTSPacketizer2 *
|
||||
packetizer, MpegTSPacketizerPacket * packet)
|
||||
|
@ -240,31 +255,13 @@ mpegts_packetizer_parse_adaptation_field_control (MpegTSPacketizer2 *
|
|||
|
||||
/* PCR */
|
||||
if (afcflags & MPEGTS_AFC_PCR_FLAG) {
|
||||
guint32 pcr1;
|
||||
guint16 pcr2;
|
||||
guint64 pcr, pcr_ext;
|
||||
|
||||
pcr1 = GST_READ_UINT32_BE (data);
|
||||
pcr2 = GST_READ_UINT16_BE (data + 4);
|
||||
pcr = ((guint64) pcr1) << 1;
|
||||
pcr |= (pcr2 & 0x8000) >> 15;
|
||||
pcr_ext = (pcr2 & 0x01ff);
|
||||
packet->pcr = pcr * 300 + pcr_ext % 300;;
|
||||
packet->pcr = mpegts_packetizer_compute_pcr (data);
|
||||
*data += 6;
|
||||
}
|
||||
|
||||
/* OPCR */
|
||||
if (afcflags & MPEGTS_AFC_OPCR_FLAG) {
|
||||
guint32 pcr1;
|
||||
guint16 pcr2;
|
||||
guint64 pcr, pcr_ext;
|
||||
|
||||
pcr1 = GST_READ_UINT32_BE (data);
|
||||
pcr2 = GST_READ_UINT16_BE (data + 4);
|
||||
pcr = ((guint64) pcr1) << 1;
|
||||
pcr |= (pcr2 & 0x8000) >> 15;
|
||||
pcr_ext = (pcr2 & 0x01ff);
|
||||
packet->opcr = pcr * 300 + pcr_ext % 300;;
|
||||
packet->opcr = mpegts_packetizer_compute_pcr (data);
|
||||
*data += 6;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ GstStructure *mpegts_packetizer_parse_eit (MpegTSPacketizer2 *packetizer,
|
|||
MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_tdt (MpegTSPacketizer2 *packetizer,
|
||||
MpegTSPacketizerSection *section);
|
||||
guint64 mpegts_packetizer_compute_pcr(const guint8 * data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -997,20 +997,13 @@ process_pcr (MpegTSBase * base, guint64 initoff, GstClockTime * pcr,
|
|||
/* GST_DEBUG ("offset %" G_GUINT64_FORMAT, GST_BUFFER_OFFSET (buf) + offset);
|
||||
GST_MEMDUMP ("something", GST_BUFFER_DATA (buf) + offset, 16);*/
|
||||
if ((*(br.data + offset + 5)) & 0x10) {
|
||||
guint16 pcr2;
|
||||
guint64 pcr, pcr_ext;
|
||||
guint64 lpcr = mpegts_packetizer_compute_pcr (br.data + offset + 6);
|
||||
|
||||
pcr = ((guint64) GST_READ_UINT32_BE (br.data + offset + 6)) << 1;
|
||||
pcr2 = GST_READ_UINT16_BE (br.data + offset + 10);
|
||||
pcr |= (pcr2 & 0x8000) >> 15;
|
||||
pcr_ext = (pcr2 & 0x01ff);
|
||||
pcr = pcr * 300 + pcr_ext % 300;
|
||||
|
||||
GST_DEBUG ("Found PCR %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT
|
||||
" at offset %" G_GUINT64_FORMAT, pcr,
|
||||
GST_TIME_ARGS (PCRTIME_TO_GSTTIME (pcr)),
|
||||
GST_INFO ("Found PCR %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT
|
||||
" at offset %" G_GUINT64_FORMAT, lpcr,
|
||||
GST_TIME_ARGS (PCRTIME_TO_GSTTIME (lpcr)),
|
||||
GST_BUFFER_OFFSET (buf) + offset);
|
||||
pcrs[nbpcr] = pcr;
|
||||
pcrs[nbpcr] = lpcr;
|
||||
pcroffs[nbpcr] = GST_BUFFER_OFFSET (buf) + offset;
|
||||
/* Safeguard against bogus PCR (by detecting if it's the same as the
|
||||
* previous one or wheter the difference with the previous one is
|
||||
|
|
Loading…
Reference in a new issue