fftools/ffmpeg_enc: stop using OutputStream.initialized

It is set by the muxing code, which will not be synchronized with
encoding code after upcoming threading changes. Use an encoder-private
variable instead.
This commit is contained in:
Anton Khirnov 2023-05-27 23:26:12 +02:00
parent 568d414074
commit c803b36b8f
1 changed files with 7 additions and 2 deletions

View File

@ -62,6 +62,8 @@ struct Encoder {
// number of packets received from the encoder
uint64_t packets_encoded;
int opened;
};
static uint64_t dup_warning = 1000;
@ -187,7 +189,7 @@ int enc_open(OutputStream *ost, AVFrame *frame)
OutputFile *of = output_files[ost->file_index];
int ret;
if (ost->initialized)
if (e->opened)
return 0;
set_encoder_id(output_files[ost->file_index], ost);
@ -362,6 +364,8 @@ int enc_open(OutputStream *ost, AVFrame *frame)
return ret;
}
e->opened = 1;
if (ost->sq_idx_encode >= 0) {
e->sq_frame = av_frame_alloc();
if (!e->sq_frame)
@ -1123,6 +1127,7 @@ void enc_flush(void)
}
for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
Encoder *e = ost->enc;
AVCodecContext *enc = ost->enc_ctx;
OutputFile *of = output_files[ost->file_index];
@ -1131,7 +1136,7 @@ void enc_flush(void)
// Try to enable encoding with no input frames.
// Maybe we should just let encoding fail instead.
if (!ost->initialized) {
if (!e->opened) {
FilterGraph *fg = ost->filter->graph;
av_log(ost, AV_LOG_WARNING,