diff options
author | Andrey Turkin <andrey.turkin@gmail.com> | 2016-05-29 15:51:36 +0300 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2016-05-31 16:50:45 +0200 |
commit | 58c6dcb4b7e77ca87d6b4bd869b098603b5b11f1 (patch) | |
tree | a720ed078cd4d88a31c6cab85a2ecdde99f9ef97 | |
parent | 2f53b5b74b658583be39d3c805024c4d93f67f6b (diff) | |
download | ffmpeg-58c6dcb4b7e77ca87d6b4bd869b098603b5b11f1.tar.gz |
avcodec/nvenc: don't enqueue timestamps until a frame was accepted
Otherwise timestamps/pending FIFOs would go out of sync if nvEncodePicture ever fails.
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
-rw-r--r-- | libavcodec/nvenc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index a31c6e8b22..e8b57e43be 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1602,8 +1602,6 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, pic_params.inputDuration = 0; nvenc_codec_specific_pic_params(avctx, &pic_params); - - timestamp_queue_enqueue(ctx->timestamp_list, frame->pts); } else { pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS; } @@ -1613,8 +1611,10 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, nv_status != NV_ENC_ERR_NEED_MORE_INPUT) return nvenc_print_error(avctx, nv_status, "EncodePicture failed!"); - if (frame) + if (frame) { av_fifo_generic_write(ctx->output_surface_queue, &inSurf, sizeof(inSurf), NULL); + timestamp_queue_enqueue(ctx->timestamp_list, frame->pts); + } /* all the pending buffers are now ready for output */ if (nv_status == NV_ENC_SUCCESS) { |