Message ID | 20220404113037.13070-4-anton@khirnov.net |
---|---|
State | Accepted |
Commit | 662364b2efb3540c5b4a2b140601fab7a9c90367 |
Headers | show |
Series | [FFmpeg-devel,01/49] fftools/ffmpeg: drop an obsolete hack | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On 4/4/2022 8:29 AM, Anton Khirnov wrote: > This field is currently used by checks > - skipping packets before the first keyframe > - skipping packets before start time > to test whether any packets have been output already. But since > frame_number is incremented after the bitstream filters are applied > (which may involve delay), this use is incorrect. The keyframe check > works around this by adding an extra flag, the start-time check does > not. > > Simplify both checks by replacing the seen_kf flag with a flag tracking > whether any packets have been output by do_streamcopy(). > --- > fftools/ffmpeg.c | 10 +++++----- > fftools/ffmpeg.h | 2 +- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > index 13be32f0cf..29b01f9d93 100644 > --- a/fftools/ffmpeg.c > +++ b/fftools/ffmpeg.c > @@ -894,8 +894,6 @@ static void output_packet(OutputFile *of, AVPacket *pkt, > > /* apply the output bitstream filters */ > if (ost->bsf_ctx) { > - if (pkt->flags & AV_PKT_FLAG_KEY) > - ost->seen_kf = 1; > ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); > if (ret < 0) > goto finish; > @@ -2043,11 +2041,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p > return; > } > > - if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && > - !ost->copy_initial_nonkeyframes && !ost->seen_kf) > + if (!ost->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) && > + !ost->copy_initial_nonkeyframes) > return; > > - if (!ost->frame_number && !ost->copy_prior_start) { > + if (!ost->streamcopy_started && !ost->copy_prior_start) { > int64_t comp_start = start_time; > if (copy_ts && f->start_time != AV_NOPTS_VALUE) > comp_start = FFMAX(start_time, f->start_time + f->ts_offset); > @@ -2101,6 +2099,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p > ost->sync_opts += opkt->duration; > > output_packet(of, opkt, ost, 0); > + > + ost->streamcopy_started = 1; > } > > int guess_input_channel_layout(InputStream *ist) > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h > index 1e14bf9fa9..04369df139 100644 > --- a/fftools/ffmpeg.h > +++ b/fftools/ffmpeg.h > @@ -536,7 +536,7 @@ typedef struct OutputStream { > int inputs_done; > > const char *attachment_filename; > - int seen_kf; > + int streamcopy_started; > int copy_initial_nonkeyframes; > int copy_prior_start; > char *disposition; fate-ffmpeg-setts-bsf, which depends on this code, still passes, so lgtm.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 13be32f0cf..29b01f9d93 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -894,8 +894,6 @@ static void output_packet(OutputFile *of, AVPacket *pkt, /* apply the output bitstream filters */ if (ost->bsf_ctx) { - if (pkt->flags & AV_PKT_FLAG_KEY) - ost->seen_kf = 1; ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); if (ret < 0) goto finish; @@ -2043,11 +2041,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p return; } - if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && - !ost->copy_initial_nonkeyframes && !ost->seen_kf) + if (!ost->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) && + !ost->copy_initial_nonkeyframes) return; - if (!ost->frame_number && !ost->copy_prior_start) { + if (!ost->streamcopy_started && !ost->copy_prior_start) { int64_t comp_start = start_time; if (copy_ts && f->start_time != AV_NOPTS_VALUE) comp_start = FFMAX(start_time, f->start_time + f->ts_offset); @@ -2101,6 +2099,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p ost->sync_opts += opkt->duration; output_packet(of, opkt, ost, 0); + + ost->streamcopy_started = 1; } int guess_input_channel_layout(InputStream *ist) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1e14bf9fa9..04369df139 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -536,7 +536,7 @@ typedef struct OutputStream { int inputs_done; const char *attachment_filename; - int seen_kf; + int streamcopy_started; int copy_initial_nonkeyframes; int copy_prior_start; char *disposition;