-
- /* generate the first dts by linearly extrapolating the
- * first two pts values to the past */
- if (avctx->max_b_frames > 0 && !ctx->first_packet_output &&
- ctx->initial_pts[1] != AV_NOPTS_VALUE) {
- int64_t ts0 = ctx->initial_pts[0], ts1 = ctx->initial_pts[1];
- int64_t delta;
-
- if ((ts0 < 0 && ts1 > INT64_MAX + ts0) ||
- (ts0 > 0 && ts1 < INT64_MIN + ts0))
- return AVERROR(ERANGE);
- delta = ts1 - ts0;
-
- if ((delta < 0 && ts0 > INT64_MAX + delta) ||
- (delta > 0 && ts0 < INT64_MIN + delta))
- return AVERROR(ERANGE);
- pkt->dts = ts0 - delta;
-
- ctx->first_packet_output = 1;
- return 0;
- }
-