[FFmpeg-cvslog] avcodec/nvenc: unregister input resource when unmapping

Timo Rothenpieler git at videolan.org
Sun Jan 28 14:38:47 EET 2018


ffmpeg | branch: release/3.4 | Timo Rothenpieler <timo at rothenpieler.org> | Sun Jan 28 12:39:03 2018 +0100| [a7c60c5b7bc51289773a7e64ebeeeccb53943bdb] | committer: Timo Rothenpieler

avcodec/nvenc: unregister input resource when unmapping

Currently the resource is only ever unregistered when the
registered_frames array is fully in use and an unmapped entry is re-used
and cleaned up.
I'm pretty sure the frame will have been cleaned up before that happens,
so I'm kinda surprised this never blew up.

Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a7c60c5b7bc51289773a7e64ebeeeccb53943bdb
---

 libavcodec/nvenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 661da486f6..ed36b582f8 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1738,6 +1738,8 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur
         ctx->registered_frames[tmpoutsurf->reg_idx].mapped -= 1;
         if (ctx->registered_frames[tmpoutsurf->reg_idx].mapped == 0) {
             p_nvenc->nvEncUnmapInputResource(ctx->nvencoder, ctx->registered_frames[tmpoutsurf->reg_idx].in_map.mappedResource);
+            p_nvenc->nvEncUnregisterResource(ctx->nvencoder, ctx->registered_frames[tmpoutsurf->reg_idx].regptr);
+            ctx->registered_frames[tmpoutsurf->reg_idx].regptr = NULL;
         } else if (ctx->registered_frames[tmpoutsurf->reg_idx].mapped < 0) {
             res = AVERROR_BUG;
             goto error;



More information about the ffmpeg-cvslog mailing list