static int mpeg_remux_packet (mpeg_demux_t *mpeg) { int r; unsigned sid, ssid; sid = mpeg->packet.sid; ssid = mpeg->packet.ssid; if (mpeg_stream_excl (sid, ssid)) { return (0); } r = 0; if (mpeg_buf_read (&packet, mpeg, mpeg->packet.size)) { fprintf(stderr, "remux: incomplete packet (sid=%02x size=%u/%u)\n", sid, packet.cnt, mpeg->packet.size ); if (par_drop) { mpeg_buf_clear (&packet); return (1); } r = 1; } if (mpeg_buf_write_clear (&pack, mpeg->ext)) { return (1); } if (mpeg_buf_write_clear (&packet, mpeg->ext)) { return (1); } return (r); }
static int mpeg_scan_packet (mpeg_demux_t *mpeg) { FILE *fp; unsigned sid, ssid; uint64_t ofs; sid = mpeg->packet.sid; ssid = mpeg->packet.ssid; if (mpeg_stream_excl (sid, ssid)) { return (0); } fp = (FILE *) mpeg->ext; ofs = mpeg->ofs; if (mpegd_set_offset (mpeg, ofs + mpeg->packet.size)) { fprintf (fp, "%08" PRIxMAX ": sid=%02x ssid=%02x incomplete packet\n", (uintmax_t) ofs, sid, ssid ); } if (sid == 0xbd) { if (mpeg->substreams[ssid].packet_cnt > 1) { if (!par_first_pts) { return (0); } if (!mpeg->packet.have_pts) { return (0); } if (mpeg->packet.pts >= pts2[ssid]) { return (0); } } if (mpeg->packet.pts < pts2[ssid]) { pts2[ssid] = mpeg->packet.pts; } } else { if (mpeg->streams[sid].packet_cnt > 1) { if (!par_first_pts) { return (0); } if (!mpeg->packet.have_pts) { return (0); } if (mpeg->packet.pts >= pts1[sid]) { return (0); } } if (mpeg->packet.pts < pts1[sid]) { pts1[sid] = mpeg->packet.pts; } } fprintf (fp, "%08" PRIxMAX ": sid=%02x", (uintmax_t) ofs, sid); if (sid == 0xbd) { fprintf (fp, "[%02x]", ssid); } else { fputs (" ", fp); } if (mpeg->packet.type == 1) { fputs (" MPEG1", fp); } else if (mpeg->packet.type == 2) { fputs (" MPEG2", fp); } else { fputs (" UNKWN", fp); } if (mpeg->packet.have_pts) { fprintf (fp, " pts=%" PRIuMAX "[%.4f]", (uintmax_t) mpeg->packet.pts, (double) mpeg->packet.pts / 90000.0 ); } fputs ("\n", fp); fflush (fp); return (0); }
static int mpeg_list_packet (mpeg_demux_t *mpeg) { FILE *fp; unsigned sid, ssid; if (par_no_packet) { return (0); } sid = mpeg->packet.sid; ssid = mpeg->packet.ssid; if (mpeg_stream_excl (sid, ssid)) { return (0); } fp = (FILE *) mpeg->ext; mpeg_list_print_skip (fp); fprintf (fp, "%08" PRIxMAX ": packet[%lu]: sid=%02x", (uintmax_t) mpeg->ofs, mpeg->streams[sid].packet_cnt - 1, sid ); if (sid == 0xbd) { fprintf (fp, "[%02x]", ssid); } else { fputs (" ", fp); } if (mpeg->packet.type == 1) { fputs (" MPEG1", fp); } else if (mpeg->packet.type == 2) { fputs (" MPEG2", fp); } else { fputs (" UNKWN", fp); } fprintf (fp, " size=%u", mpeg->packet.size); if (mpeg->packet.have_pts || mpeg->packet.have_dts) { fprintf (fp, " pts=%" PRIuMAX "[%.4f] dts=%" PRIuMAX "[%.4f]", (uintmax_t) mpeg->packet.pts, (double) mpeg->packet.pts / 90000.0, (uintmax_t) mpeg->packet.dts, (double) mpeg->packet.dts / 90000.0 ); } fputs ("\n", fp); return (0); }