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

Function guess_correct_pts

libavcodec/decode.c:293–317  ·  view source on GitHub ↗

* Attempt to guess proper monotonic timestamps for decoded video frames * which might have incorrect times. Input timestamps may wrap around, in * which case the output will as well. * * @param pts the pts field of the decoded AVPacket, as passed through * AVFrame.pts * @param dts the dts field of the decoded AVPacket * @return one of the input values, may be AV_NOPTS_VALUE */

Source from the content-addressed store, hash-verified

291 * @return one of the input values, may be AV_NOPTS_VALUE
292 */
293static int64_t guess_correct_pts(DecodeContext *dc,
294 int64_t reordered_pts, int64_t dts)
295{
296 int64_t pts = AV_NOPTS_VALUE;
297
298 if (dts != AV_NOPTS_VALUE) {
299 dc->pts_correction_num_faulty_dts += dts <= dc->pts_correction_last_dts;
300 dc->pts_correction_last_dts = dts;
301 } else if (reordered_pts != AV_NOPTS_VALUE)
302 dc->pts_correction_last_dts = reordered_pts;
303
304 if (reordered_pts != AV_NOPTS_VALUE) {
305 dc->pts_correction_num_faulty_pts += reordered_pts <= dc->pts_correction_last_pts;
306 dc->pts_correction_last_pts = reordered_pts;
307 } else if(dts != AV_NOPTS_VALUE)
308 dc->pts_correction_last_pts = dts;
309
310 if ((dc->pts_correction_num_faulty_pts<=dc->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
311 && reordered_pts != AV_NOPTS_VALUE)
312 pts = reordered_pts;
313 else
314 pts = dts;
315
316 return pts;
317}
318
319static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
320{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected