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

Function init_pts

libavformat/mux.c:383–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383static int init_pts(AVFormatContext *s)
384{
385 FFFormatContext *const si = ffformatcontext(s);
386
387 /* init PTS generation */
388 for (unsigned i = 0; i < s->nb_streams; i++) {
389 AVStream *const st = s->streams[i];
390 FFStream *const sti = ffstream(st);
391 int64_t den = AV_NOPTS_VALUE;
392
393 switch (st->codecpar->codec_type) {
394 case AVMEDIA_TYPE_AUDIO:
395 den = (int64_t)st->time_base.num * st->codecpar->sample_rate;
396 break;
397 case AVMEDIA_TYPE_VIDEO:
398 den = (int64_t)st->time_base.num * st->time_base.den;
399 break;
400 default:
401 break;
402 }
403
404 if (den != AV_NOPTS_VALUE) {
405 if (den <= 0)
406 return AVERROR_INVALIDDATA;
407
408 frac_init(&sti->priv_pts, 0, 0, den);
409 }
410 }
411
412 si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_UNKNOWN;
413 if (s->avoid_negative_ts < 0) {
414 av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO);
415 if (s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS)) {
416 s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED;
417 si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED;
418 } else
419 s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE;
420 } else if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_DISABLED)
421 si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED;
422
423 return 0;
424}
425
426static void flush_if_needed(AVFormatContext *s)
427{

Callers 2

avformat_init_outputFunction · 0.85
avformat_write_headerFunction · 0.85

Calls 2

ffstreamFunction · 0.85
frac_initFunction · 0.85

Tested by

no test coverage detected