Encoder timebase is equal to the frame timebase, so does not need to be passed separately. Also, rename in_picture to frame, which is shorter and more accurate - it always contains a frame, never a field.
Unified · Split
| @@ -746,16 +746,16 @@ static int do_audio_out(OutputFile *of, OutputStream *ost, · 745 unmodified lines | |||
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, | 748 | static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, |
| 749 | AVRational tb, const AVFrame *in_picture) | 749 | const AVFrame *frame) |
| 750 | { | 750 | { |
| 751 | double pts_time; | 751 | double pts_time; |
| 752 | 752 | ||
| 753 | if (kf->ref_pts == AV_NOPTS_VALUE) | 753 | if (kf->ref_pts == AV_NOPTS_VALUE) |
| 754 | kf->ref_pts = in_picture->pts; | 754 | kf->ref_pts = frame->pts; |
| 755 | 755 | ||
| 756 | pts_time = (in_picture->pts - kf->ref_pts) * av_q2d(tb); | 756 | pts_time = (frame->pts - kf->ref_pts) * av_q2d(frame->time_base); |
| 757 | if (kf->index < kf->nb_pts && | 757 | if (kf->index < kf->nb_pts && |
| 758 | av_compare_ts(in_picture->pts, tb, kf->pts[kf->index], AV_TIME_BASE_Q) >= 0) { | 758 | av_compare_ts(frame->pts, frame->time_base, kf->pts[kf->index], AV_TIME_BASE_Q) >= 0) { |
| 759 | kf->index++; | 759 | kf->index++; |
| 760 | goto force_keyframe; | 760 | goto force_keyframe; |
| 761 | } else if (kf->pexpr) { | 761 | } else if (kf->pexpr) { |
| @@ -780,7 +780,7 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, · 18 unmodified lines | |||
| 780 | kf->expr_const_values[FKF_N_FORCED] += 1; | 780 | kf->expr_const_values[FKF_N_FORCED] += 1; |
| 781 | goto force_keyframe; | 781 | goto force_keyframe; |
| 782 | } | 782 | } |
| 783 | } else if (kf->type == KF_FORCE_SOURCE && (in_picture->flags & AV_FRAME_FLAG_KEY)) { | 783 | } else if (kf->type == KF_FORCE_SOURCE && (frame->flags & AV_FRAME_FLAG_KEY)) { |
| 784 | goto force_keyframe; | 784 | goto force_keyframe; |
| 785 | } | 785 | } |
| 786 | 786 | ||
| @@ -801,7 +801,7 @@ static int do_video_out(OutputFile *of, OutputStream *ost, · 14 unmodified lines | |||
| 801 | return AVERROR_EOF; | 801 | return AVERROR_EOF; |
| 802 | 802 | ||
| 803 | in_picture->quality = enc->global_quality; | 803 | in_picture->quality = enc->global_quality; |
| 804 | in_picture->pict_type = forced_kf_apply(ost, &ost->kf, enc->time_base, in_picture); | 804 | in_picture->pict_type = forced_kf_apply(ost, &ost->kf, in_picture); |
| 805 | 805 | ||
| 806 | #if FFMPEG_OPT_TOP | 806 | #if FFMPEG_OPT_TOP |
| 807 | if (ost->top_field_first >= 0) { | 807 | if (ost->top_field_first >= 0) { |