Credit FFmpeg team / Andrew patch / Andrea plugins update for 5.1
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / ffmpeg-5.1.patchC
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-5.1.patchC b/cinelerra-5.1/thirdparty/src/ffmpeg-5.1.patchC
new file mode 100644 (file)
index 0000000..bce5202
--- /dev/null
@@ -0,0 +1,41 @@
+--- a/libavcodec/encode.c
++++ b/libavcodec/encode.c
+@@ -191,7 +191,7 @@
+     }
+     if (!frame->buf[0]) {
+-        if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
++        if (avci->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
+               (avci->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME)))
+             return AVERROR_EOF;
+@@ -243,8 +243,10 @@
+         avpkt->flags |= avci->intra_only_flag;
+     }
+-    if (avci->draining && !got_packet)
++    if (avci->draining && !got_packet) {
++       fflush(stderr);
+         avci->draining_done = 1;
++    }
+ end:
+     if (ret < 0 || !got_packet)
+@@ -365,10 +367,16 @@
+     if (avci->draining)
+         return AVERROR_EOF;
+-    if (avci->buffer_frame->buf[0])
++    if (avci->buffer_frame->buf[0]) {
++        if (!frame) {
++           fflush(stderr);
++            av_frame_unref(avci->buffer_frame);
++       }
+         return AVERROR(EAGAIN);
++    }
+     if (!frame) {
++       fflush(stderr);
+         avci->draining = 1;
+     } else {
+         ret = encode_send_frame_internal(avctx, frame);