MCPcopy Create free account
hub / github.com/FFMS/ffms2 / ReadPacket

Method ReadPacket

src/core/audiosource.cpp:556–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
557 while (av_read_frame(FormatContext, Packet) >= 0) {
558 if (Packet->stream_index == TrackNumber) {
559 // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
560 if (Packet->pts == AV_NOPTS_VALUE)
561 Packet->pts = LastValidTS;
562 else
563 LastValidTS = Packet->pts;
564
565 // This only happens if a really shitty demuxer seeks to a packet without pts *hrm* ogg *hrm* so read until a valid pts is reached
566 int64_t PacketTS = Frames.HasTS ? Packet->pts : Packet->pos;
567 if (PacketTS != AV_NOPTS_VALUE) {
568 while (PacketNumber > 0 && FrameTS(PacketNumber) > PacketTS) --PacketNumber;
569 while (FrameTS(PacketNumber) < PacketTS) ++PacketNumber;
570 return true;
571 }
572 }
573 av_packet_unref(Packet);
574 }
575 return false;
576}
577

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected