From 373832ae609bd9cb9ad8a34db8ff4b0b7ba79776 Mon Sep 17 00:00:00 2001 From: JackBurton79 Date: Thu, 9 Aug 2018 10:44:22 +0200 Subject: [PATCH] Commented calling _EncodeVideoFrame() with NULL. As Adrian suggested, it's not only inefficient to do that there, but also wrong. Modified the TODO comment Added a new TODO comment --- .../media/plugins/ffmpeg/AVCodecEncoder.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp index 72baca70d0..be90d0bb31 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp @@ -649,6 +649,7 @@ AVCodecEncoder::_EncodeAudio(const uint8* buffer, size_t bufferSize, if (fCodecContext->coded_frame) { // Store information about the coded frame in the context. fCodecContext->coded_frame->pts = packet.pts; + // TODO: double "!" operator ? fCodecContext->coded_frame->key_frame = !!(packet.flags & AV_PKT_FLAG_KEY); } @@ -709,12 +710,13 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount, } } - // Pass a NULL AVFrame and enter "draining" mode, then flush buffers - // before restarting encoding, again. - // TODO: It's probably not very efficient to do it like this. We should - // do this only when there is no more data (when closing the "stream") - _EncodeVideoFrame(NULL, pkt, info); - avcodec_flush_buffers(fCodecContext); + // TODO: we should pass a NULL AVFrame and enter "draining" mode, then flush buffers + // when we have finished and there is no more data. We cannot do that here, though, since + // 1. It's not efficient + // 2. It's incorrect, since many codecs need the "next" frame to be able to do optimization. + // if we drain the codec, they cannot work with the "next" frame. + //_EncodeVideoFrame(NULL, pkt, info); + //avcodec_flush_buffers(fCodecContext); av_packet_free(&pkt); return ret; }