MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / prepare_input_packet

Function prepare_input_packet

libavformat/mux.c:777–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
778{
779 FFStream *const sti = ffstream(st);
780#if !FF_API_COMPUTE_PKT_FIELDS2
781 /* sanitize the timestamps */
782 if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
783
784 /* when there is no reordering (so dts is equal to pts), but
785 * only one of them is set, set the other as well */
786 if (!sti->reorder) {
787 if (pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE)
788 pkt->pts = pkt->dts;
789 if (pkt->dts == AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE)
790 pkt->dts = pkt->pts;
791 }
792
793 /* check that the timestamps are set */
794 if (pkt->pts == AV_NOPTS_VALUE || pkt->dts == AV_NOPTS_VALUE) {
795 av_log(s, AV_LOG_ERROR,
796 "Timestamps are unset in a packet for stream %d\n", st->index);
797 return AVERROR(EINVAL);
798 }
799
800 /* check that the dts are increasing (or at least non-decreasing,
801 * if the format allows it */
802 if (sti->cur_dts != AV_NOPTS_VALUE &&
803 ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && sti->cur_dts >= pkt->dts) ||
804 sti->cur_dts > pkt->dts)) {
805 av_log(s, AV_LOG_ERROR,
806 "Application provided invalid, non monotonically increasing "
807 "dts to muxer in stream %d: %" PRId64 " >= %" PRId64 "\n",
808 st->index, sti->cur_dts, pkt->dts);
809 return AVERROR(EINVAL);
810 }
811
812 if (pkt->pts < pkt->dts) {
813 av_log(s, AV_LOG_ERROR, "pts %" PRId64 " < dts %" PRId64 " in stream %d\n",
814 pkt->pts, pkt->dts, st->index);
815 return AVERROR(EINVAL);
816 }
817 }
818#endif
819 /* update flags */
820 if (sti->is_intra_only)
821 pkt->flags |= AV_PKT_FLAG_KEY;
822
823 if (!pkt->data && !pkt->side_data_elems) {
824 /* Such empty packets signal EOS for the BSF API; so sanitize
825 * the packet by allocating data of size 0 (+ padding). */
826 av_buffer_unref(&pkt->buf);
827 return av_packet_make_refcounted(pkt);
828 }
829
830 return 0;
831}
832
833#define CHUNK_START 0x1000
834

Callers 1

write_packets_commonFunction · 0.85

Calls 4

ffstreamFunction · 0.85
av_logFunction · 0.85
av_buffer_unrefFunction · 0.85

Tested by

no test coverage detected